我得到一个“mul对象不可调用” - 错误

时间:2017-10-30 20:22:18

标签: python sympy

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 = ...)

1 个答案:

答案 0 :(得分:0)

尝试将脚本的最后一行更改为taylorCoefficient( lambda x: x**2*sp.sin(x/2), 0, 3)