APMA 0160 (A. Yew) Spring 2011
Trigonometric approximation and interpolation
Suppose f is a periodic function with period T , i.e. f (x + T ) = f (x) for all x ∈ R.
The Fourier series of f is defined to be
∞ k 2πx
a0 X
k 2πx
+ bk sin
+
ak cos
2
T
T
k=1
where the coefficients a0 , a1 , b1 , a2 , b2 , . . . are given by the definite integrals
Z
2 T /2
k 2πx
ak =
f (x) cos
dx for k = 0, 1, 2, 3, . . .
T −T /2
T
Z
2 T /2
k 2πx
bk =
f (x) sin
dx for k = 1, 2, 3, . . .
T −T /2
T
Z
Z T /2
can be replaced by integration over any interval of length T , e.g.
Owing to the periodicity,
−T /2
T
.
0
If f is a function defined on a finite interval of length T , we can construct its “periodic extension” by
making an infinite number of copies of it along the real line. The extended function will have period
equal to T , the length of the original interval, and we can define its Fourier series as above.
The Fourier convergence theorem says that if f is a function defined on an interval of length T such that
f and f 0 are both piecewise continuous, then the Fourier series of f converges to the periodic extension
of f , except at points of jump discontinuity, where the Fourier series converges to 21 [f (x+) + f (x−)]
(the midway point between the two sides of the jump).
“Convergence” means that the graph of the M th partial sum of the series,
M a0 X
k 2πx
k 2πx
(?)
+
ak cos
+ bk sin
,
2
T
T
k=1
approaches the graph of f (x) more and more closely as M gets larger. So the theorem tells us that the
Fourier series of f provides a very good approximation to the function f (x) as you add on more terms.
In practice, however, the integrals in the formulas for ak and bk can be difficult (and slow) to calculate.
Finite Fourier transform
We would like to find a good approximation to the function f (x) of the form (?) but without having to
2π
calculate integrals. First, let us simplify (?). Write
= ω and use Euler’s formula eiθ = cos θ + i sin θ
T
to get
eikωx = cos(kωx) + i sin(kωx)
e−ikωx = cos(kωx) − i sin(kωx)
eikωx + e−ikωx
2
eikωx − e−ikωx
(eikωx − e−ikωx )
sin(kωx) =
= −i
2i
2
cos(kωx) =
=⇒
So (?) becomes
M a0 X
(eikωx + e−ikωx )
(eikωx − e−ikωx )
+
ak
− bk i
2
2
2
k=1
M
M
k=1
k=1
o
o
Xn
a0 X n 1
ikωx
−ikωx
ikωx
−ikωx
1
=
+
(a
−
ib
)e
+
(a
+
ib
)e
=
c
+
c
e
+
c
e
0
k
k
k
k
k
−k
2
2
2
where c0 = 21 a0 , ck = 12 (ak − ibk ) and c−k = 12 (ak + ibk ) = c∗k .
We can further simplify this representation by writing it as
M
X
(†)
ck eikωx
k=−M
There are 2M + 1 coefficients ck in this formula. In order for (†) to be an approximation of f (x) on
jT
the interval [0, T ], we shall require that it interpolate f at the 2M + 1 “data” points xj =
for
2M + 1
j = 0, 1, 2, 3, . . . , 2M . In other words, we want
M
X
ck eikωxj = f (xj )
for j = 0, 1, . . . , 2M
k=−M
Writing N = 2M + 1 for the number of data points at which we do the interpolation, and recalling that
ω = 2π/T , the above is equivalent to
M
X
ck ei 2πjk/N = f (xj )
for j = 0, 1, . . . , 2M,
k=−M
This linear system for the “c”s can be solved to give
ck =
N −1
1 X
f (xj ) e−i 2πkj/N
N
for k = −M, −M + 1, . . . , −1, 0, 1, . . . , M − 1, M
j=0
P −1
−i 2πkj/N , given an array of f (x ) values of
Matlab’s fft command computes the sums N
j
j=0 f (xj ) e
length N . The actual coefficients ck are obtained by dividing the fft result by N .
It is important to note that fft outputs the coefficients in the order
N × (c0 , c1 , . . . , cM −1 , cM , c−M , c−M +1 , . . . , c−2 , c−1 ).
To get the coefficients in the “natural” order
N × (c−M , c−M +1 , . . . , c−2 , c−1 , c0 , c1 , . . . , cM −1 , cM ),
use the fftshift command.
The method underlying fft, namely the “fast Fourier transform” algorithm, is one of the most famous
algorithms in scientific computing. It works most efficiently when the number of interpolation points
N is even, and is particularly fast when N is a power of 2. Note, however, that (†) has 2M + 1 terms,
and 2M + 1 is always an odd number. So, in practice, fft calculates the coefficients in the sum
M
−1
X
ck eikωx
k=−M
i.e. the last term in (†) is dropped. Now there are 2M coefficients and we use N = 2M points (an even
number) for the interpolation.
The set of coefficients {ck } is called the “Fourier spectrum” of the function f .
For k = 0, 1, 2, . . . , M − 1, the “power” of f in the kth Fourier mode is defined to be
|c0 |2
for k = 0
Pk =
|ck |2 + |c−k |2 for k = 1, . . . , M − 1
The set {Pk } constitutes the “power spectrum” of f .
© Copyright 2026 Paperzz