Sections10-06.mws

Unit 2: Infinite Series

Chapter 10: Fourier Series

Sections10.6: optimizing property of Fourier series

Copyright

Copyright * 2001 by Addison Wesley Longman, Inc.

All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America.

Initializations

> restart;

> with(plots):
with(plottools):
with(student):

Warning, the name changecoords has been redefined

> read(`C:/Program Files/Maple 6.01/pvac.txt`):

Approximating f(x) via Trigonometric Polynomials

A partial sum of a Fourier series is a trigonometric polynomial approximating the function to which the series converges. For the function

> f := x;

f := x

>

defined on the interval [0, Pi] , a two-term trigonometric polynomial which might approximate it is

> g := s1*sin(x) + s2*sin(2*x);

g := s1*sin(x)+s2*sin(2*x)

>

Judging the quality of the approximation of f(x) by g(x) requires a measure of the goodness of the fit of g(x) to f(x) . In Sections8.4 we used the notion of convergence in the mean to measure convergence of a sequence of functions. The measure of performance for our trigonometric approximation will be

abs(abs(f(x)-g(x)))[2]^2 = Int((f(x)-g(x))^2,x = 0 ...

the square of the measure used for convergence in the mean. The subscript 2 indicates that the difference between f(x) and g(x) in the integral has been squared .

We illustrate this measure in the following example.

>

Example 10.12

Assigning s[1] and s[2] the values 1 in g(x) yields the approximating

> g1 := subs(s1=1, s2=1, g);

g1 := sin(x)+sin(2*x)

>

appearing in the following figure, Figure 10.27, as the solid (red) curve. The dashed (black) curve is, of course, f(x) .

> plot([f,g1],x=0..Pi,color=black,linestyle=[2,1], color=[black,red], xtickmarks=3, ytickmarks=3, labels=[x,``], labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

The calibre of g[1](x) as an approximation to f(x) = x is captured in the following animation.

> F := plot([f,g1], x=0..Pi, color=[black,red], thickness=3):
fx := unapply(f,x):
gx := unapply(g1,x):
F1 := t -> display(polygon([[t,gx(t)],[ t,fx(t)], [t+.1,fx(t+.1)], [t+.1,gx(t+.1)]], color=green)):
F2 := N -> display([seq(F1(k/10),k=0..N)]):
F3 := display([seq(F2(k),k=0..31)],insequence=true):
display([F,F3], labels=[x,y], labelfont=[TIMES,ITALIC,12], xtickmarks=3, ytickmarks=3);

[Maple Plot]

>

The integral of the square of the difference between f(x) = x and

g[1](x) = sin(x)+sin(2*x)

varies with the total area between the two curves. The green area swept in the animation above quantifies the fit. The integral "measures" the amount of green. The less "green," the better the fit between the two functions. Hence, minimizing the amount of green area yields the "best" fit according to the constraints of this particular method of measuring fit.

A calculation shows

abs(abs(f(x)-g[1](x)))[2]^2 = Int((f(x)-g[1](x))^2,... = Pi^3/3 = 10.33542556

since the value of

> q := Int((f-g1)^2,x=0..Pi);

q := Int((x-sin(x)-sin(2*x))^2,x = 0 .. Pi)

>

evaluates to

> value(q) = evalf(value(q));

1/3*Pi^3 = 10.33542556

>

Optimizing the Fit Heuristically

For our example, the measure of fit between f(x) and g(x) would be

> q := Int((f-g)^2,x=0..Pi);

q := Int((x-s1*sin(x)-s2*sin(2*x))^2,x = 0 .. Pi)

>

with value

> Q := value(q);

Q := 1/2*s1^2*Pi+1/2*s2^2*Pi-2*s1*Pi+1/3*Pi^3+s2*Pi...

>

a function of the two parameters s[1] and s[2] , graphed in Figure 10.28, below.

> p1:=plot3d(Q,s1=1..3, s2=-2..0, axes=boxed, style=patchcontour, labels=[`s1 `,` s2`,`Q `], labelfont=[TIMES,ITALIC,12], tickmarks=[3,3,3], scaling=constrained, orientation=[-45,65]):
p2:=spacecurve([[1,-2,2.5],[1,0,2.5],[3,0,2.5]],color=black, linestyle=2):
display([p1,p2]);

[Maple Plot]

>

The surface determined by Q(s[1],s[2]) has a minimum point near ( s[1], s[2] ) = ``(2,-1) which we will momentarily find by the analytic techniques of calculus.

First, however, we build the following Maple procedure which accepts a guess for the pair of parameters ( s[1], s[2] ) and plots both f(x) and the resulting approximating curve g(x) . In addition, the value of the measuring integral is computed and displayed.

> a := proc(u,v)
local G,h,p1,p2;
G := subs(s1=u,s2=v,g);
h := evalf(subs(s1=u,s2=v,Q));
p1 := plot([f,G],x=0..Pi, color=[black,red]):
p2 := textplot([1,3,convert(h,string)]):
display([p1,p2]);
end:

>

For example, the approximating function

> g1;

sin(x)+sin(2*x)

>

has s[1] = 1 and s[2] = 1 , so we try

> a(1,1);

[Maple Plot]

>

and

> a(1,.5);

[Maple Plot]

>

The reader is encourages to continue experimenting until a minimizing point is found empirically.

>

Optimizing the Fit Analytically

Equating to zero the partial derivatives of Q(s[1],s[2]) taken with respect to s[1] and s[2] yields the equations

> eq1 := diff(Q,s1) = 0;
eq2 := diff(Q,s2) = 0;

eq1 := s1*Pi-2*Pi = 0

eq2 := s2*Pi+Pi = 0

>

whose solution is ( s[1], s[2] ) = ``(2,-1) , determined in Maple by

> qq := solve({eq1,eq2},{s1,s2});

qq := {s1 = 2, s2 = -1}

>

Hence, the best fit to f(x) = x which we can obtain under this measure, using the fitting function

g(x) = s[1]*sin(x)+s[2]*sin(2*x)

is the function

> G := subs(qq,g);

G := 2*sin(x)-sin(2*x)

>

graphed (as the red curve) in Figure 10.29 (below)

> plot([x,G],x=0..Pi, color=[black,red], linestyle=[2,1], xtickmarks=3, ytickmarks=3, labels=[x,``],labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

for which we have Q(2,-1) = 2.418443925 , as determined by

> a(2,-1);

[Maple Plot]

>

Best Fit, Generalized

We next seek, for a general function f(x) on the interval [0, Pi] , the best approximating trigonometric polynomial of the form

g(x) = Sum(s[k]*sin(k*x),k = 1 .. infinity)

To minimize the measure of performance

Q = Int((f(x)-sum(s[k]*sin(k*x),k = 1 .. infinity))...

solve the normal equations

1/2 Q[s[j]] = Int((f(x)-sum(s[k]*sin(k*x),k = 1 .. infi... = 0, j = 1, `...`

for s[k], k = 1, `...` . Because the integrals of the "cross terms" vanish, that is, because

Int(sin(n*x)*sin(m*x),x = 0 .. Pi) = 0 for n <> m

these equations take the form

Int(f(x)*sin(k*x),x = 0 .. Pi) = s[k]*Int(sin^2*``(... = Pi/2 s[k]

from which we determine

s[k] = 2/Pi Int(f(x)*sin(k*x),x = 0 .. Pi)

These values for the s[k] are precisely the coefficients of the Fourier sine series for f(x) on the interval [0, Pi] . The Fourier series is the best trigonometric approximation to f(x) , provided the measure used to determine "best" is convergence in the mean.

Insight into the calculations on which this derivation is based can be obtained by working with the finite approximating sum

> g := add(s[k]*sin(k*x),k=1..5);

g := s[1]*sin(x)+s[2]*sin(2*x)+s[3]*sin(3*x)+s[4]*s...

>

Restoring f to the status of a free variable via

> f:='f';

f := 'f'

>

we write the measure of performance as

Q = Int((f(x)-Sum(s[k]*sin(k*x),k = 1 .. 5))^2,x = ...

and enter into Maple as it

> Q := Int((f(x)-g)^2,x=0..Pi);

Q := Int((f(x)-s[1]*sin(x)-s[2]*sin(2*x)-s[3]*sin(3...

>

To minimize this measure of performance, differentiate with respect to each s[k] , setting each derivative to zero. The general term for such derivatives will be of the form

Int(-2*(f(x)-s[1]*sin(x)-s[2]*sin(2*x)-s[3]*sin(3*x...

If the integrations are carried out, the surviving terms will be of the form

-2*Int(f(x)*sin(k*x),x = 0 .. Pi)+2*s[k]*Int(sin^2*...

because, for n <> m , integrals of the form

Int(sin(n*x)*sin(m*x),x = 0 .. Pi)

all vanish. Indeed, in Maple we have

> for n from 1 to 5 do
for m from 1 to n-1 do
print(Int(sin(n*x)*sin(m*x),x=0..Pi) = int(sin(n*x)*sin(m*x),x=0..Pi));
od;od;

Int(sin(2*x)*sin(x),x = 0 .. Pi) = 0

Int(sin(3*x)*sin(x),x = 0 .. Pi) = 0

Int(sin(3*x)*sin(2*x),x = 0 .. Pi) = 0

Int(sin(4*x)*sin(x),x = 0 .. Pi) = 0

Int(sin(4*x)*sin(2*x),x = 0 .. Pi) = 0

Int(sin(4*x)*sin(3*x),x = 0 .. Pi) = 0

Int(sin(5*x)*sin(x),x = 0 .. Pi) = 0

Int(sin(5*x)*sin(2*x),x = 0 .. Pi) = 0

Int(sin(5*x)*sin(3*x),x = 0 .. Pi) = 0

Int(sin(5*x)*sin(4*x),x = 0 .. Pi) = 0

>

On the other hand, integrals of the form Int(sin^2*k*x,x = 0 .. Pi) are not zero. In fact, using Maple, we find

> for k from 1 to 5 do
Int(sin(k*x)^2,x=0..Pi) = int(sin(k*x)^2,x=0..Pi);
od;

Int(sin(x)^2,x = 0 .. Pi) = 1/2*Pi

Int(sin(2*x)^2,x = 0 .. Pi) = 1/2*Pi

Int(sin(3*x)^2,x = 0 .. Pi) = 1/2*Pi

Int(sin(4*x)^2,x = 0 .. Pi) = 1/2*Pi

Int(sin(5*x)^2,x = 0 .. Pi) = 1/2*Pi

>

Incidentally, more than thirty years ago, Tom Hack, a fellow graduate student at Purdue University, pointed out that one could remember the value of such integrals by observing Int(sin^2*x+cos^2*x,x = 0 .. Pi) = Int(1,x = 0 .. P... = Pi , and apportioning "half" the contribution to the sine term and "half" to the cosine term. (Recounting this to students since, yields laughter, but correct answers!)

Thus, the equations obtained by differentiating can be evaluated to the forms below.

> for k from 1 to 5 do
q||k := value(expand(diff(Q,s[k]),sin)) = 0;
od;

q1 := -2*int(sin(x)*f(x),x = 0 .. Pi)+s[1]*Pi = 0

q2 := -2*int(sin(2*x)*f(x),x = 0 .. Pi)+s[2]*Pi = 0...

q3 := -2*int(sin(3*x)*f(x),x = 0 .. Pi)+s[3]*Pi = 0...

q4 := -2*int(sin(4*x)*f(x),x = 0 .. Pi)+s[4]*Pi = 0...

q5 := -2*int(sin(5*x)*f(x),x = 0 .. Pi)+s[5]*Pi = 0...

>

Solving each equation yields one coefficient each because the integrations eliminate all "cross terms." The vanishing of such cross terms is special to the set of functions sin(k*x) , and is the reason why such functions are used to make Fourier series.

> for k from 1 to 5 do
isolate(q||k,s[k]);
od;

s[1] = 2*int(sin(x)*f(x),x = 0 .. Pi)/Pi

s[2] = 2*int(sin(2*x)*f(x),x = 0 .. Pi)/Pi

s[3] = 2*int(sin(3*x)*f(x),x = 0 .. Pi)/Pi

s[4] = 2*int(sin(4*x)*f(x),x = 0 .. Pi)/Pi

s[5] = 2*int(sin(5*x)*f(x),x = 0 .. Pi)/Pi

>

These values for the s[k] are precisely the Fourier sine series coefficients for the interval [0, Pi] . The Fourier series is the best trigonometric approximation to f(x) , provided the measure used to determine "best" is convergence in the mean.

There are other functions with the same minimizing property, the essence of which is the vanishing of the integrals of the "cross terms." This property is called "orthogonality" in the literature, and is the basis for generalizations of the Fourier series. In the next lesson, we will obtain the Fourier-Legendre series, and similar techniques could be used to obtain series of Bessel functions, Tchebychev polynomials, Laguerre polynomials, Hermite polynomials, and many other of the special functions of applied mathematics.

>

Orthogonality of Functions

A key step in obtaining the Fourier coefficients by minimizing the mean-square norm Q is the vanishing of the "cross-terms," the integrals

Int(sin(n*x)*sin(m*x),x = 0 .. Pi), n <> m

This leads to a general definition of the orthogonality of functions.

>

Definition 10.1

Two functions f(x) and g(x) are said to be orthogonal on the interval [a, b] if

Int(f(x)*g(x),x = a .. b) = 0

There are functions other than just sines and cosines with the same orthogonal, "minimizing" property, the basis for generalizations of the Fourier series. In Sections10.7, we will use orthogonality to obtain the Fourier-Legendre series, and in Sections16.2 we will again use orthogonality to obtain the Fourier-Bessel series. Similar techniques could be used to obtain series of Chebyshev polynomials, Laguerre polynomials, Hermite polynomials, and many other of the special functions of applied mathematics.

>

Additional Remark about Orthogonality

The student is cautioned against a search for a "geometric" orthogonality in this definition. Functions orthogonal under this definition will not "look" perpendicular in any way. The definition is merely a generalization of the notion of orthogonality of vectors under the usual dot product, as learned in the standard multivariable calculus course.

The functions

> f := sin(x);
g := sin(3*x);

f := sin(x)

g := sin(3*x)

>

have been shown, in the previous lesson, to be orthogonal on the interval [0, Pi] . Indeed,

> Int(f*g,x=0..Pi) = int(f*g,x=0..Pi);

Int(sin(x)*sin(3*x),x = 0 .. Pi) = 0

>

The functions don't "look" orthogonal, as seen in the following graph.

> plot([f,g],x=0..Pi, color=black, linestyle=[1,2], scaling=constrained);

[Maple Plot]

>

Lest the student misinterpret the figure and mistakenly conclude that the two "orthogonal" functions cross at right angles, we compute the points of intersection, and compute the slopes of the curves at one of the intersections. If the curves were geometrically orthogonal at this point, the product of their slopes would be -1 . Hence,

> solve(f=g,x);

Pi, 0, 1/4*Pi, 3/4*Pi, -1/4*Pi, -3/4*Pi

>

and

> simplify(subs(x=Pi/4,diff(f,x)*diff(g,x)));

-3/2

>

Clearly, these orthogonal curves do not cross at right angles. Moreover, orthogonality of the curves in an interval property. If the interval were changed, the curves might no longer be orthogonal under this definition. For instance, if the interval be changed to [0, Pi/4] , we would have

> Int(f*g,x=0..Pi/4) = int(f*g,x=0..Pi/4);

Int(sin(x)*sin(3*x),x = 0 .. 1/4*Pi) = 1/4

>

and the same functions would no longer be considered orthogonal.

>