python - scipy.special.ellipkinc的复杂参数

标签 python numpy math scipy integral

我试图用第一类不完整的勒让德椭圆积分计算一些数学表达式:

enter image description here

其中K是第一类不完整的勒让德椭圆积分。在ellipkinc中定义为scipy.special

这是Python中的示例:

from numpy import arccos, sqrt
from scipy.special import ellipkinc as K

z = (1+5j)/2.0
x = K(arccos(z), 1/sqrt(2))



但是我收到以下错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-12-d05df015ffeb> in <module>
----> 1 K(arccos(z), 1/sqrt(2))

TypeError: ufunc 'ellipkinc' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''



为什么此函数不接受复杂的参数?如果没有,在某些程序包中是否有任何替代函数可以接受复杂的参数?

感谢您的帮助。

最佳答案

如评论中所述,当前scipy ellipkinc不接受复杂的参数。
或者,您可以使用sympy

from sympy.core import I
from sympy import acos, sqrt
from sympy import elliptic_f as K # the incomplete elliptic integral of the first kind

z = (1 + 5*I)/2
m = 1/sqrt(2)

x = K(acos(z), m).evalf()
print(x)


结果:

0.451970758717359 - 1.62162313666833*I


您可以在Wolframalpha中检查此结果

关于python - scipy.special.ellipkinc的复杂参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59230489/

相关文章:

math - 可能有多少种不同的组合?

python - Django 模型是否继承管理器? (我的好像没有)

python - 如何在 Rmarkdown 文档中显示来自 Python 代码的几何对象?

python - 在范围之间重新分类python中的numpy数组

python - 获取 numpy 数组中非零元素的数量?

java - 如何用 Java 求解 ODE?

python - python中的压缩(存档)旧日志文件

python - 使用 Python 从非常复杂的 JSON 文件中提取数据

python - 将多个 2d numpy 数组放入 3d numpy 数组

javascript - js中的数学运算(加/减)