\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}
\newcommand{\bd}{\partial}
\newcommand{\x}{\times}
\begin{document}

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

{\bf Part III.}

Outline
\begin{itemize}

\item [Pages 2-8.] The Vibrating String. 

\item [Page 9.] An Animation. 

\item [Page 10.] Extra Credit.

\end{itemize}


\vfill
\pagebreak


\begin{center}
{\bf Classic Example I: Vibrating String}
\end{center}

We are going to use Fourier series to solve some partial differential equations. 
The methods used will seem quite strange and ad hoc at first. They are in fact
standard and are used to solve a number of important PDE's used in physics, chemistry and engineering. 

We shall start will a classic problem of modeling a vibrating string.
When a string a held straight and not moving it is in equilibrium. We will start the motion but plucking it, 
that is we pinch a straight string in the middle and pull in up a bit a let it go. 


Let the string have length $L>0$ and use $x\in [0,L]$ as a as the 
distance to the left end point. Let $t$ be time. Let $u(x,t)$ be the 
height of the string away from equilibrium. If $u(x,t)$ is negative then that point of the string is below equilibrium. 

The PDE that is used to model this is called {\bf the wave equation}. It is
\[
\frac{\bd^2 u}{\bd x^2} =  k\frac{\bd^2 u}{\bd t^2},
\]
where $k>0$ is a constant. This rationale is that the force at any point should be proportional to the concavity at that point. It is a simplified model; for example it does not include a term for air resistance or internal heat loss. Real strings can wear out and break, but not our ideal string. It is customary to rewrite the wave equation as
\[
a^2 u_{xx} = u_{tt},
\]
where $a>0$ is a constant. 

Next we add {\bf boundary conditions}. These simply model the fact that we shall be holding the end points fixed. Thus, for all $t$,
\[
u(0,t) = u(L,t) = 0.
\]
Finally we add the {\bf initial conditions} or {\bf configuration}. For simplicity we shall give use  $u(L/2,0) =L/2$ and assume the string is piecewise linear.
Then
\[
u(x,0) = f(x) = \left\{ \begin{array}{ll}
x & \mbox{for } x\in [0,L/2],\\
L-x & \mbox{for } x \in (L/2,L].
\end{array}\right.
\]

\begin{center}\psfrag{0}{0}\psfrag{L}{$L$}\psfrag{L2}{$L/2$}
\includegraphics[width=3in]{Figs/string.eps}
\end{center}


We encode the fact that initially the string is not moving by
\[
u_t(x,0) = 0
\]
for all $x \in [0,L]$. In general we could specify $u_t(x,0) = g(x)$ for some function $g(x)$.

\vfill
\pagebreak

\vspace{1in}

Thus, our model is as shown in the box below.


\vspace{0.3in}
\begin{center}
\fbox{\parbox{3in}{
\[
a^2 u_{xx} = u_{tt}
\]

\[
u(0,t) = u(L,t) = 0
\]

\[
u(x,0) = f(x) \hspace{0.4in} u_t(x,0) = 0
\]
where $f(x)$ was given above.}}
\end{center}

\vfill
\pagebreak

\begin{center}
{\bf Solving the Model}
\end{center}

Our strategy is as follows. Suppose $u(x,t)$ can be written in the form
\[
u(x,t) = X(x)T(t).
\]
Plugging into the wave equation we get
\[
a^2 X''(x) T(t) = X(x)T''(t).
\]
Now we separate the terms involving $x$ from the terms involving $t$ to get
\[
\frac{X''(x)}{X(x)} =\frac{1}{a^2}  \frac{T''(t)}{T(t)}.
\]
Both $x$ and $t$ are free, independent variables. But, if we change 
$x$ notice the right hand side will not change because it depends 
only on $t$. Therefore $X''/X = $ a constant. Likewise $T''/a^2T$ = 
the same constant. We will call this constant $-\sigma$ because we 
can. Thus, we now have two second order ODEs:
\[
X'' + \sigma X = 0 \hspace{.25in}\&\hspace{.25in} T'' + \sigma a^2 T = 0.
\]
For the first we can deduce boundary conditions.
\[
u(0,t) = 0 \implies X(0)T(t) = 0 \implies X(0) = 0.
\]
Likewise $X(L)=0$. So, let's just focus on the problem 
\[
X''(x) +\sigma X(x) = 0   \hspace{.25in}  
 X(0) = X(L)=0.
\]
We know that the form of the solution will depend on the sign of $\sigma$. We will consider three cases, $\sigma <0$, $\sigma = 0$ and $\sigma >0$, and see what happens. It will turn out that nontrivial solutions will exist only for certain values of $\sigma$.



\vfill
\pagebreak

\begin{center}
{\bf Solving the Model}
\end{center}

\vspace{1in}

{\bf Case I.} Suppose $\sigma <0$. Then the general solution is
\[
X(x) = C_1 e^{\sqrt{-\sigma}x} + C_2 e^{-\sqrt{-\sigma}x}.
\]
We impose the boundary conditions $X(0) = X(L) = 0$ to get $C_1$ and $C_2$.

We get that $X(0)=0$ implies $C_1 + C_2 = 0$ and $C_1 e^{\sqrt{-\sigma}L} + C_2 e^{-\sqrt{-\sigma}L} = 0$. Thus,
\[
C_1 = - C_2
\]
and
\[
C_1 = -e^{-2\sqrt{-\sigma}L} C_2.
\]
Thus we can only get a solution besides $C_1 = C_2 = 0$ if
$e^{-2\sqrt{-\sigma}L} = 1$. But, this implies $\sigma = 0$. 
We conclude that there are no nontrivial solutions if $\sigma <0$. 

\vspace{1in}


{\bf Case II.} Suppose $\sigma = 0$. Now our equation is just $X''(x) = 0$. The general solution is 
\[
X(x) = C_1 x + C_2.
\]
Notice, $X(0)=0$ implies $C_2 = 0$, but then $X(L)=0$ implies $C_1L=0$ giving us that $C_1=0$. 
Again, there are no nontrivial solutions when
$\sigma = 0$. It seems we are wasting our time!


\vfill
\pagebreak

\begin{center}
{\bf Solving the Model}
\end{center}

\vspace{1in}

{\bf Case III.} As a final act of desperation suppose $\sigma >0$.
Now the general solution is
\[ 
X(x) = C_1 \sin \sqrt{\sigma}x + C_2 \cos \sqrt{\sigma}x.
\]
Now, $X(0) = C_2$, which implies $C_2=0$. But $X(L) = C_1 \sin (\sqrt{\sigma}L)$. This implies $C_1 = 0$ unless the sine of $\sqrt{\sigma}L$ is zero.
So, our only hope of finding nontrivial solutions is to suppose $\sqrt{\sigma}L$ is an integer multiple of $\pi$. That is
\[
\sigma = \frac{n^2 \pi^2}{L^2}
\]
for some positive integer $n$.
For these values
\[
X(L) = C_1 \sin \left(\sqrt{\sigma}L\right) = C_1 \sin (n\pi) = 0,
\]
for any value of $C_1$! Thus, for any nonzero integer $n$ we have infinitely many nontrivial solutions; we will take $n$ to be positive. 

This is not the behavior you are used from working with initial value 
problems for ODEs. There we got unique solutions.  But, so far we have only done the {\em boundary values} and we have not yet considered the initial shape and velocity
on our string. We will record our observation of nontrivial solutions by defining
\[
X_n(x) = \sin \left(\frac{n\pi x}{L}\right) \mbox{ for } n\geq 1.
\] 

Next we study the $T(t)$ equation.
\vfill
\pagebreak

\begin{center}
{\bf Solving the Model}
\end{center}

Recall 
\[
T''(t) + a^2 \sigma T(t) = 0.
\]
Since we can only get nontrivial solutions for $X(x)$ if $ \sigma=  \dfrac{n^2 \pi^2}{L^2}$ we shall assign this value to $\sigma$.
Thus, we have
\[
T''(t) + \frac{a^2n^2 \pi^2}{L^2}T(t) = 0.
\]
The general solution is
\[
T(t) = C_1 \sin \left( \frac{a n \pi t}{L} \right) + C_2 \cos \left( \frac{a n \pi t}{L} \right).
\]

Now we shall begin looking at the initial conditions. It turns out it is easier if we study the initial velocity first.
We were given
\[
u_t(x,0) = 0,
\]
meaning that the string is not moving at the moment we let go of it. Now $u_t = \bd_t (X(x)T(t)) = X(x)T'(t)$. Thus we have
\[
X(x)T'(0) = 0.
\]
Assuming we have a nontrivial solution for $X(x)$ this forces $T'(0) = 0$. We compute
\[
T'(t) = C_1  \frac{a n \pi}{L} \cos \left( \frac{a n \pi t}{L} \right) - C_2  \frac{a n \pi}{L} \sin \left( \frac{a n \pi t}{L} \right).
\]
Thus,
\[
T'(0) = C_1  \frac{a n \pi}{L} = 0 \implies C_1 = 0.
\]
There are no restrictions on $C_2$. For any value of $C_2$ 
\[
T(t) = C_2 \cos \left( \frac{a n \pi t}{L} \right)
\]
solves the differential equation in $T$ and the condition $T'(0) = 0$. 
 
We let $\dis T_n(t) = \cos \left( \frac{a n \pi t}{L} \right)$ and define $u_n(x,t) = X_n(x)T_n(t)$. 

\vspace{0.3in}

Each $u_n$ satisfies the wave equation, the two boundary conditions, and the initial velocity condition. Furthermore, by linearity, any linear combination of the $u_n$'s will also satisfy these conditions. {\bf Check this.}

\vfill
\pagebreak

\begin{center}
{\bf Solving the Model}
\end{center}


It can be shown that if we let 
\[
u(x,t) = \sum_{n=1}^\infty c_n u_n(x,t)
\]
and the $c_n$'s are such that it converges everywhere, then $u$ satisfies  the wave equation, the two boundary conditions, 
and the initial velocity condition. This in proven in Math 407.

The final step, is that we need to choose the $c_n$'s so that $$\dis \sum_{n=1}^\infty c_n u_n(x,0) = f(x).$$ We do this next.


We need for
\[
f(x) = \dis \sum_{n=1}^\infty c_n u_n(x,0) = \sum_{n=1}^\infty c_n   \sin \left(\frac{n\pi x}{L}\right) \cos \left( \frac{a n \pi 0}{L} \right)
= \sum_{n=1}^\infty c_n   \sin \left(\frac{n\pi x}{L}\right).\]
But, this is just the Fourier series for the odd periodic extension of $f(x)$.


\begin{center}\psfrag{L}{$L$}\psfrag{L2}{$L/2$}\psfrag{-L}{$-L$}\psfrag{-L2}{$-L/2$}
\includegraphics[width=3in]{Figs/stringoddext.eps}
\end{center}




Thus,
\begin{eqnarray*}
c_n &=& \frac{1}{L} \int_{-L}^L \tilde{f_o}(x) \sin \left(\frac{n\pi x}{L}\right) \, dx \\
    &=& \frac{2}{L} \int_0^L f(x) \sin \left(\frac{n\pi x}{L}\right) \, dx \\
    &=& \frac{2}{L}\int_0^{L/2} x \sin \left(\frac{n\pi x}{L}\right) \, dx + \frac{2}{L}\int_{L/2}^L (-x+L) \sin\left(\frac{n\pi x}{L}\right)\, dx \\
    &=& ..... \mbox{ busy work } .... \\
    &=& \frac{4L}{n^2\pi^2} \sin \left( \frac{n\pi}{2} \right)
\end{eqnarray*}

Therefore,
\[
u(x,t) =  \sum_{n=1}^\infty  \frac{4L}{n^2\pi^2} \sin \left( \frac{n\pi}{2} \right) \sin \left(\frac{n\pi x}{L}\right) \cos \left( \frac{a n \pi t}{L} \right).
\]
We can rewrite this as
\[
u(x,t) = \frac{4L}{\pi^2}\sum_{k=0}^\infty \frac{(-1)^k}{(2k+1)^2} \sin \left(\frac{(2k+1)\pi x}{L}\right) \cos \left( \frac{a (2k+1) \pi t}{L} \right).
\]

\vfill
\pagebreak

\begin{center}
{\bf Animation}
\end{center}

\vspace{0.25in}
Now for the fun part. We will make an animation of $u(x,t)$. We shall take $a=1$ and $L=2$.
\vspace{0.25in}

{\tt
\begin{tabular}{ll}
> with(plots);  & \# Load package of plotting commands.  \\
> c:= n -> 8*sin(n*Pi/2)/(n\^{}2*Pi\^{}2): & \# Define the coefficient function.\\
> N:=100:  &\# Number of terms to use.\\
>  &\# Finally we execute the animation command.
\end{tabular}

\begin{tabular}{ll}
> animate(\{sum((c(n)*sin(n*Pi*x/2)*cos(n*Pi*t/2)), n=1..N)\}, &\\
 \hspace*{0.2in}  x=0..2, t=0..20, frames=150, thickness=2); &
\end{tabular}}

\begin{center}
%\includegraphics[width=5in]{../S17/a5.gif} 
\end{center}

See the animation link on the course web site.

\vfill
\pagebreak

\begin{center}
{\bf Summary}
\end{center}


Our model for a vibrating string is repeated below.
\vspace{0.3in}
\begin{center}
\fbox{\parbox{3in}{
\[
a^2 u_{xx} = u_{tt}
\]

\[
u(0,t) = u(L,t) = 0
\]

\[
u(x,0) = f(x) \hspace{0.4in} u_t(x,0) = 0
\]
where $f(x)$ is given.}}
\end{center}

The solution is
\[
u(x,t) = \sum_{n=1}^\infty c_n \sin \left(\frac{n \pi x}{L} \right) \cos \left( \frac{an\pi t}{L} \right)
\]
where
\[
c_n = \frac{2}{L}\int_0^L \sin \left(\frac{n \pi x}{L} \right) f(x) \, dx.
\]


\vfill
\pagebreak






\begin{center}
{\bf Extra Credit!}
\end{center}

\vspace{1in}
\begin{quote}
Modify the wave equation by adding a damping term, $\dis \gamma \frac{\bd u}{\bd t}$. Use the same boundary and initial conditions as in the
example we just did. Solve this model. Write this up neatly and turn it in. Make an animation, put it on  web site, and send me the link.
When you are at an interview for a job or internship, bring your tablet or phone, and show your animation to the interviewer. 
\end{quote}





\vfill
\pagebreak


\end{document}
