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

只愿长相守 提交于 2020-01-20 07:53:08

问题


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

exp(1+2j)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't convert complex to float

回答1:


You need a complex version of this function:

cmath.exp(1+2j)

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




回答2:


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)


来源:https://stackoverflow.com/questions/8498310/can-i-calculate-exp12j-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!