Toolvito

Processed online by Toolvito

Fourier Transform Calculator

Find the Fourier series of a function on one period (the coefficients a₀, aₙ and bₙ with the integrals worked out), the Fourier transform of a pulse or a decaying function and its inverse, or the discrete Fourier transform (FFT) of a list of numbers. Every answer is checked numerically.

Choose what to do

Task
Fourier series

A formula, or pieces one per line, such as -1 for -pi < x < 0 and 1 for 0 < x < pi.

Optional (x).

Start of the period (0 for a half-range series). Optional when the pieces give it.

End of the period (L for a half-range series).

For the partial sum and the table, 1 to 50.

More options

Significant digits of decimal values, 2 to 30.

When you run a task here, Toolvito receives the information you submit for processing. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

How to use it

  1. Choose a task: Fourier series, Fourier transform or DFT / FFT.
  2. For a series type f(x) and one period, such as x from -pi to pi, or a function in pieces, one per line, such as -1 for -pi < x < 0 and 1 for 0 < x < pi (a square wave). Choose the form and the number of terms.
  3. For a transform type f(t), such as e^(-t^2), e^(-abs(t)) or the pulse 1 for -1 < t < 1, and choose the convention. For a DFT type the values, such as 1, 2, 3, 4.
  4. Select Calculate. Read the coefficients or the transform, the steps and the checks; download the worked solution, the JSON data and the graph (the DFT also as a CSV spectrum).

Fourier series

  • For a period P = 2L: f(x) ≈ a₀/2 + Σ (aₙ cos(nπx/L) + bₙ sin(nπx/L)) with aₙ = (1/L)∫ f(x) cos(nπx/L) dx and bₙ = (1/L)∫ f(x) sin(nπx/L) dx over one period.
  • The general coefficients are integrated exactly with n a whole number (so sin(nπ) = 0 and cos(nπ) = (−1)ⁿ). When the general formula fails for some n (such as n = 1 for x·sin x) those values are worked out on their own and listed.
  • The complex form gives cₙ = (1/P)∫ f(x)e^(−inω₀x) dx; the half-range series give the cosine (even extension) or sine (odd extension) series of f on [0, L].
  • At a jump the series converges to the middle of the jump, and near a jump the partial sums overshoot by about 9 % (the Gibbs effect) however many terms are used.

Fourier transform conventions

  • Angular frequency (engineering): F(ω) = ∫ f(t)e^(−iωt) dt, and the inverse has the factor 1/(2π).
  • Unitary: the factor 1/√(2π) on both the transform and the inverse.
  • Ordinary frequency (hertz): F(ξ) = ∫ f(x)e^(−2πiξx) dx with no factor; the inverse has e^(+2πiξx).
  • The function must decay on both sides or be zero outside a finite interval. Each answer is kept only when it agrees with a numerical integral at three frequencies of both signs.

DFT and FFT

  • X[k] = Σ x[n]·e^(−2πikn/N) for k = 0 … N − 1, computed with the fast Fourier transform (NumPy) for up to 65,536 values; exact values are shown for up to 32 values.
  • With a sample rate each bin k has the frequency k·rate/N (bins above N/2 are the negative frequencies); the magnitude, phase and power of every bin are in the table and the CSV file.
  • Scaling: none on the forward transform and 1/N on the inverse (the default, as in NumPy and MATLAB), 1/√N on both, or 1/N on the forward transform.
  • Several lines of the same length can be transformed as a 2-D grid.

How the answers are checked

Series: the first coefficients are integrated again numerically (mpmath, no antiderivative), Bessel’s inequality is tested and 100 terms are summed at a point where f is continuous. Transforms: numerical integrals of f·cos and f·sin at three frequencies (mpmath quad and quadosc) and the opposite transform. DFT: a direct sum in 25-digit arithmetic without the FFT, the inverse giving the input back, and Parseval’s theorem.

Related tools