# 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.
 In[1]:=
 Out[1]=
Here is the discrete Fourier transform of the data. It involves complex numbers.
 In[2]:=
 Out[2]=
Here is the inverse discrete Fourier transform.
 In[3]:=
 Out[3]=
Fourier works whether or not your list of data has a length which is a power of two.
 In[4]:=
 Out[4]=
This generates a list of 200 elements containing a periodic signal with random noise added.
 In[5]:=
The data looks fairly random if you plot it directly.
 In[6]:=
 Out[6]=
The discrete Fourier transform, however, shows a strong peak at , and a symmetric peak at , reflecting the frequency component of the original signal near .
 In[7]:=
 Out[7]=

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 setting 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.

 Fourier[{{u11,u12,…},{u21,u22,…},…}] two‐dimensional 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.
 In[8]:=
 Out[8]=
Here is the Fourier discrete cosine transform of the data.
 In[9]:=
 Out[9]=
Here is the Fourier discrete sine transform of the data.
 In[10]:=
 Out[10]=

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.
 In[11]:=
 Out[11]=

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.
 In[12]:=
 Out[12]=
The discrete cosine transform has most of the information in the first few modes.
 In[13]:=
 Out[13]=
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.
 In[14]:=
 Out[14]=