All those who seem stupid, they are, and also so are half of those who do not, Quevedo
In this section, we introduce the concept of the Fourier series, a powerful mathematical tool used to represent virtually any periodic function as an infinite sum of simple sine and cosine waves.
This technique is incredibly useful when analyzing physical systems modeled by inhomogeneous second-order linear differential equations of the form: $y'' + ay' + by = f(t)$ where:
A Fourier series allows to write or express any periodic function f(t) (with a period of $2\pi$) as an infinite sum of trigonometric functions. The general form of a Fourier series is given by: $\boxed{f(t) = \frac{a_0}{2} + \sum_{n=1}^\infty [a_ncos(nt)+b_nsin(nt)]}$ where:
If $f(t)$ is periodic with period $2\pi$, its Fourier series is: $f(t) = \frac{a_0}{2} + \sum_{n=1}^\infty \left[ a_n\cos(nt) + b_n\sin(nt) \right]$ where the coefficients are given by Euler’s formulas:
$\boxed{a_0 = \frac{1}{\pi}\int_{-\pi}^{\pi} f(t)dt}, \boxed{a_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(t)\cos(nt)dt}, \text{ and } \boxed{b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(t)\sin(nt)dt}$
Let’s look at the simple constant function $f(t) = 1$, defined only on the interval $0 < t < \pi$. Here, our $L = \pi$.
Let’s see what happens when we build both the odd and even extensions (Refer to Figure ii for a visual representation and aid in understanding it).

To create $F^o(t)$, we extend the function to the left side such that it is odd. If it is $+1$ on the right, it must be $-1$ on the left. This creates a classic square wave that jumps between $-1$ and $1$.
Let’s calculate the sine coefficients $b_n$:
$$b_n = \frac{2}{\pi}\int_{0}^{\pi} 1 \cdot \sin(nt)dt = \frac{2}{\pi}\left[ \frac{-\cos(nt)}{n} \right]_{0}^{\pi} = \frac{2}{n\pi}\left( -\cos(n\pi) + \cos(0) \right)$$Since $\cos(n\pi) = (-1)^n$ and $\cos(0) = 1$: $b_n = \frac{2}{n\pi}\left( 1 - (-1)^n \right)$
If $n$ is even, $1 - 1 = 0$. Otherwise, $n$ is odd, $1 - (-1) = 2$.
$b_n= \begin{cases} 0, &n,even \\\\ \frac{2}{nπ}(-(-1)+1) = \frac{4}{nπ}, &n,odd \end{cases}$
Therefore, $b_n = \frac{2}{n\pi} \cdot 2 = \frac{4}{n\pi}$.
Result: The odd extension creates an infinite Fourier Sine Series, namely $\boxed{F^o(t) = \sum_{n=1, 3, 5...}^\infty \frac{4}{n\pi}\sin(nt)}$
To create $F^e(t)$, we mirror the function across the y-axis. Since it is $+1$ on the right, it remains $+1$ on the left. This just creates a completely (kind of boring) flat, constant line extending to infinity!
Let’s calculate the cosine coefficients $a_n$:
$$a_n = \frac{2}{\pi}\int_{0}^{\pi} 1 \cdot \cos(nt)dt = \frac{2}{\pi}\left[ \frac{\sin(nt)}{n} \right]_{0}^{\pi} = 0$$(Because $\sin(n\pi) = 0$ for all integers $n$. All $a_n$ terms vanish!)
However, the constant term (the average value of the function over the interval) is: $a_0 = \frac{2}{\pi}\int_{0}^{\pi} 1 dt = \frac{2}{\pi}[\pi] = 2$
Result: The even extension gives us the Fourier Cosine Series: $F^e(t) = \frac{a_0}{2} + 0 = \frac{2}{2} = 1$
This makes perfect sense! The even extension of a flat line is just a longer flat line, so the Fourier series needs exactly zero oscillating waves to represent it—just the constant value $1$.
Example (Provided by Gemini): f(t) = t (a straight diagonal line from 0 to $\pi$). Notice how the Even extension naturally builds a Triangle Wave, while the Odd extension naturally builds a Sawtooth Wave!

For any function $f(t)$ with a period of $2\pi$, the general Fourier series is expressed as: $\boxed{f(t) = \frac{a_0}{2} + \sum_{n=1}^\infty \left[ a_n\cos(nt) + b_n\sin(nt) \right]}$ where the coefficients are defined by Euler’s formulas:
$$a_0 = \frac{1}{\pi}\int_{-\pi}^{\pi} f(t)dt \quad | \quad a_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(t)\cos(nt)dt \quad | \quad b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(t)\sin(nt)dt$$Let’s apply these to two specific, highly useful piecewise functions
Let’s evaluate the function $f(t) = t$ defined on the interval $[-\pi, \pi]$, which then repeats periodically.
$$f(t) = \begin{cases} t, & -\pi \le t < \pi \\ t-2\pi, & \pi \le t < 3\pi \\ \dots & \dots \end{cases}$$.
Step 1: Identify Symmetry
$f(t) = t$ is a strictly odd function (it has rotational symmetry around the origin). Therefore:
Step 2: Compute the Sine Coefficients ($b_n$)
Because $f(t)$ is odd, we only need to compute the $b_n$ terms. Since $f(t)\sin(nt)$ is an even product, we can use the half-interval shortcut: $b_n = \frac{2}{\pi}\int_{0}^{\pi} t\sin(nt)dt$
To solve this, we use integration by parts ($\int u dv = uv - \int v du$):
Let $u = t \implies du = dt$. Let $dv = \sin(nt)dt \implies v = -\frac{1}{n}\cos(nt)$. Applying the formula: $b_n = \frac{2}{\pi} \left[ \left( -t\frac{\cos(nt)}{n} \right)\bigg|_{0}^{\pi} - \int_{0}^{\pi} \frac{-\cos(nt)}{n}dt \right]$
First, let’s look at the remaining integral: $-\int_{0}^{\pi} \frac{-\cos(nt)}{n}dt = \left[ \frac{\sin(nt)}{n^2} \right]_{0}^{\pi} = 0$ (This entirely vanishes because $\sin(n\pi) = 0$ and $\sin(0) = 0$).
Now, let’s evaluate the boundary term: $b_n = \frac{2}{\pi} \left[ -\frac{\pi\cos(n\pi)}{n} - \left( -\frac{0 \cdot \cos(0)}{n} \right) \right] = \frac{2}{\pi} \left[ -\frac{\pi}{n}(-1)^n - 0 \right]$
Cancel the $\pi$, simplify the negative sign ($-(-1)^n = (-1)^{n+1}$), and we finally get: $b_n = \frac{2}{n}(-1)^{n+1}$
Step 3: Construct the Final Series
Substituting our coefficients back into the general formula yields the Fourier series for the sawtooth wave: $\boxed{f(t) = 2\sum_{n=1}^\infty \frac{(-1)^{n+1}}{n}\sin(nt)}$
Expanding the first few terms provides a clearer picture of the wave: $f(t) = 2\left( \sin(t) - \frac{1}{2}\sin(2t) + \frac{1}{3}\sin(3t) - \frac{1}{4}\sin(4t) + \dots \right)$

The Fourier series tries to approximate the function f(t) not just at individual points, but over the entire interval $[-\pi, \pi]$. At points of discontinuity, such as $t = -\pi, \pi, 3\pi, cdots$, the Fourier series converges to the midpoint of the jump (average of the left-hand and right-hand limits of f(t)).
For example, at $t = \pi$, the jump goes from $\pi$ down to $-\pi$. The series converges to the average value at the jump, which is $\frac{\pi + (-\pi)}{2} = 0$. In other words, in the discontinuity points, the Fourier series converges to zero (the mid point of the jump).
Additionally, you will observe the Gibbs phenomenon near these jumps, where the wave visibly oscillates and overshoots the target value by about $9\%$ before settling.

Consider a rectangular pulse centered at $t = 0$, with a height of $4$ and a width of $\pi$, repeating every $2\pi$:
$$f(t) = \begin{cases} 0, & -\pi \le t < -\pi/2 \\ 4, & -\pi/2 \le t < \pi/2 \\ 0, & \pi/2 \le t < \pi \end{cases}$$Step 1: Identify Symmetry
Since $f(-t)$ perfectly mirrors $f(t)$ across the vertical y-axis, the pulse is an even function. Therefore, $b_n = 0$ (all sine terms vanish).
Step 2: Compute the Constant Term ($a_0$)
Using the half-interval shortcut for even functions: $a_0 = \frac{2}{\pi}\int_{0}^{\pi} f(t)dt$
Since the function is only non-zero from $0$ to $\pi/2$, we adjust our bounds: $a_0 = \frac{2}{\pi}\int_{0}^{\pi/2} 4 dt = \frac{2}{\pi} \left[ 4t \right]_{0}^{\pi/2} = \frac{2}{\pi} \left( 4 \cdot \frac{\pi}{2} \right) = 4$
The constant term in our series is $\frac{a_0}{2} = 2$. This makes perfect sense, a pulse of height $4$ that is “on” exactly half the time has an average value of $2$.
Step 3: Compute the Cosine Coefficients ($a_n$)
Using the even shortcut again: $a_n = \frac{2}{\pi}\int_{0}^{\pi} f(t)\cos(nt)dt = \frac{2}{\pi}\int_{0}^{\pi/2} 4\cos(nt)dt$
$a_n = \frac{8}{\pi}\left[ \frac{\sin(nt)}{n} \right]_{0}^{\pi/2} = \frac{8}{n\pi}\sin\left(\frac{n\pi}{2}\right)$.
This expression evaluates differently depending on whether $n$ is even or odd:
$k = 1, \sin(\frac{(2k-1)\pi}{2}) = \sin(\frac{\pi}{2}) = 1; k = 2, \sin(\frac{(2k-1)\pi}{2}) = \sin(\frac{3\pi}{2}) = -1; k = 3, \sin(\frac{(2k-1)\pi}{2}) = sin(\frac{5\pi}{2}) = 1; \cdots$
Step 4: Construct the Final Series
We can now write the series exclusively using the odd index $k$: $f(t) = 2 + \sum_{k=1}^\infty \left[ \frac{8}{\pi} \frac{(-1)^{k-1}}{2k-1} \right]\cos((2k-1)t)$
Factoring out the constants: $\boxed{f(t) = 2 + \frac{8}{\pi}\sum_{k=1}^\infty \frac{(-1)^{k-1}}{2k-1}\cos((2k-1)t)}$
Discontinuities occur at the edges of the pulse ($t = \pm \pi/2$). At these points, the series converges to the average of the “floor” and the “ceiling” of the pulse (the average of the left-hand and right-hand limits of f(t)): $\frac{4 + 0}{2} = 2$. Near the discontinuities at $t = \pm \pi/2$, the Fourier series overshoots the function value but converges to the average value.
