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
Worked example
Square wave: f = −1 on (−π, 0), 1 on (0, π)
- The function is odd, so a₀ = aₙ = 0.
- bₙ = (1/π)[∫₋π⁰ −sin nx dx + ∫₀^π sin nx dx] = 2(1 − cos nπ)/(nπ).
- That is 4/(nπ) for odd n and 0 for even n.
- 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.