User:Egm4313.s12.team8/R7

=R7.1 - Verify the functions=

Problem Statement
$$ \displaystyle \text{Verify (1)-(2) }\ $$ ((4) and (5) p19.9, respectively)

$$ \displaystyle \text{Given:} $$

Verifying (1)
$$ \displaystyle \text{From equation } \, $$($$) $$ \displaystyle \, \text{ we have } $$ $$ \displaystyle \langle \bar f, \bar g \rangle := \int_0^L \bar f(x) \, \bar g(x) \, dx, \text{ where we can plug in } \phi \, \text{ from } \, $$ ($$) $$ \displaystyle \, \text{ to get} $$

$$ \displaystyle \text{From } $$ ($$), $$ \displaystyle \text{ and using equation } \, $$ ($$), $$ \displaystyle \, \text{ we get}$$

$$ \displaystyle \text{or} $$

$$ \displaystyle \text{From equation } \, $$ ($$), $$ \displaystyle \text{ for all constants of } \omega_i \text{ and } \omega_j \text{ yield } 0 \text{ as all values of } \sin (\pi) \text{ equal zero. Thus,} $$ $$ \displaystyle \langle \phi_i, \phi_j \rangle = 0 \ \text{ for } \ i \ne j $$

Verifying (2)
$$ \displaystyle \text{Given equation } \, $$($$) $$ \displaystyle \, \text{ and from } $$ ($$), $$ \displaystyle \, \text{ we have } $$

$$ \displaystyle \text{Plugging in the identity, and substituting } L=\pi \text{ from } [0,\pi] \text{ gives } $$

$$ \displaystyle \text{or} $$ $$ \displaystyle \langle \phi_j, \phi_j \rangle := \frac{1}{2} \left [ x - \frac{1}{2 \omega_j} \sin(2 \omega_j x) \right ]_0^\pi $$ $$ \displaystyle \langle \phi_j, \phi_j \rangle := \frac{1}{2} \left [ \pi - \frac{1}{2 \omega_j} \sin(2 \omega_j \pi) \right ] $$ $$ \displaystyle \text{Thus} $$ $$ \displaystyle \langle \phi_j, \phi_j \rangle := \frac{\pi}{2} = \frac{L}{2} \text{ for } i=j. $$

=R7.2 - Plot wave equation solution=

Problem Statement
Plot the truncated-series:
 * $$u(x,t)\,=\,\sum\limits_{j=1}^n a_j \cos(c \omega_j t) \sin(\omega_j x)$$

with $$n=5$$, and for:
 * $$t\,=\,\alpha p_1\,=\,\alpha \frac{2\pi}{c \omega_1}\,=\,\alpha\frac{2L}{c}$$
 * $$\alpha\,=\,0.5,\,1,\,1.5,\,2$$

and:
 * $$\omega_j\,=\,j\frac{\pi}{L}$$
 * $$a_j\,=\,\begin{cases} 0 \text{ for } j=2m \text{ (even)} \\ -4 / (\pi^3 j^3) \text{ for } j = 2 m + 1 \text{ (odd)} \end{cases}$$

Level 1 Solution
The plots are generated with the following Mathematica code:
 * [[Image:egm4313.s12.team8.tclamb.r7.2.src.gif]]


 * [[Image:egm4313.s12.team8.tclamb.plot1.png]]
 * [[Image:egm4313.s12.team8.tclamb.plot2.png]]
 * [[Image:egm4313.s12.team8.tclamb.plot3.png]]
 * [[Image:egm4313.s12.team8.tclamb.plot4.png]]

=R7.3 - Dot products, magnitudes, and angles between functions=

Problem Statement
Find: (a) The scalar product $$\displaystyle < f,g> .$$ (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 $$\displaystyle -2\leq x\leq 10 $$. (2) $$\displaystyle f(x)=\frac{1}{2}(3x^2-1), g(x)=\frac{1}2{(5x^2-3x)} $$ for $$\displaystyle -1\leq x\leq 1 $$.

Part 1
(a) We know that $$\displaystyle < f,g>=\int_{a}^{b}f(x)g(x)dx $$ Plugging in our given $$\displaystyle f $$ and $$\displaystyle g $$ functions: $$\displaystyle \int_{-2}^{10}xcos(x)dx $$    (7.3.1) Integrating (7.3.1) by parts where: $$\displaystyle du=cos(x),v=x,u=sin(x),dv=dx $$ We find: $$\displaystyle \int vdu=vu-\int udv $$ $$\displaystyle \int xcosx=xsinx-\int sinxdx $$ This leads us to the solution: $$\displaystyle =xsinx+cosx+C     (7.3.2)$$ where C=0.

(b) We know that the magnitude of a function is obtained as follows: $$\displaystyle \parallel f\parallel ==[\int_{a}^b{f^2(x)dx}]^{1/2} $$ Plugging our given values in and using trigonometric identities: $$\displaystyle \parallel f(x)\parallel =[\int_{-2}^{10}{cos^2(x)dx}]^{1/2}=[\int_{-2}^{10}{(\frac{1}{2}(cos(2x))+\frac{1}{2})dx}]^{1/2} $$    (7.3.3) Using u substitution on (7.3.3) to integrate, where: $$\displaystyle u=2x,du=2dx $$ We find: $$\displaystyle \frac{1}{4}\int_{-2}^{10}cos(u)du=\int_{-2}^{10}\frac{1}{2}dx $$ This leads to: $$\displaystyle [\frac{1}{2}(sinxcosx+x)\mid _{-2}^{10}]^{1/2} $$ And allows us to solve for our answer: $$\displaystyle \parallel f(x)\parallel =2.47 $$ Doing the same process (without needing to integrate by parts) for our given g function: $$\displaystyle \parallel g(x)\parallel =[\int_{-2}^{10}x^2dx]^{1/2} $$ $$\displaystyle \parallel g(x)\parallel =[\frac{x^3}{3}\mid _{-2}^{10}]$$ Giving us our final magnitude of: $$\displaystyle \parallel g(x)\parallel =18.33 $$

(c) We know that: $$\displaystyle cos(\theta )=\frac{}{\parallel f\parallel \parallel g\parallel }    (7.3.4)$$ Plugging in solved values shows: $$\displaystyle cos(\theta )=\frac{-7.68}{(2.478)(18.33)} $$ Leading us to: $$\displaystyle \theta =1.74 radians $$

Part 2
(a) We know that $$\displaystyle < f,g>=\int_{a}^{b}f(x)g(x)dx $$ Plugging in our given $$\displaystyle f $$ and $$\displaystyle g $$ functions: $$\displaystyle \frac{1}{2}\int_{-1}^{1}(3x^2-1)(5x^3-3x)dx $$    (7.3.5) Integrating (7.3.5), we find: $$\displaystyle \frac{1}{2}[\frac{15}{6}x^6-\frac{14}{4}x^4+\frac{3}{2}x^2\mid _{-1}^{1}]$$ This leads us to the solution: $$\displaystyle =0 $$

(b) We know that the magnitude of a function is obtained as follows: $$\displaystyle \parallel f\parallel ==[\int_{a}^b{f^2(x)dx}]^{1/2} $$ Plugging our given values in and using trigonometric identities: $$\displaystyle \parallel f(x)\parallel =[\int_{-1}^{1}(\frac{3}{2}x^2-\frac{1}{2})^2dx]^{1/2}=[\frac{9}{20}x^5-\frac{x^3}{2}+\frac{x}{4}\mid _{-1}^{1}]^{1/2}$$    (7.3.7) This allows us to solve for our answer: $$\displaystyle \parallel f\parallel =.632456$$

We now obtain the magnitude of the g function in the same way, as follows: $$\displaystyle \parallel g(x)\parallel =[\int_{-1}^{1}(\frac{5}{2}x^3-\frac{3}{2}x)^2dx]^{1/2}=[\frac{25}{28}x^7-\frac{3}{2}x^5+\frac{3}{4}x^3]\mid _{-1}^{1}]^{1/2}$$ Which leads up to our final magnitude: $$\displaystyle \parallel g(x)\parallel = .5345 $$

(c) We know that: $$\displaystyle cos(\theta )=\frac{}{\parallel f\parallel \parallel g\parallel }    (7.3.4)$$ Plugging in (7.3.8) and (7.3.9) shows: $$\displaystyle cos(\theta )=\frac{0}{(.632456)(.5345)} $$ Leading us to: $$\displaystyle \theta =\frac{\pi}{2} $$ radians

=R7.4 - Fourier series of |x|=

Problem Statement
K 2011 page 482 # 6, 9, 12, 13

-for 6 and 9 graph f(x) on $$ \displaystyle -\pi $$ to $$ \displaystyle \pi $$

-for 12 and 13 find the Fourier series of the given function f(x) and sketch or graph the partial sums up to that including $$ \displaystyle \cos(5x) $$ and $$ \displaystyle \sin(5x) $$.

Problem 6
$$ \displaystyle f(x)=|x| $$

Matlab Code:

>> x=linspace(-pi,pi)

>> y=abs(x)

>> plot(x,y)

9.
$$ \displaystyle f(x)=x $$ on $$ \displaystyle (-\pi,0) $$

$$ \displaystyle f(x)=-x+\pi $$ on $$ \displaystyle (0,\pi) $$

Matlab Code:

>> x1=linspace(-pi,0)

>> y1=x1

>> x2=linspace(0,pi)

>> y2=pi-x2

>> plot(x1,y1,x2,y2)

Problem 12
$$ \displaystyle f(x)=|x| $$

This function is an even function.

This is proven by the fact that $$ \displaystyle f(-x)=f(x) $$

Since this is an even function and of period $$ \displaystyle 2\pi $$ its Fourier series reduces to the Fourier cosine series shown here:

$$ \displaystyle f(x)=a_0 + \sum_{n = 1}^{\infty} a_n\cos(nx) $$

Where the coefficients are equal to:

$$ \displaystyle a_0=\frac{1}{\pi}\int_{0}^{\pi}f(x)dx $$

$$ \displaystyle a_n=\frac{2}{\pi}\int_{0}^{\pi}f(x)\cos(nx)dx $$

$$ \displaystyle a_0=\frac{1}{\pi}\int_{0}^{\pi}xdx $$

$$ \displaystyle a_0=\frac{\pi}{2} $$

$$ \displaystyle a_n=\frac{2}{\pi}\int_{0}^{\pi}x\cos(nx)dx $$

Using integration by parts:

$$ \displaystyle a_n=\frac{2}{\pi}(\frac{nx\sin(nx)+\cos(nx)}{n^2})$$ evaluated on x=$$ \displaystyle (0,\pi) $$

Evaluating, reduces to:

$$ \displaystyle a_n=\frac{2}{\pi}(\frac{\cos(\pi n)-1}{n^2}) $$

Plugging this back into the function equation:

$$ \displaystyle f(x)=\frac{\pi}{2} + \sum_{n = 1}^{\infty} \frac{2}{\pi}(\frac{\cos(\pi n)-1}{n^2}) \cos(nx) $$

Expanding this, one obtains:

$$ \displaystyle f(x)=\frac{\pi}{2} - \frac{4}{\pi}(\cos x+ \frac{1}{9}\cos3x+ \frac{1}{25}\cos5x+...) $$

Matlab Code:

>> x=linspace(-pi,pi)

>> y=pi/2-(4/pi)*(cos(x)+(1/9)*cos(3*x)+(1/25)*cos(5*x))

>> plot(x,y)

Problem 13
$$ \displaystyle f(x)=x $$ on $$ \displaystyle (-\pi,0) $$

$$ \displaystyle f(x)=-x+\pi $$ on $$ \displaystyle (0,\pi) $$

Since the function has a period of $$ \displaystyle 2\pi $$ its Fourier series is:

$$ \displaystyle f(x)=a_0 + \sum_{n = 1}^{\infty}(a_n\cos(nx)+ b_n\sin(nx)) $$

Where the coefficients equal:

$$ \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 $$

$$ \displaystyle a_0=\frac{1}{2\pi}\int_{-\pi}^{\pi}f(x)dx $$

$$ \displaystyle a_0=\frac{1}{2\pi}(\int_{-\pi}^{0}xdx+ \int_{0}^{\pi}(\pi-x)dx) $$

$$ \displaystyle a_0=\frac{1}{2\pi}(\frac{-\pi^2}{2}+\pi^2-\frac{\pi^2}{2}) $$

$$ \displaystyle a_0=0 $$

$$ \displaystyle a_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(nx)dx $$

$$ \displaystyle a_n=\frac{1}{\pi}(\int_{-\pi}^{0}x\cos(nx)dx + \int_{0}^{\pi}(\pi-x)\cos(nx)dx) $$

$$ \displaystyle a_n=\frac{1}{\pi}(\int_{-\pi}^{0}x\cos(nx)dx + \int_{0}^{\pi}\pi\cos(nx)dx - \int_{0}^{\pi}x\cos(nx)dx) $$

Using integration by parts and then cancelling like terms:

$$ \displaystyle a_n=\frac{1}{\pi}(\frac{2-2\cos(\pi n)}{n^2})=\frac{2-2\cos(\pi n)}{\pi n^2} $$

$$ \displaystyle b_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\sin(nx)dx $$

$$ \displaystyle b_n=\frac{1}{\pi}(\int_{-\pi}^{0}x\sin(nx)dx + \int_{0}^{\pi}(\pi-x)\sin(nx)dx) $$

$$ \displaystyle b_n=\frac{1}{\pi}(\int_{-\pi}^{0}x\sin(nx)dx + \int_{0}^{\pi}\pi\sin(nx)dx - \int_{0}^{\pi}x\sin(nx)dx) $$

Using integration by parts and then cancelling like terms:

$$ \displaystyle b_n=\frac{1}{\pi}(\frac{\pi-\pi cos(\pi n)}{n})=\frac{1-cos(\pi n)}{n} $$

Plugging this back into the function equation:

$$ \displaystyle f(x)=\sum_{n = 1}^{\infty}(\frac{2-2\cos(\pi n)}{\pi n^2}\cos(nx)+ \frac{1-cos(\pi n)}{n}\sin(nx)) $$

Expanding this, one obtains:

$$ \displaystyle f(x)=\frac{4}{\pi}(\cos x+\frac{1}{9}\cos3x+\frac{1}{25}\cos5x) + 2(\sin x + \frac{1}{3}\sin3x + \frac{1}{5}\sin5x) $$

Matlab Code:

>> x=linspace(-pi,pi)

>> y=(4/pi)*(cos(x)+(1/9)*cos(3*x)+(1/25)*cos(5*x))+2*(sin(x)+(1/3)*sin(3*x)+(1/5)*sin(5*x))

>> plot(x,y)

= R7.5 - Exact integration and numerical confirmation =

Problem Statement
Part 1: Find the exact integration of $$ \int_{0}^{p} \sin (j \omega x) \sin (k \omega x) dx$$ Where $$j \not\equiv k$$ and $$ j,k = 1,2,... $$

Given: $$ p=2 \pi, j=2, k=3$$

Part 2: Confirm the result with MATLAB's trapz command for the trapezoidal rule.

Part 1
Substituting in the provided data gives us:

$$ \int_{0}^{2 \pi} \sin (2 \omega x) \sin (3 \omega x) dx$$

Apply the following trigonometric identity:

$$ \sin(a) \sin(b)=\frac{1}{2} ( \cos(a-b)- \cos(a+b))$$ Where $$ a=2 \omega x, b=3 \omega x$$

The integral becomes:

$$ \int_{0}^{2 \pi} \frac{1}{2} ( \cos(\omega x)- \cos(5 \omega x)) dx$$

$$ \frac{1}{2 \omega} \int_{0}^{2 \pi} \cos(u)du- \frac{1}{10 \omega} \int_{0}^{2 \pi} \cos(v)dv$$

Where $$ u= \omega x, du= \omega dx, v=5 \omega x, dv=5 \omega dx$$

The finite integral becomes:

$$[ \frac{1}{2 \omega} \sin(\omega x)- \frac{1}{10 \omega} \sin(5 \omega x)]_{0}^{2 \pi}$$

We know from the book that $$\omega = \frac{2 \pi}{p}$$ Therefore $$\omega = \frac{2 \pi}{2 \pi} = 1$$

So our finite integral is now:

$$[ \frac{1}{2} \sin(x)- \frac{1}{10} \sin(5x)]_{0}^{2 \pi}=0$$

Part 2
The following is MATLAB code used to determine the definite integral from 0 to $$2 \pi$$ using a step of 0.05:

>> x=0:0.05:2*pi; y=sin(2*x).*sin(3*x); z=trapz(x,y)

z = -1.5564e-004

As we decrease the size of the step and increase the accuracy the result continues to get smaller:

>> x=0:0.01:2*pi; y=sin(2*x).*sin(3*x); z=trapz(x,y)

z = -3.8317e-007 >> x=0:0.001:2*pi; y=sin(2*x).*sin(3*x); z=trapz(x,y)

z = -1.9803e-010

The values are essentially zero and therefore, they confirm the result from integration.

=Team Contributions=