Python Tutorial Python Advanced Python References Python Libraries

Python cmath - exp() Function



The Python cmath.exp() function returns base-e exponential of a complex number z, that is e (Euler's number, 2.7182818) raised to the power of z, ez. It is a function on complex plane, and has no branch cuts.

Mathematically, it can be expressed as:

complex exp

where, z = x+iy

Syntax

cmath.exp(z)   

Parameters

z Required. Specify the exponent of e.

Return Value

Returns e raised to the power of z.

Example:

In the example below, exp() function is used to calculate e raised to the power of specified complex number.

import cmath

z1 = 2 + 2j
z2 = 2
z3 = 2j

print("cmath.exp(z1):", cmath.exp(z1))
print("cmath.exp(z2):", cmath.exp(z2))
print("cmath.exp(z3):", cmath.exp(z3))

The output of the above code will be:

cmath.exp(z1): (-3.074932320639359+6.71884969742825j)
cmath.exp(z2): (7.38905609893065+0j)
cmath.exp(z3): (-0.4161468365471424+0.9092974268256817j)

❮ Python cMath Module