python - Writing functional expression using numpy -
i trying write function using numpy, can take derivative.
i trying this, not able working
x = symbol('x') y = (np.e ** (x ** 2)) * np.sin(x - np.pi) y.diff(x)
i following error on this
'add' object has no attribute 'sin'
you should use functions sympy
, not numpy
:
import sympy x = sympy.symbol('x') y = (sympy.exp(x ** 2)) * sympy.sin(x - sympy.pi) sympy.pprint(sympy.diff(y))
yields
⎛ 2⎞ ⎛ 2⎞ ⎝x ⎠ ⎝x ⎠ - 2⋅x⋅ℯ ⋅sin(x) - ℯ ⋅cos(x)
Comments
Post a Comment