Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


The Python cmath.exp() function is used to return e raised to the power of given complex number x, i.e., ex. Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282.

Syntax

cmath.exp(x)   

Parameters

x Required. Specify the exponent of e.

Return Value

Returns e raised to the power of given complex number.

Example:

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

import cmath

x = 2 + 2j
y = 2
z = 2j

print(cmath.exp(x))
print(cmath.exp(y))
print(cmath.exp(z))

The output of the above code will be:

(-3.074932320639359+6.71884969742825j)
(7.38905609893065+0j)
(-0.4161468365471424+0.9092974268256817j)

❮ Python cMath Module