![](/img/trans.png)
[英]I'm getting the error TypeError: 'int' object is not callable
[英]I'm getting a "mul object is not callable"-error
import sympy as sp
def taylorCoefficient(f, a, n):
x = sp.symbols("x")
coefficient = []
for i in range(0, n + 1):
afgeleide = sp.diff(f(x), x, n=n)
def f(x0): return afgeleide.subs(x, x0)
coefficient += f(a) / sp.factorial(n)
return coefficient
x = sp.symbols("x")
taylorCoefficient(x ** 2 * sp.sin(x / 2), 0, 3)
我得到一個 mul 對象不可調用,但為什么呢? (在線afgeleide=...)
嘗試將腳本的最后一行更改為taylorCoefficient( lambda x: x**2*sp.sin(x/2), 0, 3)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.