Type to search, in English or Thai

  1. Home
  2. Tools
  3. Fourier series

// Tool · Fourier Series Calculator

Fourier Series Calculator: Find a₀, aₙ, bₙ and Watch the Partial Sums Converge

Define one period piece by piece, or pick a ready-made waveform, and get a0a_0, ana_n, bnb_n in closed form (for example 4π\frac{4}{\pi}) with a harmonic table, RMS, THD, and a graph of f(t)f(t) against the partial sum with a slider for the number of terms.

By Ajarn ModUpdated

Calculator

How to use it

  1. Pick a ready-made waveform, or type f(t)f(t) piece by piece. For example piece 1: 1 from 0 to pi; piece 2: -1 from pi to 2*pi.
  2. Enter the period TT, equal to the total length of the pieces. pi is accepted, e.g. 2*pi.
  3. Choose the number of harmonics NN and calculate. Then drag the slider under the graph to see the partial sum approach f(t)f(t).

The coefficient formulas

A periodic function f(t)f(t) with period TT and fundamental angular frequency ω0=2πT\omega_0 = \dfrac{2\pi}{T} has the Fourier series

f(t)=a0+∑n=1∞(ancos⁡nω0t+bnsin⁡nω0t)f(t) = a_0 + \sum_{n=1}^{\infty}\left(a_n\cos n\omega_0 t + b_n\sin n\omega_0 t\right) a0=1T∫Tf(t) dt,an=2T∫Tf(t)cos⁡nω0t dt,bn=2T∫Tf(t)sin⁡nω0t dta_0 = \frac{1}{T}\int_{T} f(t)\,dt, \qquad a_n = \frac{2}{T}\int_{T} f(t)\cos n\omega_0 t\,dt, \qquad b_n = \frac{2}{T}\int_{T} f(t)\sin n\omega_0 t\,dt

Here a0a_0 is the mean value itself. Some textbooks write a02\dfrac{a_0}{2} instead, which makes their a0a_0 twice the value shown on this page.

Symmetry saves work

SymmetryConditionConsequence
Evenf(−t)=f(t)f(-t) = f(t)bn=0b_n = 0: cosine terms only
Oddf(−t)=−f(t)f(-t) = -f(t)a0=an=0a_0 = a_n = 0: sine terms only
Half-wavef(t+T/2)=−f(t)f(t + T/2) = -f(t)odd harmonics only

The calculator detects symmetry from the computed coefficients and reports it, a quick way to check a hand calculation.

Example: the square wave

The square wave f(t)=1f(t) = 1 for 0≤t<π0 \le t < \pi and −1-1 for π≤t<2π\pi \le t < 2\pi is odd and has half-wave symmetry, so only bnb_n for odd nn survives.

bn=2π∫0πsin⁡nt dt=2nπ(1−cos⁡nπ)=4nπ (n odd)b_n = \frac{2}{\pi}\int_0^{\pi}\sin nt\,dt = \frac{2}{n\pi}\left(1 - \cos n\pi\right) = \frac{4}{n\pi}\ (n\ \text{odd}) f(t)=4π(sin⁡t+13sin⁡3t+15sin⁡5t+⋯ )f(t) = \frac{4}{\pi}\left(\sin t + \frac{1}{3}\sin 3t + \frac{1}{5}\sin 5t + \cdots\right)

The THD of a square wave is 48.34 %, which is what the calculator reports. The overshoot near each jump, about 9 % of the jump, is the Gibbs phenomenon; it does not disappear as harmonics are added.

Frequently asked questions

Is a₀ here the same as in my textbook?

Here a₀ is the mean value (1/T)∫f(t)dt. A textbook that starts the series with a₀/2 has an a₀ twice as large. The sum of the series is the same either way.

How does it produce closed forms such as 4/π?

Coefficients are computed by high-accuracy numerical integration and then compared with simple fractions times π, 1/π, 1/π² and common roots. A closed form is shown only when it matches to nine decimal places; otherwise a decimal is shown.

What is THD?

Total harmonic distortion: the RMS of all harmonics from the second upward divided by the RMS of the fundamental. It measures how far a waveform is from a sine.

Can I use u(t) inside a piece?

Yes, but splitting the period at each discontinuity is more accurate, because numerical integration works best when the function is smooth inside each piece.

More calculators