首页 > 解决方案 > “TypeError: cannot create mpf from d”',当执行“For”结构时

问题描述

import sympy.printing as printing
from IPython.display import display, Math, Latex
from sympy import *
from mpmath import *
from sympy.codegen.ast import aug_assign, For

init_printing()

c, d, c_max, d_max, jzeros = symbols("c d c_max d_max jzeros")

c_max.subs(c_max, 3)
d_max.subs(d_max, 3)

For(d, Range(d_max.subs(d_max, 3)), [jzeros.subs(jzeros, besseljzero(d, c_max))])

为什么执行上述代码时会出现此错误(“TypeError: cannot create mpf from d”)?如何使此代码工作?我正在尝试根据此“For”文档进行编码:https ://docs.sympy.org/latest/modules/codegen.html#sympy.codegen.ast.For

标签: pythonmathsympysymbolic-mathmpmath

解决方案


推荐阅读