Discrete Fourier transform
DefinitionFastFourierTransform_dftThe discrete Fourier transform (DFT) of length . A signal is a function , and its transform of length at frequency index is
Only the samples enter the sum, and the frequency index ranges over all natural numbers (the transform is -periodic in ). For the sum is empty, so the value is . This is the unnormalized convention with the minus sign in the exponent; the factor is carried by the inverse transform.
import Mathlib
namespace FastFourierTransform
/-- The discrete Fourier transform (DFT) of length `n`:
`dft n x k = ∑_{m < n} x m * exp (-2 π i m k / n)`. -/
noncomputable def dft (n : ℕ) (x : ℕ → ℂ) (k : ℕ) : ℂ :=
∑ m ∈ Finset.range n,
x m * Complex.exp (-(2 * (Real.pi : ℂ) * Complex.I * (m : ℂ) * (k : ℂ) / (n : ℂ)))
end FastFourierTransform
Read-back
What the Lean code literally says, in plain math · Aristotle (Harmonic)
Provenance note (please read first). This read-back is not blind and is not independent testimony. It was written by the same agent that drafted the Lean statement it describes, with full knowledge of the intended meaning, of the source material, and of the mission's pitch. It therefore cannot serve the purpose an independent auditor's read-back serves — catching a gap between what the author meant and what the code says — and no reviewer should treat it as independent corroboration.
This declaration introduces a function of three arguments: a natural number , a function from the natural numbers to the complex numbers, and a natural number . Its value is the complex number
where the sum runs over the natural numbers , where is the imaginary unit, where is the real constant pi regarded as a complex number, and where , and are the natural numbers , , regarded as complex numbers. The exponent is formed as the negation of the quotient .
Points worth making explicit. The argument is a total function defined at every natural number, but only the values occur in the sum: two inputs agreeing on have the same transform of length . The frequency index is an arbitrary natural number and is not restricted to . For the index set is empty, so the value is for every and every ; in that case the division by is division by zero, which in this setting yields zero and is in any case irrelevant because the sum is empty. For no factor appears in front of the sum: this is the unnormalized transform with the minus sign in the exponent.