---
title: "Fourier Series"
type: concept
related: [Orthogonal, Inner Product, Learn More, Fourier Series]
source: https://www.jemoka.com/posts/kbhfourier_series/
confidence: high
status: active
---

Fourier Series and how to find them.
For a function given at some interval of length \(l\), then the function can be written at:
\begin{equation} f(x) = \sum_{k=1}^{\infty} a_{k} \sin \qty( \frac{k\pi x}{l}) \end{equation}
or
\begin{equation} f(x) = \sum_{k=1}^{\infty} b_{k} \cos \qty( \frac{k\pi x}{l}) \end{equation}
Recall that because sin and cos are even and odd parts, the functions above force an even and oddness to your expansions. They will be particularly helpful for Dirichlet Conditions and Neumann Conditions.
But, in general, you can use a linear combination of the two by doubling the frequency over your interval \(l\):
\begin{equation} f(x) = a_0 + \sum_{k=1}^{\infty} \qty( a_{k} \cos(k \omega x) + b_{k} \sin(k \omega x)) \end{equation}
where \(\omega = \frac{2\pi}{L}\).
Statement Suppose we have a function that satisfies:
Recall that each \(\cos(\dots)\) and \(\sin (&hellip;)\) are orthogonal, we can then use the Fourier formula to figure the coefficients \(a_{k}\), \(b_{k}\).
Aside: why is \(a_0\) also orthogonal?
\begin{equation} a_0 = a_0 \cos (0 \omega x) = a_0 \cdot 1 = a_0 \end{equation}
General Fourier Decomposition Therefore, by the Fourier formula, we expect that:
\begin{equation} a_0 = \frac{\langle f, 1 \rangle}{ \langle 1,1 \rangle} = \frac{1}{L} \int_{0}^{L} f(x) \dd{x} \end{equation}
\begin{equation} a_{k} = \frac{\langle f, \cos (k\omega x) \rangle}{\langle \cos (k\omega x), \cos (k\omega x) \rangle} = \frac{2}{L} \int_{0}^{L} f(x) \cos (k\omega x) \dd{x} \end{equation}
\begin{equation} b_{k} = \frac{\langle f, \sin (k\omega x) \rangle}{\langle \sin (k\omega x), \sin (k\omega x) \rangle} = \frac{2}{L} \int_{0}^{L} f(x) \sin (k\omega x) \dd{x} \end{equation}
When computing this, recall that:
\begin{equation} \omega = \frac{2\pi}{L} \end{equation}
where \(L\) the period of your \(L\) periodic function.
Odd and Even Break If you have an even or odd \(f(x)\), we can refine the series even more into simply a sine or cosine only series.
For even \(f(x)\), we can write:
\begin{equation} a_{0} + \sum_{k=1}^{\infty} a_{k} \cos (k\omega x) \end{equation}
where:
\begin{equation} a_0 = \frac{1}{L / 2} \int_{0}^{\frac{L}{2}} f(x) \dd{x} \end{equation}
\begin{equation} a_{k} = \frac{2}{L / 2} \int_{0}^{\frac{L}{2}} f(x) \cos (k \omega x) \dd{x} \end{equation}
Whereas for odd \(f(x)\), we write:
\begin{equation} \sum_{k=1}^{\infty} b_{k} \sin (k\omega x) \end{equation}
\begin{equation} b_{k} = \frac{2}{L / 2} \int_{0}^{L / 2} f(x) \sin (k\omega x) \dd{x} \end{equation}
over any function Suppose we have a function with two roots:
\begin{equation} f(0) = 0 = f(l) \end{equation}
then, we can write it in terms of a Fourier Series by odd-extending the function to the negative direction (see &ldquo;odd extensions below&rdquo;).
This makes us be able to write \(f\) over \([0,l]\) as:
\begin{equation} f(x) = \sum_{n=1}^{\infty} b_{n} \sin \qty( \frac{n\pi}{l} x) \end{equation}
where:
\begin{equation} b_{n} = \frac{2}{l} \int_{0}^{l} f(x) \sin \qty( \frac{n \pi}{l} x) \dd{x} \end{equation}
this is just the \(l\) extension function above, but with small \(l\) as the function is odd to one side.
Here&rsquo;s the motivation:
sin and cos are even and odd parts odd extensions
Important note: this function seems to vanish at endpoints \(0\) and \(l\), and not all functions do that.
So, instead, let&rsquo;s consider the odd extension of \(f\):
\begin{equation} \hat{f}(x) = f(x), x \geq 0 \end{equation}
and
\begin{equation} \hat{f}(x) = -f(-x), x &lt; 0 \end{equation}
There will therefore be a discontinuous jump at \(0\).
Using the \(\sin\) function, which are odd, recall that Fourier Series Converges with \(L\) Periodic Function, so at \(0\) given Gibbs Phenomena, the jump will average the discontinouity down to \(0\) (given our extensions are odd).
even extensions
instead, if you want to use \(\cos\), you can make an even extension:
\begin{equation} \hat{f}(x) = f(x), x \geq 0 \end{equation}
and
\begin{equation} \hat{f}(x) = f(-x), x &lt; 0 \end{equation}
which shouldn&rsquo;t be discontinuous at \(0\) at all.
Additional Informatino Fourier Series Converges with \(L\) Periodic Function Suppose \(f(x)\) is an \(L\) periodic function with at most jump discountinuty, and \(f&rsquo;\) continuous everywhere. Then, the associated Fourier Series converges everywhere and coincides with \(f\) except for jump discontinuances, where the values are the average of limits from either side. This is called the Gibbs Phenomena
shifted sum of sinusoids see Fourier Series as exactly a shifted sum of sinusoids
Background Fourier formula Consider some orthogonal basis \(v_1, &hellip; v_{n}\), recall that if we have:
\begin{equation} v = c_1 v_1 + \dots + c_{n} v_{n} \end{equation}
we can write:
\begin{equation} c_{j} = \frac{v \cdot v_{j}}{ v_{j} \cdot v_{j}} \end{equation}
(this is similar to Writing a vector as a linear combination of orthonormal basis, but recall the \(v_{j}\) are orthogonal and not orthonormal, so we have to divide by the square of the norm of \(v\). learn more)
inner product of \(L\) periodic functions For \(f,g : [0,L] \to \mathbb{R}\), which are L-periodic, we write:
\begin{equation} \langle f,g \rangle := \frac{1}{L} \int_{0}^{L} f(x) g(x) \dd{x} \end{equation}
properties worth noting for continuous functions \([0,L]\) \(g_1, g_2, h_1, h_2, g, h\), the inner product rules hold, which gives
\(\langle c_1 g_1 + c_2 g_2, h \rangle = c_1 \langle g_1, h \rangle + c_2 \langle g_2, h \rangle\) \(\langle g, c_1h_1 + c_2h_2 \rangle = c_1 \langle g, h_1 \rangle + c_2 \langle g, h_2 \rangle\) \(\langle h,g \rangle = \langle g,h \rangle\), as the functions are over the reals \(\langle g,g \rangle\) is zero only when \(g\) is zero \(L\) periodic sinusoids are orthogonal Recall that we have two basic L-periodic sinusoids:
\(\sin \qty(\frac{2\pi k }{L}x)\) \(\cos \qty(\frac{2\pi k }{L}x)\) Let&rsquo;s write:
\begin{equation} \omega = \frac{2\pi}{L} \end{equation}
then, for any distinct integer \(k_1 \neq k_2, k_1, k_2 &gt; 0\), we see that:
\begin{equation} \int_{0}^{L} \cos (k_1 \omega x) \cos (k_2 \omega x) = \int_{0}^{L} \sin (k_1 \omega x) \sin (k_2 \omega x) = 0 \end{equation}
and further for any \(k\):
\begin{equation} \int_{0}^{L} \cos (k_1 \omega x) \sin (k_2 \omega x) = 0 \end{equation}
Meaning, every pair of \(\langle \{\sin, \cos\} (k_1 \omega x), \{\sin, \cos\} (k_1 \omega x) \rangle\) are orthogonal.
Further, for the same \(k\),
\begin{equation} \langle \cos (k\omega x), \cos (k \omega x) \rangle = \langle \sin (k\omega x), \sin (k \omega x) \rangle = \frac{L}{2} \end{equation}
in partiular:
\begin{equation} \int_{0}^{\frac{L}{2}} \sin (k \omega x) \sin (k \omega x) = \frac{L}{4} \end{equation}
if \(k\) are equal.
