Skip to content

Fourier ​

The numeric discrete Fourier transform of a list, or of a rectangular matrix (a separable 2D transform), under Wolfram's default FourierParameters→{0,1}\mathrm{FourierParameters} \to \{0, 1\} — fs=1n∑rlistr e2πi(r−1)(s−1)/nf_s = \frac{1}{\sqrt n}\sum_r \mathrm{list}_r\, e^{2\pi i (r-1)(s-1)/n}.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageFourier✓
Fourier(list)the discrete Fourier transform of a numeric list, or a rectangular numeric matrix.
Fourier(list, FourierParameters -> {a, b})the general two-parameter transform fs=∣b∣/n1−a∑rlistr e2πib(r−1)(s−1)/nf_s = \sqrt{|b|/n^{1-a}}\sum_r \mathrm{list}_r\, e^{2\pi i b (r-1)(s-1)/n}.
Typed signatures
TypePackageApplies
(list<list<number>> | list<number>, expression?) -> list<list<number>> | list<number>analyticalways

Domain: Transforms

Details
  • Always numeric, matching Wolfram exactly — even an all-exact input like Fourier({0, 0, 0}) comes back as machine floats there, never a symbolic or exact result, so this declines (stays unevaluated) rather than fabricate an exact answer for anything that isn't already a concrete numeric list or matrix.
  • A rectangular matrix gets the 2D transform, separable into the 1D transform along each dimension in turn; both dimensions' FourierParameters prefactors are folded into a single multiplication at the end rather than applied one dimension at a time, which avoids the extra rounding two separate Sqrts would otherwise leave in every entry.
  • Direct O(n2)O(n^2) summation, not an FFT — correct for any nn and fast enough at the sizes these heads see in practice; a genuinely large transform would want a radix-2 or Bluestein implementation instead.
  • Declined: a symbolic entry, an empty list, a ragged nested list, a list more than two levels deep, or an FourierParameters option that isn't a 2-element real list.

Examples

Basic #

The DFT of {1,2,3,4}\{1, 2, 3, 4\}

live ↗
InFourier([1,2,3,4])\mathrm{Fourier}(\bigl\lbrack1, 2, 3, 4\bigr\rbrack)Out[5.0,−1.0−i,−1.0,−1.0+i]\bigl\lbrack5.0, -1.0-i, -1.0, -1.0+i\bigr\rbrack

Round-trips exactly through InverseFourier

live ↗
InInverseFourier(Fourier([1,2,3,4]))\mathrm{InverseFourier}(\mathrm{Fourier}(\bigl\lbrack1, 2, 3, 4\bigr\rbrack))Out[1.0,2.0,3.0,4.0]\bigl\lbrack1.0, 2.0, 3.0, 4.0\bigr\rbrack
Scope #

A 2×22\times2 matrix — the separable 2D transform

live ↗
InFourier([[1,2],[3,4]])\mathrm{Fourier}(\bigl\lbrack\bigl\lbrack1, 2\bigr\rbrack, \bigl\lbrack3, 4\bigr\rbrack\bigr\rbrack)Out[[5.0,−1.0],[−2.0,0.0]]\bigl\lbrack\bigl\lbrack5.0, -1.0\bigr\rbrack, \bigl\lbrack-2.0, 0.0\bigr\rbrack\bigr\rbrack

A custom FourierParameters -> {1, -1}

live ↗
InFourier([1,2,3,4],KeyValuePair⁡(FourierParameters,[1,−1]))\mathrm{Fourier}(\bigl\lbrack1, 2, 3, 4\bigr\rbrack, \operatorname{KeyValuePair}(\mathrm{FourierParameters}, \bigl\lbrack1, -1\bigr\rbrack))Out[10.0,−2.0+2.0i,−2.0,−2.0−2.0i]\bigl\lbrack10.0, -2.0+2.0i, -2.0, -2.0-2.0i\bigr\rbrack

A numeric symbol is treated symbolically and the transform stays unevaluated

live ↗
InFourier(N(x,24))\mathrm{Fourier}(N(x, 24))OutFourier(x)\mathrm{Fourier}({{x}})
Possible issues #

Declines a symbolic list, as Wolfram's Fourier::fftl does

live ↗
InFourier([a,b])\mathrm{Fourier}(\bigl\lbrack a, b\bigr\rbrack)OutFourier([a,b])\mathrm{Fourier}(\bigl\lbrack a, b\bigr\rbrack)
About
Examples6
Checked againstWolfram Language 6 agree
CrosswalkWolfram Language

Implementation

primitive · kernela kernel — an algorithm over mutable state that would not be readable as a tree

nativeenginetypescriptpackages/symbols/analysis/analytic/src/fourier-transform.ts

See also: InverseFourier, FourierSeries, FourierTransform