Discrete Fourier Transforms

A common operation in analyzing various kinds of data is to find the discrete Fourier transform (or spectrum) of a list of values. The idea is typically to pick out components of the data with particular frequencies or ranges of frequencies.

Fourier[{u1,u2,,un}]discrete Fourier transform
InverseFourier[{v1,v2,,vn}]inverse discrete Fourier transform

Discrete Fourier transforms.

Here is some data, corresponding to a square pulse:
Click for copyable input
Here is the discrete Fourier transform of the data. It involves complex numbers:
Click for copyable input
Here is the inverse discrete Fourier transform:
Click for copyable input
Fourier works whether or not your list of data has a length which is a power of two:
Click for copyable input
This generates a list of 200 elements containing a periodic signal with random noise added:
Click for copyable input
The data looks fairly random if you plot it directly:
Click for copyable input
The discrete Fourier transform, however, shows a strong peak at , and a symmetric peak at , reflecting the frequency component of the original signal near :
Click for copyable input

In the Wolfram Language, the discrete Fourier transform of a list of length is by default defined to be . Notice that the zero frequency term appears at position 1 in the resulting list.

The inverse discrete Fourier transform of a list of length is by default defined to be .

In different scientific and technical fields different conventions are often used for defining discrete Fourier transforms. The option FourierParameters allows you to choose any of these conventions you want.

common convention
discrete Fourier transform
inverse discrete Fourier transform
Wolfram Language default{0,1}
data analysis{-1,1}
signal processing{1,-1}
general case{a,b}

Typical settings for FourierParameters with various conventions.

twodimensional discrete Fourier transform

Twodimensional discrete Fourier transform.

The Wolfram Language can find discrete Fourier transforms for data in any number of dimensions. In dimensions, the data is specified by a list nested levels deep. Twodimensional discrete Fourier transforms are often used in image processing.

One issue with the usual discrete Fourier transform for real data is that the result is complex-valued. There are variants of real discrete Fourier transforms that have real results. The Wolfram Language has commands for computing the discrete cosine transform and the discrete sine transform.

FourierDCT[list]Fourier discrete cosine transform of a list of real numbers
FourierDST[list]Fourier discrete sine transform of a list of real numbers

Discrete real Fourier transforms.

Here is some data corresponding to a square pulse:
Click for copyable input
Here is the Fourier discrete cosine transform of the data:
Click for copyable input
Here is the Fourier discrete sine transform of the data:
Click for copyable input

There are four types each of Fourier discrete sine and cosine transforms typically in use, denoted by number or sometimes roman numeral as in "DCTII" for the discrete cosine transform of type 2.

FourierDCT[list,m]Fourier discrete cosine transform of type m
FourierDST[list,m]Fourier discrete sine transform of type m

Discrete real Fourier transforms of different types.

The default is type 2 for both FourierDCT and FourierDST.

The Wolfram Language does not need InverseFourierDCT or InverseFourierDST functions because FourierDCT and FourierDST are their own inverses when used with the appropriate type. The inverse transforms for types 1, 2, 3, 4 are types 1, 3, 2, 4, respectively.

Check that the type 3 transform is the inverse of the type 2 transform:
Click for copyable input

The discrete real transforms are convenient to use for data or image compression.

Here is data that might be like a front or an edge:
Click for copyable input
The discrete cosine transform has most of the information in the first few modes:
Click for copyable input
Reconstruct the front from only the first 20 modes (1/10 of the original data size). The oscillations are a consequence of the truncation and are known to show up in image processing applications as well:
Click for copyable input