# University of Florida/Egm4313/s12.team11.R6

Report 6

Intermediate Engineering Analysis
Section 7566
Team 11
Due date: April 11, 2012.

## R6.1

Solved by Daniel Suh

### Problem Statement

• Find the fundamental period of $\cos(n\omega x)\!$  and $\sin(n\omega x)\!$
• Show that these functions also have period $p\!$ .
• Show that the constants $a_{0}\!$  is also a periodic function with period $p\!$ .

### Solution

• Find the fundamental period, and show that these functions have a period of $p\!$ .

$p=2L=2{\frac {\pi }{\omega }}\!$

$L={\frac {\pi }{\omega }}\!$

$f(x+np)=f(x)\!$

$f(x)=cos(n\omega x)\!$

$f(x+n{\frac {2\pi }{n\omega }})=cos(n\omega (x+{\frac {2\pi }{n\omega }}))\!$

$f(x+{\frac {2\pi }{\omega }})=cos(n\omega x+2\pi )\!$

$f(x+2L)=cos(n\omega x+2\pi )\!$

              $p=2L\!$ is the fundamental period for $cos(n\omega x)\!$ .

$f(x+np)=f(x)\!$

$f(x)=sin(n\omega x)\!$

$f(x+n{\frac {2\pi }{n\omega }})=sin(n\omega (x+{\frac {2\pi }{n\omega }}))\!$

$f(x+{\frac {2\pi }{\omega }})=sin(n\omega x+2\pi )\!$

$f(x+2L)=sin(n\omega x+2\pi )\!$

              $p=2L\!$ is the fundamental period for $sin(n\omega x)\!$ .

• Show that the constants $a_{0}\!$  is also a periodic function with period $p\!$ .

From Fourier Series,
$a_{0}={\frac {1}{2L}}\int _{-L}^{L}f(x)dx\!$

$f(x)=\cos(n\omega x)\!$

$a_{0}={\frac {\omega }{2\pi }}\int _{-{\frac {\pi }{\omega }}}^{\frac {\pi }{\omega }}cos(n\omega x)dx\!$

$a_{0}={\frac {\omega }{2\pi }}[{\frac {sin(n\omega x)}{n\omega }}|_{-{\frac {\pi }{\omega }}}^{\frac {\pi }{\omega }}]\!$

$a_{0}={\frac {\omega }{2\pi }}[{\frac {2sin(n\pi )}{n\omega }}]\!$

          $a_{0}=0\!$ $f(x)=\sin(n\omega x)\!$

$a_{0}={\frac {\omega }{2\pi }}\int _{-{\frac {\pi }{\omega }}}^{\frac {\pi }{\omega }}sin(n\omega x)dx\!$

$a_{0}={\frac {\omega }{2\pi }}[{\frac {cos(n\omega x)}{n\omega }}|_{-{\frac {\pi }{\omega }}}^{\frac {\pi }{\omega }}]\!$

$a_{0}={\frac {\omega }{2\pi }}[{\frac {-cos{n\pi }+cos{n\pi }}{n\omega }}]\!$

          $a_{0}=0\!$ ## R6.2

### Problem Statement

Solve the problems 11 and 12 from Kreyszig p.491

### Solution

First, for problem 11:
$f(x)=x^{2}\!$  from $<-1\!$  where $p=2\!$  We know that $p=2=2L\!$  so that $L=1\!$

We check is the function is even, odd or neither.
Since $f(x)\!$  satisfies the condition $f(x)=f(-x)\!$  we know that the function is even.
Given that the function is even and that $b_{n}=0\!$  for even functions, we exclude the $b_{n}\!$  term from the Fourier Series.

We find $a_{0}\!$ :
$a_{0}={\frac {1}{2L}}\int _{-L}^{L}f(x)dx\!$
Plugging in,
$a_{0}={\frac {1}{2}}\int _{-1}^{1}x^{2}dx={\frac {1}{2}}\left[{\frac {1}{3}}x^{3}\right]_{-1}^{1}={\frac {1}{2}}\left[{\frac {1}{3}}+{\frac {1}{3}}\right]={\frac {1}{3}}\!$

We find $a_{n}\!$
$a_{n}={\frac {1}{L}}\int _{-L}^{L}f(x)cos({\frac {n\pi x}{L}})dx\!$
$a_{n}=1\int _{-1}^{1}x^{2}cos(n\pi x)dx\!$
We can use the equivalent expression:
$a_{n}=2\int _{0}^{1}x^{2}cos(n\pi x)dx\!$

Now we evaluate the integral by using integration by parts. Below are the steps:
Integration by parts uses $\int fdg=fg-\int gdf\!$
${\begin{matrix}f=x^{2}&dg=cos(\pi nx)dx\\df=2xdx&g={\frac {sin(\pi nx)}{\pi n}}\end{matrix}}\!$
Then, we have:
$\left[{\frac {x^{2}sin(\pi nx)}{\pi n}}\right]_{0}^{1}-{\frac {2}{\pi n}}\int _{0}^{1}xsin(\pi nx)dx\!$
Repeating for the second term:
${\begin{matrix}f=x&dg=sin(\pi nx)\\df=dx&g={\frac {-cos(\pi nx)}{\pi n}}\end{matrix}}\!$
Then, we have:
$\left[{\frac {-xcos(\pi nx)}{\pi n}}\right]_{0}^{1}-{\frac {1}{\pi n}}\int _{0}^{1}cos(\pi nx)dx\!$
Bringing all the terms together:
$2\left[\left[{\frac {x^{2}sin(\pi nx)}{\pi n}}\right]_{0}^{1}-{\frac {2}{\pi n}}\left[{\frac {-xcos(\pi nx)}{\pi n}}\right]_{0}^{1}-{\frac {1}{\pi n}}\int _{0}^{1}cos(\pi nx)dx\right]\!$
Then,
$2\left[\left[{\frac {x^{2}sin(\pi nx)}{\pi n}}\right]_{0}^{1}-{\frac {2}{\pi n}}\left[{\frac {-xcos(\pi nx)}{\pi n}}\right]_{0}^{1}-{\frac {1}{\pi n}}\left[{\frac {sin(\pi nx)}{\pi n}}\right]_{0}^{1}\right]\!$
Evaluating at the boundaries and simplifying:
$2\left[\left[0-0\right]+{\frac {2}{\pi ^{2}n^{2}}}\left[cos(\pi n)\right]-{\frac {1}{\pi n}}\left[0-0\right]\right]\!$
Further,
${\frac {4}{\pi ^{2}n^{2}}}cos(\pi n)\!$
We can simplify one step further by acknowledging that $cos(\pi n)=(-1)^{n}\!$ .
$\therefore a_{n}={\frac {4}{\pi ^{2}n^{2}}}(-1)^{n}\!$

Finally,
$f(x)=a_{0}+\sum _{n=1}^{\infty }a_{n}cos({\frac {\pi n}{L}})x\!$

The Fourier series is:

                                   $f(x)={\frac {1}{3}}+\sum _{n=1}^{\infty }{\frac {4}{\pi ^{2}n^{2}}}(-1)^{n}cos(\pi n)x\!$ Now problem 12:
$f(x)=1-{\frac {x^{2}}{4}}\!$  from $<-2\!$  where $p=2\!$  We know that $p=4=2L\!$  so that $L=2\!$

We check is the function is even, odd or neither.
Since $f(x)\!$  satisfies the condition $f(x)=f(-x)\!$  we know that the function is even.
Given that the function is even and that $b_{n}=0\!$  for even functions, we exclude the $b_{n}\!$  term from the Fourier Series.

We find $a_{0}\!$ :
$a_{0}={\frac {1}{2L}}\int _{-L}^{L}f(x)dx\!$
Plugging in,
$a_{0}={\frac {1}{4}}\int _{-2}^{2}1-{\frac {x^{2}}{4}}dx={\frac {1}{4}}\left[x-{\frac {1}{12}}x^{3}\right]_{-2}^{2}={\frac {1}{4}}\left[{\frac {24-8}{12}}-{\frac {24+8}{12}}\right]={\frac {2}{3}}\!$

We find $a_{n}\!$
$a_{n}={\frac {1}{L}}\int _{-L}^{L}f(x)cos({\frac {n\pi x}{L}})dx\!$
$a_{n}={\frac {1}{2}}\int _{-2}^{2}(1-{\frac {x^{2}}{4}}cos(n\pi x)dx\!$
Now we evaluate the integral by using integration by parts. This process is similar to the one shown in the solution for problem 11 above and therefore will be performed in Wolfram Alpha.
The following command was given in Wolfram Alpha: integral (1-(x^2/4))*cos(pi*x) from -2 to 2.
Wolfram Alpha yields the following
${\frac {2}{\pi ^{2}n^{2}}}\!$

Finally,
$f(x)=a_{0}+\sum _{n=1}^{\infty }a_{n}cos({\frac {\pi n}{L}})x\!$

The Fourier series is:

                              $f(x)={\frac {2}{3}}+\sum _{n=1}^{\infty }{\frac {-2}{\pi ^{2}n^{2}}}cos({\frac {\pi n}{2}})x\!$ ### Part B

Solved by Francisco Arrieta

### Problem Statement

Find the Fourier series expansion for $f(x)\!$  on p. 9.8 as follows:

#### Part 1

Develop the Fourier series expansion of $f({\bar {x}})\!$

Plot $f({\bar {x}})\!$  and the truncated Fourier series $f_{n}({\bar {x}})\!$

$f_{n}({\bar {x}}):={\bar {a}}_{0}+\sum _{k=1}^{n}[{\bar {a}}_{k}\cos k\omega {\bar {x}}+{\bar {b}}_{k}\sin k\omega {\bar {x}}]\!$

for n=0,1,2,4,8. Observe the values of $f_{n}({\bar {x}})\!$  at the points of discontinuities, and the Gibbs phenomenon. Transform the variable so to obtain the Fourier series expansion of $f(x)\!$

#### Solution

$p=2L=4\!$
$L=2\!$
$\omega ={\frac {2\pi }{p}}\!$

${\bar {a}}_{0}={\frac {1}{2L}}\int _{-L}^{L}f({\bar {x}})d{\bar {x}}\!$

${\bar {a}}_{0}={\frac {1}{4}}\int _{-2}^{2}f({\bar {x}})d{\bar {x}}\!$
${\bar {a}}_{0}={\frac {A}{2}}\!$

${\bar {a}}_{k}={\frac {1}{L}}\int _{-L}^{L}f({\bar {x}})\cos k\omega {\bar {x}}d{\bar {x}}\!$

${\bar {a}}_{k}={\frac {1}{2}}\int _{-2}^{2}f({\bar {x}})\cos {\frac {k\pi {\bar {x}}}{2}}d{\bar {x}}\!$
${\bar {a}}_{k}={\frac {2A}{k\pi }}\sin {\frac {k\pi }{2}}\!$

Note:

If k is even ${\bar {a}}_{k}=0\!$

If k=1, 5, 9... ${\bar {a}}_{k}={\frac {2A}{k\pi }}\!$

If k=3, 7, 11... ${\bar {a}}_{k}={\frac {-2A}{k\pi }}\!$

${\bar {b}}_{k}={\frac {1}{L}}\int _{-L}^{L}f({\bar {x}})\sin k\omega {\bar {x}}d{\bar {x}}\!$

Note:

${\bar {b}}_{k}=0\!$  for n=1, 2...

Then Fourier series becomes a Fourier cosine series:

                                              $f_{k}({\bar {x}})={\frac {A}{2}}+\sum _{k=1}^{n}({\frac {2A}{k\pi }}\cos {\frac {k\pi }{2}}{\bar {x}})\!$ For n=0

                                              $f_{k}({\bar {x}})={\frac {A}{2}}\!$ For n=1

                                              $f_{k}({\bar {x}})={\frac {A}{2}}+({\frac {2A}{\pi }}\cos {\frac {\pi }{2}}{\bar {x}})\!$ For n=5

                                              $f_{k}({\bar {x}})={\frac {A}{2}}+{\frac {2A}{\pi }}(\cos {\frac {\pi }{2}}{\bar {x}}-{\frac {1}{3}}\cos {\frac {3\pi }{2}}{\bar {x}}+{\frac {1}{5}}\cos {\frac {5\pi }{2}}{\bar {x}})\!$ After transforming the variable of $f({\bar {x}})\!$

                                              $f_{k}(x)={\frac {A}{2}}+\sum _{k=1}^{n}({\frac {2A}{k\pi }}\cos {\frac {k\pi }{2}}(x-1.25))\!$ #### Part 2

Do the same as above, but using $f({\tilde {x}})\!$  to obtain the Fourier expansion of $f(x)\!$  ; compare to the result obtained above

#### Solution

$p=2L=4\!$
$L=2\!$
$\omega ={\frac {2\pi }{p}}\!$

${\tilde {a}}_{0}={\frac {1}{2L}}\int _{0}^{2L}f({\tilde {x}})d{\tilde {x}}\!$

${\tilde {a}}_{0}={\frac {1}{4}}\int _{0}^{4}f({\tilde {x}})d{\tilde {x}}\!$
${\tilde {a}}_{0}={\frac {A}{2}}\!$

${\tilde {a}}_{k}={\frac {1}{L}}\int _{0}^{2L}f({\tilde {x}})\cos k\omega {\tilde {x}}d{\tilde {x}}\!$

${\tilde {a}}_{k}={\frac {1}{2}}\int _{0}^{4}f({\tilde {x}})\cos k\omega {\tilde {x}}d{\tilde {x}}\!$
${\tilde {a}}_{k}={\frac {A}{k\pi }}\sin \pi k\!$

Note:

${\bar {b}}_{k}=0\!$  for n=1, 2..

${\tilde {b}}_{k}={\frac {1}{L}}\int _{0}^{2L}f({\tilde {x}})\sin k\omega {\tilde {x}}d{\tilde {x}}\!$

${\tilde {b}}_{k}={\frac {1}{2}}\int _{0}^{4}f({\tilde {x}})\sin k{\frac {\pi }{2}}{\tilde {x}}d{\tilde {x}}\!$
${\tilde {b}}_{k}={\frac {-A}{\pi k}}(\cos \pi k-1)\!$

Note:

If k is even ${\bar {a}}_{k}=0\!$

If k=1, 3, 5... ${\bar {a}}_{k}={\frac {2A}{k\pi }}\!$

Then Fourier series becomes a Fourier sine series:

                                              $f_{k}({\tilde {x}})={\frac {A}{2}}+\sum _{k=1}^{n}({\frac {2A}{k\pi }}\sin {\frac {k\pi }{2}}{\tilde {x}})\!$ For n=0:

                                              $f_{k}({\tilde {x}})={\frac {A}{2}}\!$ For n=1:

                                              $f_{k}({\tilde {x}})={\frac {A}{2}}+({\frac {2A}{\pi }}\sin {\frac {\pi }{2}}{\tilde {x}})\!$ For n=5:

                                              $f_{k}({\tilde {x}})={\frac {A}{2}}+{\frac {2A}{\pi }}(\sin {\frac {\pi }{2}}{\tilde {x}}+{\frac {1}{3}}\sin {\frac {3\pi }{2}}{\tilde {x}}+{\frac {1}{5}}\sin {\frac {5\pi }{2}}{\tilde {x}})\!$ After transforming the variable of $f({\bar {x}})\!$

                                              $f_{k}(x)={\frac {A}{2}}+\sum _{k=1}^{n}({\frac {2A}{k\pi }}\sin {\frac {k\pi }{2}}(x-.25))\!$ ## R6.3

### Problem Statement

Page 491, #15,17. Plot the truncated Fourier series for n=2,4,8.

### Solution

15.

$f(x)=\left\{{\begin{matrix}-x-\pi ,-\pi

Since $f(-x)=-f(x)$ , the function is odd.

$a_{0}=(1/\pi )*[-1\int _{-\pi }^{-\pi /2}(x+\pi )dx+\int _{-\pi /2}^{\pi /2}(x)dx+\int _{\pi /2}^{\pi }(\pi -x)dx]$
After simplification, $a_{0}=0$
. Using Equation (5) on page 490, the exapansion becomes;
$f(x)=8k/\pi ^{2}[sin(\pi *x/L)-sin(3\pi *x/L)/9...)$
With $L=\pi ,k=\pi /2$  this becomes;
$f(x)=4/\pi (sinx-sin(3x)/9+sin(5x)/25-sin(6x)/36....)$  for n is "odd".
This means when n is even, $f(x)=0$

17.
$f(x)=1-|x|,-1\leq x\leq 1$

$f(x)=\left\{{\begin{matrix}1+x-\pi ,-1

$a_{0}=1/2[\int _{-1}^{0}(1+x)dx+\int _{0}^{1}(1-x)dx]$
$a_{0}=1/2[1-1/2+1-1/2]$

 $a_{0}=1/2$ $a_{n}=1/1[\int _{-1}^{0}(1+x)cos(n\pi *x/1)dx+\int _{0}^{1}(1-x)cos(n\pi *x/1)dx]$
Simplifying results in;
$a_{n}=2[1/(n^{2}\pi ^{2})_{(}-1)^{n}/(n^{2}\pi ^{2})]$
So,

$a_{n}=4/(n^{2}\pi ^{2})$ when n is odd.
$b_{n}=1/1[\int _{-1}^{0}(1+x)sin(n\pi *x/1)dx+\int _{0}^{1}(1-x)sin(n\pi *x/1)dx]$
Simplifying results in;

$b_{n}=0$ $f(x)=1/2+\sum _{n=0}^{\infty }4/(n^{2}\pi ^{2})*cos(n\pi *x)$

Since $a_{n}=0$  for even n, $f(x)$  becomes $f(x)=1/2$  for even n.

## 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

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_{n}cos({\frac {n\pi x}{L}})+b_{n}sin({\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_{1}e^{x}+c_{2}e^{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_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{n}B_{k}sin({\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^{2}cos({\frac {k\pi x}{2}})-B_{n}{\frac {\pi ^{2}}{4}}\sum _{k=3}^{n}k^{2}sin({\frac {k\pi x}{2}})\!$

Plugging these back into the ODE:

$-{\frac {\pi ^{2}}{4}}\sum _{k=3}^{n}A_{k}k^{2}cos({\frac {k\pi x}{2}})-{\frac {\pi ^{2}}{4}}\sum _{k=3}^{n}B_{k}k^{2}sin({\frac {k\pi x}{2}})-3[-{\frac {\pi }{2}}\sum _{k=2}^{n}A_{k}ksin({\frac {k\pi x}{2}})\!$

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

$={\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_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{n}B_{k}sin({\frac {k\pi x}{2}})\!$ ### General Solution

The general solution is

$y=y_{h}+y_{p}\!$

where

$y_{h}=c_{1}e^{x}+c_{2}e^{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_{1}e^{x}+c_{2}e^{2x}+{\frac {1}{4}}+\sum _{k=1}^{2}A_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{2}B_{k}sin({\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_{1}e^{x}+2c_{2}e^{2x}-\sum _{k=2}^{2}{\frac {k\pi }{2}}A_{k}sin({\frac {k\pi x}{2}})+\sum _{k=2}^{2}{\frac {k\pi }{2}}B_{k}cos({\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_{k}cos({\frac {k\pi x}{2}})+\sum _{k=1}^{2}B_{k}sin({\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

## R6.5

Solved by: Gonzalo Perez

### Part R4.2, p.7c-26

For each value of n=3,5,9, re-display the expressions for the 3 functions $y_{p,n}(x),y_{h,n}(x),y_{n}(x)\!$ , and plot these 3 functions separately over the interval $[0,20\pi ]\!$ .

R4.2 p.7-26: Consider the L2-ODE-CC (5) p.7b-7 with $sinx\!$  as excitation:

$y''-3y'+2y=r(x)\!$  (5)p.7-7

$r(x)=sinx\!$  (1)p.9-15

and the initial conditions:

$y(0)=1,y'(0)=0.\!$  (3b)p.3-7

Exact solution: $y(x)=y_{h}(x)+y_{p}(x)\!$  (2)p.9-15

Re-display the expressions for $y_{p}(x),y_{h}(x),y(x)\!$ .

Superpose each of the above plot with that of the exact solution.

### Solution

The graphs are to be separately graphed as follows.

For n = 3, the code that will generate the graph looks like this:

For n = 6:

For n = 9:

### Part R4.3, p.7c-28

Understand and run the TA's code to produce a similar plot, but over a larger interval $[0,10]\!$ . Do zoom-in plots about the points $x=-0.5,0,+0.5\!$  and comment on the accuracy of different approximations.

R4.3 p.7-28: Consider the L2-ODE-CC (5) p.7b-7 with $log(1+x)\!$  as excitation:

$y''-3y'+2y=r(x)\!$  (5)p.7-7

$r(x)=log(1+x)\!$  (1)p.7-28

and the initial conditions:

$y(-{\frac {3}{4}})=1,y'(-{\frac {3}{4}})=0\!$  (2)p.7-28

### Solution

For n=4 (from x = 0 to x = 10):

For n=4 (zoom-in plots around x = -0.5):

For n=4 (zoom-in plots around x = 0):

For n=4 (zoom-in plots around x = +0.5):

For n=7 (from x = 0 to x = 10):

For n=11 (from x = 0 to x = 10):

Where the black line represents n=11 and the blue line represents log(1+x).

The problem asks for n=4, 7, and 11. The TA had up to n=16, but the problem does not ask for this. Manipulating the code and graphs to only account for these n values, n=16 has been disregarded.

Combined plots for n=7 and n=11 (zoom-in plots around x = -0.5):

Combined plots for n=7 and n=11 (zoom-in plots around x = 0):

Combined plots for n=7 and n=11 (zoom-in plots around x = 0.5):

### Part R4.4, p.7c-29

Understand and run the TA's code to produce a similar plot, but over a larger interval $[0.9,10]\!$ , and for n=4,7. Do zoom-in plots about $x=1,1.5,2,2.5\!$  and comments on the accuracy of the approximations.

R4.4 p.7-29: Extend the accuracy of the solution beyond ${\hat {x}}=1\!$ .

### Solution

The general code that can be used to graph the plots of n=4,7,11 is:

With the above code, we can add the following code to graph n=4.

For n = 4 (from x = 0.9 to x = 10):

For n = 7 (from x = 0.9 to x = 10):

For n=11 (from x = 0.9 to x = 10):

Repeating the same common part of the code, let's graph the other plots around x = 1, 1.5, 2, 2.5:

For n = 4, 7, 11 at x = 1:

For n = 4, 7, 11 at x = 1.5:

For n = 4, 7, 11 at x = 2:

For n = 4, 7, 11 at x = 2.5:

For the last part, the first (and unchanged TA's code) is the following:

The second part includes the change that had to be made in order to solve this problem:

## R6.6

### Problem Statement

Given: For the following differential equation: $y_{p}''+4y_{p}'+3y_{p}=2e^{2x}cos(3x)\!$

With a particular solution of the form: $y_{p}=xe^{-2x}(Mcos(3x)+Nsin(3x))\!$

Verify that this solution has a final expression of $y_{p}=6e^{-2x}(Ncos(3x)-Msin(3x))\!$  as follows:

1) Simplify the term $y_{p}''\!$
2) Simplify the 2nd term $4y_{p}'\!$  and combine with the simplified first term
3) Finally add the 3rd term $13y_{p}\!$
4) Find the final expression for $y_{p}(x)\!$

### Solution

1) To find the derivative and simplify $y_{p}''\!$  we will use www.wolframalpha.com.

The "Simplify" command will be exploited as well as the notation for taking a derivative in mathematica. The following was entered into www.wolframalpha.com:

Simplify[D[D[x*exp(-2x)*(Mcos(3x) + Nsin(3x)),x],x]]

The answer that was yielded is as follows:

$y_{p}''=-6Me^{-2x}sin(3x)+12Me^{-2x}xsin(3x)-4Me^{-2x}cos(3x)-5Me^{-2x}xcos(3x)\!$
$-4Ne^{-2x}sin(3x)-5Ne^{-2x}xsin(3x)+6Ne^{-2x}cos(3x)-12Ne^{-2x}xcos(3x)\!$

2) In the same fashion, $4y_{p}'\!$  was evaluated and simplified using www.wolframalpha.com

The following was entered into www.wolframalpha.com:

simplify[4*[D[x*exp(-2x)*(Mcos(3x) + Nsin(3x)),x]]]

The answer that was yielded is as follows:

$4y_{p}'=-12Me^{-2x}xsin(3x)+4Me^{-2x}cos(3x)-8Me^{-2x}xcos(3x)+4Ne^{-2x}sin(3x)-8Ne^{-2x}xsin(3x)+12Ne^{-2x}xcos(3x)\!$

This term can be added to the previous, and then simplified yet again using www.wolframalpha.com

The following was entered into www.wolframalpha.com

Simplify[D[D[x*exp(-2x)*(Mcos(3x) + Nsin(3x)),x],x]+ 4*[D[x*exp(-2x)*(Mcos(3x) + Nsin(3x)),x]]

The answer that was yielded is as follows:

$y_{p}''+4y_{p}'=-6Me^{-2x}sin(3x)-13Me^{-2x}xcos(3x)-13Ne^{-2x}xsin(3x)+6Ne^{-2x}cos(3x)\!$

3) The final term $13y_{p}\!$  is now added to this result, as follows:

$y_{p}''+4y_{p}'+13y_{p}=-6Me^{-2x}sin(3x)-13Me^{-2x}xcos(3x)-13Ne^{-2x}xsin(3x)+6Ne^{-2x}cos(3x)+13Me^{-2x}xcos(3x)+13Ne^{-2x}xsin(3x)\!$

$y_{p}''+4y_{p}'+13y_{p}=-6Me^{-2x}sin(3x)+(13-13)Me^{-2x}xcos(3x)+(13-13)Ne^{-2x}xsin(3x)+6Ne^{-2x}cos(3x)\!$

$y_{p}''+4y_{p}'+13y_{p}=-6Me^{-2x}sin(3x)+6Ne^{-2x}cos(3x)\!$

$y_{p}''+4y_{p}'+13y_{p}=6e^{-2x}(Ncos(3x)-Msin(3x))\!$

4) As verified above, the final term is as follows:

$y_{p}(x)=6e^{-2x}(Ncos(3x)-Msin(3x))\!$

1. www.wolframalpha.com

--Egm4313.s12.team11.sheider (talk) 22:30, 10 April 2012 (UTC)

## R6.7

Solved by Solved by Daniel Suh

#### Problem Statement

Find the separated Ordinary Differential Equations for the heat equation.

${\frac {\partial u}{\partial t}}=\kappa {\frac {\partial ^{2}u}{\partial x^{2}}}\cdots (1)\!$

$u(x,t)=F(x)\cdot G(t)\!$

### Solution

${\frac {\partial u}{\partial t}}=F(x)\cdot {\dot {G}}(t)\cdots (2)\!$

${\frac {\partial ^{2}u}{\partial x^{2}}}=F''(x)\cdot G(t)\cdots (3)\!$

Combine $(2)\!$  and $(3)\!$  into $(1)\!$

$F(x)\cdot {\dot {G}}(t)=\kappa F''(x)\cdot G(t)\!$

${\frac {{\dot {G}}(t)}{\kappa G(t)}}={\frac {F''(x)}{F(x)}}=c\!$  (constant)

Separate

          $F''(x)-cF(x)=0\!$ $G'(t)-\kappa cG(t)=0\!$ 