【问题标题】:Can i calculate exp(1+2j) in python?我可以在 python 中计算 exp(1+2j) 吗?
【发布时间】:2011-12-14 00:50:44
【问题描述】:

我可以在 python 中计算 exp(1+2j) 吗?

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

【问题讨论】:

    标签: python math


    【解决方案1】:

    你需要这个函数的复杂版本:

    cmath.exp(1+2j)
    

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

    【讨论】:

      【解决方案2】:

      您可能需要从数学模块导入 e 来执行此操作。

      例如:

      >>> from math import e
      >>> print e ** (1+2j)
      (-1.1312043837568135+2.4717266720048188j)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-21
        • 2020-01-14
        • 1970-01-01
        • 1970-01-01
        • 2021-06-09
        • 1970-01-01
        相关资源
        最近更新 更多