How to use the Fourier Series Calculator
- 1. Type f(x)Use x and functions like sin, exp, abs or sign. sign(x) gives a square wave.
- 2. Set the intervalPick (−L, L) or (0, 2L) and enter L, for example pi or 1.
- 3. Get the seriesSee a₀, aₙ and bₙ in a table and the series written out.
The formulas
A function with period 2L can be written as f(x) = a₀/2 + Σ [aₙ cos(nπx/L) + bₙ sin(nπx/L)]. Over one period, a₀ = (1/L)∫ f(x) dx, aₙ = (1/L)∫ f(x) cos(nπx/L) dx and bₙ = (1/L)∫ f(x) sin(nπx/L) dx. When L = π, the terms become cos nx and sin nx.
The tool works these integrals out numerically with Simpson's rule on 6,000 strips, so it handles any function you can type, including ones without a neat antiderivative.
Worked example
Take f(x) = x on (−π, π). x is odd, so a₀ = aₙ = 0. For bₙ, integrating by parts gives bₙ = 2(−1)ⁿ⁺¹/n. So b₁ = 2, b₂ = −1, b₃ = 0.6667, b₄ = −0.5 and b₅ = 0.4, which is exactly what the tool shows:
x = 2 sin x − sin 2x + (2/3) sin 3x − (1/2) sin 4x + …
Try f(x) = x^2 on the same interval and you get a₀ = 2π²/3 = 6.5797 and aₙ = 4(−1)ⁿ/n², so a₁ = −4, a₂ = 1, a₃ = −0.4444. Only cosine terms appear because x² is even.
Even, odd and half-range series
If f is even on (−L, L), all bₙ are 0 and you get a cosine series. If f is odd, all aₙ (and a₀) are 0 and you get a sine series. The result tells you which case you are in. At a jump, the series converges to the average of the left and right values, so a partial sum near a jump overshoots a little (the Gibbs effect). For other transforms, see the Laplace transform table.
Frequently asked questions
Why do I get 0.666667 and not 2/3?
The coefficients are computed numerically and shown as decimals. 0.666667 is 2/3 rounded to six places.
How do I enter a piecewise function?
Use step(x), which is 1 for x ≥ 0 and 0 otherwise. For example step(x)*x is 0 on the left half and x on the right half.
Why does the partial sum not match f(x)?
A few terms only approximate f. Add more terms, and remember that at a jump the series gives the average of the two sides.
Is this calculator free?
Yes. You enter your name and WhatsApp number once when you see your result, and other Uncodemy tools then open without the form.