Numerical Fourier Series Expansion Calculator
Use this calculator to approximate Fourier coefficients for a periodic function on [-L, L]. The tool computes a0, an, bn up to N terms and builds the truncated series SN(x).
What this Fourier series calculator does
This page gives you a practical way to compute a Fourier series for a user-defined function. Instead of symbolic algebra, it uses numerical integration to estimate coefficients. That makes it useful for quick analysis, engineering intuition, and checking homework or simulation results.
The calculator assumes your function repeats every 2L and computes the truncated expansion:
f(x) ≈ a0/2 + Σn=1..N [an cos(nπx/L) + bn sin(nπx/L)]
Coefficient definitions used here
Standard Fourier coefficients on [-L, L]
- a0 = (1/L) ∫-LL f(x) dx
- an = (1/L) ∫-LL f(x) cos(nπx/L) dx
- bn = (1/L) ∫-LL f(x) sin(nπx/L) dx
Integrals are evaluated numerically with Simpson's rule for good accuracy at moderate sample counts.
How to use the tool
Step-by-step
- Type your expression for f(x) (for example
x,x^2,sin(x),abs(x)). - Set L, the half-period, so total period is 2L.
- Set N, the number of harmonics to include.
- Choose integration samples (higher means slower but usually more accurate).
- Optionally enter an x-value to evaluate the truncated series at that point.
- Click Calculate Fourier Expansion.
Examples to try
1) Odd function: f(x) = x on [-π, π]
For an odd function, cosine terms tend to vanish (an ≈ 0), and sine terms dominate. You should see a classic sine-only expansion pattern.
2) Even function: f(x) = x^2 on [-π, π]
For an even function, sine terms tend to vanish (bn ≈ 0), leaving cosine terms and a constant term.
3) Piecewise-like behavior: f(x) = abs(x)
This is a strong test for convergence behavior around non-smooth points. You'll still get a valid approximation, but more harmonics are needed for visual fidelity.
Accuracy and limitations
- This is a numerical calculator, not a symbolic computer algebra system.
- Very oscillatory or singular functions may require much higher sample counts.
- If the expression is undefined at many integration points, coefficient estimates may fail.
- The truncated series approximates the periodic extension of your function, not just the local shape inside one interval.
Why Fourier series matter
Fourier expansions are central in signal processing, control systems, vibration analysis, heat transfer, quantum mechanics, and PDE solving. Converting a function into harmonics lets you inspect frequency content directly and build efficient approximations.
Use this tool as a fast sandbox: test intuition, inspect coefficient decay, and compare how smooth vs non-smooth functions behave under harmonic approximation.