Sections10-05.mws

Unit 2: Infinite Series

Chapter 10: Fourier Series

Sections10.5: periodically driven damped oscillator

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(inttrans):

Warning, the name changecoords has been redefined

> interface(showassumed=0);
assume(n,integer);

> alias(Y=laplace(y(t),t,s)):

> PX := proc(h, g)
local f, var, d;
if type(h, procedure) then RETURN(subs(
{'D' = rhs(g) - lhs(g), 'F' = h, 'L' = lhs(g)}, proc(
x::algebraic)
local y;
y := floor((x - L)/D); F(x - y*D)
end))
fi;
if type(g, equation) then var := lhs(g); d := rhs(g) fi;
f := unapply(h, var);
subs({'L' = lhs(d), 'D' = rhs(d) - lhs(d), 'F' = f}, proc(
x::algebraic)
local y;
y := floor((x - L)/D); F(x - y*D)
end)
end:

>

Damped Oscillator Driven Periodically

Consider the driven damped spring-mass system governed by the differential equation

> q := diff(y(t),t,t) + 2*diff(y(t),t) + 10*y(t) = f(t);

q := diff(y(t),`$`(t,2))+2*diff(y(t),t)+10*y(t) = f...

>

where the periodic forcing function f(t) is the periodic extension of

> g := piecewise(t<=Pi,t, t<=2*Pi,2*Pi-t);

g := PIECEWISE([t, t <= Pi],[2*Pi-t, t <= 2*Pi])

>

The graph of g(t) on its domain of [ 0, 2*Pi ] is given by

> plot(g,t=0..2*Pi, labels=[t,`g `], labelfont=[TIMES,ITALIC,12], xtickmarks=6, ytickmarks=3, scaling=constrained);

[Maple Plot]

>

A Maple representation of f(t) is obtained with the PX command introduced in Sections10.1, so that

> f := PX(g,t=0..2*Pi):

>

with graph, Figure 10.24, given by

> plot(f(t),t=0..6*Pi, color=black, scaling=constrained, ytickmarks=2, xtickmarks=[6,12,18], labels=[t,`f `],labelfont=[TIMES,ITALIC,12]);

[Maple Plot]

>

Exact Solution by Laplace Transform

A graph of the exact motion of this oscillator, started with the inert initial conditions

y(0) = 0 , y'(0) = 0

can be found via the Laplace transform. To this end, we obtain F(s), the transform of f(t) , with the formula for periodic functions from Sections6.7. Thus, with p = 2*Pi , the period of f(t) . We obtain

F(s) = 1/(1-exp(-p*s)) Int(f(t)*exp(-s*t),t = 0 .. p) = (1-exp(-Pi*s))/(s^2)/(1+exp(-Pi*s))

a calculation executed in Maple via

> F := simplify(int(g*exp(-s*t),t=0..2*Pi)/(1-exp(-2*Pi*s)));

F := -(exp(-Pi*s)-1)/((exp(-Pi*s)+1)*s^2)

>

Transforming the differential equation and solving for Y , the Laplace transform of y(t) , we get

Y = 1/(s^2)/(s^2+2*s+10) (1-exp(-Pi*s))/(1+exp(-Pi*s))

calculations which we execute in Maple as follows.

The transform of the differential equation then yields

> q1 := laplace(lhs(q),t,s) = F;

q1 := s*(s*Y-y(0))-D(y)(0)+2*s*Y-2*y(0)+10*Y = -(ex...

>

Our notation has been simplified by aliasing the letter "Y" to the Laplace transform of y(t) . Further simplification arises from imposing the inert initial contitions. Thus,

> q2 := subs(y(0)=0, D(y)(0)=0, q1);

q2 := s^2*Y+2*s*Y+10*Y = -(exp(-Pi*s)-1)/((exp(-Pi*...

>

Solving for the unknown transform Y, we obtain

> q3 := factor(solve(q2,Y));

q3 := -(exp(-Pi*s)-1)/(s^2*(s^2+2*s+10)*(exp(-Pi*s)...

>

It is impossible to invert this transform with just a finite number of elementary functions, so we expand

(1-exp(-Pi*s))/(1+exp(-Pi*s))

in powers of exp(-Pi*s) , obtaining

-1+2 Sum((-1)*exp(-k*Pi*s),k = 0 .. infinity)

The inverse Laplace transform of the factor

1/(s^2)/(s^2+2*s+10)

is the function

h(t) = exp(-t)/25 ( 1/2 cos(3*t)-2/3 sin(3*t) ) + (5*t-1)/50

so the solution to the differential equation is

y(t) = -h(t)+2 Sum((-1)^k*h(t-k*Pi)*Heaviside(t-k*Pi),k = 0 .. inf...

To obtain this solution in Maple, begin by getting a series expansion of Y(s) in powers of exp(-Pi*s) . For this, in Y(s) , replace exp(-Pi*s) with the single letter z , obtaining

> if has(q3,exp(-Pi*s)) then q4 := subs(exp(-Pi*s)=z,q3)
else q4 := subs(exp(Pi*s)=1/z,q3);fi;

q4 := -(z-1)/(s^2*(s^2+2*s+10)*(z+1))

>

The conditionals in the code for making this replacement are required to guarantee that each time this worksheet is executed, the result is the same. Maple can return the expression for Y(s) as a fraction containing either exp(-Pi*s) or exp(Pi*s) . The replacement of the negative exponential with z is crucial for the next step, a Taylor expansion in powers of the negative exponential.

Perform a Taylor expansion about z = 0 to obtain

> q5 := convert(taylor(q4,z=0,7),polynom);

q5 := 1/(s^2*(s^2+2*s+10))-2*z/(s^2*(s^2+2*s+10))+2...
q5 := 1/(s^2*(s^2+2*s+10))-2*z/(s^2*(s^2+2*s+10))+2...

>

Change z back to exp(-Pi*s) , getting

> q6 := subs(z=exp(-Pi*s),q5);

q6 := 1/(s^2*(s^2+2*s+10))-2*exp(-Pi*s)/(s^2*(s^2+2...
q6 := 1/(s^2*(s^2+2*s+10))-2*exp(-Pi*s)/(s^2*(s^2+2...

>

then invert this truncated series representation of Y(s) to obtain what should be an approximation to y(t) . Thus,

> q7 := invlaplace(q6,s,t);

q7 := (-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/...
q7 := (-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/...
q7 := (-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/...
q7 := (-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/...
q7 := (-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/...
q7 := (-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/...

> collect( q7, [seq( Heaviside(t-k*Pi), k=1..6 ) ] );

(-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/75*exp...
(-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/75*exp...
(-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/75*exp...
(-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/75*exp...
(-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/75*exp...
(-1/5*t+Pi+1/25+1/25*exp(-t+5*Pi)*cos(3*t)-4/75*exp...

>

A graph of this version of the solution, namely

y^`^` = -h(t)+2 Sum((-1)^k*h(t-k*Pi)*Heaviside(t-k*Pi),k = 0 .. 7)

is given in Figure 10.25, where, on the interval [0, 20] , the solution is exact because

Heaviside(t-k*Pi), k*`>`*7

is zero, since 8*Pi*`>`*20 .

> p := plot(q7,t=0..20, color=black, xtickmarks=5, ytickmarks=4,labels=[t,``],labelfont=[TIMES,ITALIC,12], view=[0..20,0.. .33]):
p;

[Maple Plot]

>

The first term dropped from the Taylor expansion of Y(s) was z^7 = exp(-7*Pi*s) . If that term had been retained, and inverted, it would have contributed a multiple of Heaviside(t-7*Pi) , and this term is zero for t < 21 . Hence, on the interval [0,20], we have kept enough terms for the graph to represent y(t) exactly.

>

Approximate Solution by Fourier Series

We next obtain a sequence of approximate solutions which rapidly converge to the exact solution. In the differential equation, the driving function f(t) is replaced by f[k](t) , a partial sum of the Fourier series of f(t) , and the corresponding solution y[k](t) computed. The sequence of approximate solutions y[k](t) converges rapidly to the exact solution.

Using the general formalism of Sections10.1, we obtain a Fourier series representation of f(t) . Hence, with the interval [0, 2*L] taken as [ 0, 2*Pi ] so

> L := Pi;

L := Pi

>

we obtain

a[0] = 1/Pi Int(f(t),t = 0 .. 2*Pi) = Pi

a[n] = 1/Pi Int(f(t)*cos(n*t),t = 0 .. 2*Pi) = 2 ((-1)^n-1)/(n^2)/Pi

b[n] = 1/Pi Int(f(t)*sin(n*t),t = 0 .. 2*Pi) = 0

by writing the integrals

> q0 := Int(g,t=0..2*L)/L;
qa := Int(g*cos(n*Pi*t/L),t=0..2*L)/L;
qb := Int(g*sin(n*Pi*t/L),t=0..2*L)/L;

q0 := Int(PIECEWISE([t, t <= Pi],[2*Pi-t, t <= 2*Pi...

qa := Int(PIECEWISE([t, t <= Pi],[2*Pi-t, t <= 2*Pi...

qb := Int(PIECEWISE([t, t <= Pi],[2*Pi-t, t <= 2*Pi...

>

and evaluating them to get the Fourier coefficients

> a0 := value(q0);
a := simplify(value(qa));
b := value(qb);

a0 := Pi

a := 2*(-1+(-1)^n)/(n^2*Pi)

b := 0

>

We note that b[n] = 0 for all n , so the sine terms disappear from the series. Also, examining the a[n] via the list

> seq(subs(n=k,a),k=1..10);

-4*1/Pi, 0, -4/9*1/Pi, 0, -4/25*1/Pi, 0, -4/49*1/Pi...

>

we see that just the cosine terms with an odd index "survive." Hence, the first three distinct partial sums of the resulting Fourier series are

> for k from 1 by 2 to 5 do
f||((k+1)/2) := a0/2 + sum(a*cos(n*Pi*t/L),n=1..k);
od;

f1 := 1/2*Pi-4*cos(t)/Pi

f2 := 1/2*Pi-4*cos(t)/Pi-4/9*cos(3*t)/Pi

f3 := 1/2*Pi-4*cos(t)/Pi-4/9*cos(3*t)/Pi-4/25*cos(5...

>

Letting y[k](t), k = 1, 2, 3 , be the solutions of the original IVP when f(t) is replaced by f[k](t) , we obtain Figure 10.26 wherein the approximations y[k] are plotted against y^`^` .

To obtain the solutions y[k](t) in Maple, and to obtain the graphs shown in Figure 10.26, we execute the following loop which uses Maple's dsolve command to solve three IVPs whose right-hand sides are the partial sums f[k] . Within the same loop, the graphs of the solutions are generated, and displayed against the graph of the exact solution in Figure 10.25.

Also, we re-generate figure 10.25 with a thickened black line, and use it in Figure 10.26 to enhance visibility.

> p := plot(q7,t=0..20, color=black, thickness=3):
for k from 1 to 3 do
Q||k := rhs(dsolve({lhs(q) = f||k, y(0)=0, D(y)(0)=0}, y(t),method=laplace));
p||k := plot(Q||k,t=0..20, color=red, ytickmarks=2);
d||k := display([p,p||k],xtickmarks=5, ytickmarks=4, labels=[t,``], labelfont=[TIMES,ITALIC,12], view=[0..20,0.. .33]);
od:

>

Figure 10.26 is then

> display(array([d||(1..3)]),scaling=constrained);

[Maple Plot]

>

The third partial sum approximates f(t) well enough for the graph of the resulting approximation to y(t) to be indistinguishable from the graph of the exact solution. In Chapter 14 we will study additional techniques for obtaining approximate analytic solutions of differential equations.

We close by separately displaying the three graphs comprising Figure 10.26. The thick black curve is the exact solution, and the approximate solutions y[k] are in red.

> d1;

[Maple Plot]

> d2;

[Maple Plot]

> d3;

[Maple Plot]

>