Fourier Series Calculator
A Fourier series decomposes a periodic function into a sum of sine and cosine waves of different frequencies (harmonics). This calculator shows the exact Fourier coefficients for three classic waveforms: the square wave (amplitude +1 for x in (0,pi) and -1 for x in (-pi,0)), the sawtooth wave (f(x) = x/pi for x in (-pi,pi)), and the triangle wave (f(x) = (2/pi)*|x| - 1 for x in (-pi,pi)). Select the waveform, the number of harmonics (1 to 20), and an x value to evaluate the partial sum. The calculator shows a coefficient table, the partial sum formula, and the partial sum value at your chosen x alongside the exact function value. For a square wave, the series is (4/pi)*(sin(x) + sin(3x)/3 + sin(5x)/5 + ...). For a sawtooth, it is (2/pi)*(sin(x) - sin(2x)/2 + sin(3x)/3 - ...). Fourier series are fundamental in signal processing, differential equations, acoustics, and electronics.
Fourier coefficients table
| Harmonic n | an (cosine coeff) | bn (sine coeff) | Contribution at x |
|---|
Fourier series formulas
Square wave: f(x) = (4/pi) * sum(k=1,3,5,...,N) sin(k*x) / k
Sawtooth: f(x) = (2/pi) * sum(k=1 to N) (-1)^(k+1) * sin(k*x) / k
Triangle: f(x) = (8/pi^2) * sum(k=1,3,5,...,N) (-1)^((k-1)/2) * sin(k*x) / k^2
General: f(x) = a0/2 + sum(n=1 to N) (an*cos(nx) + bn*sin(nx))
Fourier series: frequently asked questions
What is a Fourier series?
A Fourier series represents a periodic function as an infinite sum of sine and cosine terms (harmonics). Any function that satisfies the Dirichlet conditions (finite number of discontinuities and maxima/minima per period) can be expressed as f(x) = a0/2 + sum of (an*cos(n*x) + bn*sin(n*x)) for n from 1 to infinity.
What are the Fourier coefficients?
For a 2*pi-periodic function f(x): a0 = (1/pi)*integral of f(x) dx from -pi to pi; an = (1/pi)*integral of f(x)*cos(n*x) dx; bn = (1/pi)*integral of f(x)*sin(n*x) dx. For odd functions (like square wave and sawtooth), all cosine coefficients an are zero. For even functions, all sine coefficients bn are zero.
What is Gibbs phenomenon?
Near jump discontinuities in a periodic function, the Fourier series partial sum overshoots the true value by about 9% of the jump height, regardless of how many terms are included. This overshoot does not decrease with more terms; instead, it becomes narrower. This is called the Gibbs phenomenon, named after J. Willard Gibbs.
What is the difference between Fourier series and Fourier transform?
A Fourier series applies to periodic functions and decomposes them into discrete frequency components (harmonics at n*omega0 for integer n). The Fourier transform applies to non-periodic functions and produces a continuous spectrum of frequencies. The discrete Fourier transform (DFT) used in signal processing is a related but distinct operation.
What are common applications of Fourier series?
Fourier series are used in signal processing (audio, radio), image compression (JPEG uses the discrete cosine transform, a variant), solving partial differential equations (heat equation, wave equation), analysing vibrations and acoustics, and electrical engineering for analysing periodic signals and power systems.
Sources
- Fourier series: NIST DLMF 1.8, Fourier Series.
- Classic waveform Fourier expansions: Wolfram MathWorld, Fourier Series Square Wave.
Reviewed by the CalculatorHub team, edited by James Graham, 14 June 2026. See our methodology.