4
Fourier Transforms: Discrete and Continuous Jake VanderPlas [email protected] September 4, 2014 1. Continuous Fourier Transforms For an n-dimensional function g(~x), we can define the Fourier Transform 1 ˆ g( ~ k)= Z d n xg(~x)e -i~x· ~ k (1) The corresponding inverse Fourier Transform is g(~x)= Z d n k (2π) n ˆ g( ~ k)e i ~ k·~x . (2) From these, we can see that the n-dimensional Dirac delta function can be written δ n D (~x - ~x 0 )= 1 (2π) n Z d n ke -i ~ k·(~x-~x 0 ) (3) such that Z d n xf (~x)δ n D (~x - ~x 0 )= f (~x 0 ) (4) Note that the fourier transform convention in eqns ??-?? is useful in that it leads to a particularly simple form of the convolution theorem, without any gratuitous factors of 2π: h(~x)= Z d n x 0 f (~x 0 )g(~x - ~x 0 ) ⇐⇒ ˆ h( ~ k)= ˆ f ( ~ kg( ~ k) (5) 2. Discrete Fourier Transform For computational purposes, it is more useful to consider the discrete fourier transform. It is helpful to define some notation to make the following expressions more compact. First 1 for mathematica users, this fourier transform convention corresponds to the option FourierParameters->{1,1}.

Fourier

Embed Size (px)

Citation preview

Fourier Transforms: Discrete and Continuous

Jake VanderPlas

[email protected]

September 4, 2014

1. Continuous Fourier Transforms

For an n-dimensional function g(~x), we can define the Fourier Transform1

g(~k) =

∫dnxg(~x)e−i~x·

~k (1)

The corresponding inverse Fourier Transform is

g(~x) =

∫dnk

(2π)ng(~k)ei

~k·~x. (2)

From these, we can see that the n-dimensional Dirac delta function can be written

δnD(~x− ~x′) =1

(2π)n

∫dnke−i

~k·(~x−~x′) (3)

such that ∫dnxf(~x)δnD(~x− ~x′) = f(~x′) (4)

Note that the fourier transform convention in eqns ??-?? is useful in that it leads to a

particularly simple form of the convolution theorem, without any gratuitous factors of√

2π:

h(~x) =

∫dnx′f(~x′)g(~x− ~x′) ⇐⇒ h(~k) = f(~k)g(~k) (5)

2. Discrete Fourier Transform

For computational purposes, it is more useful to consider the discrete fourier transform.

It is helpful to define some notation to make the following expressions more compact. First

1for mathematica users, this fourier transform convention corresponds to the option

FourierParameters->{1,1}.

– 2 –

let an element of the n-dimensional array Gj1,j2···jn be written Gj, where j is understood to

be an n dimensional vector of integers, with 0 ≤ ji < Ni. We’ll also define the multiple sum

∑j

≡N1−1∑j1=0

N2−1∑j2=0

· · ·Nn−1∑jn=0

(6)

Using this notation, we can write the n-dimensional discrete fourier transform as

Gk =∑j

Gje(−2πi/N)j·k, 0 ≤ km < Nm (7)

The corresponding inverse discrete fourier transform is given by

Gj =

[∏m

1

(Nm)n

]∑k

Gke(2πi/N)j·k, 0 ≤ j` < N` (8)

From this, we see that the Kronecker delta function can be written

δnjj′ =

[∏m

1

(Nm)n

]∑k

e(2πi/N)k·(j−j′) (9)

such that

Gj =∑j′

δnjj′Gj′ (10)

The expressions in equations ?? and ?? can be quickly computed using the Fast Fourier

Transform algorithm.

3. The Relationship Between Discrete and Continuous Fourier Transforms

Often it is desirable to approximate a continuous fourier transform given a discrete

sampling of the function. Here we will work in one dimension, though the generalization to

multiple dimensions is straightforward.

Consider a continuous function g(x), which is sampled at N equal intervals Gj = g(xj)

with xj ≡ x0 + j∆x, 0 ≤ j < N . Assuming that g(x) ≈ 0 outside the range x0 ≤ x ≤(x0 +N∆x), we can approximate the integral in equation ?? as

g(t) =

∫dxg(x)e−ixt

≈ ∆xN−1∑j=0

g(xj)e−ixt

– 3 –

≈ ∆xN−1∑j=0

g(xj)e−it(x0+j∆x) (11)

We would like to sample the fourier transform g(t) at N equally spaced intervals in t. To

this end, let tk = t0 + k∆t such that,

g(tk) ≈ ∆xN−1∑j=0

g(xj)e−i(t0+k∆t)(x0+j∆x) (12)

Now to make this look like equation ??, we let ∆t = 2π/(N∆x) and rearrange to find

1

∆xg(tk)e

i(tk−t0)x0 ≈N−1∑j=0

g(xj)e−it0xje−2πijk/N (13)

We see that this matches equation ?? with

Gj ≡ g(xj)e−it0xj

Gk ≡e−ix0t0

∆xg(tk)e

ix0tk (14)

Thus the continuous fourier transform can be approximated using a discrete sampling and

an FFT, by using the appropriate exponential weighting of the sampled functions. The

extension of this to multiple dimensions follows by applying the correct transformation along

each dimension.

Note that when using the FFT and IFFT routines in, e.g. fftpack, the choice of t0 is

not necessarily free (though by exploiting the periodic boundary conditions implicit in an

FFT, any range in t can be calculated). The fiducial t range is symmetric about t = 0, so

that t0 = (−N/2)∆t = −π/∆x.

4. A More Correct Form

In many cases, the discrete sampling of the previous section is not simply the value of

g(x) at each point xj, but an average over a range xj − ∆x/2 < x < xj + ∆x/2. To be

correct in this situation, we need to recognize that our sampled values at position xj are an

estimator of a different quantity, namely

gW (xj) =

∫dxg(x)Wj(xj − x) (15)

– 4 –

with

Wj(x) =

{1/∆x, |x− xj| < ∆x/2

0, otherwise(16)

By the convolution theorem, we can write

g(t) = gW (t)/Wj(t) (17)

Where the fourier transform of the window function is given by

Wj(t) =sin(t∆x/2)

t∆x/2(18)

Thus we can compute g(t) correctly by applying the FFT approach from the previous section

to compute gW (t) from the sampled values, then dividing by the Fourier transorm of the

pixel window in equation ??.

At first glance, it seems that there might be a problem, because 1/Wj(t) diverges for

t∆x = 2πn, with n a non-zero integer. It turns out that the limits of the fft save us here:

we showed above that tk = (k −N/2)∆t = π(2k/N − 1)/∆x, with 0 ≤ k < N , so that that

we are limited to the domain −π ≤ t∆x < π, which lies safely within the finite range. The

result does not change the smaller wave numbers, but weights the larger wave-numbers by

an increasing factor of up to ∼ 1.5.