FourierSeries - Iowa State...

8

Click here to load reader

Transcript of FourierSeries - Iowa State...

Page 1: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

Fourier Series

(Com S 477/577 Notes)

Yan-Bin Jia

Nov 29, 2016

1 Introduction

Many functions in nature are periodic, that is,

f(x+ τ) = f(x),

for some fixed τ , which is called the period of f . Though function approximation using orthogonalpolynomials is very convenient, there is only one kind of periodic polynomial, that is, a constant.So, polynomials are not good for approximating periodic functions. In this case, trigonometricfunctions are quite useful.

A large class of important computational problems falls under the category of “Fourier transformmethods” or “spectral methods”. For some of these problems, the Fourier transform is simply anefficient computational tool for data manipulation. For other problems, the Fourier transform isitself of intrinsic interest.

Fourier methods have revolutionized fields of science and engineering, from radio astronomyto medical imaging, from seismology to spectroscopy. The wide application of Fourier methods iscredited principally to the existence of the fast Fourier transform (FFT). The most direct applica-tions of the FFT are to the convolution or deconvolution of data, correlation and autocorrelation,optimal filtering, power spectrum estimation, and the computational of Fourier integrals.

A physical process can be described either in the time domain, by the values of some quantityh as a function of time t, or else in the frequency domain, where the process is specified by givingits amplitude H as a function of frequency ξ with −∞ < ξ < ∞. For many purposes it is usefulto think of h(t) and H(ξ) as being two different representations of the same function. These tworepresentations are related to each other by the Fourier transform equations,

H(ξ) =

∫ ∞

−∞h(t)e2πiξt dt,

h(t) =

∫ ∞

−∞H(ξ)e−2πiξt dξ, i2 = 1.

2 Fourier Series

A trigonometric polynomial of order n is any function of the form

p(x) =a02

+

n∑

j=1

(aj cos jx+ bj sin jx), (1)

1

Page 2: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

where a0, . . . , an and b1, . . . , bn are real or complex numbers. Such a trigonometric polynomial hasperiod 2π.

When approximating a function f(x) with period τ 6= 2π, we have to make some adjustmentby considering instead the function

g(x) = f(

τx/(2π))

,

which has period 2π. Having constructed a trigonometric polynomial approximation p(x) to g(x),we obtain a τ -periodic polynomial approximation p(2πx/τ) to f(x). For this reason we will fromnow on assume that the function f(x) to be approximated is already 2π-periodic.

The trigonometric polynomial (1) has an equivalent complex form

p(x) =

n∑

j=−n

cjeijx, where i2 = −1, (2)

under Euler’s formulaeix = cosx+ i sin x.

We then expand (2):

p(x) = c0 +n∑

j=1

(cj + c−j) cos jx+ in∑

j=1

(cj − c−j) sin jx.

A comparison between the above and (1) yields

aj = cj + c−j ,

bj = i(cj − c−j),

j = 0, . . . , n. Solution of each pair of such equations gives us, for j = 0, . . . , n,

cj =aj − ibj

2,

c−j =aj + ibj

2.

The functions 1, e±ix, e±2ix, . . . , form an orthonormal basis with respect to the inner product

〈g, h〉 =1

∫ 2π

0g(x)h(x) dx, (3)

where h(x) is the complex conjugate of h(x). More specifically,

〈eijx, eikx〉 =

{

1, if j = k,0, if j 6= k.

The Fourier series for a function f(x) is given by

f(x) ≈

∞∑

j=−∞

f(j)eijx, (4)

2

Page 3: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

where

f(j) = 〈f(x), eijx〉

=1

∫ 2π

0f(x)e−ijxdx.

are the Fourier coefficients. From the above definition we easily see that f(−j) = f(j). In (4),“≈” means that the Fourier series converges to f(x) under rather mild conditions. For example,the series converges uniformly if f(x) is continuous and f ′(x) is piecewise continuous.

Theorem 1 The partial sumn∑

j=−n

f(j)eijx

of the Fourier series for f(x) is the best approximation to f(x) by trigonometric polynomials oforder n under the inner product defined in (3); that is, with respect to the norm

‖g‖2 =

1

∫ 2π

0|g(x)|2 dx.

Furthermore, it can be shown that Parseval’s relation

∞∑

j=−∞

|f(j)|2 =1

∫ 2π

0|f(x)|2 dx

holds.The Fourier coefficients f(j) can help us “understand” the function f(x). Suppose f(x) is a real

function with period 2π. It can be viewed as the motion of a point at time x on a line. Substitutethe polar form

f(j) = |f(j)|eiθj

into the Fourier series (4) and use the fact that f(j) and f(−j) are complex conjugates:

f(x) ≈ |f(0)| cos θ0 + 2

∞∑

j=1

|f(j)| cos(θj + jx).

Thus we have obtained a representation of the periodic motion as a superposition of simple harmonicoscillations. The jth such motion (with j > 0), 2|f(j)| cos(θj + jx), has

amplitude: 2|f(j)|,

frequency: j2π ,

angular frequency: j,

period or wavelength: 2πj ,

phase angle: θj.

3

Page 4: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

The number |f(j)| measures the strength of the presence of a simple harmonic motion of frequencyj2π in the total motion. It can be shown that

f(j) = O(

|j|−l−1)

, (5)

when the lth derivative of f(x) exists and is piecewise continuous. The sequence |f(0)|, |f (1)|, . . . iscalled the spectrum of f(x) over which the “total energy” ‖f‖22 is distributed. A “noisy” functionwill have sizeable |f(j)| for large j. For a “smooth” function, the spectrum will decrease rapidly asj increases.

The method of smoothing often consists in generating the Fourier coefficients of f(x) from data,filtering these coefficients to suppress high frequencies (which usually correspond to noise), andthen reconstructing the function as a Fourier series with “purified” or “filtered” coefficients. Thefigure1 below shows two 2π-periodic functions and their power spetrums. The second function isobtained from the first by filtering out its higher frequencies.

Since it is generally difficult or impossible to compute the Fourier coefficients {f(j)} exactly,we use their discrete approximations that result from sampling f at the points xk = 2πk

N fork = 0, . . . , N − 1. They are

fN (j) = 〈f, eijx〉N , j = 0, . . . , N − 1 (6)

=1

N

N−1∑

k=0

f(xk)e−ijxk . (7)

Here the discrete inner product 〈 , 〉N is defined as

〈g, h〉N =1

N

N−1∑

i=0

g(xi)h(xi),

1From [1, p. 271].

4

Page 5: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

Under this inner product, the functions 1, e±ix, e±i2x, . . . are still orthogonal, namely,

〈eikx, eijx〉N =

{

1, if k = j (mod N),0, otherwise.

But now we have

fN(j) = 〈f, eijx〉N

= 〈

∞∑

k=−∞

f(k)eikx, eijx〉N by (4)

=

∞∑

k=−∞

f(k) · 〈eikx, eijx〉N

=∑

k=j (mod N)

f(k). (8)

Equation (8) immediately implies that

· · · = fN (j −N) = fN (j) = fN(j +N) = · · · .

The points x0, . . . , xN−1 are called the sampling points, f(x0), . . . , f(xN−1) the sampling values,2πN the sampling interval, and N

2π the sampling frequency.2 From equation (8) we see that all the

Fourier coefficients f(k), k = j mod N , get mashed together and show up indistinguishably inthe discrete Fourier series. This is referred to as aliasing. We cannot tell the difference betweentwo basis functions eik

2πN and eij

2πN , k = j (mod N), because they agree at all sampling point

x0, . . . , xN−1.Aliasing is illustrated3 on the next page on a continuous function in (a) which is nonzero only

for a finite time interval T . The Fourier transform of the function, shown in (b), has no limitedbandwidth but rather finite amplitude for all frequencies. Suppose the original function is sampledwith a sampling interval ∆, then the resulting Fourier transform in (c) is defined between frequencies− 1

2∆ and 12∆ . Power outside that frequency range is folded over or “aliased” into the range.4 To

eliminate this effect, the original function should go through low-pass filtering before sampling.Plugging (5) into (8) yields

fN (j) =∑

k=j (mod N)

O(

|k|−l−1)

= fN

(

j)

+O

(

(

N

2

)−l−1)

,

where

j =

{

j mod N, if 0 ≤ j mod N ≤ N2 ;

(j mod N)−N, if j mod N > N2 .

2To generalize, for a function with period τ , the sampling frequency is N

τ.

3The figure is from [3, p. 507].4This folding effect is in part created by H(−f) = H(f).

5

Page 6: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

So we see that the Fourier coefficients f(j) with |j| ≤ N2 dominate other coefficients. For

this reason, fN(j) is usually taken only as an approximation to f(j) with |j| ≤ N2 . Thus when we

sample a real function at N equally spaced points, in the interval [0, 2π), the aliasing effect preventsthe observation of periodic phenomena in f(x) with frequencies higher than (N/2)/2π. Phraseddifferently, we have the following result.

(c)

Theorem 2 (Sampling Theorem) If we wish to observe a certain periodic phenomenon of fre-quency v, then we must sample at a frequency at least as large as 2v.

Observe that fN (−j) is a conjugate of fN (j), for all j, since

fN (−j) = 〈f, ei(−j)x〉N by (6)

=1

N

N−1∑

k=0

f(xk)e−i(−j)xk by (7)

=1

N

N−1∑

k=0

f(xk)eijxk

= fN (j). by (7)

The corresponding trigonometric polynomial approximant of f(x) has the form:

p(x) =∑

|j|<N/2

fN (j)eijx +Re(

fN (N/2)ei(N/2)x)

6

Page 7: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

= fN (0) + 2Re

N/2−1∑

j=1

fN (j)eijx

+Re(

fN (N/2)ei(N/2)x)

.

The last term is present only when N is even. Having mentioned it for completeness’s sake, we willnow discuss the case when N is odd, that, is N = 2n + 1 for some integer n. In this case, the Nfunctions 1, e±ix, . . . , e±inx are orthonormal with respect to the discrete inner product 〈 , 〉N . Byvirtually the same reasoning of least-squares approximation by orthogonal polynomials, we havethe following theorem.

Theorem 3 For any m ≤ n = N−12 , the mth order trigonometric polynomial

pm(x) =m∑

j=−m

fN (j)eijx

is the best approximation to f(x) by trigonometric polynomials of order m with respect to thediscrete mean-square norm

‖g‖2 =(

〈g, g〉N

)1

2

=1

N

(

N−1∑

k=0

∣g(2πk

N

)∣

2)

1

2

.

3 Fast Computation — FFT

We are interested in the frequencies present in f(x) and their strength (or magnitude). But dueto aliasing, fN (j), defined in (7), is good as an approximation to f(j) only for −N

2 < j ≤ N2 .

Thus, for very large N we want to be able to calculate fN (j), for 0 ≤ |j| ≤ N2 , or equivalently, for

0 ≤ j ≤ N − 1, from f(x0), . . . , f(xN−1), where xk = 2πkN . A straightforward calculation would

take time O(N2).A significant improvement can be achieved by reducing the above problem to a discrete Fourier

transform (DFT). DFT is the mapping

z =

z0z1...

zN−1

7−→ z =

z0z1...

zN−1

such that

zj =N−1∑

k=0

zkωjkN , j = 0, . . . , N − 1,

where ωN is an Nth root of 1, that is, ωN = e−i 2πN . The mapping can also be written as a matrix

equation:

1 1 1 · · · 1

1 ωN ω2N · · · ωN−1

N...

...... · · ·

...

1 ωN−1N ω

2(N−1)N · · · ω

(N−1)2

N

z0z1...

zN−1

=

z0z1...

zN−1

.

7

Page 8: FourierSeries - Iowa State Universityweb.cs.iastate.edu/~cs577/handouts/fourier-series.pdfFourierSeries (Com S 477/577 Notes) ... eix = cosx +isinx. We then expand (2): p(x) = c0 +

If we take zj = f(xj), 0 ≤ j ≤ N − 1, then

fN (j) =1

Nzj , j = 0, 1, . . . , N − 1.

To verify, by definition (7) we have

fN (j) =1

N

N−1∑

k=0

f(xk)e−ijxk

=1

N

N−1∑

k=0

f(xk)e−ij 2πk

N

=1

N

N−1∑

k=0

f(xk)(

ωjN

)k

=1

Nzj .

Fast Fourier transform allows us to compute the discrete Fourier coefficients in time O(N logN).With N = 106, for example, the improvement is from roughly two weeks of CPU time to 30 seconds!

References

[1] S. D. Conte and C de Boor. Elementary Numerical Analysis: An Algorithmic Approach.McGraw-Hill, Inc., 3rd edition, 1980.

[2] M. Erdmann. Lecture notes for 16-811 Mathematical Fundamentals for Robotics. The RoboticsInstitute, Carnegie Mellon University, 1998.

[3] W. H. Press, et al. Numerical Recipes in C++: The Art of Scientific Computing. CambridgeUniversity Press, 2nd edition, 2002.

8