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

\subsection{Alternative Fourier Series}

\subsubsection*{Half-range series}

Consider $f(x)$ defined only on $0 \le x < L$.
Then we can extend its range over $-L \le x < L$
in two simple ways:
\begin{enumerate}[(i)]
    \item Require it to be odd ($f(-x) = -f(x)$),
        with period $2L$, Then $a_n = 0$ because
        $\cos$ is even, and
        \begin{flashcard}[sine-half-range-series-coeffs]
        \prompt{Coefficients for the sine half-range
        series (odd function)?}
        \[ b_n = \cloze{\frac{2}{L} \int_0^L f(x) \sin
        \frac{n\pi x}{L} \dd x \tag{1.11}} \]
        \end{flashcard}
        This is a Fourier sine series, for example
        the saw tooth (1.6).
    \item Require it to be even $f(-x) = f(x)$.
        Then $b_n = 0$ and
        \begin{flashcard}[cosine-half-range-series-coeffs]
        \prompt{Coefficients for the cosine half-range
        series (even function)?}
        \[ a_n = \cloze{\frac{2}{L} \int_0^L f(x) \cos
        \frac{n\pi x}{L} \dd x \tag{1.12}} \]
        \end{flashcard}
        for example $f(x) = (1-x^2)^2$ (Example
        sheet 1 question 1).
\end{enumerate}

\subsubsection*{Complex Representation}

Recall:
\[ \cos \frac{n\pi x}{L} = \half (e^{in\pi x/L} +
e^{-in\pi x/L}) \]
\[ \sin \frac{n\pi x}{L} = \frac{1}{2i} (e^{in\pi x/L} -
e^{-in\pi x/L}) \]
So Fourier series (1.4) becomes:
\begin{align*}
    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} \\
    &= \half a_0 + \half \sum_{n = 1}^\infty (a_n
    - ib_n) e^{in\pi x/L} + \half \sum{n =
    1}^\infty (a_n + b_n) e^{-in\pi x/L} \\
    &= \sum_{m = -\infty}^\infty c_m e^{im\pi x/L}
    \tag{1.13}
\end{align*}
\begin{hiddenflashcard}
    \prompt{Complex Fourier Series?}
    \[ \boxed{ f(x) = \cloze{\sum_{m =
    -\infty}^\infty c_m e^{im\pi x/L} } } \]
\end{hiddenflashcard}
For $m > 0$, $m = n$, $c_m = \half (a_n - ib_n)$.
For $m = 0$, $c_0 = \half a_0$. For $m < 0$, $m =
-n$, $c_m = \half (a_{-m} + ib_{-m})$.
Equivalently
\begin{flashcard}
    \prompt{Complex Fourier Series coefficients?}
    \[ c_m = \cloze{ \frac{1}{2L} \int_{-L}^L f(x)
    e^{-im\pi x/L} \dd x } \tag{1.14} \]
\end{flashcard}
Our inner product is upgraded to
\[ \langle f, g \rangle = \int f^* g \]
using complex conjugate $f^*$. Orthogonal:
\[ \int_{-L}^L e^{-im\pi x/L} e^{in\pi x/L} = 2L
\delta_{mn} \tag{1.15} \]
Parseval's:
\begin{flashcard}
    \prompt{Complex Parseval's?}
    \[ \int_{-L}^L |f(x)|^2 \dd x = \cloze{
    2L \sum_{m = -\infty}^\infty |c_m|^2 } \]
\end{flashcard}

\subsection{Some Fourier Series Motivations}

\subsubsection*{Self-adjoint matrices}

Suppose $\bf{u}, \bf{v}$ are complex $N$-vectors,
with inner product
\[ \langle \bf{u}, \bf{v} \rangle = \bf{u}^\dag
\bf{v} \tag{1.16} \]
($\bf{u}^\dag$ means complex conjugate and
transpose, i.e. $\bf{u}^\dag = (\bf{u}^*)^\top$).
Let $A$ be an $N \times N$ matrix which is self
adjoint (or Hermitian). Note that by simple
algebra, this property means that $\langle A
\bf{u}, \bf{v} \rangle = \langle \bf{u}, A \bf{v}
\rangle$ for all $\bf{u}, \bf{v}$. \myskip
The eigenvalues of $A$ are $\lambda_n$ and satisfy
\[ A \bf{v}_n = \lambda_n \bf{v}_n \tag{1.17} \]
(where $\bf{v}_n$ are eigenvectors). The
eigenvalues have the following properties:
\begin{enumerate}[(i)]
    \item The eigenvalues are real ($\lambda_n^* =
        \lambda_n$).
    \item If $\lambda_n \neq \lambda_m$ then the
        eigenvectors are orthogonal
        \[ \langle \bf{v}_n, \bf{v}_m \rangle = 0 \]
    \item If we rescale our eigenvectors to be
        unit length then $\{\bf{v}_1, \bf{v}_2,
        \dots, \bf{v}_N\}$ are an orthonormal
        basis.
\end{enumerate}
Given $\bf{b}$ we can solve for $\bf{x}$ given
\[ A \bf{x} = \bf{b} \tag{1.18} \]
Express
\[ \bf{b} = \sum_{n = 1}^N b_n \bf{v}_n \]
where $b_n$ are knowns. Seek a solution
\[ \bf{x} = \sum_{n = 1}^N c_n \bf{v}_n \]
where $c_n$ are unknowns. Substitute into (1.18):
\[ A \bf{x} = \sum_{n = 1}^N A c_n \bf{v}_n =
\sum_{n = 1}^N c_n \lambda_n \bf{v}_n \]
\[ \bf{b} = \sum_{n = 1}^N b_n \bf{v}_n \]
equate and use orthogonality
\[ c_n \lambda_n = b_n \implies c_n = \frac{b_n
}{\lambda_n} \]
So the solution is
\[ \bf{x} = \sum_{n = 1}^N \frac{b_n}{\lambda_n}
\bf{v}_n \tag{1.19} \]

\subsubsection*{Solving inhomogeneous ODE with
Fourier series}

We wish to find $y(x)$ given $f(x)$ for
\[ \mathcal{L} y \equiv -\dfrac[2]{y}{x} = f(x)
\tag{1.20} \]
(the minus sign is by convention, and $f(x)$ is
the driving force / source). Boundary conditions:
\[ y(0) = y(L) = 0 \]
The related eigenvalue problem is
\[ \mathcal{L} y_n = \lambda_n y_n \]
with the same boundary conditions. Has
eigenfunctions and eigenvalues
\[ y_n(x) = \sin \left( \frac{n\pi x}{L} \right)
\qquad \lambda_n = \left( \frac{n\pi}{L} \right)^2
\tag{1.21} \]
(verify this, also self adjoins ODE with
orthogonal eigenfunctions). \myskip
Seek solution as half range sine series. Try
\[ y(x) = \sum_{n = 1}^\infty c_n \sin \frac{n\pi
x}{L} \]
where $c_n$ are unknowns. Expand
\[ f(x) = \sum_{n = 1}^\infty b_n \sin \frac{n\pi
x}{L} \]
where $b_n$ are knowns. Using (1.11)
\[ b_n \frac{2}{L} \int_0^L f(x) \sin \frac{n\pi
x}{L} \dd x \]
Substitute into (1.20):
\[ \mathcal{L} y = -\dfrac[2]{}{x} \left( \sum_n
c_n \sin \frac{n\pi x}{L} \right) = \sum_{n =
1}^\infty c_n \left( \frac{n\pi}{L} \right)^2 \sin
\frac{n\pi x}{L} \stackrel{\text{want}}{=}
\sum_n b_n \sin \frac{n\pi x}{L} \]
By orthogonality (1.1) we have
\[ c_n \left( \frac{n\pi}{L} \right)^2 = b_n
\implies c_n = \frac{b_n}{\left( \frac{n\pi}{L}
\right)^2} \]
and solution is
\[ y(x) = \sum_n \frac{b_n}{\left( \frac{n\pi}{L}
\right)^2} \sin \frac{n\pi x}{L} = \sum_n
\frac{b_n}{\lambda_n} y_n \tag{1.22} \]

\begin{example*}[``square wave'' source]
    $L = 1$. Define $f(x) = 1$, $0 \le x < 1$, odd
    function. This has Fourier series (1.7)
    \[ f(x) = 4 \sum_m \frac{\sin (2m - 1) \pi
    x}{(2m - 1) \pi} \]
    So the solution (1.22) should be
    \[ y(x) = \sum_n \frac{b_n}{\lambda_n} y_n =
    4\sum_m \frac{\sin (2m - 1) \pi x}{((2m - 1)
    \pi)^3} \]
    ($n = 2m - 1$). But this is the Fourier series
    (1.9) for
    \[ y(x) = \half x(1 - x) \tag{1.23} \]
\end{example*}
