You need a complex version of this function:
cmath.exp(1+2j)
See http://docs.python.org/library/cmath.html
Answer from duffymo on Stack OverflowW3Schools
w3schools.com › python › ref_cmath_exp.asp
Python cmath.exp() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... #import cmath for complex number operations import cmath #find the exponential of a complex number print (cmath.exp(2 + 3j)) Try it Yourself »
NumPy
numpy.org › devdocs › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.5.dev0 Manual
>>> x = np.linspace(-2*np.pi, 2*np.pi, 100) >>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane >>> out = np.exp(xx)
GeeksforGeeks
geeksforgeeks.org › complex-numbers-python-set-2-important-functions-constants
Complex Numbers in Python | Set 2 (Important Functions and Constants) | GeeksforGeeks
Introduction to python complex ... article. Operations on complex numbers : 1. exp() :- This function returns the exponent of the complex number mentioned in its argument....
Published July 15, 2022
Python
docs.python.org › 3.0 › library › cmath.html
cmath — Mathematical functions for complex numbers — Python v3.0.1 documentation
Return the exponential value e**x.
NumPy
numpy.org › doc › stable › reference › generated › numpy.exp.html
numpy.exp — NumPy v2.4 Manual
>>> x = np.linspace(-2*np.pi, 2*np.pi, 100) >>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane >>> out = np.exp(xx)
SciPy
docs.scipy.org › doc › numpy-1.9.0 › reference › generated › numpy.exp.html
numpy.exp — NumPy v1.9 Manual
November 2, 2014 - >>> x = np.linspace(-2*np.pi, 2*np.pi, 100) >>> xx = x + 1j * x[:, np.newaxis] # a + ib over complex plane >>> out = np.exp(xx)
Real Python
realpython.com › python-complex-numbers
Simplify Complex Numbers With Python – Real Python
October 21, 2023 - While there aren’t separate representations for the trigonometric or exponential form in Python, you can verify if mathematical principles hold. For example, plugging in Euler’s formula to the trigonometric form will turn it into the exponential one. You can either call the cmath module’s exp() or raise the e constant to a power to get the same result: ... >>> import cmath >>> algebraic = 3 + 2j >>> geometric = complex(3, 2) >>> radius, angle = cmath.polar(algebraic) >>> trigonometric = radius * (cmath.cos(angle) + 1j*cmath.sin(angle)) >>> exponential = radius * cmath.exp(1j*angle) >>> for number in algebraic, geometric, trigonometric, exponential: ...
Ilya Safro
eecis.udel.edu › ~boncelet › ipynb › ComplexNumbers.html
Complex Numbers
Python handles computation with relative ease. Python uses "j" for the imaginary number · Euler's formula says \[\exp(\theta) = \cos(\theta) + j\sin(\theta)\]
DataCamp
datacamp.com › tutorial › exponents-in-python
Exponents in Python: A Comprehensive Guide for Beginners | DataCamp
November 25, 2024 - Yes, Python supports negative and ... positive power. Fractional exponents: Use the ** operator or math.pow(). Note that a negative base with a fractional exponent results in a complex number. Modular exponentiation can be performed using the pow() function with three arguments: ...
Codecademy
codecademy.com › docs › python:numpy › math methods › .exp()
Python:NumPy | Math Methods | .exp() | Codecademy
April 17, 2025 - Yes, np.exp() supports complex numbers and returns the exponential of each complex input using Euler’s formula. math.exp() works only with single scalar values, while np.exp() can handle arrays, lists, and complex numbers, applying the function ...
Top answer 1 of 4
6
In the mathematical order of operations, exponentation comes before multiplication and unary minus counts as multiplication (by -1). So your expression is the same as -(1**0.5), which doesn't involve any imaginary numbers.
If you do (-1)**0.5 you'll get an error in Python 2 because the answer isn't a real number. If you want a complex answer, you need to use a complex input by doing (-1+0j)**0.5. (In Python 3, (-1)**0.5 will return a complex result.)
2 of 4
2
Try (-1)**0.5 instead.
-1**0.5 is parsed as -(1**0.5), which is equal to -1.
>>> -1**0.5
-1
>>> (-1)**0.5
(6.123e-17+1j)
MicroPython
docs.micropython.org › en › latest › library › cmath.html
cmath – mathematical functions for complex numbers — MicroPython latest documentation
The cmath module provides some basic mathematical functions for working with complex numbers. Availability: not available on WiPy and ESP8266. Floating point support required for this module. ... Return the cosine of z. ... Return the exponential of z.
B_Jupyter
audiolabs-erlangen.de › resources › MIR › PCP › PCP_07_exp.html
Unit 7: Exponential Function
Then, in Exercise 2, you will write a Python program to compute and plot the Gaussian function given the exponential function. Finally, you will apply in Exercise 3 the exponential function to create spirals with different properties, which will deepen your understanding of the relationship between the complex ...