discrete fourier transform calculator
Discrete Fourier Transform Calculator guide
The discrete Fourier transform converts a finite sample sequence into an equal number of complex frequency coefficients. Enter the real samples in time order. For a real waveform leave the imaginary field at a single zero. For a complex waveform provide one imaginary component for every real sample.
Play the instrument ↑- Default result
- 4 Fourier bins
Calculation and units
For bin k, multiply sample n by a complex exponential with angle minus two pi times k times n divided by the record length N. Add the products across the complete time record. No factor of one divided by N is applied on this forward path. The magnitude column is the Euclidean length of the real and imaginary pair.
Worked examples
Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.
One cycle cosine
Real samples = 1 0 -1 0 · Imaginary samples (0 for real input) = 0.
4 Fourier bins. Negative exponential with no scaling. DC has real part 0 and imaginary part 0. Bins follow unshifted DFT order. Table readings (Bin, Real, Imaginary, Magnitude): (0, 0, 0, 0) / (1, 2, 0, 2) / (2, 0, 0, 0) / (3, 2, 0, 2).
A real cosine creates a pair of equal frequency components. The two nonzero bins are a conjugate pair on opposite sides of the unshifted array.
Offset only
Real samples = 3 3 3 3 · Imaginary samples (0 for real input) = 0.
4 Fourier bins. Negative exponential with no scaling. DC has real part 12 and imaginary part 0. Bins follow unshifted DFT order. Table readings (Bin, Real, Imaginary, Magnitude): (0, 12, 0, 12) / (1, 0, 0, 0) / (2, 0, 0, 0) / (3, 0, 0, 0).
The DC coefficient equals the sum of the samples. All other bins cancel for this constant sequence.
Delayed unit impulse
Real samples = 0 1 0 0 · Imaginary samples (0 for real input) = 0.
4 Fourier bins. Negative exponential with no scaling. DC has real part 1 and imaginary part 0. Bins follow unshifted DFT order. Table readings (Bin, Real, Imaginary, Magnitude): (0, 1, 0, 1) / (1, 0, -1, 1) / (2, -1, 0, 1) / (3, 0, 1, 1).
Every magnitude is one. The changing real and imaginary components reveal phase rotation that a magnitude-only comparison would hide.
Alternating signs
Real samples = 1 -1 1 -1 · Imaginary samples (0 for real input) = 0.
4 Fourier bins. Negative exponential with no scaling. DC has real part 0 and imaginary part 0. Bins follow unshifted DFT order. Table readings (Bin, Real, Imaginary, Magnitude): (0, 0, 0, 0) / (1, 0, 0, 0) / (2, 4, 0, 4) / (3, 0, 0, 0).
All of the signal lands at the Nyquist bin. That index is its own negative-frequency partner in this even-length record.
Complex rotating tone
Real samples = 1 0 -1 0 · Imaginary samples (0 for real input) = 0 1 0 -1.
4 Fourier bins. Negative exponential with no scaling. DC has real part 0 and imaginary part 0. Bins follow unshifted DFT order. Table readings (Bin, Real, Imaginary, Magnitude): (0, 0, 0, 0) / (1, 4, 0, 4) / (2, 0, 0, 0) / (3, 0, 0, 0).
Adding the matching sine as an imaginary component produces one complex rotating tone. The forward sign convention places it at index one.
Odd length record
Real samples = 1 2 3 · Imaginary samples (0 for real input) = 0.
3 Fourier bins. Negative exponential with no scaling. DC has real part 6 and imaginary part 0. Bins follow unshifted DFT order. Table readings (Bin, Real, Imaginary, Magnitude): (0, 6, 0, 6) / (1, -1.5, 0.8660254, 1.7320508) / (2, -1.5, -0.8660254, 1.7320508).
A three-point transform has one DC coefficient and one conjugate pair. There is no separate Nyquist bin for an odd sample count.
Interpreting the result
Read the first row as DC. To obtain bin labels in hertz, use the sample rate divided by N as the grid spacing. Bins above the halfway point represent negative frequencies in unshifted order. For a real input the rows at k and N minus k have equal real parts and opposite imaginary parts.
Measurement and model limits
This is a direct calculation intended for short records. The samples are used without tapering or removal of their mean. Record length limits spectral resolution and incomplete cycles distribute energy across bins. The magnitude column contains raw coefficient sizes. A single-sided amplitude spectrum needs its own scaling and special handling of DC and Nyquist.
Music theory tools → · Inverse Discrete Fourier Transform Calculator → · NumPy DFT order and normalization →
Answers before you play
Common questions
Can I use an odd number of samples?
Yes. A direct transform works for any supported length. An odd-length record has no bin exactly at half the sampling rate.
How can I recover the input?
Copy both component columns in their existing order into the inverse transform calculator. Use the component values rather than the magnitudes to retain phase.
Why is DC sometimes so large?
DC equals the sum of the input samples under this normalization. Dividing it by the sample count yields the average level.
Where does the imaginary part come from?
The exponential includes a sine term that measures alignment with the quadrature component of each tone. Even a real input can have complex Fourier coefficients.