R6.4
solved by Luca Imponenti
Problem Statement
Consider the L2-ODE-CC (5) p.7b-7 with the window function f(x) p.9-8 as excitation:
 
 
and the initial conditions
 
 
1.  Find  such that:
 such that:
 
with the same initial conditions as above.
Plot  for
 for  for x in
 for x in ![{\displaystyle [0,10]\!}](../../../7afee0f848455b66aae9ef3f95de42d3509f2f26.svg)
2.  Use the matlab command ode45 to integrate the L2-ODE-CC, and plot the numerical solution to compare with the analytical solution.
- Level 1:  
Fourier Series
One period of the window function p9.8 is described as follows
 
From the above intervals one can see that the period,  and therefore
  and therefore  Applying the Euler formulas from
Applying the Euler formulas from  to
  to   the Fourier coefficients are computed:
 the Fourier coefficients are computed:
 





The integral from  to
  to   can be omitted from this point on since it is always zero.
 can be omitted from this point on since it is always zero.




and 




The coefficients give the Fourier series:
![{\displaystyle f(x)=a_{0}+\sum _{n=1}^{\infty }[a_{n}cos({\frac {n\pi x}{L}})+b_{n}sin({\frac {n\pi x}{L}})]\!}](../../../1882b82559d4f1569411c84a2b6e3d86f161f7fe.svg)

![{\displaystyle +{\frac {A}{n\pi }}(cos({\frac {n\pi }{8}})-cos({\frac {9n\pi }{8}}))sin({\frac {n\pi x}{2}})]\!}](../../../8893708df79a090f008049edab53aed382f0f66e.svg) 
 
Homogeneous Solution
Considering the homogeneous case of our ODE:

The characteristic equation is



Therefore our homogeneous solution is of the form

Particular Solution
Considering the case with f(x) as excitation

![{\displaystyle +(cos({\frac {k\pi }{8}})-cos({\frac {9k\pi }{8}}))sin({\frac {k\pi x}{2}})]\!}](../../../5cd6ccf84a4564bffcd87fc35ab5fb5eccc20fad.svg) 
 
The solution will be of the form 

Taking the derivatives


Plugging these back into the ODE:

![{\displaystyle +{\frac {\pi }{2}}\sum _{k=2}^{n}B_{k}kcos({\frac {k\pi x}{2}})]+2[A_{0}+\sum _{k=1}^{n}A_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{n}B_{k}sin({\frac {k\pi x}{2}})]\!}](../../../fc340f38bcb387f8388802845e941835a8138559.svg)
![{\displaystyle ={\frac {A}{2}}+\sum _{k=1}^{n}{\frac {A}{k\pi }}[(sin({\frac {9k\pi }{8}})-sin({\frac {k\pi }{8}}))cos({\frac {k\pi x}{2}})+(cos({\frac {k\pi }{8}})-cos({\frac {9k\pi }{8}}))sin({\frac {k\pi x}{2}})]\!}](../../../6c55a889240e8411f80b6f6e1b9954e45d32b4c8.svg)
Setting the two constants equal


This is valid for all values of n. Since the coefficients of the excitation  and
  and   are zero for all even n, then the coefficients
 are zero for all even n, then the coefficients  and
  and   will also be zero, so we must only find these coefficients for odd n's. 
Now carrying out the sum to
 will also be zero, so we must only find these coefficients for odd n's. 
Now carrying out the sum to  and comparing like terms yields the following sets of equations. Written in matrix form:
 and comparing like terms yields the following sets of equations. Written in matrix form:
 
 
Assuming  this matrix can be solved to obtain
  this matrix can be solved to obtain

For the remaining coefficients to be solved all sums will be used so a more general equation may be written:
 
 
Results of these calculations are shown below:

The solution to the particular case can be written for all n (assuming A=1):
      
General Solution
The general solution is 

where

Different coefficients  will be calculated for each n. These coefficients are easily solved for by applying the given initial conditions. Below are the calculations for n=2.
 will be calculated for each n. These coefficients are easily solved for by applying the given initial conditions. Below are the calculations for n=2.

Applying the first initial condition 

Taking the derivative

Applying the second initial condition 

Solving the two equations for two unknowns yields:

So the general solution for n=2 is:

Below is a plot showing the general solutions for n=2,4,8:


Matlab Plots
Using ode45 the following graph was generated for n=0:

and for n=1
