python - Writing functional expression using numpy -


i trying write function using numpy, can take derivative.enter image description here

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

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -