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

Report 7

## R 7.1

### Question

Verify (4)-(5) p.19-9.
(4):

${\displaystyle <\Phi _{i},\Phi _{j}>=0,i\neq j}$

(5):

${\displaystyle <\Phi _{i},\Phi _{j}>={\frac {L}{2}},i=j}$

### Solution

We know that:

${\displaystyle \Phi _{j}(x):=sin\omega _{j}x,j=1,2,...}$

We also know by definition that:

${\displaystyle \langle {\bar {f}},{\bar {g}}\rangle :=\int _{0}^{L}{\bar {f}}(x)\,{\bar {g}}(x)\,dx}$

Therefore, we start with Eq. (4) and use the above definitions to obtain the following results:

${\displaystyle <\Phi _{i},\Phi _{j}>=\int _{0}^{L}sin(\omega _{i}x)sin(\omega _{j}x)dx}$

For simplicity's sake, we set L equal to ${\displaystyle \pi }$. This yields the following result:

${\displaystyle \int _{0}^{\pi }sin(\omega _{i}x)sin(\omega _{j}x)dx={\frac {(\omega _{i}-\omega _{j})sin((\omega _{i}+\omega _{j})x)+(-\omega _{i}-\omega _{j})sin((\omega _{i}-\omega _{j})x)}{2\omega _{i}^{2}-2\omega _{j}^{2}}}}$

This last expression is evaluated from ${\displaystyle \pi }$ to zero. We know as a geometric property that the following two things are true:

${\displaystyle sin(C\pi )=0}$
${\displaystyle sin(0)=0}$

Where "C" is any positive integer. We also know that since L = ${\displaystyle \pi }$, p = 2L = ${\displaystyle 2\pi }$, and ${\displaystyle \omega ={\frac {2\pi }{p}}={\frac {2\pi }{2\pi }}=1}$, so therefore every sine term in the definite integral is 0 when both ${\displaystyle \pi }$ and 0 are evaluated. Therefore, we know that:

${\displaystyle <\Phi _{i},\Phi _{j}>=0,i\neq j}$

Now, for Eq. (5), we evaluate is as follows:

${\displaystyle <\Phi _{j},\Phi _{j}>=\int _{0}^{L}sin(\omega _{j}x)^{2}dx}$

Again, we set L equal to ${\displaystyle \pi }$ to make the expression easier to evaluate. This yields:

${\displaystyle \int _{0}^{\pi }sin(\omega _{j}x)^{2}dx=-({\frac {sin(2\omega _{j}x)-2\omega _{j}x}{4\omega _{j}}})}$

This integral is evaluated from ${\displaystyle \pi }$ to 0. Again, we know that the sine terms will be zero no matter which boundary we plug again, since ${\displaystyle \omega =1}$. Therefore, the evaluation simplifies to:

${\displaystyle -(-{\frac {2\omega _{j}\pi }{4\omega _{j}}}-0)={\frac {\pi }{2}}}$

Since we set L equal to ${\displaystyle \pi }$, we have thus proven Eq. (5).

### Author

This problem was solved and uploaded by: William Knapper

## R 7.2

### Question

Plot the truncated series ${\displaystyle \displaystyle u(x,t)=\sum _{j=1}^{n}a_{j}cos(cw_{j}t)sin(\omega _{j}x)}$
with n=5 and for ${\displaystyle \displaystyle t=\alpha {\frac {2L}{c}}}$
where ${\displaystyle \displaystyle \alpha =0.5,1,1.5,2}$

### Solution

Matlab Code:

% Report 7 Problem 2
% Plot truncated series for n=5
% Given values
L = 2;
c = 3;
% Calculate alphas for use in t
alpha = (0.5:.5:2); % four alpha terms
t = ((alpha.*2*L)/c); % four "t" terms corresponding to the four alpha terms
% Calculate omegas (w)
j = (1:1:5); % series terms 1-5
w = ((j*pi)/L); % omega correspoding to series terms 1-5
% Calculate "a" coefficients
% Check if "a" is odd or even, then assign value
a = j;
for k=1:5;
if mod(k,2) == 0 % even term
a(k) = 0;
else % odd term
a(k) = -4/(pi^3*k^3);
end
end
% Calculate truncated series (note that a2=a4=0, so those terms in the
% series have no contribution
x=(0:0.01:2);
% For t=0.5
y1=zeros(size(x));
for k=1:5
y1 = y1 + a(k)*cos(c*w(k)*t(1))*sin(w(k)*x);
end
% For t=1.0
y2=zeros(size(x));
for k=1:5
y2 = y2 + a(k)*cos(c*w(k)*t(2))*sin(w(k)*x);
end
% For t=1.5
y3=zeros(size(x));
for k=1:5
y3 = y3 + a(k)*cos(c*w(k)*t(3))*sin(w(k)*x);
end
% For t=2.0
y4=zeros(size(x));
for k=1:5
y4 = y4 + a(k)*cos(c*w(k)*t(4))*sin(w(k)*x);
end
% Compare to original function
yorg = x.*(x-2);
plot(x,y1,x,y2,x,y3,x,y4,x,yorg)
legend('t=0.5','t=1.0','t=1.5','t=2.0','org function')

Plot of 4 different t's and original function:

### Author

This problem was solved and uploaded by: Josh House

## R 7.3

### Question

Find the a) scalar product, b) the magnitude, and c) the angle between:

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

and

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

### Solution

The scalar product between 2 functions on the interval [a,b] is defined by:

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

The magnitude of a function is defined by:

${\displaystyle \displaystyle \left\|f\right\|=^{\frac {1}{2}}=\left[\int _{a}^{b}f^{2}(x)dx\right]^{\frac {1}{2}}\ }$

The angle between 2 functions is defined by:

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

Problem 1:

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

Using integration by parts: ${\displaystyle \displaystyle u=x,du=dx,dV=\cos(x)dx,V=\sin(x)\ }$

The integral becomes:  ${\displaystyle \displaystyle x\sin(x)-\int \sin(x)dx=x\sin(x)+\cos(x)\mid _{-2}^{10}=-7.68\ }$
${\displaystyle \displaystyle \left\|f\right\|=[\int _{-2}^{10}\cos ^{2}(x)dx]^{\frac {1}{2}}=[\int _{-2}^{10}{\frac {1+\cos(2x)}{2}}dx]^{\frac {1}{2}}=[{\frac {x}{2}}+{\frac {\sin(2x)}{4}}\mid _{-2}^{10}]^{\frac {1}{2}}=2.46\ }$
${\displaystyle \displaystyle \left\|g\right\|=[\int _{-2}^{10}x^{2}dx]^{\frac {1}{2}}=[{\frac {x^{3}}{3}}\mid _{-2}^{10}]^{\frac {1}{2}}=18.33\ }$
${\displaystyle \displaystyle \cos(\theta )={\frac {-7.68}{18.33*2.46}}\Rightarrow \theta =1.742\ }$ rads

Problem 2:

${\displaystyle \displaystyle =\int _{-1}^{1}{\frac {1}{2}}(3x^{2}-1)*{\frac {1}{2}}(5x^{3}-3x)dx=\int _{-1}^{1}({\frac {15}{4}}x^{5}-{\frac {7}{2}}x^{3}+{\frac {3}{4}}x)dx\ }$

The integral becomes: ${\displaystyle \displaystyle {\frac {5}{8}}x^{6}-{\frac {7}{8}}x^{4}+{\frac {3}{8}}x^{2}\mid _{-1}^{1}=0\ }$
${\displaystyle \displaystyle \left\|f\right\|=[\int _{-1}^{1}[{\frac {1}{2}}(3x^{2}-1)]^{2}dx]^{\frac {1}{2}}=[\int _{-1}^{1}({\frac {9}{4}}x^{4}-{\frac {3}{2}}x^{2}+{\frac {1}{4}})dx]^{\frac {1}{2}}=[{\frac {9}{20}}x^{5}-{\frac {1}{2}}x^{3}+{\frac {1}{4}}x\mid _{-1}^{1}]^{\frac {1}{2}}=0.632\ }$
${\displaystyle \displaystyle \left\|g\right\|=[\int _{-1}^{1}[{\frac {1}{2}}(5x^{3}-3x)]^{2}dx]^{\frac {1}{2}}=[\int _{-1}^{1}({\frac {25}{4}}x^{6}-{\frac {15}{2}}x^{4}+{\frac {9}{4}}x^{2})dx]^{\frac {1}{2}}=[{\frac {25}{28}}x^{7}-{\frac {3}{2}}x^{5}+{\frac {3}{4}}x^{3}\mid _{-1}^{1}]^{\frac {1}{2}}=0.535\ }$
${\displaystyle \displaystyle \cos(\theta )=0\Rightarrow \theta =\pi /2\ }$ rads.

### Author

This problem was solved and uploaded by: David Herrick

## R 7.4

### Question

K. 2011 p482 pb. 6,9,12,13:

problems 6,9: Sketch or graph f(x) for ${\displaystyle -\pi .

problems 12,13: Find the fourier series for the f(x) in problems 6 and 9 respectively up to n = 5.

Problem 6: f(x) = |x| for ${\displaystyle -\pi

Problem 9: f(x) = x for ${\displaystyle -\pi

and f(x) = ${\displaystyle \pi -x}$ if ${\displaystyle 0

### Solution

Problem 6: f(x) = |x|

MATLAB code used:

Problem 9:
${\displaystyle f(x)=x}$ if ${\displaystyle -\pi
${\displaystyle f(x)=\pi -x}$ if ${\displaystyle 0

MATLAB code used:

Problem 12:
f(x) = |x| breaks down into:
${\displaystyle f(x)=-x}$ if ${\displaystyle -\pi and
${\displaystyle f(x)=x}$ if ${\displaystyle 0
The formula for the fourier series is:
${\displaystyle f(x)=a_{0}+\sum _{n=1}^{\infty }[a_{n}\cos(nx)+b_{n}\sin(nx)]}$
The euler formulas are also:
${\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}$
Therefore:
${\displaystyle a_{0}={\frac {1}{2\pi }}[\int _{-\pi }^{0}-xdx+\int _{0}^{\pi }xdx]}$
${\displaystyle a_{n}={\frac {1}{\pi }}[\int _{-\pi }^{0}-x\cos(nx)dx+\int _{0}^{\pi }x\cos(nx)dx]}$
${\displaystyle b_{n}={\frac {1}{\pi }}[\int _{-\pi }^{0}-x\sin(nx)dx+\int _{0}^{\pi }x\sin(nx)dx]}$
After integration for ${\displaystyle a_{0}}$ and integration by parts for ${\displaystyle a_{n}}$ and ${\displaystyle b_{n}}$:
${\displaystyle a_{0}={\frac {\pi }{2}}}$
${\displaystyle a_{n}={\frac {2}{\pi n^{2}}}(\cos(-n\pi )-1)}$
${\displaystyle b_{n}=0}$
Similarly, for n = even, ${\displaystyle a_{n}=0}$ and for n = odd, ${\displaystyle a_{n}={\frac {-4}{n^{2}\pi }}}$
Therefore, the fourier series out to n = 5 is:

${\displaystyle f_{5}(x)={\frac {\pi }{2}}-{\frac {4}{\pi }}\cos(x)-{\frac {4}{9\pi }}\cos(3x)-{\frac {4}{25\pi }}\cos(5x)}$

Problem 13:
${\displaystyle f(x)=x}$ if ${\displaystyle -\pi
${\displaystyle f(x)=\pi -x}$ if ${\displaystyle 0
The euler formulas are the same as in problem 12. Plugging in problem 13's f(x):
${\displaystyle a_{0}={\frac {1}{2\pi }}[\int _{-\pi }^{0}xdx+\int _{0}^{\pi }(\pi -x)dx]}$
${\displaystyle a_{n}={\frac {1}{\pi }}[\int _{-\pi }^{0}x\cos(nx)dx+\int _{0}^{\pi }(\pi -x)\cos(nx)dx]}$
${\displaystyle b_{n}={\frac {1}{\pi }}[\int _{-\pi }^{0}x\sin(nx)dx+\int _{0}^{\pi }(\pi -x)\sin(nx)dx]}$
Therefore, after using integration for ${\displaystyle a_{0}}$ and integration by parts for ${\displaystyle a_{n}}$ and ${\displaystyle b_{n}}$:
${\displaystyle a_{0}=0}$
${\displaystyle a_{n}={\frac {2}{n^{2}\pi }}(1-\cos(n\pi ))}$
${\displaystyle b_{n}={\frac {1}{n}}(1-\cos(n\pi ))}$
Therefore, when n is odd, ${\displaystyle a_{n}={\frac {4}{n^{2}\pi }}}$ and ${\displaystyle b_{n}={\frac {2}{n}}}$.
Similarly, when n is even, ${\displaystyle a_{n}=0=b_{n}}$.
Therefore, the fourier series out to n = 5 is:

${\displaystyle f_{5}(x)={\frac {4}{\pi }}[\cos(x)+{\frac {1}{9}}\cos(3x)+{\frac {1}{25}}\cos(5x)]+2[\sin(x)+{\frac {1}{3}}\sin(3x)+{\frac {1}{5}}\sin(5x)]}$

### Author

The problem was solved and uploaded by John North.

## R 7.5

### Question

Consider (1)p.12-4:
${\displaystyle <\Phi _{2j-1}\Phi _{2k-1}>=\int _{0}^{p}\sin j\omega x\cdot \sin k\omega xdx}$
where ${\displaystyle p=2\pi ,j=2,k=3.}$

1. Find the exact integration of (1)p.12-4 with the given data.
2. Confirm the result with matlab's trapz command for the trapezoidal rule as explained in (4)p.11-2.

### Solution

#### Part 1

Using (3)p19-10 we get:
${\displaystyle \int _{0}^{2\pi }\sin j\omega x\cdot \sin k\omega xdx=\int _{0}^{2\pi }{\frac {1}{2}}\left[cos(j\omega -k\omega )x-cos(j\omega +k\omega )x\right]dx}$

Integrating we get:
${\displaystyle {\frac {sin((j\omega -k\omega )x)}{2(j\omega -k\omega )}}-{\frac {sin((j\omega +k\omega )x)}{2(j\omega +k\omega )}}}$

Plugging in the known values we have:
${\displaystyle {\frac {sin((2\omega -3\omega )x)}{2(2\omega -3\omega )}}-{\frac {sin((2\omega +3\omega )x)}{2(2\omega +3\omega )}}={\frac {sin(-1\omega x)}{-2\omega }}-{\frac {sin(5\omega x)}{10\omega }}}$

Solving from 0 to ${\displaystyle 2\pi }$:
${\displaystyle \left[{\frac {sin(-2\omega \pi )}{-2\omega }}-{\frac {sin(10\omega \pi )}{10\omega }}\right]-\left[{\frac {sin(0)}{-2\omega }}-{\frac {sin(0)}{10\omega }}\right]}$

We know that:
${\displaystyle sin(C\pi )=0}$ if C is any integer
${\displaystyle sin(0)=0}$

Thus, if ${\displaystyle \omega }$ is an an integer, the solution to the equation becomes:
${\displaystyle 0-0=0}$

Therefore:

${\displaystyle <\Phi _{3},\Phi _{5}>=\int _{0}^{2\pi }\sin 2\omega x\cdot \sin 3\omega xdx=0}$

#### Part 2

Using MATLAB's TRAPZ method, a variable X was created from 0 to ${\displaystyle 2\pi }$ and the integral of

${\displaystyle \sin j\omega x\cdot \sin k\omega xdx}$

was found from 0 to ${\displaystyle 2\pi }$. The assumption of ${\displaystyle \omega }$ being an integer and in this case = 1 was made.

The following was the outcome in MATLAB:

-3.8317e-007 is used as an equivalent to 0.

Therefore through MATLAB's TRAPZ method,

${\displaystyle \int _{0}^{2\pi }\sin 2\omega x\cdot \sin 3\omega xdx=0}$

### Author

Part 1 of this problem was solved and uploaded by Radina Dikova.

Part 2 of this problem was solved and uploaded by Derik Bell.

## Contribution Summary

Problem 1 was solved by: William Knapper

Problem 2 was solved by: Joshua House

Problem 3 was solved by: David Herrick

Problem 4 was solved by: John North

Problem 5 part 1 was solved by: Radina Dikova

Problem 5 part 2 was solved by: Derik Bell