User:Egm4313.s12.team8.kyle/R6.4

Problem Statement
Consider the L2-ODE-CC with the window function from R6.2, $$f(x)$$, as excitation:
 * $$y'' - 3y' + 2y = r(x)$$
 * $$r(x) = f(x)$$

And the initial conditions:
 * $$y(0) = 1,\;y'(0) = 0$$

Part 1
Find $$y_n(x)$$ such that:
 * $$y_n'' + a y_n' + b y_n = r_n(x)$$

with the same initial conditions.

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

Part 2
Use the MATLAB command ode45 to integrate the L2-ODE-CC, and plot the numerical solution to compare with the analytical solution.

Part 1
From R6.2, we know that our excitation functions are given by:
 * $$r_0(x) = f_0(x) = \frac{A}{2}$$
 * $$r_1(x) = f_1(x)= \frac{A}{2} + \frac{A}{\pi}\sin (\frac{\pi (x-.25)}{2})$$

Case $$n = 0$$
Setting $$n=0$$ yields the following:

$$r_0(x) = \frac12 A$$

So the ODE takes the form:

$$y''(x)-3y'(x)+2y(x)=A/2$$

Inputting into Wolfram Alpha with the initial conditions:

$$y(0)=1$$ and $$y'(0)=0$$

Yields the solution:

$$ y_{0}(x) = \frac14 (A (e^x-1)^2-4 e^x (e^x-2))$$

Case $$n = 1$$
Setting $$n=1$$ yields the following:

$$r_1(x) = \frac12 A + \frac{A}{\pi} \sin{\frac{\pi \left(x - \frac14 \right)}2}$$

So the ODE takes the form:

$$y''(x)-3y'(x)+2y(x)=\frac12 A + \frac{A}{\pi} \sin{\frac{\pi \left(x - \frac14 \right)}2}$$

Inputting into Wolfram Alpha with the initial conditions:

$$y(0)=1$$ and $$y'(0)=0$$

Yields the solution:

$$ y_{1}(x) = -0.598093 A e^x+0.283756 A e^{2x}+0.019468 A sin(1.5708 x)+0.0643367 A cos(1.5708 x)+0.25 A+2e^x-e^{2 x}$$

Part 2
Using the following Matlab function and inputs allows us to compare the analytical and numerical solutions:


 * [[Image:Egm4313.s12.team8.r6.4.y0.png]]


 * [[Image:Egm4313.s12.team8.r6.4.y1.png]]


 * [[Image:Egm4313.s12.team8.r6.4.y+y0+y1.png]]


 * [[Image:Egm4313.s12.team8.r6.4.y+y0+y1.zoomed.png]]

The zoomed plot shows, as expected, an increase in accuracy as n increases from 0 to 1.