Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 类型错误:can';t使用Sympy将表达式转换为浮点_Python_Floating Point_Typeerror_Sympy - Fatal编程技术网

Python 类型错误:can';t使用Sympy将表达式转换为浮点

Python 类型错误:can';t使用Sympy将表达式转换为浮点,python,floating-point,typeerror,sympy,Python,Floating Point,Typeerror,Sympy,我试图使用sympy,但它的符号对象有问题 import sympy as sy from scipy import special as sp def derivativeBMax2(s): x = sy.symbols('x', real=True) B0 = 1 H = 1 alpha = 2.4048 B_azimuthal = B0 * H * sp.jv(1, alpha * sy.sqrt((float(x) ** 2) + (s ** 2))) sp.jv的文件:

我试图使用sympy,但它的符号对象有问题

import sympy as sy
from scipy import special as sp

def derivativeBMax2(s):    
x = sy.symbols('x', real=True)
B0 = 1 
H = 1
alpha = 2.4048 
B_azimuthal = B0 * H * sp.jv(1, alpha * sy.sqrt((float(x) ** 2) + (s ** 2)))
sp.jv的文件:

它的第二个参数需要一个浮点,当我将x转换为浮点时,它将引发

TypeError: can't convert expression to float 
我想最终用sympy的diff()来区分B_方位角


如何使x同时成为scipy jv函数的符号和浮点?

如果scipy需要浮点,则您无能为力(除了用浮点替换符号x)。如果您想以符号方式使用它,为什么不在
symphy/functions/special/bessel.py
中使用symphy的
besselj
函数呢。该函数的docstring给出了使用符号参数的示例,并进行了区分。

什么是B0、H、alpha、s?请发一篇。对不起,我刚刚编辑了这篇文章。它们都是等于1.5的整数
alpha
s
仍然未定义,对此表示担忧!alpha是定义的常数,s是函数中的自由参数