+ 2

Evaluating Differentials

Okay so I have the following problem, I am running this code in Python 3.6: ----------------------------------------------- from sympy import Symbol x= Symbol('x') y= Symbol('y') y= x**4 + 7*x**3 + 8 y=diff(y,x) print(y) ------------------------------------------------- Now this code runs perfectly, and gives me the output: 4*x**3 + 21*x**2 now after this, if i want to calculate the derivative at some value, let's say x=2... how to do that? I will be grateful if someone helps me out, without changing the method, that is using the sympy itself.

11th May 2018, 5:53 PM
Saurabh Shukla
Saurabh Shukla - avatar
3 Antworten
+ 9
Hi Saurabh, You should use the subs() method for that: print(y.subs(x, 2)) >>> 116
11th May 2018, 7:10 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
it worked, I am really thankful :)
13th May 2018, 5:16 PM
Saurabh Shukla
Saurabh Shukla - avatar
0
so I am in bit of a situation: I have evaluated a function Ylm using sympy, it is a function of 'theta' and 'phi'. Now when I am trying to plot this in this way: >>>plot3d(Ylm ,(theta,0,3.14),(phi,0,6.28)) It is plotting in Cartesian system; but obviously I want to plot in spherical polar coordinates; so can anybody help me to plot Ylm in spherical polar coordinates.
14th May 2018, 5:11 PM
Saurabh Shukla
Saurabh Shukla - avatar