% vim: tw=50
% 07/10/2022 10AM

\mychapter{Self-Adjoint ODEs}

\newpage
\section{Fourier Series}

\subsection{Periodic Functions}

A function $f(x)$ is periodic if
\[ f(x + T) = f(x) \qquad \forall x \]
where $T$ is the period.
\begin{center}
    \includegraphics[width=0.6\linewidth]
    {images/1f3b74c6462111ed.png}
\end{center}

\begin{example*}
    Simple harmonic motion
    \[ y = A \sin \omega t \]
    where $A$ is amplitude and period $T =
    \frac{2\pi}{\omega}$ with angular frequency
    $\omega$ (frequency $= \frac{1}{T}$).
\end{example*}

\subsubsection*{Properties of sin and cosine
functions}

Consider the set of functions
\[ g_n(x) = \cos \frac{n \pi x}{L}, \qquad h_n(x)
= \sin \frac{n \pi x}{L} \]
which are periodic on the interval $0 \le n >
\infty$, $0 \le x < 2L$). (Note: Period $T = 2L$).
\\
Recall the identities:
\begin{align*}
    \cos A \cos B
    &= \half (\cos(A - B) + \cos(A + B)) \\
    \sin A \sin B
    &= \half (\cos(A - B) - \cos(A + B)) \\
    \sin A \cos B
    &= \half (\sin(A - B) + \sin(A + B))
\end{align*}

\hiddenfc{\[ \cos A \cos B = \cloze{ \half (\cos(A -
B) + \cos(A + B)) } \]}
\hiddenfc{\[ \sin A \sin B = \cloze{ \half (\cos(A -
B) - \cos(A + B)) } \]}
\hiddenfc{\[ \sin A \cos B = \cloze{ \half (\sin(A -
B) + \sin(A + B)) } \]}

\noindent
Define an \emph{inner product} for two periodic
functions $f, g$ on the interval $0 \le x < 2L$
by:
\[ \langle f, g \rangle = \int_0^{2L} f(x)g(x) \dd x
\tag{$*$} \]
\myskip
STUFF --- \myskip
For $n \neq m$,
\begin{align*}
    \langle h_n, h_m \rangle
    &= \int_0^{2L} \sin \frac{n \pi x}{L} \sin
    \frac{m \pi x}{L} \dd x \\
    &= \int_0^{2L} \half \left( \cos \left(
    \frac{(n - m) \pi x}{L} \right) - \cos \left(
    \frac{(n + m) \pi x}{L} \right) \right) \dd x
    \\
    &= 0
\end{align*}<++>

\myskip
STUFF --- \myskip
For $n = m$,
\begin{align*}
    \langle h_n, h_n \rangle
    &= \int_0^{2L} \sin^2 \frac{n \pi x}{L} \dd x
    \\
    &= \half \int_0^{2L} \left(1 - \cos \frac{2 \pi n
    x}{L} \right) \dd x \\
    &= L \qquad (n \neq 0)
\end{align*}
Hence,
\[ \langle h_n, h_m \rangle = \begin{cases}
    L \delta_{nm} & \forall \,\, n, m \neq 0 \\
    0 & m = 0
\end{cases} \tag{1.1} \]
Similarly (exercise)
\[ \langle g_n, g_m \rangle = \int_0^{2L} \cos
\frac{n\pi x}{L} \cos \frac{m\pi x}{L} \dd x =
\begin{cases}
    L \delta{nm} & \forall\,\, n, m \neq 0 \\
    2L \delta_{0n} & m = 0
\end{cases} \tag{1.2} \]
\[ \langle h_n, g_m \rangle = \int_0^{2L} \sin
\frac{n\pi x}{L} \cos \frac{m\pi x}{L} \dd x = 0
\quad \forall \,\, n, m \tag{1.3} \]

\subsection{Definition of Fourier Series}

We can express any `well-behaved' periodic
function $f(x)$ with period $2L$ as
\[ f(x) = \half a_0 + \sum_{n = 1}^\infty a_n \cos
\frac{n \pi x}{L} + \sum_{n = 1}^\infty b_n \sin
\frac{n\pi x}{L} \tag{1.4} \]
where $a_n, b_n$ are constants such that the right
hand side is convergent for all $x$ where $f$ is
continuous. At a discontinuity $x$, the Fourier
Series approaches the midpoint (replace left hand
side)
\[ \half (f(x_+) + f(x_-)) \]

\subsubsection*{Fourier coefficients}

Consider
\begin{align*}
    \langle h_m(x), f(x) \rangle
    &= \int_0^{2L} \sin \frac{m \pi x}{L} f(x) \dd
    x \\
    &= L b_m
\end{align*}
by orthogonal relation (1.1-1.3). Hence we find
\begin{flashcard}
\prompt{What are the coefficients $a_n$, $b_n$ of Fourier
series?}
\begin{equation*}
\boxed{
\begin{aligned}
    b_n
    &= \cloze{ \frac{1}{L} \int_0^{2L} f(x) \sin
    \frac{n\pi x}{L} \dd x} \\
    a_n
    &= \cloze{ \frac{1}{L} \int_0^{2L} f(x) \cos
    \frac{n\pi x}{L} \dd x}
\end{aligned}
}
\tag{1.5}
\end{equation*}
\end{flashcard}

\begin{note*}
    \begin{enumerate}[(i)]
        \item $a_n$ includes $n = 0$, since $\half
            a_0$ is the \emph{average} $\langle
            f(x) \rangle = \frac{1}{2L}
            \int_0^{2L} f(x) \dd x$
        \item Range of integration is one period,
            so
            \[ \int_0^{2L} \dd x \cdots =
            \int_{-L}^L \dd x \cdots \]
        \item Think of Fourier series (1.4) as a
            decomposition into harmonics. Simplest
            Fourier series are sine and cosine
            functions: for example pure mode $\sin
            \frac{3\pi x}{L}$, has $b_3 = 1$, $b_n
            = 0$ for all $n \neq 3$.
    \end{enumerate}
\end{note*}

\begin{example*}[Sawtooth]
    Consider $f(x) = x$ for $-L \le x < L$ and
    periodic elsewhere:
    \begin{center}
        \includegraphics[width=0.6\linewidth]
        {images/7a3442c8462511ed.png}
    \end{center}
    Here, we have
    \[ a_n = \half \int_{-L}^L x \cos \frac{n \pi
    x}{L} \dd x = 0 \]
    for all $n$, since the resulting function is
    odd. However:
    \begin{align*}
        b_n
        &= \frac{2}{L} \int_0^L x \sin \frac{n\pi
        x}{L} \dd x \\
        &= -\frac{2}{n \pi} \left[ x \cos \frac{n
        \pi x}{2} \right]_0^L + \frac{2}{n\pi}
        \int_0^L \cos \frac{n\pi x}{L} \dd x \\
        &= -\frac{2L}{n\pi} \cos n\pi +
        \frac{2L}{(n\pi)^2} \sin n\pi \\
        &= \frac{2L}{n \pi} (-1)^{n + 1}
    \end{align*}
    So the sawtooth Fourier series is
    \begin{align*}
        f(x)
        &= \frac{2L}{\pi} \sum_{n = 1}^\infty
        \frac{(-1)^{n + 1}}{n} \sin \frac{n\pi
        x}{L} \\
        &= \frac{2L}{\pi} \left( \sin \frac{\pi
        x}{L} - \half \sin \frac{2\pi x}{L} +
        \frac{1}{3} \sin \frac{3 \pi x}{L}  -
        \cdots \right)
    \end{align*}
    which is slowly convergent.
    \begin{center}
        \includegraphics[width=0.6\linewidth]
        {images/69787cf0462611ed.png}
    \end{center}
\end{example*}
