So I am currently in Calculus 2 and we recently began talking about Taylor Series (yay....), becuase its a natoriously hard topic, my teacher recomended we write a programing code that is able to do Taylor Series in order to better understand the mechanics. So far this has really helped and I was able to get it to find the 4 deritives but I am not sure how to get it to plug in the correct C value into the function and the 4 deritives. Can someone show me what do do next? Thanks:
import sympy as sy
sy.init_printing()
H=0
#Variables
while H!=100:
x=sy.symbols("x")
f=(input('Please enter function, x '))
c=int(input('Enter the center of the equasion, c '))
#Derivatives
dx=sy.Derivative(f)
dx=dx.doit()
Dx=sy.Derivative(dx)
Dx=Dx.doit()
DX=sy.Derivative(Dx)
DX=DX.doit()
D_X=sy.Derivative(DX)
D_X=D_X.doit()
H=H+1
print('The First Deritive, is:')
print(dx)
print('The Second Deritive, is:')
print(Dx)
print('The Third Deritive, is:')
print(DX)
print('The Fourth Deritive, is:')
print(D_X)
Allow me to point out that d1x
, d2x
, d3x
and d4x
would be much better names than dx
, Dx
, DX
, and D_X
.
print('The First derivative, is:')
print(dx)
print(f'The value of the first derivative at {c} is:')
print(dx.subs(x,c))
print('The Second derivative, is:')
print(Dx)
print(f'The value of the second derivative at {c} is:')
print(Dx.subs(x,c))
print('The Third derivative, is:')
print(DX)
print(f'The value of the third derivative at {c} is:')
print(DX.subs(x,c))
print('The Fourth derivative is:')
print(D_X)
print(f'The value of the fourth derivative at {c} is:')
print(D_X.subs(x,c))