Fourier Series Calculator
Free Fourier series calculator: get a₀, aₙ, bₙ coefficients, the partial-sum graph, and step-by-step derivation for any periodic function.
Coefficients
a₀ and 8 harmonics
| n | aₙ | bₙ |
|---|---|---|
| 0 | 0 | — |
| 1 | 0 | 1.999 |
| 2 | 0 | -0.9995 |
| 3 | 0 | 0.6663 |
| 4 | 0 | -0.4997 |
| 5 | 0 | 0.3998 |
| 6 | 0 | -0.3332 |
| 7 | 0 | 0.2856 |
| 8 | 0 | -0.2499 |
Step-by-Step Solution
How the coefficients are derived
Identify period & frequency
Interval [-3.14, 3.14], T = 6.28, ω = 2π/T = 1.0005.
Compute a₀ (average value)
a₀ = (1/T) ∫ f(x) dx = 0.
Compute aₙ (cosine coefficients)
aₙ = (2/T) ∫ f(x) cos(nωx) dx for n = 1 .. 8.
Compute bₙ (sine coefficients)
bₙ = (2/T) ∫ f(x) sin(nωx) dx for n = 1 .. 8.
Assemble the series
f(x) ≈ a₀ + Σ [aₙ cos(nωx) + bₙ sin(nωx)], n = 1 .. 8.
What Is a Fourier Series?
Decomposing any periodic function into sines and cosines
A Fourier series rewrites a periodic function as a sum of sines and cosines. Square waves, triangle waves, sawtooth ramps, and even discontinuous step functions can all be approximated by adding enough harmonics together.
Core Idea
f(x) ≈ a₀ + Σ [aₙ cos(nωx) + bₙ sin(nωx)]
f(x)
Periodic function
a₀
DC / average term
aₙ, bₙ
Harmonic amplitudes
ω = 2π/T
Angular frequency
The technique is essential in signal processing (decomposing a waveform into frequency components), PDEs (separation of variables for the heat and wave equations), and data compression (JPEG, MP3, MPEG all rely on Fourier-style basis representations).
Coefficient Formulas by Series Type
Five modes, three integral families
1. Full Fourier Series
Both sines and cosines on a symmetric interval. The default mode for general periodic functions on [−L, L].
a₀ = (1/T) ∫ₐᵇ f(x) dx
aₙ = (2/T) ∫ₐᵇ f(x) cos(nωx) dx
bₙ = (2/T) ∫ₐᵇ f(x) sin(nωx) dx
2. Half-Range Sine Series
Odd extension on [0, L]. Vanishes at both endpoints — used when boundary conditions are f(0) = f(L) = 0.
f(x) ≈ Σ bₙ sin(nπx/L) · bₙ = (2/L) ∫₀ᴸ f(x) sin(nπx/L) dx
3. Half-Range Cosine Series
Even extension on [0, L]. Zero slope at endpoints — used when boundary conditions are f′(0) = f′(L) = 0.
f(x) ≈ a₀ + Σ aₙ cos(nπx/L) · aₙ = (2/L) ∫₀ᴸ f(x) cos(nπx/L) dx
4. Complex (Exponential) Series
Algebraically cleaner. Used in signal processing and as the bridge to the Fourier transform.
f(x) ≈ Σ cₙ e^(inωx) · cₙ = (1/T) ∫ₐᵇ f(x) e^(−inωx) dx
Quick Reference & Worked Example
Standard textbook results at a glance
| Function on [−π, π] | Non-zero coefficients | Parity |
|---|---|---|
| x | bₙ = (−1)^(n+1) · 2/n | Odd |
| x² | a₀ = π²/3, aₙ = 4(−1)^n/n² | Even |
| |x| | a₀ = π/2, aₙ = −4/(πn²) (odd n) | Even |
| Square wave (±1) | bₙ = 4/(nπ) (odd n) | Odd |
| Triangle wave | aₙ = −4/(π·n²) (odd n) | Even |
| Sawtooth (= x) | bₙ = (−1)^(n+1) · 2/n | Odd |
Worked Example: Square Wave
Decompose f(x) = −1 on (−π, 0) and +1 on (0, π):
Period T = 2π ω = 1
Step 1: f(x) is odd → a₀ = 0 and every aₙ = 0.
Step 2: bₙ = (2/2π) · ∫₋π^π f(x) sin(nx) dx = (2/π) · ∫₀^π sin(nx) dx
Step 3: Evaluate: bₙ = (2/π) · [(1 − cos(nπ))/n] = (2/π) · (1 − (−1)^n)/n
Step 4: bₙ = 4/(nπ) for odd n; bₙ = 0 for even n.
Result: f(x) = (4/π)[sin(x) + sin(3x)/3 + sin(5x)/5 + …] ✓
Where Fourier Series Are Used
Applications across science and engineering
Audio & Signal Processing
Decomposes a waveform into frequency components for filtering, equalization, and lossy compression in MP3/AAC.
Heat & Wave Equations
Separation of variables in PDEs naturally produces Fourier expansions; coefficients fix the boundary/initial data.
Image Compression (JPEG)
JPEG uses a discrete cosine transform — a half-range Fourier cosine series on 8×8 image blocks.
Communications
Modulation, demodulation, and OFDM in 4G/5G/Wi-Fi all rely on Fourier representations of signals.
Quantum Mechanics
Solutions to the Schrödinger equation in a periodic potential expand in plane-wave (Fourier) basis.
Electrical Engineering
Steady-state response of linear circuits to non-sinusoidal periodic inputs uses harmonic-by-harmonic analysis.
Common Mistakes & Convergence
The pitfalls that show up in homework problems
Wrong period
Set the interval to one full period of the periodic extension. For a square wave centred at 0, that is [−π, π], not [0, π].
Forgetting the (2/T) factor
aₙ and bₙ have a 2/T scaling; a₀ has only 1/T. Mixing them produces coefficients off by a factor of 2.
Ignoring even/odd parity
If f(x) is even, every bₙ vanishes. If it is odd, every aₙ (and a₀) vanishes. Use a half-range mode to bake this in.
Gibbs overshoot near jumps
At a jump discontinuity the partial sum overshoots by ~9% of the jump height regardless of N. The overshoot narrows as N grows; it does not disappear.
Related Calculators
Tools that compose well with Fourier analysis
Frequently Asked Questions
Common questions about Fourier series and how to compute them
Embed Fourier Series Calculator
Add this calculator to your website or blog for free.
You Might Also Like
Related calculators from other categories
Last updated Apr 28, 2026