Fourier Series Calculator
When a periodic waveform needs to be broken into its fundamental frequencies, manually evaluating the Euler–Fourier integrals for the coefficients a₀, aₙ, and bₙ is tedious and prone to sign errors. A Fourier series calculator automates this decomposition, returning the amplitude of each cosine and sine harmonic for any integrable periodic function you provide.
Students use it to verify homework on square waves and sawtooth signals. Engineers rely on it to preview total harmonic distortion in switching power supplies or audio amplifiers before simulating a circuit. In every case, the goal is the same: replace a complex repeating pattern with an infinite sum of simple trigonometric terms that are easier to analyze and filter.
The calculator above accepts either a custom piecewise definition or a selection of common waveforms. You set the fundamental period 2L and the number of harmonics N. The tool then evaluates the definite integrals for each coefficient, formats the resulting series, and overlays the partial-sum graph on the original function so you can inspect convergence behavior directly.
What Formulas Power a Fourier Series Calculator?
For a real-valued function f(x) with period 2L, the expansion takes the form:
f(x) = a₀/2 + Σ_{n=1}^{∞} [aₙ cos(nπx/L) + bₙ sin(nπx/L)]
The coefficients are found through integration over one full period:
- a₀ = (1/L) ∫_{-L}^{L} f(x) dx
- aₙ = (1/L) ∫_{-L}^{L} f(x) cos(nπx/L) dx
- bₙ = (1/L) ∫_{-L}^{L} f(x) sin(nπx/L) dx
When the period equals 2π, these simplify to the textbook versions with L = π:
- a₀ = (1/π) ∫_{-π}^{π} f(x) dx
- aₙ = (1/π) ∫_{-π}^{π} f(x) cos(nx) dx
- bₙ = (1/π) ∫_{-π}^{π} f(x) sin(nx) dx
Symmetry shortcuts save time. If f(x) is even, every bₙ is zero, producing a cosine series. If f(x) is odd, a₀ and aₙ vanish, leaving a sine series. The calculator detects these symmetries automatically and skips the associated integrals.
Can a Fourier Series Calculator Handle Piecewise Functions?
Yes. Most real signals are not single expressions. You can define the waveform segment by segment, specifying breakpoints and separate formulas for each interval. The calculator integrates each piece individually and accumulates the contributions into a single set of coefficients.
This is essential for rectified sine waves, pulse-width-modulated trains, and mechanical vibration profiles where the load changes abruptly. As long as the function satisfies the Dirichlet conditions–finite jumps and a finite number of maxima and minima in one period–the series converges.
Step-by-Step Example: Square Wave Expansion
Consider the odd square wave
f(x) = -1, −π < x < 0 f(x) = 1, 0 < x < π
with period 2π. Because the function is odd, symmetry tells us immediately that a₀ = 0 and aₙ = 0 for all n ≥ 1.
For bₙ:
bₙ = (1/π) ∫{-π}^{π} f(x) sin(nx) dx = (1/π) [ ∫{-π}^{0} (-1) sin(nx) dx + ∫_{0}^{π} (1) sin(nx) dx ] = (2/(nπ)) [1 − (−1)ⁿ]
Thus bₙ = 4/(nπ) when n is odd, and bₙ = 0 when n is even. The resulting Fourier series is:
f(x) = (4/π) [ sin(x) + (1/3)sin(3x) + (1/5)sin(5x) + (1/7)sin(7x) + … ]
Entering this waveform into the calculator confirms these coefficients in seconds and plots the partial sum. You can watch the ringing near the jumps–Gibbs phenomenon–diminish in width but not in height as more terms are added.
Practical Applications of Fourier Series in 2026
Fourier analysis remains a backbone of modern engineering education and design. In electronics, it predicts the harmonic content of clock signals and switch-mode power supplies. In structural engineering, it decomposes vibration modes of bridges and rotating machinery. In signal processing, it underlies filter design and audio compression algorithms.
Modern online calculators have bridged the gap between theory and practice. Instead of stopping at symbolic coefficients, they visualize how adding the 3rd, 5th, and 7th harmonics gradually reconstructs a square wave, giving concrete meaning to the abstract infinite sums taught in differential equations courses.
How to Get Accurate Results Every Time
- Check symmetry before you start. Identifying even or odd parity cuts the number of integrals in half and eliminates common sign mistakes.
- Define periods explicitly. A waveform running from 0 to T requires different integral limits than one centered at zero; the calculator needs the exact interval length 2L.
- Use 5–20 harmonics for smooth shapes. Discontinuous waveforms need more terms to resolve steep edges, though Gibbs overshoot will remain visible near jumps.
- Validate a₀ separately. The constant term a₀ divided by 2 should equal the average value of the function over one period; this sanity check catches input errors instantly.