We found the Taylor series of the solution of the initial value problem. Let's write out a reasonably large partial sum of the terms and plot it.
import sympy as sp
sp.init_printing()
x,y0,v0 = sp.symbols('x y0 v0')
def approxe(N):
term1 = y0 ; sum1 = term1;
term2 = v0*x; sum2 = term2
for n in range(1,N):
term1 *= x**3/(3*n )/(3*n-1); sum1 += term1
term2 *= x**3/(3*n+1)/(3*n ); sum2 += term2
return sum1 + sum2
def approx(N,Y0,V0):
return sp.lambdify(x,approxe(N).subs({y0:Y0,v0:V0}),'numpy')
approxe(15)
%matplotlib inline
from pylab import plot,ylim,legend,axhline,axvline
from numpy import linspace
X = linspace(-8,3,500)
axhline(y=0, color='k', alpha=0.3)
axvline(x=0, color='k', alpha=0.3)
plot(X,approx(15,0,1)(X),label='15 terms')
plot(X,approx(25,0,1)(X),label='25 terms')
ylim(-5,5)
legend(loc='lower right');
axhline(y=0, color='k', alpha=0.3)
axvline(x=0, color='k', alpha=0.3)
plot(X,approx(15,1,0)(X),label='15 terms')
plot(X,approx(25,1,0)(X),label='25 terms')
ylim(-5,5)
legend(loc='lower right');
X = linspace(-15,3,500)
axhline(y=0, color='k', alpha=0.3)
axvline(x=0, color='k', alpha=0.3)
plot(X,approx(25,1,0)(X),label='25 terms')
plot(X,approx(35,1,0)(X),label='35 terms')
plot(X,approx(55,1,0)(X),label='55 terms')
ylim(-1,2)
legend(loc='lower right');