Complex Fourier Series Animation
Fourier Series and the Heat Equation
Introduction: Rotating Vectors and Complex Fourier Series
The animation of many rotating vectors, each at a constant integer frequency, when added tip-to-tail produces a complex path over time. The final tip traces out a specific shape determined by the initial size and angle of each vector. By adjusting these initial conditions, any desired shape can be approximated, provided enough vectors are used. This decomposition is a complex Fourier series, where the fundamental building blocks are rotating vectors rather than sine waves.
The action of each individual vector is simple—rotation at a steady rate—but the collective sum yields strikingly intricate behavior. Despite the apparent chaos, the motion follows a rigid mathematical structure that can be fully described and controlled. The formula for this decomposition is remarkably concise.
Fourier series are often introduced as sums of sine waves for real-valued functions. That real-valued case is a special instance of the more general rotating vector phenomenon. The original context arose from the heat equation, a partial differential equation describing how temperature distributions evolve over time.
Motivating the Heat Equation
The heat equation is a linear equation: if two functions are solutions, their sum is also a solution, and scaling a solution by a constant yields another solution. This property is straightforward but incredibly important.
For a rod of length L with fixed-temperature endpoints, a simple family of solutions exists: cosine waves of the form:
\cos\left(\frac{n\pi x}{L}\right)
with frequencies tuned so the function is flat at the endpoints (boundary conditions). Over time, these waves decay exponentially:
\text{Temperature}(x,t) = e^{-k\left(\frac{n\pi}{L}\right)^2 t} \cos\left(\frac{n\pi x}{L}\right)
Higher frequency waves decay faster. Because the equation is linear, scaling and summing these cosine solutions produces solutions for initial conditions that are combinations of cosine waves. The sum smooths out over time as high-frequency terms quickly vanish, leaving only low-frequency components.
The Step Function Problem
A natural initial condition for two rods of different temperatures brought together is a step function:
Left rod temperature = 1 degree (for 0 \le x < 0.5)
Right rod temperature = -1 degree (for 0.5 < x \le 1)
Total length L = 1
This function is flat and discontinuous—very different from a smooth sine wave. Yet Fourier asked: can this step function be expressed as an infinite sum of sine waves? This question seemed absurd at the time, but it led to a revolutionary idea.
Fourier's Bold Idea: Infinite Sums of Sine Waves
Fourier considered representing any initial temperature distribution as an infinite sum of sine or cosine functions satisfying the boundary conditions. For the step function with the given boundary conditions (flat endpoints), the appropriate basis functions are cosines whose frequencies are integer multiples of a base frequency.
The representation is:
f(x) = \frac{4}{\pi} \left( \cos(2\pi x) - \frac{1}{3}\cos(6\pi x) + \frac{1}{5}\cos(10\pi x) - \frac{1}{7}\cos(14\pi x) + \cdots \right)
The coefficients follow a pattern: 1, -\frac{1}{3}, +\frac{1}{5}, -\frac{1}{7}, etc., all scaled by 4/\pi. Only odd frequencies appear.
Approximations and Infinite Series
Any finite sum of sine waves cannot exactly equal a flat, discontinuous function. However, an infinite sum can approach the step function arbitrarily closely. This is analogous to an infinite sum of rational numbers equaling an irrational number: the partial sums get arbitrarily close and stay close.
For functions, the same idea applies pointwise. For a given input x < 0.5, the partial sums approach 1; for x > 0.5, they approach -1; at x = 0.5, all cosines are zero, so the limit is 0. Thus the infinite sum equals a function that is discontinuous at x = 0.5, taking the value 0 at that point (halfway along the jump). The limit of continuous functions can produce a discontinuous function.
Using this infinite sum, the heat equation solutions associated with each cosine wave can be added to obtain an exact solution for how the step function evolves over time. This was a monumental achievement in 1822.
Complex Fourier Series: Rotating Vectors
From Real-Valued Functions to Complex Drawings
Instead of functions with real-number outputs (which are essentially one-dimensional pencil sketches), consider functions whose outputs can be any complex number in the 2D plane. Such a function can be thought of as a drawing: as the input t ranges over an interval (say 0 to 1), the output traces a path in the complex plane.
Breaking such a 2D drawing into rotating vectors is more general than the sine-wave decomposition for real-valued functions. Real-valued functions are a special case: the rotating vectors come in pairs rotating in opposite directions (frequencies n and -n) with equal lengths and horizontal reflections. Their sum stays on the real line, producing an oscillation—a sine wave.
The Complex Exponential
The core of Fourier series is the complex exponential:
e^{i t}
As t increases, this value moves around the unit circle at a rate of 1 radian per unit time. For a function defined on [0,1], a vector rotating n full cycles in one second is written as:
e^{2\pi i n t}
The factor 2\pi ensures that when t goes from 0 to 1, the argument covers 2\pi n radians, completing n full rotations.
Negative frequencies correspond to rotation in the opposite direction: e^{-2\pi i n t}. The constant vector is e^{0 \cdot 2\pi i t} = 1.
Formula for Rotating Vectors
Each rotating vector is multiplied by a complex coefficient c_n, which determines its initial angle and magnitude. The full Fourier series is:
f(t) = \sum_{n=-\infty}^{\infty} c_n e^{2\pi i n t}
c_0: constant term, representing the center of mass or average position of the drawing.
c_n for n \neq 0: adjusted so that c_n e^{2\pi i n t} is a vector rotating with frequency n.
Pairs of positive and negative frequencies correspond to real sine waves when the function is real-valued.
Computing Fourier Coefficients
The Constant Term
The constant term c_0 is the average value of f(t) over the interval [0,1]:
c_0 = \int_0^1 f(t) dt
Because the interval length is 1, the integral equals the average. This can be understood by noting that if f(t) is expressed as the sum of rotating vectors, the average of each rotating vector over one full period is zero (it makes whole number rotations around zero), except the constant vector, whose average is itself. Thus the integral isolates c_0.
General Coefficient Formula
To find any other coefficient c_n, multiply f(t) by e^{-2\pi i n t} before integrating. This "de-rotates" the nth vector so it becomes stationary, while all other vectors still complete whole number rotations (because their frequencies are shifted by -n). Their averages become zero, leaving only c_n:
c_n = \int_0^1 f(t) e^{-2\pi i n t} dt
This single expression captures all the complexity of decomposing a drawing into rotating vectors. The operation is analogous to "giving a smartphone to an overactive child"—multiplying by the conjugate exponential freezes the desired component.
Numerical Computation
In practice, the integral is computed numerically. The interval [0,1] is divided into many small pieces of size \Delta t. For each piece, the value f(t) e^{-2\pi i n t} \Delta t is summed. This approximates the integral. More efficient numerical integration methods exist, but the basic idea is the same.
For rendering, the computer treats the path (often from an SVG file) as a complex function f(t) and computes c_n for a desired range of n (e.g., -50 to 50). The resulting coefficients determine initial angles and magnitudes of vectors. Setting them all rotating and adding tip-to-tail produces an approximation of the original path. As the number of vectors increases, the approximation improves.
Example: Step Function
Returning to the step function—a real-valued, one-dimensional "drawing" that stays at 1 for 0 \le t < 0.5 and jumps to -1 for 0.5 < t \le 1. Its Fourier series approximation consists of pairs of vectors rotating in opposite directions, corresponding to cosine waves.
The coefficients can be computed analytically using the integral formula:
c_n = \int_0^{0.5} 1 \cdot e^{-2\pi i n t} dt + \int_{0.5}^1 (-1) \cdot e^{-2\pi i n t} dt
For n=0, the integral yields the average value 0. For non-zero n, evaluating the integrals gives the coefficients that match the sine series derived earlier. The result is:
Only odd n have non-zero coefficients.
c_n = \frac{2}{i\pi n} for odd n (after adjusting for sign).
Pairing positive and negative n yields the cosine series: \frac{4}{\pi} \left( \cos(2\pi t) - \frac{1}{3}\cos(6\pi t) + \cdots \right).
This step function example demonstrates how the general complex Fourier series simplifies to the familiar sine/cosine form for real-valued functions.
Conclusion and Broader Implications
Fourier series originated from the heat equation, a seemingly unrelated physical problem. The idea of breaking functions into simple oscillations proved far-reaching, extending well beyond heat flow.
The crucial insight is that exponential functions, including complex exponentials and even matrix exponentials, play a central role in solving linear differential equations. Decomposing a function into exponentials and using linearity to solve an equation is a recurring theme across many areas of science and engineering.
Fourier series provide a first glimpse of this deeper idea: by representing a function as a combination of exponentials (rotating vectors), one can translate a differential equation into algebraic equations for the coefficients. This approach generalizes to Fourier transforms, Laplace transforms, and other integral transforms, each leveraging the elegant properties of exponentials.

Ask anything
We've read this whole study set, so questions about it get the best answers.