Solved.tools — Free Online Calculators & Tools

We use cookies for analytics and advertising. Learn more about our cookie policy

Fourier Transform Calculator

Last updated: 22 August 2026

Reviewed by Gavin · Research and drafting assisted by AI

🌊 Fourier Transform Calculator

Compute the discrete Fourier transform (DFT) of a finite real-valued input sequence. For each frequency bin k the tool reports the real part, imaginary part, magnitude |X[k]|, and phase ∠X[k] in radians, then performs an inverse-DFT round-trip to verify the result.

N = 4 samples parsed.
Presets:
DFT of N = 4 samples — magnitude and phase
k = 0: X[0] = 0.0000 + 0.0000i |X[0]| = 0, ∠X[0] = 0.0000 rad
k = 1: X[1] = 2.0000 + 0.0000i |X[1]| = 2, ∠X[1] = 0.0000 rad
k = 2: X[2] = 0.0000 − 0.0000i |X[2]| = 0, ∠X[2] = -1.5708 rad
k = 3: X[3] = 2.0000 + 0.0000i |X[3]| = 2, ∠X[3] = 0.0000 rad
Bin k = 0
Re = 0.0000
Im = 0.0000
|X| = 0
∠X = 0.0000 rad
Bin k = 1
Re = 2.0000
Im = 0.0000
|X| = 2
∠X = 0.0000 rad
Bin k = 2
Re = 0.0000
Im = 0.0000
|X| = 0
∠X = -1.5708 rad
Bin k = 3
Re = 2.0000
Im = 0.0000
|X| = 2
∠X = 0.0000 rad
Inverse DFT round-trip check
Original: [ 1.0000, 0.0000, -1.0000, 0.0000 ]
Recovered x̂[n]: [ 1.000000, 0.000000, -1.000000, 0.000000 ]
Max |x[n] − x̂[n]| = 0.000000000000(≈ machine epsilon for double precision)
Formula: X[k] = Σₙ x[n] · exp(−2π i k n / N), for k = 0, 1, …, N−1. Magnitude |X[k]| = √(Re² + Im²) and phase ∠X[k] = atan2(Im, Re). Round-trip uses the inverse DFT x[n] = (1/N) Σₖ X[k] · exp(+2π i k n / N). For N up to 16 the naive O(N²) DFT is instantaneous; for production work with larger N, the O(N log N) FFT (Cooley & Tukey, 1965) is the standard approach. See Joseph Fourier's Théorie analytique de la chaleur (1822) for the continuous origin of the series.
Was this helpful?


Fourier Transform Calculator

A Fourier transform calculator takes a finite, real-valued input sequence x[0], x[1], …, x[N−1] and decomposes it into the frequencies it contains, producing a complex spectrum X[0], X[1], …, X[N−1] with one complex number per frequency bin. The magnitude |X[k]| tells you how much of frequency k is present in the signal; the phase ∠X[k] tells you the timing offset of that frequency component relative to the start of the window. Together they are the frequency-domain fingerprint of any finite digital signal, and they are the foundation of audio engineering, image compression, mobile communications, vibration analysis, and medical imaging.

This calculator evaluates the textbook discrete Fourier transform (DFT) directly for sequences of length N between 2 and 16, returning the real part, imaginary part, magnitude, and phase of every bin, and then runs the inverse DFT to verify the round trip.

How to Use the Fourier Transform Calculator

  1. Paste a comma-separated list of real numbers into the input box, for example 1, 0, -1, 0. Whitespace and semicolons are also accepted as separators.
  2. The calculator parses the sequence and shows N, the number of samples.
  3. The DFT is computed for every bin k = 0, 1, …, N−1. For each bin you see Re(X[k]), Im(X[k]), |X[k]|, and ∠X[k] in radians.
  4. The inverse DFT is then run on the result and the maximum absolute error against your original input is displayed, typically around 10⁻¹⁵ for these small N (double-precision machine epsilon).
  5. Try the preset buttons for the most common canonical inputs: a pure DC constant, a cosine, a linear ramp, an impulse, and a square wave.

The maximum supported length is 16, because the naive DFT runs in O(N²) time. For larger N you would use the fast Fourier transform (FFT), which runs in O(N log N).

The Formula

The discrete Fourier transform is defined as:

X[k] = Σ_{n=0}^{N-1} x[n] · exp(−2π i k n / N),   for k = 0, 1, …, N−1

Each X[k] is a complex number a + bi, where:

Re(X[k]) = Σ x[n] · cos(2π k n / N)
Im(X[k]) = − Σ x[n] · sin(2π k n / N)

The magnitude and phase follow from the rectangular form:

|X[k]|  = √(Re(X[k])² + Im(X[k])²)
∠X[k]   = atan2(Im(X[k]), Re(X[k]))    (radians, range −π … +π)

The inverse DFT, used for the round-trip check, is:

x[n] = (1/N) · Σ_{k=0}^{N-1} X[k] · exp(+2π i k n / N)

The forward transform has no 1/N prefactor; the inverse carries the 1/N. This is the standard engineering convention; the symmetric form divides both by √N instead and is preferred in some mathematics texts but is functionally equivalent.

Worked Examples

The following five inputs are the canonical sanity checks for any DFT implementation. Paste each one in and confirm the output.

Example 1, DC: [1, 0]

A single nonzero sample followed by zero. The DFT spreads its energy evenly across both bins because N is so small. X[0] = 1, X[1] = 1. The inverse DFT recovers [1, 0] exactly.

Example 2, DC + Nyquist: [1, 1]

A constant sequence. The full energy is concentrated in the DC bin. X[0] = 2 (the sum of the input), X[1] = 0. The Nyquist bin is exactly zero for a real constant input. This is the simplest possible low-pass signal.

Example 3, Cosine πn: [1, 0, -1, 0]

The discrete-time cosine cos(πn) sampled at the Nyquist rate. Because the input is real, the spectrum is conjugate symmetric: the energy appears at both k = 1 and k = N−1 = 3, each with magnitude 2 and phase 0. The DC bin X[0] and the Nyquist bin X[2] are both zero. The round-trip error is on the order of 10⁻¹⁶.

Example 4, Linear ramp: [1, 2, 3, 4]

A non-trivial real sequence. X[0] = 10 (the sum), X[1] = −2 + 2i with magnitude 2√2 ≈ 2.828 and phase 3π/4 ≈ 2.356 rad, X[2] = −2 + 0i (purely real, negative, magnitude 2), and X[3] = −2 − 2i, which is the conjugate of X[1] as the conjugate-symmetry property of real-input DFT requires. The round-trip recovers [1, 2, 3, 4] to machine precision.

Example 5, All-DC: [1, 1, 1, 1]

Same as example 2 but with N = 4. X[0] = 4, X[1] = X[2] = X[3] = 0. A constant signal has only a DC component; every other bin is zero.

Bonus, Impulse: [1, 0, 0, 0]

The discrete delta function. Its DFT is identically 1 at every bin: X[k] = 1 for all k. The inverse DFT recovers [1, 0, 0, 0] exactly. The impulse is the identity element of the Fourier transform, just as the number 1 is the identity of multiplication.

Where the Fourier Transform Shows Up

The Fourier transform is one of the most widely used ideas in applied mathematics, and the discrete form is the engine of every digital signal you have ever heard or seen.

Audio compression (MP3, AAC, Ogg Vorbis). Modern audio codecs decompose the signal into short overlapping windows, transform each window with a modified discrete cosine transform, and discard the frequency components the human ear cannot perceive (psychoacoustic masking). A typical MP3 file is roughly one tenth the size of the uncompressed CD audio it represents, and the difference is almost inaudible because the codec is exploiting Fourier-domain perceptibility, not time-domain redundancy.

Image compression (JPEG, MPEG, HEVC). JPEG splits each image into 8×8 blocks of pixels and applies a 2D discrete cosine transform, a close cousin of the DFT, to each block. The converted coefficients are then quantised: high-frequency components (which the eye barely sees) are stored with less precision, and many are dropped entirely. The reconstructed image is visually close to the original but uses a fraction of the data.

Vibration analysis and modal testing. Mechanical engineers attach accelerometers to engines, bridges, and turbine blades and examine the frequency spectrum of the recorded vibration. A healthy bearing has a characteristic frequency fingerprint; a failing one develops sidebands that are immediately visible in |X[k]|. The DFT, in the form of the FFT, is the standard tool for this kind of analysis.

Mobile and Wi-Fi communications (OFDM). 4G LTE, 5G NR, Wi-Fi (802.11a/g/n/ac/ax), and digital TV all use orthogonal frequency division multiplexing, a modulation scheme that splits a wideband channel into thousands of narrow sub-carriers using an inverse FFT at the transmitter and an FFT at the receiver. Without the FFT, modern wireless data rates would be impossible.

Medical imaging (MRI). Magnetic resonance imaging reconstructs cross-sectional images of the body by sampling the frequency-domain signal (k-space) directly and applying an inverse 2D or 3D Fourier transform to recover the spatial image. The technique is literally called "Fourier transform imaging" in the medical physics literature.

Spectrum analysers and audio editors. Every visual audio spectrum you have seen, whether in a music player, a digital audio workstation, a hearing aid fitting tool, or a laboratory spectrum analyser, is the magnitude of a sliding-window FFT of the input signal. The bars and peaks you see are exactly the |X[k]| values this calculator produces.

Common Mistakes

Mistake 1: Assuming N must be a power of 2. A common misconception is that you can only use the DFT for N = 2, 4, 8, 16, …. That constraint applies to the fast Fourier transform (FFT), which uses a divide-and-conquer strategy that only factorises cleanly for powers of 2 (or for highly composite N in the more general Cooley-Tukey variants). The DFT itself works for any positive integer N; this calculator accepts N = 2 through 16 without restriction. If you have data of length 7, the DFT still works, it just does not factor into an FFT as efficiently.

Mistake 2: Confusing magnitude with the real part. |X[k]| is always non-negative, even when the underlying Re(X[k]) is negative. Many people look at a spectrum and see that the real part goes negative and assume something is wrong, but the magnitude is the physically meaningful quantity (it is proportional to the energy at that frequency). For a real-valued input, |X[k]| is symmetric: |X[k]| = |X[N−k]|.

Mistake 3: Ignoring phase wrap-around. ∠X[k] is computed with atan2 and returned in the range −π … +π. The same physical phase can be represented as θ or θ + 2π, and the calculator returns the wrapped value. If you are interested in continuous phase, you will need to unwrap it (add multiples of 2π to remove the discontinuities). For most signal-processing applications the wrapped phase is fine.

Mistake 4: Forgetting that the input must be a real or complex sequence, not a function. The DFT takes a sequence of samples x[0], x[1], …, not a closed-form function. If you have a function, you must first sample it at N evenly spaced points. The choice of sample spacing determines the frequency range you are analysing: the highest unambiguous frequency is the Nyquist frequency, half the sample rate. Frequencies above the Nyquist will alias to lower frequencies and corrupt your spectrum.

Mistake 5: Aliasing above the Nyquist frequency. If your input contains energy at frequencies higher than half the sample rate, those components fold back into the spectrum and appear at incorrect bins. This is called aliasing and is the single most common source of garbage-in/garbage-out in DFT analysis. To avoid it, band-limit your input with an anti-aliasing filter before sampling, or sample fast enough that the highest frequency of interest is comfortably below Nyquist.

Frequently Asked Questions

What is the difference between the DFT and the FFT?

The discrete Fourier transform (DFT) is the mathematical operation: a sum over N terms for each of N output bins, giving an O(N²) algorithm. The fast Fourier transform (FFT) is a family of algorithms, the most famous due to Cooley and Tukey (1965), that compute the same result in O(N log N) time by recursively splitting the sum into smaller pieces. The output of the FFT is bit-for-bit identical to the output of the DFT. For the small N (up to 16) supported by this calculator, the difference is irrelevant, both are instantaneous. For N in the millions, the FFT is essential.

Can the Fourier transform handle complex input?

Yes. The formula X[k] = Σ x[n] · exp(−2π i k n / N) works for any complex sequence x[n]; you just substitute a complex number for x[n] in the sum. This calculator takes a real input for simplicity, but the code generalises trivially. A complex input is the right model when the signal has both in-phase and quadrature components, as in radar, software-defined radio, and many communications receivers.

What does the phase ∠X[k] mean physically?

The phase tells you the time offset of the frequency-k component relative to the start of your sample window. A pure cosine cos(2π k n / N + φ) has all its energy at bin k with phase φ. If you shift the entire input by one sample, every phase changes by 2πk/N. The phase spectrum is what makes a signal recognisable beyond its power spectrum: the human ear is sensitive to the relative phases of harmonics, which is why a piano and a violin playing the same note sound different even though they share the same magnitude spectrum.

Why are X[1] and X[N−1] equal in magnitude for a real input?

A real-valued input has the conjugate-symmetry property X[k] = conj(X[N−k]). Taking magnitudes of both sides gives |X[k]| = |X[N−k]|. This is why the magnitude spectrum of a real signal is symmetric around the middle. The phase spectrum is anti-symmetric: ∠X[k] = −∠X[N−k]. This is the discrete-time analogue of the well-known fact that the Fourier transform of a real function is Hermitian symmetric.

What is Parseval's theorem and does it apply here?

Parseval's theorem says the total energy in the time domain equals the total energy in the frequency domain: Σₙ |x[n]|² = (1/N) · Σₖ |X[k]|². It applies to the DFT exactly as written here, and is a useful sanity check: if you compute the energy of the input and the energy of the spectrum (scaled by 1/N) and they disagree, something is wrong. You can verify it on this calculator by inputting any sequence and summing both sides.

Is the Fourier transform the same as the Laplace transform?

No. The Fourier transform is the Laplace transform evaluated on the imaginary axis (s = iω). The Laplace transform has an extra real component in the exponent, which makes it converge for a strictly larger class of functions, but at the cost of returning a complex function of a complex variable instead of just a complex function of a real frequency. For real-world signals that are well-behaved and decay to zero, the two converts give equivalent information; the Fourier transform is the right tool for periodic or steady-state signals, the Laplace transform for transient or unstable ones.


Learn more:

Also try these free tools: