f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this...

12
1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, k a and k b , in the Fourier series 0 1 () cos( ) sin( ) k k k fx a a kx b kx To do this, we need the following result on the orthogonality of the trigonometric functions. I’d like you to prove the following. Question: The following integral relations hold: 1 if 1 1 cos( ) cos( ) 2 if 0 0 otherwise 1 if 1 1 sin( )sin( ) 0 otherwise 1 cos( )sin( ) 0 for all integers , . n k nx kx dx n k n k nx kx dx nx kx dx nk An equivalent way of stating this theorem is that the collection cos(2 ) cos( ) 1 sin( ) sin(2 ) , , , , , , 2 x x x x is an orthonormal set of functions in 2 ( , ) L Proof. First, we prove the length of each function in 2 ( , ) L is 1. 2 2 2 2 2 1 1 1 2 2 when is a nonzero integer, cos( ) cos ( ) 1 1 (1 cos(2 ) (1 1/ 2sin(2 )) 1 2 2 sin( ) sin ( ) 1 1 (1 cos(2 ) 2 2 dx dx k kx kx dx dx kx dx kx kx kx dx dx kx dx (1 1/ 2sin(2 )) 1 kx Now, prove that any two of them the inner product is 0. In fact, if we have the following, then we have proved the result.

Transcript of f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this...

Page 1: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

1.2 Computation of Fourier Series

In this section, we compute the Fourier coefficients, ka and kb , in the Fourier series

0

1

( ) cos( ) sin( )k k

k

f x a a kx b kx

To do this, we need the following result on the orthogonality of the trigonometric functions. I’d like you

to prove the following.

Question: The following integral relations hold:

1 if 11

cos( )cos( ) 2 if 0

0 otherwise

1 if 11sin( )sin( )

0 otherwise

1cos( )sin( ) 0 for all integers , .

n k

nx kx dx n k

n knx kx dx

nx kx dx n k

An equivalent way of stating this theorem is that the collection

cos(2 ) cos( ) 1 sin( ) sin(2 )

, , , , , ,2

x x x x

is an orthonormal set of functions in 2( , )L

Proof. First, we prove the length of each function in 2( , )L is 1.

2

2 2

2 2

1 11

22

when is a nonzero integer,

cos( ) cos ( ) 1 1(1 cos(2 ) (1 1/ 2sin(2 )) 1

2 2

sin( ) sin ( ) 1 1(1 cos(2 )

2 2

dx dx

k

kx kxdx dx kx dx kx

kx kxdx dx kx dx

(1 1/ 2sin(2 )) 1kx

Now, prove that any two of them the inner product is 0. In fact, if we have the following, then we have

proved the result.

Page 2: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

For all integers ,

1 1 sin(( ) ) sin(( )cos( )cos( ) cos(( ) ) cos(( ) ) 0

2 2

1 1 sin(( ) ) sin(( )sin( )sin( ) cos(( ) ) cos(( ) )

2 2

n k

n k x n k xnx kx dx n k x n k x dx

n k n k

n k x n k xnx kx dx n k x n k x dx

n k n k

0

For all integers , ,

1 1 cos(( ) ) cos(( )sin( )cos( ) sin(( ) ) sin(( ) ) 0

2 2

n k

k n x k n xkx nx dx k n x k n x dx

k n k n

Now, we use the orthogonality relations: cos(2 ) cos( ) 1 sin( ) sin(2 )

, , , , , ,2

x x x x

to

compute the Fourier coefficients. We start with the equation

(1) 0

1

( ) cos( ) sin( )k k

k

f x a a kx b kx

To find , 1,na n , we multiply both sides by cos( )nx

, and integrate, then use the properties in the

above:

0

1

0

1

1 1( )cos( ) cos( ) sin( ) cos( )

1 = cos( ) cos( )cos( ) sin( )cos( )

=

k k

k

k k

k

n

f x nx dx a a kx b kx nx dx

a nx a kx nx b kx nx dx

a

To find 0 ,a we integrate both sides of (1), we have

0 0

1

1 1( ) cos( ) sin( )

2 2k k

k

f x dx a a kx b kx dx a

To find ,nb we multiply both sides of (1) by sin( )nx

, and integrate, then use the properties in the

above:

0

1

0

1

1 1( )sin( ) cos( ) sin( ) sin( )

1 = sin( ) cos( )sin( ) sin( )sin( ) =

k k

k

k k n

k

f x nx dx a a kx b kx nx dx

a nx a kx nx b kx nx dx b

Page 3: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

Theorem 1: If 0

1

( ) cos( ) sin( )k k

k

f x a a kx b kx

on the interval x , then

0

1( )

2

1( )cos( ) for 1

1( )sin( )

n

n

a f x dx

a f x nx dx n

b f x nx dx

The na and nb are called the Fourier coefficients of the function f .

Now, we consider the general interval a t a . Suppose F is a function defined on the interval

[ , ] . The substitution /x t a leads to the following change of variables formula:

1 1

( ) ( )a

a

tF x dx F dt

a a

By using this change of variables, the following theorem can be derived from the above theorem.

Theorem 2: If 0

1

( ) cos( / ) sin( / )k k

k

f x a a k x a b k x a

on the interval a x a , then

0

1( )

2

1( )cos( / ) for 1

1( )sin( / )

a

a

a

na

a

na

a f t dta

a f t n t a dt na

b f t n t a dta

Example 1: Let

1 if 0 1

( )0 otherwise

xf x

Please compute the Fourier series for f valid on the interval 2 2x .

Solution: With 2a in the above Theorem, the Fourier cosine coefficients are

2 1

02 0

2 1

2 0

1 1 1 1( ) ( ) 1

2 4 4 4

for 1,

1 1 1 sin( / 2)( )cos( / ) ( )cos( / 2) cos( / 2)

2 2

a

a

a

na

a f t dt f t dt dta

n

na f t n t a dt f t n t dt n t dt

a n

Page 4: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

When n is even, these coefficients are zero. When 2 1n k is odd, then sin( / 2) ( 1)kn .

Therefore,

( 1)

, 2 1(2 1)

k

na n kk

Similarly,

1

0

1 1 1( )sin( / ) sin( / ) (cos( / 2) 1)

2

a

na

b f t n t a dt n t a dt na n

when 4 , 0

1when 4 1,

(4 1)

1when 4 2,

(2 1)

1when 4 3,

(4 3)

n

n

n

n

n j b

n j bj

n j bj

n j bj

Thus, the Fourier series for f is

0

1

( ) cos( / 2) sin( / 2)k k

k

F x a a k x b k x

where ,n na b given as above.

Later, we will consider the question, whether or not the Fourier series ( )F x for f equals ( )f x itself.

Cosine and Sine Expansions

Even and Odd Functions

Definition: Let : be a function;f R R f is even if ( ) ( );f x f x f is odd if ( ) ( )f x f x .

Page 5: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

The graph of an even function is symmetric about the y axis, as illustrated in Figure 2. 2( ) ,f x x

( ) cosf x x are even functions. The graph of an odd function is symmetric about the origin, as

illustrated in Figure 3. ( ) 2 ,f x x ( ) sinf x x are odd functions. The following properties follow from

the definition.

Even X Even = Even Even X Odd = Odd Odd X Odd = Even

Another important property of even and odd functions is given in the next Theorem.

Theorem: (1) If F is an even function, then 0

( ) 2 ( )a a

aF x dx F x dx

(2) If F is an odd function, then ( ) 0a

aF x dx

This theorem follows easily from Figure 2 and 3. If F is even, then the integral over the left half interval

[ ,0]a is the same as the integral over the right half interval [0,a] . Thus, the integral over [ , ]a a is

twice the integral over [0, ]a . If F is odd, then the integral over the left half interval [ ,0]a cancels

with the integral over the right half interval [0,a] . In this case, the integral over [ , ]a a is 0.

If the Fourier series of a function only involves the cosine terms, then it must be an even function (since

cosine is even). Likewise, a Fourier series that only involves sines must be odd. The converse of this fact

is also true, which is the content of the next Theorem.

Theorem 3: (1) If ( )f x is an even function, then its Fourier series on the interval [ , ]a a will only

involve cosines. That is, 0

1

( ) cos( / )k

k

f x a a k x a

with

0

0

0

1( )

2( )cos( / ) for 1

a

a

n

a f x dxa

a f x n x a dx na

(2). If ( )f x is an odd function, then its Fourier series on the interval [ , ]a a will only involve sines. That

is, 1

( ) sin( / )k

k

f x b k x a

with

0

2( )sin( / )

a

nb f x n x a dxa

Fourier Cosine and Sine Series on a Half Interval.

Suppose f is defined on the interval [0, ]a . By considering even or odd extensions of f , we can

expand f as a cosine or sine series. To express f as a cosine series, we consider the even extension of

:f

Page 6: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

( ) if 0

( )( ) if 0

e

f x x af x

f x a x

The function ef is an even function defined on [ , ]a a . Therefore, only cosine terms appear in its

Fourier expansion:

(2) 0

1

( ) cos( / ) e k

k

f x a a k x a a x a

where na is given in Theorem 3. Since ( ) ( ) for 0ef x f x x a , the integral formulas in Theorem

3 only involve ( )f x rather than ( )ef x and so (2) becomes

0

1

( ) cos( / ) 0k

k

f x a a k x a x a

with

0

0

0

1( )

2( )cos( / ) for 1

a

a

n

a f x dxa

a f x n x a dx na

Likewise, to express f as a sine series, then we consider the odd extension of f :

0

( ) if 0( )

( ) if 0

f x x af x

f x a x

The odd function, 0 ( )f x has only sine terms in its Fourier expansion. Since 0 ( ) ( )f x f x for

0 x a , we obtain the following sine expansion for f :

1

( ) sin( / ) 0k

k

f x b k x a x a

where nb is given in Theorem 3:

0

2( )sin( / )

a

nb f x n x a dxa

Let f be a function and let ( )F x be its Fourier series on [ , ] :

0

1

0

1

( ) cos( ) sin( )

lim cos( ) sin( )

k k

k

N

k kN

k

F x a a kx b kx

a a kx b kx

Page 7: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

where ,k ka b are the Fourier coefficients of f . We say that the Fourier series converges if the preceding

limit exists (as N ). Theorem 1 and Theorem 2 only compute the Fourier series of a given function.

We have yet shown that a given Fourier series converges (or what it converges to). Later, we will show

that under a mild hypothesis on the differentiability of f , the following principle holds:

Let f be a 2 periodic function.

If f is continuous at a point x , then its Fourier series, ( )F x , converges and

( ) ( )F x f x .

If f is not continuous at a point x , then its Fourier series, ( )F x , converges the average of the

left and right limits of f at x , that is

1( ) lim (t) lim (t)

2 t x t xF x f f

.

The second statement includes the first because if f is continuous at x , then the left and right limits

of f at x are both equal to ( )f x and so in this case, ( ) ( ).F x f x We will prove the above results

later. In the following, we present several examples to gain insight into the computation of Fourier

series and the rate at which Fourier series converge.

Example 2: Consider the function ( )f x x on x . Find its Fourier series.

Solution: This function is odd and so only the sine coefficients are nonzero. Its Fourier coefficients are

0 0

2 2( )sin( ) sin( )kb f x kx dx x kx dx

12( 1)k

k

(using integration by parts)

and so its Fourier series for the interval x is

1

1

2( 1)( ) sin( )

k

k

F x kxk

Discussions: The function ( )f x x is not 2 periodic. Its periodic extension, f , is given in Figure 4.

Page 8: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

According to the preceding principle, ( )F x converges to ( )f x , at points where f is continuous. At

points of discontinuity of f , ( , , , )x , ( )F x will converge to the average of the left and

right limits of ( )f x . For example, ( ) 0F (since sin 0k ), which is the average of the left and

right limit of f at x .

To see how fast the partial sums of this Fourier series converges to ( ),f x we graph the partial sum

1

1

2( 1)( ) sin( )

kN

N

k

S x kxk

For various values of .N The graph of

110

10

1

2( 1)( ) sin( )

k

k

S x kxk

is given in Figure 5 together with the graph of ( )f x (the squiggly curve is the graph of 10S ).

First, notice that the accuracy of the approximation of ( )f x by 10 ( )S x gets worse the closer x is to a

point of discontinuity. For example, near x , the graph of 10 ( )S x must travel from about y to

y in a very short interval, resulting in a slow rate of convergence near .x

Page 9: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

Second, notice the blips in the graph of the Fourier series just before and just after the points of

discontinuity of ( )f x . This effect is called the Gibbs phenomenon.

Figure 6. Gibbs phenomenon for 50S

Example 3. Consider the sawtooth wave illustrated in Figure 7. The formula for f on the interval

0 x given by

if 0 / 2

( )if / 2

x xf t

x x

and extends to the interval 0x as an even function. Compute its Fourier series.

Since f is an even function, only the cosine terms are nonzero. By Theorem 3, we have

That is, 0

1

( ) cos( )k

k

F x a a kx

with

0

0

1( )

4a f x dx

Page 10: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

0

/2

0 /2

2

For 1

2( )cos( )

2 2 = cos( ) ( )cos( )

4cos( / 2) 2cos( ) 2 =

n

n

a f x nx dx

x nx dx x nx dx

n n

n

Only the 4 2 0ka . These coefficients simplify to

4 2 2

2

(2 1)ka

k

So, the Fourier series for the sawtooth wave is

2

0

2 1( ) cos((4 2) )

4 (2 1)k

F x k xk

The sawtooth wave is already periodic and it is continuous. Thus its Fourier series ( )F x equals the

sawtooth wave, ( )f x , for every x by the principle stated at the beginning of this section. The

convergence rate is much faster than for the Fourier series in Example 2. To illustrate the rate of

convergence, with plot the sum of the first two terms of its Fourier series,

2

2cos(2 )( )

4

xS x

In Figure 8. The sum of just two terms of this Fourier series gives a more accurate approximation of the

sawtooth wave than 10 or 50 terms of the Fourier series in the previous (discontinuous) example.

Indeed, the graph of the first 10 terms of this Fourier series (given in Figure 9) is almost indistinguishable

form the original function.

Page 11: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

Example 4. Find the Fourier series of 2( ) sinf x x . You can use the formulas to get the Fourier series,

but you can get the Fourier series using trigonometric identity:

2

0 2

1 1 1 1( ) sin cos 2 ( , )

2 2 2 2f x x x a a

Question: Find the Fourier sine series for the function 2( ) 1f x x valid on the interval 0 1x .

Answer: we first extend f as an odd function:

2

2

1 for 0 1 ( )

1 for 1 0o

x xf x

x x

The Fourier coefficients for of is

2 2 2 2

1 12

3 30 0

2 ( 1) 2( 1) 22 ( )sin( ) 2 ( 1)sin( ) 2

n n

n

n nb f x n x dx x n x dx

n

Page 12: f f x a a kx b kx 0 kk k 1 S - Texas A&M University1.2 Computation of Fourier Series In this section, we compute the Fourier coefficients, a k and b k, in the Fourier series 0 1 (

When 2 ,n k

2

1kb

k

When 2 1,n k

2 2 2 2

2 1 3 3

12 12 3 42

(2 1)k

k kb

k

Thus, the Fourier sin series for 2( ) 1f x x on the interval 0 1x is

2 2 2 2

3 31

1 12 12 3 4( ) sin 2 2 sin(2 1)

(2 1)k

k kF x k k x

k k

Question: Solve the heat equation:

( , ) ( , ) 0, 0

( ,0) ( ) 0

(0, ) 0

( , ) 0

t xxu x t u x t t x

u x f x x

u t

u t

where if 0 / 2

( )if / 2

x xf x

x x

Sketch of the answer: From the discussion in 1.1, the solution to this problem is

(3) 2

1

( , ) sin( ) k t

k

k

u x t b kx e

Let 0t in (3), we have 1

( ) ( ,0) sin( )k

k

f x u x b kx

.

Therefore, the kb must be chosen as the Fourier sine coefficients of ( )f x , which by Theorem 3, are

0

2( )sin( )kb f t kt dt

After do the integral, we have. When 2k j , 0kb ; when 2 1k j , 2 1 2

4( 1)

(2 1)

j

jbj

2(2 1)

21

4( 1)( , ) sin((2 1) )

(2 1)

jj t

k

u x t j x ej