Fourier Series Calculator

Enter a function f(x), set the half-period L, and choose the number of terms N to compute your Fourier Series. The calculator returns the DC coefficient a₀, cosine coefficients aₙ, sine coefficients bₙ, and the partial sum approximation Sₙ(x) — with a chart showing how well the series approximates the original function.

Select the periodic function to expand as a Fourier series.

units

The series is computed over the interval [-L, L]. Use L = π for standard trigonometric expansions.

How many harmonic terms to include in the partial sum Sₙ(x). More terms = better approximation.

Optional: enter a specific x value to see the numerical value of Sₙ(x) at that point.

Results

Sₙ(x) at given x

--

DC Coefficient a₀

--

a₁ (1st Cosine Coeff.)

--

b₁ (1st Sine Coeff.)

--

a₂ (2nd Cosine Coeff.)

--

b₂ (2nd Sine Coeff.)

--

Energy Captured by Sₙ (%)

--

Fourier Coefficients |aₙ| and |bₙ| by Harmonic

Results Table

Frequently Asked Questions

What is a Fourier Series?

A Fourier Series is a way to represent a periodic function as an infinite sum of sine and cosine waves. Every repeating signal — no matter how complex — can be decomposed into harmonics with specific amplitudes (aₙ, bₙ). The partial sum Sₙ(x) uses only the first N harmonics and approximates the original function increasingly well as N grows.

What are the coefficients a₀, aₙ, and bₙ?

a₀ is the DC (average) component: a₀ = (1/L)∫f(x)dx over [-L,L]. aₙ are the cosine coefficients: aₙ = (1/L)∫f(x)cos(nπx/L)dx. bₙ are the sine coefficients: bₙ = (1/L)∫f(x)sin(nπx/L)dx. Together they fully characterize how much of each frequency is present in the signal.

What is the half-period L?

L is half the period of the function. The Fourier series is computed over the symmetric interval [-L, L], giving a full period of 2L. For standard trigonometric functions like sin(x), use L = π. For signals defined over [-1, 1], use L = 1.

How many terms N should I use?

It depends on how smooth the function is. Smooth functions like parabolas converge quickly — 5 to 10 terms often give excellent accuracy. Discontinuous functions like the square wave or sawtooth converge slowly due to the Gibbs phenomenon, where overshoot near jumps persists even with many terms. Using 15–20 terms is advisable for such waveforms.

What is the Gibbs phenomenon?

The Gibbs phenomenon is the overshoot (about 9%) that appears near jump discontinuities in the Fourier approximation of functions like the square wave. It does not disappear as N increases — the overshoot simply becomes narrower. This is an inherent property of representing discontinuous functions with sinusoidal basis functions.

Why is the energy captured percentage useful?

By Parseval's theorem, the total energy of a periodic function equals the sum of the squared amplitudes of all its Fourier coefficients. The 'energy captured' metric shows what fraction of the total signal energy is represented by the first N terms, giving you an objective measure of approximation quality without needing to plot the result.

Can this calculator handle piecewise functions?

This calculator supports standard closed-form functions (sawtooth, square wave, triangle wave, parabola, half-rectified sine, constant). For arbitrary piecewise functions, the integrals need to be split at each breakpoint and evaluated separately — that level of symbolic integration is best handled in tools like Wolfram Alpha or Symbolab with manual formula entry.

What is the difference between the Fourier Series and the Fourier Transform?

The Fourier Series applies to periodic functions and produces a discrete set of coefficients at harmonically related frequencies (nπ/L). The Fourier Transform applies to non-periodic functions and produces a continuous frequency spectrum. For periodic signals, the Fourier Series is the right tool; the Fourier Transform is used for one-off transient signals.

More Math Tools