Discrete Fourier Transform Calculator
Read a sampled sequence as discrete frequency components
A discrete Fourier transform, or DFT, answers a specific spectral question: which repeating patterns occur in this ordered list of samples, and how strongly do they occur? Time-domain data shows values in measurement order. That view is useful for seeing peaks, dips, and trends, but it does not directly separate a once-per-record pattern from a twice-per-record pattern, a slow drift, or several mixed periodic components. The DFT expresses the same finite record as frequency bins so those components can be inspected individually.
This DFT calculator accepts a comma-separated real sequence such as 1,0,-1,0. After you select Compute DFT, it returns one complex coefficient for each frequency-bin index k. Each coefficient measures how the entered samples align with a rotating sinusoidal reference at that bin. It is suited to quick signal-processing checks, vibration or audio experiments, communications exercises, and other evenly spaced data where periodic structure may be present.
The DFT output is intentionally shown as complex numbers rather than as a simplified chart. The sections below explain the bin notation, state the calculation performed by the page, use a short sequence with exact results, and describe the sampling assumptions that affect interpretation of a spectrum.
Enter evenly spaced samples for this DFT calculation
For this DFT calculator, enter one comma-separated list of sample values in time order. Each value should represent the same interval after the previous one. For example, four equally spaced samples of a changing signal could be entered as 1,0,-1,0; an eight-sample periodic pattern could be 0,1,0,-1,0,1,0,-1. Equal spacing is essential because the DFT treats every position in the record as one uniform sample step.
This DFT page does not request a sampling rate, so it reports frequency positions as bins, not hertz. Bin k represents k cycles across a record of N samples. When the sampling rate Fs is known separately, the bin frequency is fk = kFs/N. The result therefore identifies the component's position within the sampled record; the sampling setup supplies the physical frequency unit.
The sequence parser splits only on commas, trims surrounding whitespace, converts each piece to a number, and ignores pieces that are not numeric. An entry such as 1, 2, bad, 3 consequently runs as 1,2,3. If fewer DFT bins appear than intended, check for misspellings, nonnumeric labels, or punctuation that did not create a comma-separated value.
How this calculator computes each DFT frequency bin
This calculator computes the standard unnormalized DFT directly from the entered samples. For every output bin k, it multiplies each input sample x[n] by a complex rotating reference, then adds those contributions from the first sample through the last. The reference rotates more rapidly for higher bin indices, so a bin becomes large when the samples reinforce that particular rotation.
For the discrete Fourier transform used here, the coefficient at bin k is:
The script evaluates that DFT expression with cosine and sine terms. Its real and imaginary accumulators are equivalent to:
Each result is printed as a+bi, preserving phase as well as magnitude. This implementation returns the raw DFT sum: it does not divide coefficients by N, apply a window, or zero-pad the sequence. Those choices make the displayed values the direct transform of the exact record entered, but they also mean raw coefficient sizes are not automatically comparable between records of different lengths.
Worked DFT example for the sequence 1,0,-1,0
Run the DFT calculator with 1,0,-1,0. This four-sample record has a zero total, so its DC coefficient cancels. Its sign change across the record also produces a nonzero oscillatory component. The page calculates the following raw coefficients:
| Bin | Complex result | Plain-language meaning |
|---|---|---|
| k = 0 | 0.0000+0.0000i | No DC offset; the samples average to zero. |
| k = 1 | 2.0000+0.0000i | A strong once-per-record oscillatory component is present. |
| k = 2 | 0.0000+0.0000i | No two-cycles-per-record component appears in this short sequence. |
| k = 3 | 2.0000+0.0000i | The mirrored high bin repeats the information expected for a real-valued input. |
Bins 1 and 3 both have nonzero values because the entered sequence is real. Real-valued sequences have conjugate-symmetric DFT coefficients: high-index bins mirror their low-index partners. In a longer real-valued record, the upper half of the displayed output generally does not provide independent magnitude information, although the calculator correctly returns every bin from 0 through N â 1.
To obtain the magnitude of a complex DFT coefficient, use:
For this DFT example, bins 1 and 3 each have magnitude 2. Their zero imaginary parts show that these particular components align with the cosine reference under the calculator's indexing convention.
Interpret the complex DFT coefficients in the result panel
After computing a DFT, the result panel lists bins from k = 0 through k = N-1, matching the order of the JavaScript loop. Start by checking the coefficient at k = 0: it is the sum of all entered samples, so a large DC value signals a substantial average offset. Then compare coefficient magnitudes to identify the repeating structures that contribute most strongly to the record. For real input data, the expected mirroring between upper and lower bins is also a useful check.
In this DFT output, the sign of the imaginary part is not a quality judgment about a frequency. It is part of the coefficient's phase information, describing the time alignment between the record and the bin's rotating reference. Two sequences may have equal magnitude spectra yet different complex coefficients because their components are shifted relative to one another. Retaining both real and imaginary values is what allows a transform to preserve enough information for reconstruction.
Since the calculator does not normalize by N, adding more samples can increase raw coefficient values even when the underlying signal amplitude is unchanged. Divide or otherwise scale coefficients outside this page if you need a particular amplitude convention. Likewise, bin positions become hertz only after you provide the sampling rate used to acquire the data; the transform alone has no knowledge of elapsed time between samples.
DFT assumptions, limits, and useful checks
This DFT calculator works on one finite record of evenly spaced real samples. It does not fill missing measurements, remove noise, select a window, or infer the sample interval. If a record captures a waveform over a non-integer number of cycles, its energy can spread into adjacent DFT bins. This spectral leakage is a property of analyzing a finite segment, not evidence that the calculation is malfunctioning.
Frequency resolution in a DFT is tied to record length: an N-sample input produces N bin positions. A longer record provides more closely spaced bins when the sample rate remains fixed. Zero padding can create additional displayed transform samples between the original bin positions, but it does not add measured detail. Windowing can reduce leakage in many uses, while also changing amplitude scaling and spectral shape; neither operation is performed by this page.
Noise affects a DFT spectrum by distributing random variation across bins, whereas a stable periodic component tends to reinforce one or a small number of rotating references. When inspecting measured data, compare nearby coefficients, consider repeated records when available, and inspect phase when timing relationships matter. The calculator organizes the entered record into these components; it does not decide which components are signal.
When learning the DFT, begin with sequences whose behavior can be checked by hand. A constant list concentrates at DC, a simple alternating pattern emphasizes a higher bin, and a short pulse produces broad spectral content. Then progress to measured records. If a result is unexpected, verify the sample order, equal spacing, record length, and whether the signal frequency falls exactly on a DFT bin.
Phasor Lock: a DFT bin alignment mini-game
Phasor Lock turns the DFT's rotating-reference idea into a timing game. A reference phasor circles a ring of sample points, and your goal is to tap as it aligns with cyan signal glows for the target bin. Later rounds introduce reverse rotation, red noise decoys, and narrower timing windows, illustrating why phase alignment reinforces a DFT coefficient while unrelated contributions tend to cancel.
Takeaway: a DFT bin grows when many samples reinforce the same rotating reference. Well-timed hits in the game mimic constructive interference; mistimed hits and noise act more like cancellation.
