Can i calculate exp(1+2j) in python?

后端 未结 2 1427
死守一世寂寞
死守一世寂寞 2020-12-20 14:13

Can i calculate exp(1+2j) in python?

exp(1+2j)
Traceback (most recent call last):
  File \"\", line 1, in 
TypeError: can\'t conve         


        
相关标签:
2条回答
  • 2020-12-20 15:01

    You may want to import e from the math module to do this.

    For example:

    >>> from math import e
    >>> print e ** (1+2j)
    (-1.1312043837568135+2.4717266720048188j)
    
    0 讨论(0)
  • 2020-12-20 15:07

    You need a complex version of this function:

    cmath.exp(1+2j)
    

    See http://docs.python.org/library/cmath.html

    0 讨论(0)
提交回复
热议问题