Processing math: 100%

Numerical Methods

Outline

Introduction

Linear
Equations

Interpolation

Numerical
Solutions

Computer
Measurement

      

Discrete Fourier Transform

Fourier analysis is a form of interpolation that uses periodic functions to interpolate between discrete data points. Consider a set of n data points (xj,yj) where the points are equally spaced in x: xj=jΔx. We seek an interpolation periodic function I(x) with a period nΔx that passes through all of the points. This function can be expressed as a Fourier series which can either be written in terms of sines and cosines,

I(x)=k=0[akcos(2πkxnΔx)+bksin(2πkxnΔx)],

or in terms of complex exponentials,

I(x)=k=Ykexp(i2πkxnΔx).

The equivalence of these two expressions can be shown using Euler's formula: eix=cosx+isinx. The coefficients can be complex and are related by,

ak=Yk+Ykandbk=YkYk.

If I(x) is a real function, then ak and bk are real and Yk=Yk so that ak=2Re(Yk) and bk=2Im(Yk).

Although it is possible to construct many periodic functions that go through all the data points yn with wavelengths smaller than Δx, it makes sense to restrict the sum over k to the fewest necessary to go through all the points. There are two common choices: k can be restricted to the range k=0,1,2,,n1 or k=n/2,,2,1,0,1,2,,n/2. The first choice appears more often in the literature but the second choice produces the smoothest interpolation function I(x). To keep the discussion general, we restrict the sum over k to the range k=q,q+1,q+2,,q+n1 and the starting value q can be specified later.

The points (xj,yj) are substituted into expression for the Fourier series,

yj=q+n1k=qYkexp(i2πkxjnΔx)=q+n1k=qYkei2πkj/n.

To determine the Fourier coefficients Yk, multiply by ei2πkj/n and sum over j.

n1j=0yjei2πkj/n=n1j=0q+n1k=qYkei2π(kk)j/n.

In the double sum on the right side, consider a specific value of k and sum over j. This sum is zero unless k=k so the double sum evaluates to nYk. This yields an expression for the Fourier coefficients,

Yk=1nn1j=0yjei2πkj/n.

Equation (6) is called the Discrete Fourier Transform (DFT) of the data series yj and Eq. (4) is known as the inverse discrete Fourier transform.

The form below accepts a sequence of complex numbers yj and calculates the discrete Fourier transform. It is also possible to input the values of Yk on the right and calculate the inverse discrete Fourier transform. The smoothest fit is obtained for q=Int(n/2+1) where Int(x) rounds down to the nearest integer. The q button calculates this value.

Real space

Reciprocal space

yj
-2.5
0.0
2.5
5.0
7.5
10.0
-1.0
0.0
1.0
2.0
3.0
Re[f(x)]
Im[f(x)]
Yk
0
1
2
3
4
5
6
-1.0
-0.5
0.0
0.5
1.0
1.5
Re[Fq]
Im[Fq]

j

k

   q=    

Re[yj]  Im[yj]

Re[Yk]  Im[Yk]

Below is the code that calculates a discrete Fourier transform.

If the data points yj are real, then real coefficients ak and bk can be found for the Fourier series in terms of sines and cosines, Eq. (1).