Solution of
y''+cos(x) y=0
for y(x) with y(0)=1 and y'(0)=0.
An exact solution can be found in this case, and can
be compared with the series solution.
In[1]:=
![]()
Let's find a solution valid out to
. The first step in finding a series solution is to find an expansion for Cos[x]:
In[2]:=
![]()
In[3]:=
![]()
Out[3]=
![]()
In[4]:=
![]()
Out[4]=
![]()
In[5]:=
![]()
Out[5]=
![(a[0] + 2 a[2]) + (-a[0]/2 + a[2] + 12 a[4]) x^2 + (a[0]/24 - a[2]/2 + a[4] + 30 a[6]) x^4 + (-a[0]/720 + a[2]/24 - a[4]/2 + a[6] + 56 a[8]) x^6 + (a[0]/40320 - a[2]/720 + a[4]/24 - a[6]/2 + a[8] + 90 a[10]) x^8 + O[x]^9 == 0](HTMLFiles/index_9.gif)
Here are the unknowns in the expansion of
that we must solve for:
In[6]:=
![]()
Out[6]=
![]()
Here are the algebraic equations for those coefficients:
In[7]:=
![]()
Out[7]=
![a[0] + 2 a[2] == 0 && -a[0]/2 + a[2] + 12 a[4] == 0 && a[0]/24 - a[2]/2 + a[4] + 30 a[6] == 0 && -a[0]/720 + a[2]/24 - a[4]/2 + a[6] + 56 a[8] == 0 && a[0]/40320 - a[2]/720 + a[4]/24 - a[6]/2 + a[8] + 90 a[10] == 0](HTMLFiles/index_14.gif)
We actually don't need the TableForm for the math, it is just nice to look at:
In[8]:=
![]()
Out[8]//TableForm=
|
|
|
|
|
|
|
|
|
|
In[9]:=
![]()
Out[9]=
![{{a[2] -> -a[0]/2, a[4] -> a[0]/12, a[6] -> -a[0]/80, a[8] -> (11 a[0])/8064, a[10] -> -(17 a[0])/129600}}](HTMLFiles/index_22.gif)
In[10]:=
![]()
Out[10]=
![a[0] - 1/2 a[0] x^2 + 1/12 a[0] x^4 - 1/80 a[0] x^6 + (11 a[0] x^8)/8064 - (17 a[0] x^10)/129600 + O[x]^11](HTMLFiles/index_24.gif)
In[11]:=
![]()
Out[11]=
![a[0] - 1/2 x^2 a[0] + 1/12 x^4 a[0] - 1/80 x^6 a[0] + (11 x^8 a[0])/8064 - (17 x^10 a[0])/129600](HTMLFiles/index_26.gif)
So here is the series solution that satisfies the specified initial conditions:
In[12]:=
![]()
Out[12]=
![]()
Now find exact solution:
In[13]:=
![]()
In[14]:=
![]()
Out[14]=
![]()
In[15]:=
![]()
Out[15]=
![]()
Plot approximate (red) and exact (green) solutions:
In[16]:=
![Plot[{ey[x], yss1[x]}, {x, 0, 10}, PlotRange -> {-10, 10}, PlotStyle -> {RGBColor[0, 1, 0], RGBColor[1, 0, 0]}]](HTMLFiles/index_34.gif)
![[Graphics:HTMLFiles/index_35.gif]](HTMLFiles/index_35.gif)
Out[16]=
![]()
Converted by Mathematica (March 3, 2003)