\documentclass{article}
%\pagestyle{empty}
\usepackage{graphicx, amsmath, psfrag}
\setlength{\textheight}{9in}
\setlength{\topmargin}{0.0in}
\setlength{\textwidth}{6in}
\setlength{\oddsidemargin}{+0.5in}
\newcommand{\dis}{\displaystyle}
\begin{document}

\begin{center}{\bf Lecture Notes for Ch 10\\Fourier Series and Partial Differential Equations}\end{center}

{\bf Part I.}

Outline
\begin{itemize}

\item [Page 2.] Review even and odd functions. Very important. 

\item [Page 3.] Some Damn Useful Integral Formulas. 

\item [Page 4.] Definition of Fourier series and a Theorem.

\item [Pages 5-8.] Verification of parts of the Theorem.

\item [Pages 9-10.] Fourier series of a Square Wave.

\item [Pages 11-12.]  Fourier series of a Triangle Wave.

\end{itemize}


\vfill
\pagebreak


\begin{center}
{\bf Review of Even and Odd Functions}
\end{center}

\begin{center}
\fbox{
Even: $f(-x) = f(x)$ \hspace{0.6in} Odd: $f(-x)=-f(x)$.}
\end{center}

\begin{itemize}
\item [Even Examples:] $5x^6-3x^4+2$, $\frac{x^4+1}{x^2-7}$, $|x|$, 
                       $\cos(x)$, $\cos(x^5)$, $\sin^4(x)$.
\item [Odd Examples:] $x^{1/3}$, $x^7-6x^3$, $x|x|$, $\sin(x)$, $\sin^5(x^7)$.

\item [Neither:] $x^2+x$, $x+\cos(x)$, $\frac{1}{x+1}$.



\begin{center}
\psfrag{E}{Three Even Functions}
\psfrag{O}{Three Odd Functions}
\hspace*{-1in}\includegraphics[height=2in]{Figs/evenodd.eps}
\end{center}


\item [Problem:] Let $f(x)$ be an odd function and suppose it is defined 
at $x=0$. What is $f(0)$? Prove this!

\item [Problem:] Find a function with domain the whole real line that is 
both even and odd. (There is only one correct answer.)

\item [Fact:] If $f(x)$ is even, then 
$\dis \int_{-a}^a f(x)\,dx = 2\int_0^a f(x)\,dx$.

\item [Fact:] If $f(x)$ is odd, then $\dis \int_{-a}^a f(x)\,dx = 0$.
Draw pictures to see intuitively why these two facts hold.

\item [Fact:] If $f(x)$ is even and differentiable, then $f'(x)$ is odd, and 
vice versa. This can be proved with the Chain Rule. Suppose $f(x)$ is even 
and differentiable. Then $(f(-x))' = f'(-x)(-1)$.
But $f(-x)= f(x)$, so $(f(-x))'= (f(x))' = f'(x)$. Thus, $f'(-x)(-1) = f'(x)$,
or $f'(-x) = -f'(x)$. You can also draw pictures of tangent lines to curves
to see this intuitively.

%\end{itemize}

\item [Exercises:] Suppose that $f(x)$ and $g(x)$ are even and 
      the $h(x)$ and $k(x)$ are odd. Then show that:

\begin{center}
\begin{tabular}{ll}
(a)  $f(x)g(x)$ is even. &  (f) $f(g(x))$ is even.  \\

(b) $f(x)h(x)$ is odd.   &  (g) $f(h(x))$ is even.  \\

(c) $h(x)k(x)$ is even.  &  (h) $h(f(x))$ is even.  \\

(d) $f(x)+g(x)$ is even. &  (i) $h(k(x))$ is odd.   \\

(e) $h(x)+k(x)$ is odd.  &  (j) $f(x) + h(x)$ need not be even or odd. 
\end{tabular}
\end{center}


\item [Example:] Let $p(x) = f(x)h(x)$. Then $p(-x) = f(-x)h(-x)= f(x)(-h(x)) =
-f(x)h(x) = -p(x)$. Hence we have an odd function.

\end{itemize}
\vfill
\begin{center}
\fbox{\bf You may be tested on this!}
\end{center}

\vfill
\pagebreak

\begin{center}
{\bf Some Damn Useful Integral Formulas}
\end{center}


\begin{enumerate}

\item $\dis
\int_{-L}^L \cos \left( \frac{m\pi x}{L}\right) \cos \left(\frac{n\pi x}{L} \right) \,\, dx = \left\{
\begin{array}{rrr}
0 & \mbox{ for } & m\neq n, \\
L &  \mbox{ for } & m =  n.
\end{array}\right.
$
\vspace{.25in}

\item $\dis
\int_{-L}^L \cos \left( \frac{m\pi x}{L}\right) \sin \left(\frac{n\pi x}{L} \right) \,\, dx = 0,\: \mbox{for all integers $m$ and $n$}
$

\vspace{.25in}
\item $\dis
\int_{-L}^L \sin \left( \frac{m\pi x}{L}\right) \sin \left(\frac{n\pi x}{L} \right) \,\, dx = \left\{
\begin{array}{rrr}
0 & \mbox{ for } & m\neq n, \\
L &  \mbox{ for } & m =  n.
\end{array}\right.
$
\end{enumerate}


\vspace{.25in}
Below and to the left are the overlaid plots of $\cos 4\pi x$ and $\cos 2\pi x$. 
Below and to the right is the graph of their product. Study this. Make some similar plots on your own until the formulas above make sense. 


\begin{center}
\includegraphics[height=2in]{Figs/cos4xandcos2x.eps}
\hspace{0.5in}
\includegraphics[height=2in]{Figs/cos4xXcos2x.eps}
\end{center}

We will prove only a special case of \#1. Let $L=\pi$, $m=3$ and $n=2$.
The proof uses the trig identities
\[
\cos (\theta + \phi) = \cos \theta \cos \phi - \sin \theta \sin \phi
\]
and its corollary
\[
\cos (\theta - \phi) = \cos \theta \cos \phi + \sin \theta \sin \phi
\]
Thus,
\[
\cos \theta \cos \phi = \frac{1}{2}\left( \cos (\theta + \phi) + \cos (\theta - \phi) \right). 
\]
Applying this to our case gives
\[
\cos 3x \cos 2x =  \frac{1}{2}\left( \cos 5x + \cos x\right).
\]
Thus,
\[
\int_{-\pi}^{\pi} \cos 3x \cos 2x \, dx = \frac{1}{2}\int_{-\pi}^{\pi} \cos 5x + \cos x \, dx = 0 + 0 = 0.
\]

Let's consider one more special case: $L=\pi$, $m=n=2$. Then
\[
\int_{-\pi}^{\pi} \cos^2 2x \, dx =  \frac{1}{2}\int_{-\pi}^{\pi} \cos 4x + \cos 0 \,dx = \frac{0+2\pi}{2} = \pi.
\]

From these ideas you should be able to derive the three integrals formulas. If you have had linear algebra, 
you might notice that the integral of a product of two functions is a kind of inner product and  so the 
cosine and sine functions used above are mutually  orthogonal.
\pagebreak

\begin{center}{\bf Definition of Fourier Series}\end{center}



Let $f(x)$ be a piecewise continuous periodic function with period $2L$.\footnote{Technical note: 
It is also required that $f(x)$ is bounded and that in each period of $f(x)$ there are only finitely many extrema.} 
The Fourier Series of $f(x)$ is,

\[
\frac{a_0}{2} + \sum_{n=1}^\infty a_n \cos \left( \frac{n\pi x}{L} \right) + \sum_{n=1}^\infty b_n \sin \left( \frac{n\pi x}{L} \right),
\]
where 
\[
a_n = \frac{1}{L} \int_{-L}^L \cos \left( \frac{n\pi x}{L} \right) f(x) \, dx, \:\:\: n = 0,1,2,3,\dots,
\]
and
\[
b_n = \frac{1}{L} \int_{-L}^L \sin \left( \frac{n\pi x}{L} \right) f(x) \, dx, \:\:\: n = 1,2,3,\dots.
\]

{\bf Theorem.} The Fourier series of $f(x)$ converges to $f(x)$ if
$f$ is continuous at $x$. If $f$ is discontinuous at $x$ then this 
must be a jump discontinuity. Let
\[
f(x^+) = \lim_{c \to x^+} f(c) \hspace{.4in}\mbox{and} \hspace{.4in}
f(x^-) = \lim_{c \to x^-} f(c).
\]
Then the Fourier series of $f$ converges to the average of these two limits,
\[
\frac{f(x^+) + f(x^-)}{2}.
\]

If $f$ is an even function then $b_n = 0$, for $n=1, 2, 3, \dots.$

If $f$ is an odd function then $a_n = 0$, for $n=0, 1, 2, 3, \dots.$

In all cases $a_0/2$ is the average value of $f(x)$ over one period. 

\vspace{1in}

We will verify parts of this theorem. The full proof is covered in Math 407.

\vfill
\pagebreak

\begin{center}
{\bf We verify the formula for $\mathbf a_0$ and show it is the average value of $\mathbf f(x)$.}
\end{center}

Let $c_n = \cos \left(\frac{n\pi x}{L}\right)$ and $s_n = \sin  \left(\frac{n\pi x}{L}\right)$.

\vspace{,25in}

Suppose $$f(x) = \frac{a_0}{2} + \sum_{n=1}^\infty a_n c_n + \sum_{n=1}^\infty b_n s_n.$$ 
We will show that 
\[
a_0 = \frac{1}{L} \int_{-L}^L \cos (0) f(x) \, dx.
\]

\begin{eqnarray*}
\frac{1}{L} \int_{-L}^L \cos (0) f(x) \, dx &=& \frac{1}{L} \int_{-L}^L 1\cdot f(x) \, dx \\
&& \\
&& \\
&=&  \frac{1}{L} \int_{-L}^L \left(  \frac{a_0}{2} + \sum_{n=1}^\infty a_n c_n + \sum_{n=1}^\infty b_n s_n\right)\, dx \\
&& \\
&& \\
&=&  \frac{1}{L}\int_{-L}^L \frac{a_0}{2}\, dx +  \frac{1}{L}  \sum_{n=1}^\infty a_n  \int_{-L}^L c_n \, dx  + \frac{1}{L}  \sum_{n=1}^\infty b_n  \int_{-L}^L s_n \, dx\\
&& \\
&& \\
&=& a_0 +  \frac{1}{L}  \sum_{n=1}^\infty a_n\cdot 0  + \frac{1}{L}  \sum_{n=1}^\infty b_n \cdot 0  = a_0
\end{eqnarray*}
since,

\vspace{.2in}

$\dis
\int_{-L}^L \cos \left(\frac{n\pi x}{L} \right) \, dx = \frac{L}{n\pi} \sin \left( \frac{n\pi x}{L} \right) \bigg|_{-L}^{L} = 0 - 0 = 0, 
$

\vspace{.2in}

$\dis
\int_{-L}^L \sin \left(\frac{n\pi x}{L} \right) \, dx = \frac{-L}{n\pi} \cos \left( \frac{n\pi x}{L} \right) \bigg|_{-L}^{L} =  
\frac{-L}{n\pi} \left( \cos(n\pi) - \cos(-n\pi) \right) = 0,
$
\vspace{.2in}

and
\vspace{.2in}

$\dis
\frac{1}{L} \int_{-L}^L  \frac{a_0}{2}\, dx = \frac{a_0}{2L} \int_{-L}^L  1 \, dx =  \frac{a_0}{2L} \cdot 2L = a_0.
$
\vspace{.2in}

Finally, recall that the average value of $f(x)$ over a cycle is $\dis \frac{1}{2L} \int_{-L}^L f(x) \, dx$. Thus,
$a_0/2$ is the  average value of $f(x)$ over a cycle.

\vfill
\pagebreak

\begin{center}
{\bf We check the formula for $\mathbf a_7$, \\but the method is the same for all n $\mathbf \geq$ 1.}
\end{center}

\vspace{.2in}

\begin{eqnarray*}
a_7 &\stackrel{?}{=} &  \frac{1}{L} \int_{-L}^L \cos \left( \frac{7\pi x}{L}\right) f(x) \, dx  \\
&&\\
&=&  \frac{1}{L} \int_{-L}^L c_7\left( \frac{a_0}{2} + \sum_{n=1}^\infty a_n c_n + \sum_{n=1}^\infty b_n s_n\right) \, dx \\
&&\\
&=& \frac{a_0}{2L} \int_{-L}^L c_7 \, dx +  \frac{1}{L} \sum_{n=1}^\infty a_n \int_{-L}^L c_n c_7 \, dx +  \frac{1}{L} \sum_{n=1}^\infty b_n  \int_{-L}^L s_n c_7 \, dx \\
&&\\
&=& \frac{a_0}{2L}\cdot 0 + \frac{1}{L} (0+0+0+0+0+0+a_7L+0+0+0+\cdots ) +  \frac{1}{L}(0+0+0+\cdots ) \\
&&\\
&=& a_7.
\end{eqnarray*}

\vspace{0.5in}
%\pagebreak

\begin{center}
{\bf Next we check $\mathbf b_4$}.
\end{center}

\vspace{.2in}

\begin{eqnarray*}
b_4 &\stackrel{?}{=} &  \frac{1}{L} \int_{-L}^L \sin \left( \frac{4\pi x}{L}\right) f(x) \, dx  \\
&&\\
&=&  \frac{1}{L} \int_{-L}^L s_4\left( \frac{a_0}{2} + \sum_{n=1}^\infty a_n c_n + \sum_{n=1}^\infty b_n s_n\right) \, dx \\
&&\\
&=& \frac{a_0}{2L} \int_{-L}^L s_4 \, dx +  \frac{1}{L} \sum_{n=1}^\infty a_n \int_{-L}^L c_n s_4 \, dx +  \frac{1}{L} \sum_{n=1}^\infty b_n  \int_{-L}^L s_n s_4 \, dx \\
&&\\
&=& \frac{a_0}{2L}\cdot 0 + \frac{1}{L} (0+0+0+\cdots ) +  \frac{1}{L}(0+0+0+b_4L+0+0+0+\cdots ) \\
&&\\
&=& b_4.
\end{eqnarray*}

\vfil
\pagebreak

\begin{center}{\bf Even and Odd Properties}\end{center}

\vspace{1in}

If $f(x)$ is an odd function then
\[
a_n = \frac{1}{L} \int_{-L}^L \cos \left( \frac{n\pi x}{L} \right) f(x) \, dx = 0,
\]
since the product of an even function with an odd function is odd.


\vspace{1in}

If $f(x)$ is an even function then
\[
b_n = \frac{1}{L} \int_{-L}^L \sin \left( \frac{n\pi x}{L} \right) f(x) \, dx = 0,
\]
since the product of an odd function with an even function is odd.

\vfill 
\pagebreak
 
\begin{center}{\bf An Example: The Square Wave}\end{center}

Let
\[
f(x) = \left\{ \begin{array}{lll}
-1 & \mbox{ for } & -\pi < x < 0 \\
1  & \mbox{ for } & 0 < x < \pi,
\end{array} \right.
\]
with $f(x+2\pi) = f(x)$ for all $x$.  

\vspace{.3in}

\begin{center}\psfrag{Square}{Square}\psfrag{Wave}{\hspace*{0.3in}Wave}
\includegraphics[width=6in]{Figs/sqplot1.eps}
\end{center}

{\bf Problem.} Find the Fourier series of $f(x)$.

\vspace{.3in}

{\bf Solution.} Since $f(x)$ is odd, $a_n=0$ for  $n=0, 1, 2, \dots$.

\vspace{.3in}

Next,
\[
b_n = \frac{1}{\pi} \int_{-\pi}^\pi \sin(nx) f(x) \\, dx = \frac{2}{\pi} \int_0^\pi \sin(nx)\cdot 1 \, dx =
\]
\[
\frac{-2}{n\pi} \left( \cos(n\pi) - \cos(0)\right) = \left\{\begin{array}{lll}
0 & \mbox{ for } & n \mbox{ even } \\
\frac{4}{n\pi}  & \mbox{ for } & n \mbox{ odd. }\end{array} \right.
\]

\vspace{.25in}

Thus,
\[
f(x) = \sum_{k=1}^\infty \frac{4}{(2k-1)\pi} \sin \left( (2k-1)x \right) = \frac{4}{\pi} \sin x + \frac{4}{3\pi} \sin 3x + \frac{4}{5\pi} \sin 5x + \cdots.
\] 

Recall that using $(2k-1)$ is a way to generate only odd numbers.

\vspace{.3in}

On the next page we plot a few partial sums. 

\vspace{.3in}

Let $f_N(x) = \sum_{k=1}^N \frac{4}{(2k-1)\pi} \sin \left( (2k-1)x \right)$.


\vfill 
\pagebreak


\begin{center}
{\bf Plots of $f_N(x)$ for $N=1, 2, 3, 4, 10, 100$}
\end{center}
\begin{center}\psfrag{N}{$N=1$}\psfrag{=}{}\psfrag{1}{}
\includegraphics[width=6in]{Figs/sqplot2.eps}
\end{center}
\begin{center}\psfrag{N}{$N=2$}\psfrag{=}{}\psfrag{2}{}
\includegraphics[width=6in]{Figs/sqplot3.eps}
\end{center}
\begin{center}\psfrag{N}{$N=3$}\psfrag{=}{}\psfrag{3}{}
\includegraphics[width=6in]{Figs/sqplot4.eps}
\end{center}
\begin{center}\psfrag{N}{$N=4$}\psfrag{=}{}\psfrag{4}{}
\includegraphics[width=6in]{Figs/sqplot5.eps}
\end{center}\psfrag{N}{$N=10$}\psfrag{=}{}\psfrag{10}{}
\begin{center}
\includegraphics[width=6in]{Figs/sqplot6.eps}
\end{center}
\begin{center}\psfrag{N}{$N=100$}\psfrag{=}{}\psfrag{100}{}
\includegraphics[width=6in]{Figs/sqplot7.eps}
\end{center}

\vfill
\pagebreak


\begin{center}{\bf Another Example! A Triangle Wave}\end{center}

Problem: Find the Fourier series of the wave depicted below.

\begin{center}
\includegraphics[width=6in]{Figs/triplots1.eps}
\end{center}

Solution: First note that since the period is 2, $L=1$. We can see that for $0<x<1$, $f(x)=1-x$. 

Since this function is even, $b_n=0$ for $n=1, 2, 3, \dots$. Also $\frac{a_0}{2} = $ ave.~value of $f(x)$ = $\frac{1}{2}$. Thus, $a_0=1$.

Now,
\begin{eqnarray*}
a_n &=& \frac{1}{1} \int_{-1}^1 \cos(n\pi x) f(x) \, dx\\ 
    &=& 2 \int_0^1 \cos(n\pi x)(1-x) \, dx\\
    &=& \frac{2}{n\pi}\left( \sin(n\pi x) - x \sin(n\pi x) - \frac{1}{n\pi} \cos( n\pi x) \right) \bigg|_0^1 \\
    &=& \frac{2}{n\pi}\left[ \left(-\frac{1}{n\pi} \cos(n\pi)\right) - \left(-\frac{1}{n\pi}\right) \right]\\
    &=& \left\{\begin{array}{ll}0 & \mbox{for even } n\\
\frac{4}{n^2\pi^2} &   \mbox{for odd } n.\end{array}\right.
\end{eqnarray*}
Thus,
\[
f(x) = \frac{1}{2} + \sum_{k=1}^\infty \frac{4}{(2k-1)^2 \pi^2} \cos \left( (2k-1)\pi x\right). 
\]

\vspace{0.3in}

On the next page we plot a few partial sums. 

\vspace{0.3in}

Let $f_N(x) = \frac{1}{2} + \sum_{k=1}^N \frac{4}{(2k-1)^2 \pi^2} \cos \left( (2k-1)\pi x\right)$.




\vfill 
\pagebreak


\begin{center}
{\bf Plots of $f_N(x)$ for $N=1, 2, 3, 30$}
\end{center}
\begin{center}

$N=1$

\includegraphics[width=6in]{Figs/triplotsplot2.eps}
\end{center}
\begin{center}

$N=2$

\includegraphics[width=6in]{Figs/triplotsplot3.eps}
\end{center}
\begin{center}

$N=3$

\includegraphics[width=6in]{Figs/triplotsplot4.eps}
\end{center}
\begin{center}

$N=30$

\includegraphics[width=6in]{Figs/triplotsplot5.eps}
\end{center}


\vfill
\pagebreak




\end{document}
