University of Florida/Egm4313/s12.team11.imponenti/R6.4

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:
 * $$y''-3y'+2y=f(x)\!$$

and the initial conditions
 * $$y(0)=1 \, \ y'(0)=0\!$$

1. Find $$y_n(x)\!$$ such that:
 * $$y_n''+ay_n'+by_n=r_n(x)\!$$

with the same initial conditions as above.

Plot $$y_n(x)\!$$ for $$n=2,4,8\!$$ for x in $$[0,10]\!$$

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: $$n=0,1\!$$

Fourier Series
One period of the window function p9.8 is described as follows


 * $$f(x) =

\begin{cases} 0 & \ \ -1.75 < x <l 0.25 \\ A & \ \ 0.25< x < 2.25 \\ \end{cases} $$

From the above intervals one can see that the period, $$p=4\!$$ and therefore $$L=2\!$$ Applying the Euler formulas from $$-1.75$$ to  $$2.25\!$$ the Fourier coefficients are computed: $$a_0=\frac{1}{2L}\int_{-1.75}^{2.25}f(x)\ dx\!$$

$$a_0=\frac{1}{4}(\int_{-1.75}^{0.25}0\ dx+\int_{0.25}^{2.25}A\ dx)\!$$

$$a_0=+\frac{1}{4}(0+\int_{0.25}^{2.25}A\ dx)\!$$

$$a_0=\frac{1}{4}(2.25A-0.25A)\!$$

$$a_0=\frac{A}{2}\!$$

The integral from $$-1.75\!$$ to  $$0.25\!$$ can be omitted from this point on since it is always zero.

$$a_n=\frac{1}{L}\int_{0.25}^{2.25}f(x)cos(\frac{n\pi x}{L})\ dx\!$$

$$a_n=\frac{1}{2}\int_{0.25}^{2.25}Acos(\frac{n\pi x}{2})\ dx\!$$

$$a_n=\frac{2A}{2n\pi}(sin(\frac{2.25n\pi}{2})-sin(\frac{0.25n\pi}{2})\!$$

$$a_n=\frac{A}{n\pi}(sin(\frac{9n\pi}{8})-sin(\frac{n\pi}{8})\!$$

and

$$b_n=\frac{1}{L}\int_{0.25}^{2.25}f(x)sin(\frac{n\pi x}{L})\ dx\!$$

$$b_n=\frac{1}{2}\int_{0.25}^{2.25}Asin(\frac{n\pi x}{2})\ dx\!$$

$$b_n=\frac{2A}{2n\pi}(cos(\frac{2.25n\pi}{2})-cos(\frac{0.25n\pi}{2})\!$$

$$b_n=\frac{A}{n\pi}(Acos(\frac{n\pi}{8})-Acos(\frac{9n\pi}{8})\!$$

The coefficients give the Fourier series:

$$f(x)=a_0+\sum_{n=1}^{\infty}[a_ncos(\frac{n\pi x}{L})+b_nsin(\frac{n\pi x}{L})]\!$$

$$f(x)=\frac{A}{2}+\sum_{n=1}^{\infty}[\frac{A}{n\pi}(sin(\frac{9n\pi}{8})-sin(\frac{n\pi}{8}))cos(\frac{n\pi x}{2})\!$$
 * $$+\frac{A}{n\pi}(cos(\frac{n\pi}{8})-cos(\frac{9n\pi}{8}))sin(\frac{n\pi x}{2})]\!$$

Homogeneous Solution
Considering the homogeneous case of our ODE:

$$y''-3y'+2y=0\!$$

The characteristic equation is

$$\lambda^2-3\lambda+2=0\!$$

$$(\lambda-1)(\lambda-2)=0\!$$

$$\lambda_1=1, \lambda_1=2\!$$

Therefore our homogeneous solution is of the form

$$y_h=c_1e^x+c_2e^{2x}\!$$

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

$$y''-3y'+2y=\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})]\!$$

The solution will be of the form

$$y_n=A_0+\sum_{k=1}^{n}A_kcos(\frac{k\pi x}{2})+\sum_{k=1}^{n}B_ksin(\frac{k\pi x}{2})\!$$

Taking the derivatives

$$y_n'=-A_n\frac{\pi}{2}\sum_{k=2}^{n}ksin(\frac{k\pi x}{2})+B_n\frac{\pi}{2}\sum_{k=2}^{n}kcos(\frac{k\pi x}{2})\!$$

$$y_n''=-A_n\frac{\pi^2}{4}\sum_{k=3}^{n}k^2cos(\frac{k\pi x}{2})-B_n\frac{\pi^2}{4}\sum_{k=3}^{n}k^2sin(\frac{k\pi x}{2})\!$$

Plugging these back into the ODE:

$$-\frac{\pi^2}{4}\sum_{k=3}^{n}A_kk^2cos(\frac{k\pi x}{2})-\frac{\pi^2}{4}\sum_{k=3}^{n}B_kk^2sin(\frac{k\pi x}{2})-3[-\frac{\pi}{2}\sum_{k=2}^{n}A_kksin(\frac{k\pi x}{2})\!$$

$$+\frac{\pi}{2}\sum_{k=2}^{n}B_kkcos(\frac{k\pi x}{2})]+2[A_0+\sum_{k=1}^{n}A_kcos(\frac{k\pi x}{2})+\sum_{k=1}^{n}B_ksin(\frac{k\pi x}{2})]\!$$

$$=\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})]\!$$

Setting the two constants equal

$$2A_0=\frac{A}{2}\!$$

$$A_0=\frac{A}{4}\!$$

This is valid for all values of n. Since the coefficients of the excitation $$sin(\frac{9k\pi}{8})-sin(\frac{k\pi}{8})\!$$ and  $$cos(\frac{k\pi}{8})-cos(\frac{9k\pi}{8})\!$$ are zero for all even n, then the coefficients $$A_k\!$$  and  $$B_k\!$$ will also be zero, so we must only find these coefficients for odd n's. Now carrying out the sum to $$n=1\!$$ and comparing like terms yields the following sets of equations. Written in matrix form:
 * $$ \begin{bmatrix}2 & 0\\

\\0 & 2\end{bmatrix}* \begin{bmatrix} A_1 \\ B_1\end{bmatrix}= \begin{bmatrix} \ \frac{A}{\pi}(sin(\frac{9\pi}{8})-sin(\frac{\pi}{8})) \\   \ \frac{A}{\pi}(cos(\frac{\pi}{8})-cos(\frac{9\pi}{8}))\end{bmatrix}\!$$

Assuming $$A=1\!$$ this matrix can be solved to obtain

$$A_1=-0.1218 \, \ B_1=0.2941\!$$

For the remaining coefficients to be solved all sums will be used so a more general equation may be written:
 * $$ \begin{bmatrix}

2-\frac{(\pi k)^2}{4} & \frac{-3\pi k}{2}\\ \frac{-3\pi k}{2} & 2-\frac{(\pi k)^2}{4}\end{bmatrix}* \begin{bmatrix} A_k \\ B_k\end{bmatrix}= \begin{bmatrix} \ \frac{A}{\pi k}(sin(\frac{9\pi k}{8})-sin(\frac{\pi k}{8})) \\ \ \frac{A}{\pi k}(cos(\frac{\pi k}{8})-cos(\frac{9\pi}{8}))\end{bmatrix}\!$$

Results of these calculations are shown below:

$$A=\begin{bmatrix} A_1 \\ A_2 \\ .\\ .\\ A_7 \\ A_8\end{bmatrix}= \begin{bmatrix} -0.1218 \\ 0 \\ 0.0084 \\ 0 \\ 0.0014 \\ 0 \\ 0.0001 \\ 0\end{bmatrix}  , \ B=\begin{bmatrix} B_1 \\ B_2 \\ .\\ .\\ B_7 \\ B_8\end{bmatrix}= \begin{bmatrix} 0.2941 \\ 0 \\ 0.0019 \\ 0 \\ 0.0014 \\ 0 \\ 0.0007 \\ 0\end{bmatrix}\!$$

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

$$y_n=\frac{1}{4}+\sum_{k=1}^{n}A_kcos(\frac{k\pi x}{2})+\sum_{k=1}^{n}B_ksin(\frac{k\pi x}{2})\!$$

General Solution
The general solution is

$$y=y_h+y_p\!$$

where

$$y_h=c_1e^x+c_2e^{2x}\!$$

Different coefficients $$c_1 \, \ c_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.

$$y=c_1e^x+c_2e^{2x}+\frac{1}{4}+\sum_{k=1}^{2}A_kcos(\frac{k\pi x}{2})+\sum_{k=1}^{2}B_ksin(\frac{k\pi x}{2})\!$$

Applying the first initial condition $$y(0)=1\!$$

$$y(0)=c_1+c_2+A_1+A_2=1\!$$

Taking the derivative

$$y'=c_1e^x+2c_2e^{2x}-\sum_{k=2}^{2}\frac{k\pi}{2}A_ksin(\frac{k\pi x}{2})+\sum_{k=2}^{2}\frac{k\pi}{2}B_kcos(\frac{k\pi x}{2})\!$$

Applying the second initial condition $$y'(0)=0\!$$

$$y'(0)=c_1+2c_2+\frac{2\pi}{2}B_2=0\!$$

Solving the two equations for two unknowns yields:

$$c_1=2.2436 \, \ c_2=-1.1218\!$$

So the general solution for n=2 is:

$$y=2.2436e^x-1.1218e^{2x}+\frac{1}{4}+\sum_{k=1}^{2}A_kcos(\frac{k\pi x}{2})+\sum_{k=1}^{2}B_ksin(\frac{k\pi x}{2})\!$$

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