Fourier 401
Fourier 401
1 Introduction
We consider vectors in CN . We will define an orthogonal basis e(0) , . . . , e(N−1) which is important in many applications.
>
A vector f = [ f0 , . . . , fN−1 ]> can be written as f = fˆ0 e(0) + · · · + fˆN−1 with a coefficient vector fˆ = fˆ0 , . . . , fˆN−1 .
f , e(k)
fˆk = (k) (k)
e ,e
with coefficients ak , bk ∈ C.
Since
Note that eit is on the unit circle in the complex plane. Let ω := e2πi/N . The equation zN = 1 has the N solutions
ω 0 , ω 1 , . . . , ω N−1
We consider a step size 1/N and the discrete points t j = j/N for j ∈ Z. A signal is given by values f j at the points t j , j ∈ Z.
As the signal is periodic we have
f j+N = f j for j ∈ Z.
Hence we only need to specify the values
f = [ f0 , . . . , fN−1 ]> ∈ CN .
Let k ∈ Z be an integer. We now want to use the values of the trigonometric function e2πikt at the points t j : This function has
the values given by the vector
h i>
e(k) := e2πik·0/N , . . . , e2πik· j/N
This means that the vectors e(k) for all k ∈ Z are actually only N different vectors which keep repeating: Consider e.g. N = 5
(−2) (−1) (0) (1) (2) (3) (4)
. . . , e|{z} e(5) , |{z}
, e|{z}, e , e , e , e , e , |{z} e(6) , . . .
e(3) e(4) e(0) e(1)
In order to represent the vector f = [ f0 , . . . , f4 ]> ∈ C5 we need a basis of 5 vectors. We pick the vectors e(0) , e(1) , e(2) , e(3) , e(4) .
We could also have picked the vectors e(−2) , e(−1) , e(0) , e(1) , e(2) , but these are exactly the same vectors, just in a different
order.
We also define the corresponding vectors c(k) and s(k) for cos(k2πt) and sin(k2πt):
For N = 5 the vectors e(0) , e(1) , e(2) , e(3) , e(4) can also be written as e(0) , e(1) , e(2) , e(−2) , e(−1) because of aliasing. Hence
n o n o
C5 = span e(0) , e(1) , e(2) , e(3) , e(4) = span c(0) , c(1) , c(2) , s(1) , s(2)
We claim that the vectors e(0) , . . . , e(N−1) form an orthogonal basis of CN : We have
N−1 N−1
e(k) , e(l) = ∑ e2πik j/N e−2πil j/N = ∑ a j a := e2πi(k−l)/N
j=0 j=0
For k = l we have a = 1 and hence
e(k) , e(k) = N. (2)
A vector f = [ f0 , . . . , fN−1 ]> ∈ CN can be written as a linear combination of e(0) , . . . , e(N−1) . Using the orthogonality we
obtain for the coefficients fˆk
f , e(k)
N−1
1 N−1
f = ∑ fˆk e (k)
fˆk = (k) (k) = ∑ f j e−2πik j/N (3)
k=0 e ,e N j=0
Given a vector f ∈ CN in the “time domain” we obtain a vector fˆ ∈ CN in the “frequency domain”. This operation is called
the discrete Fourier transform FN , its inverse is called FN−1 :
fˆ = FN f , f = FN−1 fˆ
We claim that the vectors c(0) , c(1) , . . . , c(M) , s(1) , . . . , s(M) also form an orthogonal basis. Using (1) it is easy to see that
these vectors are orthogonal on each other and
N
c(0) , c(0) = N, c(k) , c(k) = s(k) , s(k) = for k = 1, 2, 3, . . .
2
in the frequency domain. The inverse discrete Fourier transform FN−1 maps the vector fˆ back to the vector ~f :
fˆ = FN f , f = FN−1 fˆ
As an example consider the vector f = [1, 1, 1, 1]> in the time domain. Since this corresponds to the function v(t) = 1 the
Fourier vector is fˆ = [1, 0, 0, 0]:
Matlab has the built-in functions fft and ifft for the discrete Fourier transform and its inverse. But they have the factors
N, N −1 reversed, compared with our definitions. Therefore we define
four = @(f)fft(f)/length(f);
ifour = @(f) ifft(f)*length(f);
Case of odd N
>
Assume we have for N = 5 a vector f = [ f0 , . . . , f4 ]> and we compute the discrete Fourier transform fˆ = fˆ0 , fˆ1 , fˆ2 , fˆ3 , fˆ4 .
f = fˆ0 e(0) + fˆ1 e(1) + fˆ2 e(2) + fˆ3 e(3) + fˆ4 e(4)
z}|{ z}|{
(0) (1) (2) (−2)
ˆ ˆ ˆ
= f0 e + f1 e + f2 e + f3 e ˆ + f4 e(−1)
ˆ
= a0 c(0) + a1 c(1) + a2 c(2) + b1 s(1) + b2 s(2)
using aliasing.
For [a0 , a1 , a2 , b1 , b2 ]> ∈ R5 we obviously have that f = a0 c(0) + a1 c(1) + a2 c(2) + b1 s(1) + b2 s(2) ∈ R5 . Since
c(0) , c(1) , c(2) , s(1) , s(2) are linearly independent vectors in R5 a vector f ∈ R5 corresponds to a unique vector
[a0 , a1 , a2 , b1 , b2 ]> ∈ R5 .
For a real vector f ∈ R5 the coefficients fˆ0 , . . . , fˆ4 will be complex in general, but the coefficients a0 , a1 , a2 , b1 , b2 will be
real.
Therefore the function
v(t) = fˆ0 + fˆ1 e2πit + fˆ2 e4πit + fˆ3 e−4πit + fˆ4 e−2πit
= a0 · 1 + a1 cos(2πt) + a2 cos(4πt) + b1 sin(2πt) + b2 sin(4πt)
is a 1-periodic trigonometric function with frequency ≤ 2 which satisfies v(t j ) = f j . This is called an interpolating function.
>
For any odd N = 2M + 1 the Fourier vector fˆ0 , fˆ1 , . . . , fˆN−1 yields the interpolating function v(t) given by
v(t) = fˆ0 + fˆ1 e2πit + · · · + fˆn eM2πit + fˆN−M e(−M)2πit + · · · + fˆN−1 u(−1)2πit (4)
= a0 · 1 + a1 cos(2πt) + · · · + aM cos(M2πt) + b1 sin(2πt) + · · · + b2 sin(4πt) (5)
Here fˆ0 corresponds to frequency 0, it gives the mean value of our data. Then fˆ1 and fˆN−1 together tell us about frequency
1. The highest frequency terms fˆM , fˆM+1 for frequency M are in the middle of the vector.
Case of even N
>
Consider for N = 6 a discrete signal a vector ~f = [ f0 , . . . , f5 ] with the discrete Fourier transform fˆ = fˆ0 , fˆ1 , fˆ2 , fˆ3 , fˆ4 , fˆ5 .
f = fˆ0 e(0) + fˆ1 e(1) + fˆ2 e(2) + fˆ3 e(3) + fˆ4 e(4) + fˆ5 e(5)
= fˆ0 e(0) + fˆ1 e(1) + fˆ2 e(2) + fˆ3 21 e(3) + e(−3) + fˆ4 e(−2) + fˆ5 e(−1)
= a0 c(0) + a1 c(1) + a2 c(2) + a3 c(3) + b1 s(1) + b2 s(2)
v(t) = fˆ0 + fˆ1 e2πit + fˆ2 e4πit + fˆ3 12 e6πit + e−6πit + fˆ4 e−4πit + fˆ5 e−2πit
which satisfies v(t j ) = f j . Note that for the highest frequency 3 we only use cos(6πt) and NOT sin(6πt). This makes
sense since sin(6πt) is zero at the points t j :
j
sin(3 · 2πt j ) = sin(3 · 2π ) = sin( jπ) = 0
6
For general even N = 2M the Fourier vector ( fˆ0 , fˆ1 , . . . , fˆN−1 ) yields the interpolating function
v(t) = fˆ0 + fˆ1 e2πit + · · · + fˆM−1 e(M−1)2πit + fˆM 21 eM2πit + e−M2πit + fˆM+1 e−(M−1)2πit + · · · + fˆN−1 e−2πit
1 N−1 N−1
fˆk = ∑ f j e−2πik j/N ⇔ fj = ∑ fˆk e2πik j/N Inversion
N j=0 k=0
1 N−1 2 N−1 2
∑ fj
N j=0
= ∑ fˆk Parseval (6)
k=0
1 N−1
qj = ∑ f` g j−` ⇔ q̂k = fˆk ĝk Convolution
N `=0
Recall that (
N for k = l
e(k) , e(`) =
0 for k 6= l
This gave us the formula for fˆk in (3), and we obtain from f = fˆ0 e(0) + · · · + fˆN−1 e(N−1)
N−1 2 (k) (k)
(f, f) = ∑ fˆk e ,e
k=0 | {z }
N
yielding the Parseval formula. In the same way we obtain
1 N−1 N−1
∑ j j ∑ fˆk ĝk
N j=0
f g =
k=0
For the convolution we plug in the Fourier representation of g j−` and switch the order of the sums:
Hence we have q j = ∑N−1 2πik j/N with q̂ = fˆ ĝ . Remember that the signals are periodic (wrap-around): g = g
k=0 q̂k e k k k j j+N . So
g j−` with j − ` < 0 has to be interpreted in this way.
1.7 Efficient computation of FN and FN−1 : Fast Fourier Transform
>
Assume we are given the vector fˆ = fˆ0 , . . . , fˆN−1 ∈ CN in the frequency domain. We want to find the vector f = FN−1 f =
N−1
fj = ∑ fˆk e2πik j/N
k=0
1 1 1 ··· 1
1 ω1 ω2 ··· ω N−1
f = EN fˆ, EN =
1 ω2 ω4 ··· ω 2(N−1)
with ω := e2πi/N
.. .. .. ..
. . . .
1 ω N−1 ω 2(N−1) · · · ω (N−1)(N−1)
If we naively evaluate the formula f = EN fˆ we have to compute N multiplications and N − 1 additions for each component,
in addition to computing ω, ω 2 , . . . , ω N−1 . This means that the computation of f costs at least N 2 multiplications (plus
a similar number of additions etc.). For a vector of length N = 1000 this means that we have at least 106 operations. This
means that it is not practical to compute discrete Fourier transforms of long vectors.
Fortunately there is a way to reorganize the computation in such a way that only N · log2 N operations are required. E.g., for
N = 1024 we have
N 2 ≈ 106 , N · log2 N = 1024 · 10 ≈ 104
Assume that N is even. Then we can split up the sum in even and odd terms: Using wN/2 = w2N we obtain
N−1 N/2−1 N/2−1 N/2−1 N/2−1
j(2k) j(2k+1)
fj = ∑ wNjk fˆk = ∑ wN fˆ2k + ∑ wN fˆ2k+1 = ∑ jk ˆ
wN/2 f2k + wNj ∑ jk ˆ
wN/2 f2k+1
k=0 k=0 k=0 k=0 k=0
| {z } | {z }
aj bj
N/2−1 jk ˆ −1 ˆe
>
f2k for j = 0, . . . , N2 − 1: This is FN/2 f where fˆe := fˆ0 , fˆ2 , . . . , fˆN−2 ∈ CN/2 is the vector
Consider a j := ∑k=0 wN/2
N N jk N/2
of even Fourier coefficients. For j = 2 ,...,N − 1 we can write j = 2 + J and have wN/2 = wJK
N/2 since wN/2 = 1. Hence
a N +J = aJ , i.e.,
2
a0
ye
.. −1 e
with ye := FN/2
= ŷ
. ye
aN−1
N/2−1 >
wNj jk ˆ −1 ˆo
f2k+1 for j = 0, . . . , N2 − 1: Consider FN/2 f where fˆo := fˆ1 , fˆ3 , . . . , fˆN−1 ∈ CN/2 is the
Consider b j := ∑ wN/2
k=0
| {z }
cj
jk N/2
vector of odd Fourier coefficients. For j = N2 , . . . , N − 1 we can write j = N
2 + J and obtain with wN/2 = wJK
N/2 and wN = −1
that b N +J = −bJ , i.e.,
2
1
b0
yo
wN
.. −1 o
= with yo := FN/2 ŷ
. −yo ..
.
bN−1 N/2−1
wN
Let cN denote the number of operations needed to compute the vector FN−1 fˆ. We need to compute 2 transforms of length
1/2 N/2−1 N
N/2, wN := e2πi/N = wN/2 , N2 − 2 multiplications to get 1, wN , . . . , wN , 2 multiplications to get yo , and N additions to
e o
compute y ± y . Let 1 operation denote [1 addition/subtraction, 1 multiplication/division/square root and memory access
for reading writing], then
cN = 2cN/2 + N
This algorithm is implemented in the Matlab functions fft and ifft and therefore used in our functions four and ifour .
2 Applications
Assume we are given a signal u ∈ CN , and we want to find the best least square fit using frequencies 0, 1, . . . , K
n o n o
VK = span e(−K) , e(−K+1) , . . . , e(K) = span c(0) , c(1) , s(1) , . . . , c(K) , s(K)
where dimVK = 2K + 1 ≤ N. Applying the DFT gives û := FN u, and because of the orthogonality of e(k) we get the least
squares fit w ∈ VK given by
w := û0 e(0) + û1 e(1) + · · · + ûK e(K) + ûN−K e(−K) + · · · + ûN−1 e(−1)
v(t) = û0 + û1 e2πit + · · · + ûK eK2πit + ûN−K e−K2πit + · · · + ûN−1 e−2πit
2.2 Any linear translation invariant operator becomes diagonal in frequency space
Consider the “translation operator” T which maps [u0 , . . . , uN−1 ]> to [uN , u0 , . . . , uN−1 ]> , this corresponds to the matrix
1
1
T =
..
.
1
A linear mapping A ∈ CN×N is called translation invariant if it satisfies AT v = TAv for all v ∈ CN , i.e.,
AT = TA
Note that
Te(k) = e2πik/N e(k) = ω k e(k) , ω := e2πi/N
I.e., the matrix T has the eigenvalues ω 0 , ω 1 , . . . , ω N−1 (these are the N different roots of 1), and corresponding eigenvectors
e(0) , . . . , e(N−1) .
Conversely, if we have Av = ω k v we must have v = ck e(k) with some ck ∈ C.
Let v := Ae(k) . Then
T v = TAe(k) = ATe(k) = Ae(k) ω k = ω k v
hence there is ck ∈ C with v = ck e(k) . Hence we have shown
Ae(k) = ck e(k)
fˆ0
ĝ0 c0
.. .. ..
ĝk = ck fˆk , . . . , ĝN−1 = cN−1 fˆN−1 , i.e., . = . .
ĝN−1 cN−1 fˆN−1
In general computing v = Au in the time domain takes N 2 operations, and computing u = A−1 v in the time domain using
Gaussian elimination takes 13 N 3 operations. Since the cost of the DFT is only N log N, it is much more efficient to perform
these operations in the frequency domain.
1 N−1
vj = ∑ u` g j−`
N `=0
(note that g j is considered a periodic signal with g j−N = g j here). We can interpret this as applying a “filter” to the signal u.
This filter given by g j can e.g. be a smoothing filter. By using the DFT we can compute the filtered signal v using O(N log N)
operations.
Moreover, we can get back from the filtered signal v to the original signal u using O(N log N) operations if ĝk 6= 0 for all k.
This is called “deconvolution”.
2.4 Approximating the solution of a differential equations (periodic setting)
fˆ0 = 0 · û0 = 0
This means that in order to obtain a solution the vector f = [ f0 , . . . , fN−1 ]> must have sum zero.
If this condition is satisfied, we obtain the solution û = [û0 , . . . , ûN−1 ]> given by
û0 = arbitrary, ûk = fˆk /Ck for k = 1, . . . , N − 1
This means that we can add c · [1, . . . , 1]> with arbitrary c ∈ R to the solution vector.
Therefore the matrix A has the null space span {[1, . . . , 1]}, and we have (range A)> = span {[1, . . . , 1]}.
Note that for β = 0 we have the differential equation −U 00 (t) = f (t), and it is clear that for any solution U(t) also U(t) + c
is a solution.