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

Report 7

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

## R7.1

Solved by Andrea Vargas

### Problem Statement

Verify (4)-(5) pg 19-9:
(4) ${\displaystyle \langle \phi _{i},\phi _{j}\rangle =0\!}$ for ${\displaystyle i\neq j\!}$
(5) ${\displaystyle \langle \phi _{j},\phi _{j}\rangle ={\frac {L}{2}}\!}$ for ${\displaystyle i=j\!}$

### Solution

From the lecture notes on p.19-9 we know that:
(2) ${\displaystyle \phi _{i}=\sin(\omega _{i}x)\!}$
(3) ${\displaystyle \langle \phi _{i},\phi _{j}\rangle =\int _{0}^{L}\phi _{i}(x)\phi _{j}(x)dx\!}$

Then, we have
${\displaystyle \langle \phi _{i},\phi _{j}\rangle =\int _{0}^{L}\phi _{i}(x)\phi _{j}(x)dx=\int _{0}^{L}sin(\omega _{i}x)\sin(\omega _{j}x)dx\!}$

Since the period of ${\displaystyle \sin(x)\!}$ is ${\displaystyle 2\pi \!}$ and we know that ${\displaystyle p=2L\!}$, we can assume that ${\displaystyle L=\pi \!}$ for simplicity.

We can compute the result of the previous integral using Wolfram ALpha (Mathematica software). The following is the input given to the software:
int from 0 to pi sin(ax)sin(bx)

where a is ${\displaystyle \omega _{i}\!}$ and b is ${\displaystyle \omega _{j}\!}$. The software generates the following answer:

${\displaystyle \int _{0}^{L}\sin(ax)sin(bx)={\frac {b\sin(\pi a)\cos(\pi b)-a\cos(\pi a)\sin(\pi b)}{a^{2}-b^{2}}}\!}$

Substituting for ${\displaystyle \omega _{i}\!}$ and ${\displaystyle \omega _{j}\!}$:
${\displaystyle \int _{0}^{L}\sin(ax)sin(bx)={\frac {\omega _{j}\sin(\pi \omega _{i})\cos(\pi \omega _{j})-\omega _{i}\cos(\pi \omega _{i})\sin(\pi \omega _{j})}{\omega _{i}^{2}-\omega _{j}^{2}}}\!}$
We also know that ${\displaystyle \sin(c\pi )=0\!}$ where c is any integer. We can cancel any terms with ${\displaystyle \sin(\pi \omega _{i})\!}$ or ${\displaystyle \sin(\pi \omega _{j})\!}$ as they are equal to zero.
Then, we can verify:

                         (4)  ${\displaystyle \langle \phi _{i},\phi _{j}\rangle =0\!}$ for ${\displaystyle i\neq j\!}$


Similarly we can verify (5).
We have
${\displaystyle \langle \phi _{j},\phi _{j}\rangle =\int _{0}^{L}\phi _{j}(x)\phi _{j}(x)dx=\int _{0}^{L}sin(\omega _{j}x)\sin(\omega _{j}x)dx\!}$

Here, we will keep the integration boundaries as ${\displaystyle 0\rightarrow L\!}$ to be consistent with the problem statement.

We can compute the result of the previous integral using Wolfram ALpha (Mathematica software). The following is the input given to the software:
int 0 to L (sin(ax))^2

where a is ${\displaystyle \omega _{j}\!}$. The software generates the following answer:

${\displaystyle \int _{0}^{L}\sin(ax)^{2}={\frac {L}{2}}-{\frac {\sin(2aL)}{4a}}\!}$

Substituting for ${\displaystyle \omega _{j}\!}$:
${\displaystyle \int _{0}^{L}\sin(ax)^{2}={\frac {L}{2}}-{\frac {\sin(2L\omega _{j})}{4\omega _{j}}}\!}$

We know from the previous explanation that ${\displaystyle L=\pi \!}$.So,we can apply the same assumption as before that ${\displaystyle \sin(c\pi )=0\!}$ where c is any integer. This allows us to cancel any terms with ${\displaystyle sin(2L\omega _{j})\!}$ as they are equal to zero.
Then, we can verify:

                         (5)  ${\displaystyle \langle \phi _{j},\phi _{j}\rangle ={\frac {L}{2}}\!}$ for ${\displaystyle i=j\!}$


## R7.2

Solved by Francisco Arrieta

### Problem Statement

Plot the truncated series ${\displaystyle u(x,t)=\sum _{j=1}^{n}a_{j}\cos C\omega _{j}t\sin \omega _{j}x\!}$ with ${\displaystyle n=5\!}$ and for:

${\displaystyle t=\alpha P_{1}=\alpha {\frac {2\pi }{C\omega _{1}}}=\alpha {\frac {2L}{C}}\!}$

${\displaystyle \alpha =0.5,1,1.5,2\!}$

### Solution

Using:

${\displaystyle \left\{{\begin{matrix}f(x)=x(x-2)\\g(x)=0\\C=3\\L=4\end{matrix}}\right.\!}$

Then:

${\displaystyle a_{j}={\frac {2}{L}}\int _{0}^{L}f(x)\sin \omega _{j}xdx\!}$

${\displaystyle =2\left[{\frac {(-1)^{j}-1}{\pi ^{3}j^{3}}}\right]\!}$

${\displaystyle \therefore a_{j}=0\!}$ for all even values of j

Plugging back to the truncated series:

${\displaystyle u(x,t)=\sum _{j=1}^{n}2\left[{\frac {(-1)^{j}-1}{\pi ^{3}j^{3}}}\right]\cos[C{\frac {j\pi }{L}}\alpha {\frac {2L}{C}}]\sin[{\frac {j\pi }{L}}x]\!}$

${\displaystyle =\sum _{j=1}^{n}2\left[{\frac {(-1)^{j}-1}{\pi ^{3}j^{3}}}\right]\cos(\alpha j2\pi )\sin({\frac {j\pi }{2}}x)\!}$

For ${\displaystyle n=5\!}$ :

${\displaystyle u(x,t)=[{\frac {-4}{\pi ^{3}}}\cos(2\pi \alpha )\sin({\frac {\pi x}{2}})]+[{\frac {-4}{27\pi ^{3}}}\cos(6\pi \alpha )\sin({\frac {3\pi x}{2}})]+[{\frac {-4}{125\pi ^{3}}}\cos(10\pi \alpha )\sin({\frac {5\pi x}{2}})]\!}$

When ${\displaystyle \alpha =0.5\!}$ :

When ${\displaystyle \alpha =1\!}$ :

When ${\displaystyle \alpha =1.5\!}$ :

When ${\displaystyle \alpha =2\!}$ :

--Egm4313.s12.team11.arrieta (talk) 06:20, 22 April 2012 (UTC)

## R7.3

#### Problem Statement

Find (a) the scalar product, (b) the magnitude of ${\displaystyle f\!}$ and ${\displaystyle g\!}$ ,(c) the angle between ${\displaystyle f\!}$ and ${\displaystyle g\!}$ for:

1) ${\displaystyle f(x)=cos(x),\ g(x)=x\ for-2\leq x\leq 10\!}$

2) ${\displaystyle f(x)={\frac {1}{2}}(3x^{2}-1),\ g(x)={\frac {1}{2}}(5x^{3}-3x)\ for-1\leq x\leq 1\!}$

#### Part 1

solved by Kyle Gooding

##### Scalar Product

${\displaystyle =\int _{a}^{b}f(x)g(x)\ dx\!}$

${\displaystyle =\int _{-2}^{10}x\cos(x)\ dx\!}$

Using integration by parts;

${\displaystyle =[x\sin(x)+\cos(x)]_{-2}^{10}}$

                      ${\displaystyle =-7.68\!}$

##### Magnitude

${\displaystyle \|f\|=^{1/2}=\int _{a}^{b}f^{2}(x)\ dx\!}$

${\displaystyle =\int _{-2}^{10}[\cos(x)]^{2}\ dx\!}$

${\displaystyle =[.5(x+\sin(x)\cos(x)|_{-2}^{10}]^{1/2}}$

                       ${\displaystyle \|f\|=2.457\!}$


${\displaystyle \|g\|=\int _{a}^{b}g^{2}(x)\ dx\!}$

${\displaystyle =\int _{-2}^{10}x^{2}\ dx}$
${\displaystyle =[x^{3}/3]_{-2}^{10}}$

                       ${\displaystyle \|g\|={\frac {1008}{3}}\!}$

##### Angle Between Functions

${\displaystyle cos(\theta )={\frac {}{\|f\|\|g\|}}\!}$

${\displaystyle cos(\theta )={\frac {-7.68}{{\frac {1008}{3}}(2.457)}}}$

                      ${\displaystyle \theta =89.47}$
The two functions are nearly orthogonal.


#### Part 2

solved by Luca Imponenti

##### Scalar Product

${\displaystyle =\int _{a}^{b}f(x)g(x)\ dx\!}$

${\displaystyle =\int _{-1}^{1}[{\frac {1}{2}}(3x^{2}-1)][{\frac {1}{2}}(5x^{3}-3x)]\ dx\!}$

${\displaystyle =\int _{-1}^{1}{\frac {1}{4}}(15x^{5}-4x^{3}+3x)\ dx\!}$
${\displaystyle =\left.{\frac {1}{4}}({\frac {15}{6}}x^{6}-x^{4}+{\frac {3}{2}}x^{2})\right|_{-1}^{1}\!}$
${\displaystyle ={\frac {1}{4}}[({\frac {15}{6}}1^{6}-1^{4}+{\frac {3}{2}}1^{2})-({\frac {15}{6}}(-1)^{6}-(-1)^{4}+{\frac {3}{2}}(-1)^{2})]\!}$

Since all exponents are even, everything in brackets cancels out

                      ${\displaystyle =0\!}$

##### Magnitude

${\displaystyle \|f\|=^{1/2}=\int _{a}^{b}f^{2}(x)\ dx\!}$

${\displaystyle =\int _{-1}^{1}[{\frac {1}{2}}(3x^{2}-1)]^{2}\ dx\!}$
${\displaystyle =\int _{-1}^{1}{\frac {1}{4}}(9x^{4}-6x^{2}+1)\ dx\!}$
${\displaystyle =\left.{\frac {1}{4}}({\frac {9}{5}}x^{5}-2x^{3}+x)\right|_{-1}^{1}\!}$
${\displaystyle ={\frac {1}{4}}[({\frac {9}{5}}1^{5}-2(1)^{3}+1)-({\frac {9}{5}}(-1)^{5}-2(-1)^{3}+(-1))]\!}$
${\displaystyle ={\frac {1}{4}}[{\frac {4}{5}}-(-{\frac {4}{5}})]\!}$
                       ${\displaystyle \|f\|={\frac {2}{5}}\!}$


${\displaystyle \|g\|=\int _{a}^{b}g^{2}(x)\ dx\!}$

${\displaystyle =\int _{-1}^{1}[{\frac {1}{2}}(5x^{3}-3x)]^{2}\ dx\!}$
${\displaystyle =\int _{-1}^{1}{\frac {1}{4}}(25x^{6}-30x^{4}+9x^{2})\ dx\!}$
${\displaystyle =\left.{\frac {1}{4}}({\frac {25}{7}}x^{7}-6x^{5}+3x^{3})\right|_{-1}^{1}\!}$
${\displaystyle ={\frac {1}{4}}[({\frac {25}{7}}1^{7}-6(1)^{5}+3(1)^{3})-({\frac {25}{7}}(-1)^{7}-6(-1)^{5}+3(-1)^{3})]\!}$
${\displaystyle ={\frac {1}{4}}[{\frac {4}{7}}-(-{\frac {4}{7}})]\!}$
                       ${\displaystyle \|g\|={\frac {2}{7}}\!}$

##### Angle Between Functions

${\displaystyle cos(\theta )={\frac {}{\|f\|\|g\|}}\!}$

Since ${\displaystyle =0\!}$ the two functions are orthogonal

                         ${\displaystyle \theta =90\!}$


## R7.4

Solved by Gonzalo Perez

### K 2011 pg.482 pb. 6

#### Problem Statement

Sketch or graph ${\displaystyle f(x)\!}$ which for ${\displaystyle -\pi is given as follows:

${\displaystyle f(x)=\left|x\right|\!}$

#### Solution

The MATLAB code shown below was used to developed the graph of ${\displaystyle f(x)=\left|x\right|\!}$:

### K 2011 pg.482 pb. 9

#### Problem Statement

Sketch or graph ${\displaystyle f(x)\!}$ which for ${\displaystyle -\pi is given as follows:

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

#### Solution

The MATLAB code shown below was used to developed the graph of the piecewise function ${\displaystyle f(x)=\left\{{\begin{matrix}x,if:-\pi :

Solved by Jonathan Sheider

### K 2011 p.482 pb. 12

#### Problem Statement

Find the Fourier series of the given function which is assumed to have a period of ${\displaystyle 2\pi \!}$. Show the details of your work.
Sketch or graph the partial sums up to that including ${\displaystyle cos(5x)\!}$ and ${\displaystyle sin(5x)\!}$

Given:

${\displaystyle f(x)=|x|\!}$

#### Solution

The Fourier series of a function with a period of ${\displaystyle p=2\pi \!}$ is defined:

${\displaystyle f(x)=a_{0}+\sum _{n=1}^{\infty }(a_{n}cos(nx)+b_{n}sin(nx))\!}$

Where:

${\displaystyle a_{0}={\frac {1}{2\pi }}\int _{-\pi }^{\pi }f(x)dx\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\int _{-\pi }^{\pi }f(x)cos(nx)dx\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\int _{-\pi }^{\pi }f(x)sin(nx)dx\!}$

This particular function given in the problem can be also defined in a piecewise manner over this interval, namely:

${\displaystyle f(x)=\left\{{\begin{matrix}-x{\text{ if }}-\pi \leq x\leq 0\\x{\text{ if }}0\leq x\leq \pi \end{matrix}}\right.\!}$

Calculating the first term ${\displaystyle a_{0}\!}$:

${\displaystyle a_{0}={\frac {1}{2\pi }}\left(\int _{-\pi }^{0}-xdx+\int _{0}^{\pi }xdx\right)\!}$
${\displaystyle a_{0}={\frac {1}{2\pi }}\left(\left[{\frac {-x^{2}}{2}}\right]_{-\pi }^{0}+\left[{\frac {x^{2}}{2}}\right]_{0}^{\pi }\right)\!}$
${\displaystyle a_{0}={\frac {1}{2\pi }}\left(-\left({\frac {-\pi ^{2}}{2}}\right)+\left({\frac {\pi ^{2}}{2}}\right)\right)\!}$
${\displaystyle a_{0}={\frac {1}{2\pi }}(\pi ^{2})\!}$

                                                         ${\displaystyle a_{0}={\frac {\pi }{2}}\!}$


Calculating the coefficient ${\displaystyle a_{n}\!}$:

${\displaystyle a_{n}={\frac {1}{\pi }}\left(\int _{-\pi }^{0}-xcos(nx)dx+\int _{0}^{\pi }xcos(nx)dx\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(-\int _{-\pi }^{0}xcos(nx)dx+\int _{0}^{\pi }xcos(nx)dx\right)\!}$

Using integration by parts with the following substitutions:

${\displaystyle u=x\!}$ and therefore ${\displaystyle du=dx\!}$
${\displaystyle dv=cos(nx)dx\!}$ and therefore ${\displaystyle v={\frac {1}{n}}sin(nx)\!}$

This yields for the integral:

${\displaystyle a_{n}={\frac {1}{\pi }}\left(-\left[{\frac {1}{n}}xsin(nx)-\int {\frac {1}{n}}sin(nx)dx\right]_{-\pi }^{0}+\left[{\frac {1}{n}}xsin(nx)-\int {\frac {1}{n}}sin(nx)dx\right]_{0}^{\pi }\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(-\left[{\frac {1}{n}}xsin(nx)+{\frac {1}{n^{2}}}cos(nx)\right]_{-\pi }^{0}+\left[{\frac {1}{n}}xsin(nx)+{\frac {1}{n^{2}}}cos(nx)\right]_{0}^{\pi }\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(-\left[{\frac {1}{n^{2}}}-\left({\frac {1}{n}}(-\pi )sin(-n\pi )+{\frac {1}{n^{2}}}cos(-n\pi )\right)\right]+\left[{\frac {1}{n}}\pi sin(n\pi )+{\frac {1}{n^{2}}}cos(n\pi )-{\frac {1}{n^{2}}}\right]\right)\!}$

Note that for all n = 1,2,3... : ${\displaystyle sin(n\pi )=0\!}$ as ${\displaystyle sin(\pi )=sin(2\pi )=sin(3\pi )...=0\!}$ therefore these terms are evaluated as zero, which yields:

${\displaystyle a_{n}={\frac {1}{\pi }}\left(-\left[{\frac {1}{n^{2}}}-\left(0+{\frac {1}{n^{2}}}cos(-n\pi )\right)\right]+\left[0+{\frac {1}{n^{2}}}cos(n\pi )-{\frac {1}{n^{2}}}\right]\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(-{\frac {1}{n^{2}}}+{\frac {1}{n^{2}}}cos(-n\pi )+{\frac {1}{n^{2}}}cos(n\pi )-{\frac {1}{n^{2}}}\right)\!}$

Note that ${\displaystyle cos(-x)=cos(x)\!}$ therefore:

${\displaystyle a_{n}={\frac {1}{\pi }}\left(-{\frac {1}{n^{2}}}+{\frac {1}{n^{2}}}cos(n\pi )+{\frac {1}{n^{2}}}cos(n\pi )-{\frac {1}{n^{2}}}\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(-{\frac {2}{n^{2}}}+{\frac {2}{n^{2}}}cos(n\pi )\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(\left(-{\frac {2}{n^{2}}}\right)(1-cos(n\pi )\right)\!}$
${\displaystyle a_{n}=-{\frac {2}{n^{2}\pi }}\left(1-cos(n\pi )\right)\!}$

To evaluate the term ${\displaystyle (1-cos(n\pi ))\!}$:

Note that ${\displaystyle cos(n\pi )=-1\!}$ for odd n values as ${\displaystyle cos(\pi )=cos(3\pi )=cos(5\pi )...=-1\!}$

And that ${\displaystyle cos(n\pi )=1\!}$ for even n values as ${\displaystyle cos(2\pi )=cos(4\pi )=cos(6\pi )...=1\!}$.

Therefore, it can be concluded that for odd n values:

${\displaystyle (1-cos(n\pi ))=1-(-1)=2\!}$

And for even n values:

${\displaystyle (1-cos(n\pi )=1-(1)=0\!}$

Therefore, for the coefficient ${\displaystyle a_{n}\!}$, all even terms will equal zero while all odd terms will have a multiplier of 2, this yields (for all odd n values):

                                            ${\displaystyle a_{n}=-{\frac {4}{n^{2}\pi }}{\text{ for }}n=1,3,5...\!}$


Calculating the coefficient ${\displaystyle b_{n}\!}$:

${\displaystyle b_{n}={\frac {1}{\pi }}\left(\int _{-\pi }^{0}-xsin(nx)dx+\int _{0}^{\pi }xsin(nx)dx\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(-\int _{-\pi }^{0}xsin(nx)dx+\int _{0}^{\pi }xsin(nx)dx\right)\!}$

Using integration by parts with the following substitutions:

${\displaystyle u=x\!}$ and therefore ${\displaystyle du=dx\!}$
${\displaystyle dv=sin(nx)dx\!}$ and therefore ${\displaystyle v={\frac {-1}{n}}cos(nx)\!}$

This yields for the integral:

${\displaystyle b_{n}={\frac {1}{\pi }}\left(-\left[{\frac {-1}{n}}xcos(nx)-\int {\frac {-1}{n}}cos(nx)dx\right]_{-\pi }^{0}+\left[{\frac {-1}{n}}xcos(nx)-\int {\frac {-1}{n}}cos(nx)dx\right]_{0}^{\pi }\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(-\left[{\frac {-1}{n}}xcos(nx)+{\frac {1}{n^{2}}}sin(nx)\right]_{-\pi }^{0}+\left[{\frac {-1}{n}}xcos(nx)+{\frac {1}{n^{2}}}sin(nx)\right]_{0}^{\pi }\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(-\left[0-\left({\frac {-1}{n}}(-\pi )cos(-n\pi )+{\frac {1}{n^{2}}}sin(-n\pi )\right)\right]+\left[{\frac {-1}{n}}\pi cos(n\pi )+{\frac {1}{n^{2}}}sin(n\pi )-0\right]\right)\!}$

Note that for all n = 1,2,3... : ${\displaystyle sin(n\pi )=0\!}$ as ${\displaystyle sin(\pi )=sin(2\pi )=sin(3\pi )...=0\!}$ therefore these terms are evaluated as zero, which yields:

${\displaystyle b_{n}={\frac {1}{\pi }}\left(-\left[0-\left({\frac {-1}{n}}(-\pi )cos(-n\pi )+0\right)\right]+\left[{\frac {-1}{n}}\pi cos(n\pi )+0\right]\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(\left[{\frac {1}{n}}(\pi )cos(-n\pi )\right]+\left[{\frac {-1}{n}}\pi cos(n\pi )\right]\right)\!}$

Note that ${\displaystyle cos(-x)=cos(x)\!}$ therefore:

${\displaystyle b_{n}={\frac {1}{\pi }}\left({\frac {1}{n}}\pi cos(n\pi )+{\frac {-1}{n}}\pi cos(n\pi )\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(0\right)\!}$

                                                       ${\displaystyle b_{n}=0\!}$


Therefore there will be no ${\displaystyle sin(nx)\!}$ terms in the Fourier representation. In conclusion, the Fourier series representation for the given function is as follows:

${\displaystyle f(x)={\frac {\pi }{2}}-{\frac {4}{\pi }}cos(x)-{\frac {4}{3^{2}\pi }}cos(3x)-{\frac {4}{5^{2}\pi }}cos(5x)+...\!}$

                                    ${\displaystyle f(x)={\frac {\pi }{2}}-{\frac {4}{\pi }}\left(cos(x)+{\frac {1}{9}}cos(3x)+{\frac {1}{25}}cos(5x)+...\right)\!}$


A graph of the function, and the Fourier series for ${\displaystyle n=1,3,5\!}$ is shown below:

--Egm4313.s12.team11.sheider (talk) 06:00, 22 April 2012 (UTC)

### K 2011 p.482 pb. 13

#### Problem Statement

Find the Fourier series of the given function which is assumed to have a period of ${\displaystyle 2\pi \!}$. Show the details of your work.
Sketch or graph the partial sums up to that including ${\displaystyle cos(5x)\!}$ and ${\displaystyle sin(5x)\!}$

Given:

${\displaystyle f(x)=\left\{{\begin{matrix}-x{\text{ if }}-\pi

#### Solution

The Fourier series of a function with a period of ${\displaystyle p=2\pi \!}$ is defined:

${\displaystyle f(x)=a_{0}+\sum _{n=1}^{\infty }(a_{n}cos(nx)+b_{n}sin(nx))\!}$

Where:

${\displaystyle a_{0}={\frac {1}{2\pi }}\int _{-\pi }^{\pi }f(x)dx\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\int _{-\pi }^{\pi }f(x)cos(nx)dx\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\int _{-\pi }^{\pi }f(x)sin(nx)dx\!}$

Calculating the first term ${\displaystyle a_{0}\!}$:

${\displaystyle a_{0}={\frac {1}{2\pi }}\left(\int _{-\pi }^{0}xdx+\int _{0}^{\pi }(\pi -x)dx\right)\!}$
${\displaystyle a_{0}={\frac {1}{2\pi }}\left(\left[{\frac {x^{2}}{2}}\right]_{-\pi }^{0}+\left[\pi x-{\frac {x^{2}}{2}}\right]_{0}^{\pi }\right)\!}$
${\displaystyle a_{0}={\frac {1}{2\pi }}\left(-\left({\frac {\pi ^{2}}{2}}\right)+\left(\pi ^{2}-{\frac {\pi ^{2}}{2}}\right)\right)\!}$
${\displaystyle a_{0}={\frac {1}{2\pi }}\left(-{\frac {\pi ^{2}}{2}}+\pi ^{2}-{\frac {\pi ^{2}}{2}}\right)\!}$
${\displaystyle a_{0}={\frac {1}{2\pi }}\left(\pi ^{2}-\pi ^{2}\right)\!}$

                                                         ${\displaystyle a_{0}=0\!}$


Calculating the coefficient ${\displaystyle a_{n}\!}$:

${\displaystyle a_{n}={\frac {1}{\pi }}\left(\int _{-\pi }^{0}xcos(nx)dx+\int _{0}^{\pi }(\pi -x)cos(nx)dx\right)\!}$

Using integration by parts with the following substitutions for the integral ${\displaystyle \int _{-\pi }^{0}xcos(nx)dx\!}$:

${\displaystyle u=x\!}$ and therefore ${\displaystyle du=dx\!}$
${\displaystyle dv=cos(nx)dx\!}$ and therefore ${\displaystyle v={\frac {1}{n}}sin(nx)\!}$

Using integration by parts with the following substitutions for the integral ${\displaystyle \int _{0}^{\pi }(\pi -x)cos(nx)dx\!}$:

${\displaystyle u=\pi -x\!}$ and therefore ${\displaystyle du=-dx\!}$
${\displaystyle dv=cos(nx)dx\!}$ and therefore ${\displaystyle v={\frac {1}{n}}sin(nx)\!}$

This yields for the overall expression:

${\displaystyle a_{n}={\frac {1}{\pi }}\left(\left[{\frac {1}{n}}xsin(nx)-\int {\frac {1}{n}}sin(nx)dx\right]_{-\pi }^{0}+\left[{\frac {1}{n}}(\pi -x)sin(nx)-\int -{\frac {1}{n}}sin(nx)dx\right]_{0}^{\pi }\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(\left[{\frac {1}{n}}xsin(nx)+{\frac {1}{n^{2}}}cos(nx)\right]_{-\pi }^{0}+\left[{\frac {1}{n}}(\pi -x)sin(nx)-{\frac {1}{n^{2}}}cos(nx)\right]_{0}^{\pi }\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(\left[{\frac {1}{n^{2}}}-\left({\frac {1}{n}}(-\pi )sin(-n\pi )+{\frac {1}{n^{2}}}cos(-n\pi )\right)\right]+\left[-{\frac {1}{n^{2}}}cos(n\pi )+{\frac {1}{n^{2}}}\right]\right)\!}$

Note that for all n = 1,2,3... : ${\displaystyle sin(n\pi )=0\!}$ as ${\displaystyle sin(\pi )=sin(2\pi )=sin(3\pi )...=0\!}$ therefore these terms are evaluated as zero, which yields:

${\displaystyle a_{n}={\frac {1}{\pi }}\left(\left[{\frac {1}{n^{2}}}-0-{\frac {1}{n^{2}}}cos(-n\pi )\right]+\left[-{\frac {1}{n^{2}}}cos(n\pi )+{\frac {1}{n^{2}}}\right]\right)\!}$

${\displaystyle a_{n}={\frac {1}{\pi }}\left({\frac {1}{n^{2}}}-{\frac {1}{n^{2}}}cos(-n\pi )-{\frac {1}{n^{2}}}cos(n\pi )+{\frac {1}{n^{2}}}\right)\!}$

Note that ${\displaystyle cos(-x)=cos(x)\!}$ therefore:

${\displaystyle a_{n}={\frac {1}{\pi }}\left({\frac {1}{n^{2}}}-{\frac {1}{n^{2}}}cos(n\pi )-{\frac {1}{n^{2}}}cos(n\pi )+{\frac {1}{n^{2}}}\right)\!}$

${\displaystyle a_{n}={\frac {1}{\pi }}\left({\frac {2}{n^{2}}}-{\frac {2}{n^{2}}}cos(n\pi )\right)\!}$
${\displaystyle a_{n}={\frac {1}{\pi }}\left(\left({\frac {2}{n^{2}}}\right)(1-cos(n\pi ))\right)\!}$
${\displaystyle a_{n}={\frac {2}{n^{2}\pi }}\left(1-cos(n\pi )\right)\!}$

To evaluate the term ${\displaystyle (1-cos(n\pi ))\!}$:

Note that ${\displaystyle cos(n\pi )=-1\!}$ for odd n values as ${\displaystyle cos(\pi )=cos(3\pi )=cos(5\pi )...=-1\!}$

And that ${\displaystyle cos(n\pi )=1\!}$ for even n values as ${\displaystyle cos(2\pi )=cos(4\pi )=cos(6\pi )...=1\!}$.

Therefore, it can be concluded that for odd n values:

${\displaystyle (1-cos(n\pi ))=1-(-1)=2\!}$

And for even n values:

${\displaystyle (1-cos(n\pi ))=1-(1)=0\!}$

Therefore, for the coefficient ${\displaystyle a_{n}\!}$, all even terms will equal zero while all odd terms will have a multiplier of 2, this yields (for all odd n values):

                                            ${\displaystyle a_{n}={\frac {4}{n^{2}\pi }}{\text{ for }}n=1,3,5...\!}$


Calculating the coefficient ${\displaystyle b_{n}\!}$:

${\displaystyle b_{n}={\frac {1}{\pi }}\left(\int _{-\pi }^{0}xsin(nx)dx+\int _{0}^{\pi }(\pi -x)sin(nx)dx\right)\!}$

Using integration by parts with the following substitutions for the integral ${\displaystyle \int _{-\pi }^{0}xsin(nx)dx\!}$:

${\displaystyle u=x\!}$ and therefore ${\displaystyle du=dx\!}$
${\displaystyle dv=sin(nx)dx\!}$ and therefore ${\displaystyle v={\frac {-1}{n}}cos(nx)\!}$

Using integration by parts with the following substitutions for the integral ${\displaystyle \int _{0}^{\pi }(\pi -x)sin(nx)dx\!}$:

${\displaystyle u=\pi -x\!}$ and therefore ${\displaystyle du=-dx\!}$
${\displaystyle dv=sin(nx)dx\!}$ and therefore ${\displaystyle v={\frac {-1}{n}}cos(nx)\!}$

This yields for the overall expression:

${\displaystyle b_{n}={\frac {1}{\pi }}\left(\left[{\frac {-1}{n}}xcos(nx)-\int {\frac {-1}{n}}cos(nx)dx\right]_{-\pi }^{0}+\left[{\frac {-1}{n}}(\pi -x)cos(nx)-\int -{\frac {-1}{n}}cos(nx)dx\right]_{0}^{\pi }\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(\left[{\frac {-1}{n}}xcos(nx)+{\frac {1}{n^{2}}}sin(nx)\right]_{-\pi }^{0}+\left[{\frac {-1}{n}}(\pi -x)cos(nx)-{\frac {1}{n^{2}}}sin(nx)\right]_{0}^{\pi }\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(\left[0-\left({\frac {-1}{n}}(-\pi )cos(-n\pi )+{\frac {1}{n^{2}}}sin(-n\pi )\right)\right]+\left[-{\frac {1}{n^{2}}}sin(n\pi )-\left({\frac {-1}{n}}\pi \right)\right]\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(-{\frac {1}{n}}\pi cos(-n\pi )-{\frac {1}{n^{2}}}sin(-n\pi )-{\frac {1}{n^{2}}}sin(n\pi )+{\frac {1}{n}}\pi \right)\!}$

Note that for all n = 1,2,3... : ${\displaystyle sin(n\pi )=0\!}$ as ${\displaystyle sin(\pi )=sin(2\pi )=sin(3\pi )...=0\!}$ therefore these terms are evaluated as zero, which yields:

${\displaystyle b_{n}={\frac {1}{\pi }}\left(-{\frac {1}{n}}\pi cos(-n\pi )-0-0+{\frac {1}{n}}\pi \right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left({\frac {1}{n}}\pi -{\frac {1}{n}}\pi cos(-n\pi )\right)\!}$

Note that ${\displaystyle cos(-x)=cos(x)\!}$ therefore:

${\displaystyle b_{n}={\frac {1}{\pi }}\left({\frac {1}{n}}\pi -{\frac {1}{n}}\pi cos(n\pi )\right)\!}$
${\displaystyle b_{n}={\frac {1}{\pi }}\left(\left({\frac {\pi }{n}}\right)(1-cos(n\pi ))\right)\!}$
${\displaystyle b_{n}={\frac {1}{n}}\left(1-cos(n\pi )\right)\!}$

To evaluate the term ${\displaystyle (1-cos(n\pi ))\!}$:

Note that ${\displaystyle cos(n\pi )=-1\!}$ for odd n values as ${\displaystyle cos(\pi )=cos(3\pi )=cos(5\pi )...=-1\!}$

And that ${\displaystyle cos(n\pi )=1\!}$ for even n values as ${\displaystyle cos(2\pi )=cos(4\pi )=cos(6\pi )...=1\!}$.

Therefore, it can be concluded that for odd n values:

${\displaystyle (1-cos(n\pi ))=1-(-1)=2\!}$

And for even n values:

${\displaystyle (1-cos(n\pi ))=1-(1)=0\!}$

Therefore, for the coefficient ${\displaystyle b_{n}\!}$, all even terms will equal zero while all odd terms will have a multiplier of 2, this yields (for all odd n values):

                                            ${\displaystyle b_{n}={\frac {2}{n}}{\text{ for }}n=1,3,5...\!}$


In conclusion, the Fourier series representation for the given function is as follows:

${\displaystyle f(x)=0+\left({\frac {4}{\pi }}cos(x)+{\frac {4}{3^{2}\pi }}cos(3x)+{\frac {4}{5^{2}\pi }}cos(5x)+...\right)+\left(2sin(x)+{\frac {2}{3}}sin(3x)+{\frac {2}{5}}sin(5x)+...\right)\!}$

                   ${\displaystyle f(x)={\frac {4}{\pi }}\left(cos(x)+{\frac {1}{9}}cos(3x)+{\frac {1}{25}}cos(5x)+...\right)+2\left(sin(x)+{\frac {1}{3}}sin(3x)+{\frac {1}{5}}sin(5x)+...\right)\!}$


A graph of the function, and the Fourier series for ${\displaystyle n=1,3,5\!}$ is shown below:

--Egm4313.s12.team11.sheider (talk) 06:00, 22 April 2012 (UTC)

## R7.5

Solved by Daniel Suh

### Problem Statement

Consider the following,
${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle =\int _{0}^{p}\phi _{2j-1}(x)\cdot \phi _{2k-1}(x)dx\!}$

${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle =\int _{0}^{p}\sin {j\omega x}\cdot \sin {k\omega x}\;dx\!}$

with ${\displaystyle j\neq k\;and\;j,k=1,2,...\!}$, and ${\displaystyle p=2\pi ,j=2,k=3\!}$

1. Find the integration with the given data.

2. Confirm the results with Matlab's trapz command for the trapezoidal rule.

### Solution

#### Part 1

##### Trigonometric Identities

Angle Sum and Difference Identities

${\displaystyle (1)\cos {(a+b)}=\cos {a}\cos {b}-\sin {a}\sin {b}\!}$
${\displaystyle (2)\cos {(a-b)}=\cos {a}\cos {b}+\sin {a}\sin {b}\!}$

Rearrange

${\displaystyle (1)\sin {a}\sin {b}=\cos {a}\cos {b}-\cos {(a+b)}\!}$
${\displaystyle (2)\cos {a}\cos {b}=\cos {(a-b)}-\sin {a}\sin {b}\!}$

Substitute and Combine

${\displaystyle \sin {a}\sin {b}=\cos {(a-b)}-\sin {a}\sin {b}-\cos {(a+b)}\!}$
${\displaystyle 2\sin {a}\sin {b}=\cos {(a-b)}-\cos {(a+b)}\!}$
${\displaystyle \sin {a}\sin {b}={\frac {1}{2}}\cos {(a-b)}-{\frac {1}{2}}\cos {(a+b)}\!}$

##### Utilize Trig Identities

${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle =\int _{0}^{p}\sin {jwx}\cdot \sin {kwx}\;dx\!}$

${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle =\int _{0}^{2\pi }\sin {2\omega x}\cdot \sin {3\omega x}\;dx\!}$

${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle =\int _{0}^{2\pi }{\frac {1}{2}}\cos {(2\omega x-3\omega x)}-{\frac {1}{2}}\cos {(2\omega x+3\omega x)}\;dx\!}$

${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle ={\frac {1}{2}}\int _{0}^{2\pi }\cos {(-\omega x)}\;dx-{\frac {1}{2}}\int _{0}^{2\pi }\cos {(5\omega x)}\;dx\!}$

${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle ={\frac {1}{2}}\sin {(-\omega x)}|_{0}^{2\pi }-{\frac {1}{2}}\sin {(5\omega x)}|_{0}^{2\pi }\!}$

${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle =(0-0)-(0-0)\!}$

                      ${\displaystyle \left\langle \phi _{2j-1},\phi _{2k-1}\right\rangle =0\!}$


#### Part 2

>> X = 0:2*pi/100:2*pi;

>> Y = sin(2*X).*sin(3*X);

>> Z = trapz(X,Y)

Z =

 2.9490e-017