Search for probability and statistics terms on Statlect
StatLect

Discrete Fourier transform of cosine and sine waves

by , PhD

The Discrete Fourier Transforms (DFTs) of cosine and sine waves have particularly simple analytical expressions.

Table of Contents

The transform

Let x be an $N	imes 1$ vector.

The Discrete Fourier Transform of x is another $N	imes 1$ vector X whose entries satisfy[eq1]where i is the imaginary unit.

We can use the DFT to obtain the frequency-domain representation [eq2]

Properties of trigonometric functions and complex exponentials

To derive the DFT of the sine and cosine functions, we will use the following properties.

For any angle $	heta $, we have[eq3]

Since the period of the trigonometric functions is $2pi $, we have[eq4]for any integer $j$ and any angle $	heta $.

Finally, we have[eq5]

DFT of a cosine wave with integer frequency

Let us start from a cosine wave:[eq6]where $j=0,ldots ,N-1$.

The number $l$ of cycles per $N$ samples (frequency) is assumed to be a positive integer less than $N$.

The cosine wave can be written as[eq7]which implies that its Discrete Fourier Transform is[eq8]

Proof

We can write[eq9]which is a frequency-domain representation of $x_{j+1}$ as a linear combination of periodic basis functions. The two basis functions belong to the set of basis functions used in the DFT. Since the representation of a vector as a linear combination of a basis is unique, the coefficients of the linear combination inside the square brackets must be the values of the discrete Fourier transform. They are all equal to 0, except those corresponding to the frequencies $l$ and $N-l$, which are equal to $N/2$ and $N/2$ respectively.

DFT of a sine wave with integer frequency

Consider the sine wave:[eq10]where $j=0,ldots ,N-1$.

The number $l$ of cycles per $N$ samples is again assumed to be a positive integer less than $N$.

The sine wave can be written as[eq11]which implies that the Discrete Fourier Transform is[eq12]

Proof

We have[eq13]which is a frequency-domain representation of $x_{j+1}$ as a linear combination of DFT basis functions. Therefore, the coefficients of the linear combination inside the square brackets are the values of the DFT (see also the previous proof). They are all equal to 0, except those corresponding to the frequencies $l$ and $N-l$, which are equal to [eq14]and [eq15]respectively.

Linear combinations of sine and cosine waves

Since the DFT is a linear operator, we can use its linearity to easily derive the DFT of linear combinations of sine and cosine waves.

Example Let $l$ and $m$ be positive integers, with $l
eq m$. Let the entries of x be defined by[eq16]Then, the DFT of x is[eq17]

Cosine with phase shift

Let us now analyze the case of a shifted cosine wave:[eq18]where:

The Discrete Fourier Transform is[eq20]

Proof

We can derive the frequency-domain representation of $x_{j+1}$ as follows: [eq21]As in the previous proof, we can easily read the values of the DFT from the frequency-domain representation: all the values of the DFT are equal to 0, except those corresponding to the frequencies $l$ and $N-l$, which are equal to [eq22] and [eq23] respectively.

Sine with phase shift

Similarly, we can analyze a shifted sine wave:[eq24]where:

The Discrete Fourier Transform is[eq26]

Proof

We can derive the frequency-domain representation of $x_{j+1}$ as follows: [eq27]As in the previous proofs, we can read the values of the DFT from the frequency-domain representation: all the values of the DFT are equal to 0, except those corresponding to the frequencies $l$ and $N-l$, which are equal to [eq28] and [eq29] respectively.

Spectral leakage

What happens when[eq6]or[eq24] but the frequency parameter $l$ is not an integer?

In other words, what happens when the sine or cosine waves have frequencies that do not belong to the set of analysis frequencies used to compute the DFT?

What happens is that the neat results presented above (DFT is zero everywhere except at the frequencies $l$ and $N-l$) are no longer valid.

When $l$ is not integer, the DFT can be non-zero everywhere, although it tends to be larger in magnitude around the frequencies $l$ and $N-l$. This phenomenon is known as spectral leakage.

Example of spectral leakage

As an example, we set $N=20$, [eq6]and $l=3.5$.

Then, we compute the DFT X and its amplitude spectrum[eq33]

The amplitude spectrum, displayed in the next plot, clearly shows that although the amplitudes are large around the $l=3.5$ and $N-l$ frequencies, there is leakage to all the other frequencies.

Plot of a real signal and its symmetric amplitude spectrum.

How to cite

Please cite as:

Taboga, Marco (2021). "Discrete Fourier transform of cosine and sine waves", Lectures on matrix algebra. https://www.statlect.com/matrix-algebra/discrete-Fourier-transform-of-cosine-and-sine.

The books

Most of the learning materials found on this website are now available in a traditional textbook format.