我想用sympy求出等式x^5+4x^4+3x^2+5的三阶导数。
我的代码是:x = symbols(‘x’)
y = parse_expr(exp)
z = diff(y,x,n)
print(z)
给出答案的形式是12*x*(5*x+8)而不是60*x**2+96x
from sympy import *
x = symbols('x')
exp = x**5 + 4*x**4 + 3*x**2 + 5
y = diff(exp,x,3)
print("y = ", y)
z = y.expand()
print("z = ", z)
这给:
y = 12*x*(5*x + 8)
z = 60*x**2 + 96*x