Differential Equations

Fourier Series Calculator

Fourier coefficients aₙ and bₙ, half-range sine and cosine series, and partial sums of a piecewise periodic function.

Tool no.
ECT-E07
Rev
1.0
Updated
Oct 2026
Method
Euler formulas, Gauss–Kronrod integration
Examples

Given

expression, from, to. For example x^2, -1, 1. Pieces must join with no gaps.

Answers

f(x) ≈—
Runs in your browser. Nothing you enter is uploaded.Euler formulas · Parseval
How to use this calculator

Write f one piece per line as expression, from, to. For a full series the pieces cover one whole period; for a half-range series they cover [0, L] and the function is extended evenly (cosine series) or oddly (sine series). Coefficients that match simple forms such as 4/(3π) are shown exactly.

Formulas

Seriesf(x) ≈ a₀/2 + Σ[an cos(nπx/L) + bn sin(nπx/L)]
Cosine coefficientsan = (1/L)∫ f(x) cos(nπx/L) dx
Sine coefficientsbn = (1/L)∫ f(x) sin(nπx/L) dx
Half rangean or bn = (2/L)∫₀L …
Parseval(1/L)∫ f² dx = a₀²/2 + Σ(an² + bn²)

Worked example

Square wave: f = −1 on (−π, 0), 1 on (0, π)

  1. The function is odd, so a₀ = aₙ = 0.
  2. bₙ = (1/π)[∫₋π⁰ −sin nx dx + ∫₀^π sin nx dx] = 2(1 − cos nπ)/(nπ).
  3. That is 4/(nπ) for odd n and 0 for even n.
  4. f(x) = (4/π)[sin x + sin 3x/3 + sin 5x/5 + …].

Frequently asked questions

Why does the partial sum overshoot at a jump?

That is the Gibbs phenomenon: near a discontinuity the partial sums overshoot by about 9% of the jump, however many terms you add. The overshoot gets narrower but not smaller.

What does the series converge to at a jump?

The average of the left and right limits. For the square wave at x = 0 that is 0.

Which half-range series should I use?

Both represent f on [0, L]. Use the sine series when the problem needs f = 0 at both ends (a string fixed at the ends, a bar held at 0°); use the cosine series for insulated ends.