You are on page 1of 28

DE.03.

B1

áExperiment 3:
Differential Equations&Mathematica Clear@f, F, s, tD;
2
©1999 Bill Davis and Jerry Uhl F@s_D = €€€€€€€€€€€€€€€€
s2 + 4
Produced by Bruce Carpenter Published by Math Everywhere, Inc. 2
€€€€€€€€€€€€€€€€
www.matheverywhere.com 4 + s2
f@t_D = InverseLaplaceTransform @F@sD, s, tD
DE.03 Laplace Transform and Fourier Sin@2 tD

Analysis LaplaceTransform@f@tD, t, sD
2
€€€€€€€€€€€€€€€€
Basics 4 + s2

áExperiment 4:
Clear@f, Lf, s, xD;
B.1) The Laplace transform Y@sD of y@tD is 5.2
F@s_D = €€€€€€€€€€€€€
infinity s+2
Y@sD = Ù0 E-s t y@tD â t. 5.2
€€€€€€€€€€€€€
2+s
The Laplace transform of y'@tD is s Y@sD - y@0D. f@t_D = InverseLaplaceTransform @F@sD, s, tD
5.2 E-2 t
The Laplace transform of y''@tD is s2 Y@sD - s y@0D - y¢ @0D LaplaceTransform@f@tD, t, sD
5.2
€€€€€€€€€€€€€
2+s
Here's the inside scoop on the Laplace transform: Before computers, folks did these by looking up functions
and their inverse Laplace transforms in printed tables.
The functions legal for the Laplace transform are all functions f@tD
with the property that Different functions have different Laplace transforms.
E-s t f@tD ® 0 as t ® ∞ áB.1.a.i) The Laplace transform of the first derivative
for all large positive s.
Look at this:
Sin@p tD, Cos@p tD , Ek t , Log@tD
Clear@y, t, sD;
and any quotient of polynomials are all legal. LaplaceTransform@y¢ @tD, t, sD
The Laplace transform of a given function f@tD is another function, s LaplaceTransform@y@tD, t, sD - y@0D
F@sD, given by One reason folks fall for the charms of the Laplace transform is that if
infinity -s t
F@sD = Ù0 E f@tD â t. g@tD = y'@tD,
(The t variable is integrated out, leaving only s). then you are guaranteed that the Laplace transforms line up like this:
G@sD = s Y@sD - y@0D
For instance, here's the Laplace transform of where
f@tD = t: G@sD is the Laplace transform of g@tD = y¢ @tD
and

Clear@f, F, s, tD; Y@sD is the Laplace transform of y@tD.


f@t_D = t;
F@s_D = LaplaceTransform@f@tD, t, sD
1 This is a good fringe benefit because it tells you how to write down
€€€€€€€

s2 the Laplace transform of g@tD = y¢ @tD once you've got your hands on
Check: y@tD and its Laplace transform.

à E
-s t
f@tD â t
Play with it:
0
1 ∞ áExperiment 1:
IfARe@sD > 0, €€€€€€€
€, E-s t t â tE
s 2 à0 Clear@y, Y, s, tD;
This is Mathematica's way of telling you that if s > 0, then y@t_D = E-0.4 t ;
infinity -s t 1 LaplaceTransform@y¢ @tD, t, sD
Ù0 E f@tD â t = €€€€€€
s2
. 0.4
- €€€€€€€€€€€€€€€€€€€
If Mathematica is given the Laplace transform of f@tD, then 0.4 + s
Together@s LaplaceTransform@y@tD, t, sD - y@0DD
Mathematica can often recover the formula for f@tD:
0.4
InverseLaplaceTransform @F@sD, s, tD - €€€€€€€€€€€€€€€€€€€
0.4 + s
t
áExperiment 2:
Some more play:
Clear@y, s, tD;
áExperiment 1: y@t_D = E-t Cos@p tD;
Together@LaplaceTransform@y¢ @tD, t, sDD
Clear@f, F, s, tD;
f@t_D = Sin@tD; -1 - p2 - s
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
F@s_D = LaplaceTransform@f@tD, t, sD 1 + p2 + 2 s + s2
Together@s LaplaceTransform@y@tD, t, sD - y@0DD
1
€€€€€€€€€€€€€€€€ -1 - p2 - s
1 + s2 €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
InverseLaplaceTransform @F@sD, s, tD 1 + p2 + 2 s + s2
Sin@tD Even when Mathematica can't handle the calculations, you can be
InverseLaplaceTransform @F@sD, s, tD == f@tD certain that if
True g@tD = y¢ @tD,
áExperiment 2: then you are guaranteed that
Clear@f, F, s, tD;
G@sD = s Y@sD - y@0D
f@t_D = E-t ; because you can use integration by parts to explain this formula. Do it.
F@s_D = LaplaceTransform@f@tD, t, sD á Answer:
1
€€€€€€€€€€€€€
1+s Remember,
InverseLaplaceTransform @F@sD, s, tD ∞
E-t
Y@sD = Ù0 E-s t y@tD â t,
InverseLaplaceTransform @F@sD, s, tD == f@tD and because g@tD = y¢ @tD
True ∞
G@sD = Ù0 E-s t y'@tD â t, .

53
DE.03.B1®B2
Clear@G, H, g, y, Derivative, sD;
H@s_D = s G@sD - y¢ @0D
The upshot: s G@sD - y¢ @0D

Explaining why The formula in part a.i) also says that


G@sD = s Y@sD - y@0D G@sD = s Y@sD - y@0D:
Expand@H@sD •. G@sD ® s Y@sD - y@0DD
is the same as explaining why
∞ ∞ -s y@0D + s2 Y@sD - y¢ @0D
-s t ¢ -s t
Ù0 E y @tD â t = s Ù0 E y@tD â t - y@0D.
To get a grasp on the left side, remember
∞ n
So
Ù0 E y @tD â t = limit of Ù0 E y @tD â t as n ® ∞
-s t ¢ -s t ¢
H@sD = s2 Y@sD - s y@0D - y¢ @0D,
as advertised.
Now work on
n
Ù0 E-s t y¢ @tD â t Try this formula out:
using integration by parts:
áExperiment 1:
The integration by parts formula is
Clear@y, s, x, tD;
n n
Ù0 u@tD v¢ @tD â t = u@tD v@tD Èn0 - Ù0 v@tD u¢ @tD â t. y@t_D = Sin@5 tD;
LaplaceTransform@y² @tD, t, sD
Make the assignments: 125
- €€€€€€€€€€€€€€€€€€€
25 + s2
u@tD = E-s t and v¢ @tD = y¢ @tD. Together@s2 LaplaceTransform@y@tD, t, sD - s y@0D - y¢ @0DD
125
This gives - €€€€€€€€€€€€€€€€€€€
25 + s2
u¢ @tD = -s E-s t and v@tD = y@tD áExperiment 2:
Plug into the integration by parts formula to get Clear@y, s, tD;
n 1
Ù0 E-s t y¢ @tD â t y@t_D = Sin@tD + €€€€€ Sin@2 tD;
2
n Together@LaplaceTransform@y² @tD, t, sDD
= E-s t y@tDÈn0 - Ù0 -s E-s t y@tD â t
n -8 - 5 s2
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

= E-s t y@tDÈn0 + s Ù0 E-s t y@tD â t H1 + s2 L H4 + s2 L
n Together@s2 LaplaceTransform@y@tD, t, sD - s y@0D - y¢ @0DD
= E-s n y@nD- y@0D + s Ù0 E-s t y@tD â t.
-8 - 5 s2
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

As n ® ∞, H1 + s2 L H4 + s2 L
n It works in theory even in cases Mathematica can't handle.
Ù0 E-s t y¢ @tD â t ® G@sD,

E-s n y@nD ® 0,
and B.2) Using the magic of the Laplace Transform to come up
n with formulas for forced exponential diffeqs and forced
s Ù0 E-s t y@tD â t ® s Y@sD.
So oscillator diffeqs
G@sD = -y@0D + s Y@sD = s Y@sD - y@0D áB.2.a) Using the Laplace transform to solve a forced exponential
as advertised. diffeq
Showcase the Laplace transform by using it to come up with the exact
If someone ever asks you whether you have seen the Laplace formula for the solution of
y¢ @tD + 1.2 y@tD = 4.75 E-0.09 t Cos@3.5 tD
transform, now you can say that you've seen a little bit about it. And with y@0D = 5.2.
you can tell them that you saw it first in DiffEq&Mathematica. á Answer:

áB.1.a.ii) With the Laplace transform, this is duck soup. You look at the diffeq:
Look at this: y¢ @tD + 1.2 y@tD = 4.75 E-0.09 t Cos@3.5 tD
Clear@y, t, sD;
LaplaceTransform@y² @tD, t, sD
with y@0D = 5.2.
2
s LaplaceTransform@y@tD, t, sD - s y@0D - y @0D ¢ and then you enter
You already know the Laplace transform of y¢ @tD is Clear@f, t, Y, y, sD;
s Y@sD - y@0D. r = 1.2;
f@t_D = 4.75 E-0.09 t Cos@3.5 tD;
How does this fact guarantee that the Laplace transform of y¢¢ @tD is LaplaceTransform@f@tD, t, sD + starter
s2 Y@sD - s y@0D - y¢ @0D? starter = 5.2; Y@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
r+s
á Answer: 4.75 H0.09+sL
5.2 + €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
12.25+H0.09+sL2
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
1.2 + s
Put
This is the Laplace transform of the solution.
h@tD = y¢¢ @tD and g@tD = y¢ @tD
To get the formula for the solution y@tD you calculate the inverse
so that
Laplace transform of Y@sD.
h@tD = g¢ @tD.
The formula for the solution y@tD is:
y@t_D = Chop@Expand@InverseLaplaceTransform @Y@sD, s, tDDD
According to part a.i) above, you are guaranteed that 4.80893 E-1.2 t + 0.391074 E-0.09 t Cos@3.5 tD + 1.23312 E-0.09 t Sin@3.5 tD
H@sD = s G@sD - g@0D:

54
DE.03.B2
LaplaceTransform@f@tD,t,sD+ b ystarter+ s ystarter + yprimestarter
That's all there is to it. Y@sD = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
s2 +b s+c

Check whether this y@tD solves y¢ @tD + 1.2 y@tD = 4.75 E-0.09 t Cos@3.5 tD: with b = 2.0, c = 6.5, f@tD = 9.1 E-1.9 t , ystarter = 1.5 and
Chop@Expand@y¢ @tD + 1.2 y@tDDD yprimestarter = -4.7.
4.75 E-0.09 t Cos@3.5 tD
Then your grandparents would look in a printed table to find which
Yepper. function y@tD has Y@sD for its Laplace transform.
Check whether this y@0D = 5.2 for this y@tD:
y@0D
5.2 This is similar to what you are doing, but you're using the computer to
Everything checks. find which function y@tD has Y@sD for its Laplace transform.

áB.2.b) Using the Laplace transform to solve a forced oscillator áB.2.d)


diffeq Part of the job of mathematics is to explain why things are guaranteed
to work out.
Showcase the Laplace transform by using it to come up with the exact Explain why the methods used in parts a) and b) above worked.
formula for the forced, damped oscillator coming from
á Answer:
y² @tD + 1.3 y¢ @tD + 6.5 y@tD = 9.1 E-0.8 t
with y@0D = 1.6 and y¢ @0D = 3.7. áExplanation for the forced exponential diffeq
á Answer:
y'[t] + r y[t] = f[t]:
With the Laplace transform, this is also duck soup.
It's just a little algebra.
You look at the diffeq:
Enter the differential equation with everything cleared:
y² @tD + 1.3 y¢ @tD + 6.5 y@tD = 9.1 E-0.8 t Clear@y, t, f, Y, r, sD;
diffeq = y'@tD + r y@tD == f@tD
with y@0D = 1.6 and y¢ @0D = 3.7 .
r y@tD + y¢ @tD == f@tD
and then you enter Replace all the functions involved by their Laplace transforms:
Clear@f, t, Y, y, sD
laplaced = diffeq •.
b = 1.3; c = 6.5;
8y@tD -> LaplaceTransform@y@tD, t, sD,
f@t_D = 9.1 E-0.8 t ;
y'@tD -> LaplaceTransform@y'@tD, t, sD,
ystarter = 5.2; yprimestarter = 3.7;
f@tD -> LaplaceTransform@f@tD, t, sD<
1
Y@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD + b ystarter + r LaplaceTransform@y@tD, t, sD + s LaplaceTransform@y@tD, t, sD - y@0D ==
s2 + b s + c LaplaceTransform@f@tD, t, sD
s ystarter + yprimestarterL
10.46 + 5.2 s + €€€€€€€€€€€€€ 9.1
0.8+s €
Solve this for the Laplace Transform of y@tD:
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
6.5 + 1.3 s + s2 sol = Simplify@Solve@laplaced, LaplaceTransform@y@tD, t, sDDD

LaplaceTransform@f@tD, t, sD + y@0D
This is the Laplace transform of the solution. 99LaplaceTransform@y@tD, t, sD ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ==
r+s
To get the formula for the solution y@tD you calculate the inverse There is is.
Laplace transform of Y@sD. This tells you that the Laplace transform Y[s] of the solution y[t] is
LaplaceTransform@f@tD,t,sD+ y@0D
The formula for the solution y@tD is: Y@sD = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
r+s

y@t_D = Chop@Expand@InverseLaplaceTransform @Y@sD, s, tDDD which is exactly the formula used in part a).
1.4918 E-0.8 t + 3.7082 E-0.65 t Cos@2.46526 tD + 2.96268 E-0.65 t Sin@2.46526 tD

That's all there is to it.


Check whether this y@tD solves y² @tD + 1.3 y¢ @tD + 6.5 y@tD = 9.1 E-0.8 t : áExplanation for the forced oscillator diffeq
¢ ¢
Chop@Expand@Hy L @tD + 1.3 y @tD + 6.5 y@tDDD ¢ y''[t] + b y'[t] + c y[t] = f[t]:
9.1 E-0.8 t
Again, it's just a little algebra.
Yepper.
Enter the differential equation with everything cleared:
Check whether y@0D = 1.6 and y¢ @0D = 3.7 . Clear@y, t, f, b, c, s, YD;
y@0D diffeq = y''@tD + b y'@tD + c y@tD == f@tD
5.2 c y@tD + b y¢ @tD + y² @tD == f@tD
y'@0D
Replace all the functions involved by their Laplace transforms:
3.7
laplaced = diffeq •.
Everything checks. 8y@tD -> LaplaceTransform@y@tD, t, sD,
y'@tD -> LaplaceTransform@y'@tD, t, sD,
Amazing thing this Laplace transform. y''@tD -> LaplaceTransform@y''@tD, t, sD,
f@tD -> LaplaceTransform@f@tD, t, sD<
áB.2.c) Using the Laplace transform to solve a forced oscillator c LaplaceTransform@y@tD, t, sD + s2 LaplaceTransform@y@tD, t, sD +
b Hs LaplaceTransform@y@tD, t, sD - y@0DL - s y@0D - y¢ @0D ==
diffeq LaplaceTransform@f@tD, t, sD
You are using Mathematica to handle the Laplace transform. Solve this for the Laplace Transform of y@tD:
How was it done in your grandparents' diffeq class? sol = Solve@laplaced, LaplaceTransform@y@tD, t, sDD
á Answer:
99LaplaceTransform@y@tD, t, sD ®
In your grandparents' time, they would look at a diffeq such as -LaplaceTransform@f@tD, t, sD - b y@0D - s y@0D - y¢ @0D
€ ==
- €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
c + b s + s2

There is is.
y² @tD + 2.0 y¢ @tD + 6.5 y@tD = 9.1 E-1.9 t This tells you that the Laplace transform Y@sD of the solution y@tD is
with y@0D = 1.5 and y¢ @0D = -4.7 . LaplaceTransform@f@tD,t,sD + b y@0D+ s y@0D+ y @0D
Y@sD = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

¢

c+ b s+s2
and write down

55
DE.03.B2®B3
f@tD 4 cycles
which is exactly the formula used in part b). 0.6

0.4

0.2
B.3) Fourier fit of periodic functions One Period
t
1 2 3 4
áB.3.a)
Look at these:
áFunction 4:
áFunction 1: Clear@f, tD;
Clear@f, tD; f@t_D = Sign@Sin@3 tDD;
f@t_D = Cos@2 p tD; 2p
L = €€€€€€€€€ ;
L = 1; 3
cycles = 2; cycles = 3;
PlotAf@tD, 8t, 0, cycles L<, PlotStyle ® 88Thickness@0.02D, Blue<<,
AxesLabel ® 8"t", "f@tD"<, PlotLabel ® "cycles" cycles, PlotAf@tD, 8t, 0, cycles L<,
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<, PlotStyle ® 88Thickness@0.02D, Blue<<, AxesLabel ® 8"t", "f@tD"<,
L 1
9TextA"One Period", 9 €€€€€ , 0.1=E==E; AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ , PlotLabel ® "cycles" cycles,
2 GoldenRatio
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
f@tD 2 cycles
1 L
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2
0.5 f@tD 3 cycles
One Period 1
0.5 1 1.5 2 t
0.5
-0.5
One Period
-1 t
1 2 3 4 5 6

-0.5

-1
Folks call all of these functions periodic.
How do you recognize periodic functions?
á Answer:

Most folks, like you, just eyeball a plot looking for cycles.
Once you spot a cycle, then you can say that its length L represents one

áFunction 2: period of the function. This gives you


Clear@f, tD; f@t + LD = f@tD for all t¢ s.
t t
f@t_D = €€€€€ - FloorA €€€€€ E; This is the definition that some folks prefer
2 2 when they talk about periodic functions.
L = 2;
cycles = 4;
áB.3.b.i) Fast Fourier fit of periodic functions
PlotAf@tD, 8t, 0, cycles L<, At the December, 1807 meeting of the French Academy of Sciences,
PlotStyle ® 88Thickness@0.02D, Blue<<, AxesLabel ® 8"t", "f@tD"<, mathematician and engineer Joseph Fourier announced that you can
1
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ , approximate an arbitrary function by sums of sine and cosine waves.
GoldenRatio
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
Those in attendance thought he was slightly off his rocker, but
L eventually they were all forced to change their minds because time has
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2 confirmed that Fourier's idea was one of the great scientific
f@tD
1
4 cycles break-throughs of all time. In this problem, you get the opportunity to
get your hands on Fourier's idea in action.
0.8
Go for it.
0.6
Activate these custom Mathematica instructions
0.4
made for your enjoyment and economic use.
They come from the home office to you.
0.2
One Period Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k,
t jump, num, numtab, coeffs, t, LD;
2 4 6 8
1
áFunction 3: jump@n_D := jump@nD = NA €€€€€€€€€ E;
2n
Clear@f, tD; Fvalues@F_, L_, n_D :=
f@t_D = -0.4 + E-1.5 Ht-Floor@tDL ; N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD;
L = 1;
cycles = 4;
numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D;
PlotAf@tD, 8t, 0, cycles L<, 2pIkt

PlotStyle ® 88Thickness@0.02D, Blue<<, AxesLabel ® 8"t", "f@tD"<, Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€
L ,
1 8k, -n + 1, n - 1<E;
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
GoldenRatio coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD,
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<, Part@InverseFourier@listD, Drop@numtab@nD, 1DDD •
L N@Sqrt@Length@listDDD
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2
FastFourierfit@F_, L_, n_, t_D :=
Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD;

56
DE.03.B3
To get an idea of what these new instructions can do for you, look at 1
this plot of a function f@tD whose period is L = 2, plotted for three 0.8
cycles:
0.6
Clear@f, tD;
t t 0.4
f@t_D = CosA1.5 J €€€€€ - FloorA €€€€€ ENE;
2 2 0.2
L = 2;
cycles = 3; t
0.5 1 1.5 2
fplot =
PlotAf@tD, 8t, 0, cycles L<, PlotStyle ® 88Thickness@0.02D, Blue<<, Evidently, Fourierfit@f, n, tD picks 2 n - 1 equally spaced data points off
AxesLabel ® 8"t", "f@tD"<, PlotLabel ® "cycles" cycles,
Epilog ® 98Red, Thickness@0.03D, Line@880, 0<, 8L, 0<<D<, the plot of f@tD between t = 0 and t = L and tries to fit these points with
L a combination of complex exponentials.
9TextA"One Period", 9 €€€€€ , 0.1=E==,
2
AspectRatio ® 1E;
f@tD
1
3 cycles When you kick n up, you get a really good fit:
0.8
n = 8;
FastFourierfit@f, L, n, tD
0.6
0.693549 - H0.0116423 - 0.154929 IL E-I p t - H0.0116423 + 0.154929 IL EI p t +
0.4 H0.0189249 + 0.0711746 IL E-2 I p t + H0.0189249 - 0.0711746 IL E2 I p t +
0.2
H0.0242786 + 0.043772 IL E-3 I p t + H0.0242786 - 0.043772 IL E3 I p t +
ne Period H0.0261085 + 0.0291675 IL E-4 I p t + H0.0261085 - 0.0291675 IL E4 I p t +
1 2 3 4 5 6 t H0.0269223 + 0.0194654 IL E-5 I p t + H0.0269223 - 0.0194654 IL E5 I p t +
Now stay with the same function f@tD: H0.0273257 + 0.0120596 IL E-6 I p t + H0.0273257 - 0.0120596 IL E6 I p t +
H0.0275192 + 0.00578952 IL E-7 I p t + H0.0275192 - 0.00578952 IL E7 I p t
f@tD
t t Clear@realfitD;
CosA1.5 J €€€€€ - FloorA €€€€€ ENE realfit@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD
2 2
0.693549 - 0.0232846 Cos@p tD + 0.0378498 Cos@2 p tD +
Stay with L = 2 and go with n = 4 and look at: 0.0485571 Cos@3 p tD + 0.052217 Cos@4 p tD + 0.0538446 Cos@5 p tD +
n = 4; 0.0546514 Cos@6 p tD + 0.0550385 Cos@7 p tD + 0.309858 Sin@p tD +
FastFourierfit@f, L, n, tD 0.142349 Sin@2 p tD + 0.087544 Sin@3 p tD + 0.0583351 Sin@4 p tD +
0.721126 + H0.0158769 + 0.149139 IL E-I p t + H0.0158769 - 0.149139 IL EI p t + 0.0389307 Sin@5 p tD + 0.0241191 Sin@6 p tD + 0.011579 Sin@7 p tD
H0.0462506 + 0.059115 IL E-2 I p t + H0.0462506 - 0.059115 IL E2 I p t + cycles = 3;
H0.0512009 + 0.0243066 IL E-3 I p t + H0.0512009 - 0.0243066 IL E3 I p t fitplot = PlotA8f@tD, realfit@tD<, 8t, 0, cycles L<,
That ran really fast. PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
AxesLabel ® 8"t", ""<,
Now look at this plot of f@tD and FastFourierfit@f, L, n, tD with 1
n = 4 and L = 2: PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
GoldenRatio
Clear@realfitD; Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
realfit@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD L
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2

0.721126 + 0.0317538 Cos@p tD + 0.0925012 Cos@2 p tD + 0.102402 Cos@3 p tD + 3 cycles


0.298279 Sin@p tD + 0.11823 Sin@2 p tD + 0.0486133 Sin@3 p tD
1
See how realfit@tD plots out: 0.8
fitplot = PlotA8f@tD, realfit@tD<, 8t, 0, cycles L<,
0.6
PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
AxesLabel ® 8"t", ""<, 0.4
1 0.2
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ , One Period
GoldenRatio t
1 2 3 4 5 6
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
L
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
Hot plot.
2
3 cycles

1 And you get an extra benefit:


0.8
When you put the period L of f@tD into the FastFourierFit@f, L, t, nD
0.6

0.4
instruction, then the periods of the complex exponentials used by the fit
0.2 match the period of the forcing function f@tD, and you continue to get
One Period
1 2 3 4 5 6
t
that good fit all the way:
What's happening here? cycles = 8;
á Answer: fitplot = PlotA8f@tD, realfit@tD<, 8t, 0, cycles L<,
PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
Look at this embellished plot of the first cycle still going with L = 2 AxesLabel ® 8"t", ""<,
1
and n = 4: PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
GoldenRatio
first = Plot@8f@tD, realfit@tD<, 8t, 0, L<, Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
PlotStyle ® 88Thickness@0.01D, Blue<, 8Thickness@0.01D, Red<<, L
AxesLabel ® 8"t", ""<, DisplayFunction ® IdentityD; 9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2
L L
fdata = TableAN@8t, f@tD<D, 9t, 0, L - €€€€€€€€€€€€€€€€€€ , €€€€€€€€€€€€€€€€€€ =E; 8 cycles
2n-1 2n-1
fdataplot = ListPlot@fdata, 1
PlotStyle ® PointSize@0.04D, DisplayFunction ® IdentityD; 0.8
Show@first, fdataplot, DisplayFunction ® $DisplayFunctionD;
0.6

0.4

0.2
e Period
t
2.5 5 7.5 10 12.5 15

You've got to agree that Fourier knew what he was talking about.

57
DE.03.B3®B4
f@tD
áB.3.b.ii) 5
4
You could use the Mathematica Fit instruction to get the same effect 3
as the FastFourierfit instruction. 2
1
Why would anyone want this new FastFourierfit instruction? t
2 4 6 8 10 12 14
á Answer:
And you are asked to come up with a formula for the solution of
When you try to fit using many data points, the Fit instruction can bog y² @tD + 1.8 y¢ @tD + 8.3 y@tD = f@tD
with y@0D = 4.7 and y¢ @0D = -0.9.
down badly.
First you enter everything:
On the other hand, the FastFourierfit instruction really smokes. b = 1.8;
c = 8.3;
Try it out on another function whose period is 2 p. startery = 4.7;
Clear@f, n, tD starteryprime = -0.9;
f@t_D = ESin@tD ; Clear@t, yD;
FastFourierfit@f, 2 p, 4, tD
oscdiffeq = 8y''@tD + b y'@tD + c y@tD == f@tD,
1.26607 + 0.565161 I E-I t - 0.565161 I EI t - 0.13577 E-2 I t - 0.13577 E2 I t - y@0D == startery, y'@0D == starteryprime<;
0.0224399 I E-3 I t + 0.0224399 I E3 I t ColumnForm@oscdiffeqD
FastFourierfit@f, 2 p, 8, tD 8.3 y@tD + 1.8 y¢ @tD + y² @tD == 5.3 Sin@3 H €€€€
t - Floor@ €€€€
t DLD
2 2
1.26607 + 0.565159 I E-I t - 0.565159 I EI t - 0.135748 E-2 I t - 0.135748 E2 I t - y@0D == 4.7
0.0221684 I E-3 I t + 0.0221684 I E3 I t + 0.00273712 E-4 I t + 0.00273712 E4 I t + ¢
y @0D == -0.9
0.000271463 I E-5 I t - 0.000271463 I E5 I t - 0.0000224889 E-6 I t - Then you see how the solution plots out:
0.0000224889 E6 I t - 1.60474 ´ 10-6 I E-7 I t + 1.60474 ´ 10-6 I E7 I t
ndsol = NDSolve@oscdiffeq, y@tD, 8t, 0, endtime<, MaxSteps ® 2000D;
FastFourierfit@f, 2 p, 12, tD Clear@ysolD;
-I t It -2 I t 2It
1.26607 + 0.565159 I E - 0.565159 I E - 0.135748 E - 0.135748 E -
0.0221684 I E-3 I t + 0.0221684 I E3 I t + 0.00273712 E-4 I t + 0.00273712 E4 I t + ysol@t_D = y@tD •. ndsolP1T; ndsplot =
0.000271463 I E -5 I t
- 0.000271463 I E 5It
- 0.0000224887 E -6 I t
- Plot@ysol@tD, 8t, 0, endtime<, PlotStyle ® 88Thickness@0.02D, Blue<<,
PlotRange ® All, AxesLabel ® 8"t", "y@tD"<D;
0.0000224887 E6 I t - 1.59922 ´ 10-6 I E-7 I t + 1.59922 ´ 10-6 I E7 I t +
y@tD
9.96062 ´ 10-8 E-8 I t + 9.96062 ´ 10-8 E8 I t + 5.51839 ´ 10-9 I E-9 I t -
5.51839 ´ 10-9 I E9 I t - 2.75296 ´ 10-10 E-10 I t - 2.75296 ´ 10-10 E10 I t 4
3
Almost instant responses. 2
1
t
2 4 6 8 10 12 14
-1
The demands of modern science made it essential to be able to do About what you expected.
Fourier fits as fast as possible. In fact, fast Fourier fits continue to play Now the job is to come up with a formula for this solution.
the starring role in most everything electronic including hot fields such You try the convolution integral method and Mathematica bogs down.
The integrals are just too complicated.
as signal analysis, data compression and high definition television.

The ideas behind the workings of a fast Fourier fit instruction have Then you think of the LapalceTransform and experiment with the
Laplace transform of f@tD:
attracted the attention of some of the best mathematical scientists of all LaplaceTransform@f@tD, t, sD
time. None other than Gauss came up with a fast Fourier fit algorithm t t
5.3 LaplaceTransform ASinA3 J €€€€€ - FloorA €€€€€ ENE, t, sE
2 2
in 1866. The modern version of the workings behind the fast Fourier Mathematica again balks.
fit sprang out of the 1960's with the work by John Tukey and his The integrals involved are just to complicated.
What do you do?
cohorts at IBM and Princeton. á Answer:
In their book, "Numerical Methods and Software" (Prentice-Hall, 1989),
David Kahner, Cleve Moler and Stephen Nash say Instead of solving
"Many knowledgeable people feel that [Tukey's fast Fourier fit] is
the single most important contribution to computing since y² @tD + 1.8 y¢ @tD + 8.3 y@tD = f@tD
the advent of the stored programming concept."
with y@0D = 4.7 and y¢ @0D = -0.9,
Those who want to study Tukey's idea should look at this book.
you use Fourier fit to come up with a good sine and cosine wave
Mathematica's workings behind the FastFourierfit instruction depend
approximation, approxf@tD, of f@tD and then you use the Laplace
heavily on Tukey's idea.
Transform to solve the nearby oscillator diffeq
B.4) Combining Fourier fit and the Laplace transform to y² @tD + 1.8 y¢ @tD + 8.3 y@tD = approxf@tD

come up with good approximate formulas for periodically with y@0D = 4.7 and y¢ @0D = -0.9.
Here you go:
forced oscillators
Activate this code:
"A cumbersome [exact] formula that gives a solution in explicit form is Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k,
frequently less useful than a simple approximate formula."
jump, num, numtab, coeffs, t, LD;
--------DiffEq master V. I. Arnold
1
jump@n_D := jump@nD = NA €€€€€€€€€ E;
2n
áB.4.a) Fvalues@F_, L_, n_D :=
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD;
You are given this periodic forcing function f@tD:
endtime = 15.0;
Clear@f, tD numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D;
t t
f@t_D = 5.3 SinA3 J €€€€€ - FloorA €€€€€ ENE; 2pIkt
2 2 Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€
L ,
fplot = Plot@f@tD, 8t, 0, endtime<,
8k, -n + 1, n - 1<E;
PlotStyle ® 88Thickness@0.02D, Blue<<, AxesLabel ® 8"t", "f@tD"<D;
coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD,
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD •
N@Sqrt@Length@listDDD

58
DE.03.B4®B5
FastFourierfit@F_, L_, n_, t_D := y@tD
Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD;
4
3
Look at 2
1
Show@fplotD; t
f@tD 2 4 6 8 10 12 14
-1
5
4 Both plots are fakes but they are both very good fakes.
3
2
1
t
B.5) Fourier integral fit of periodic functions
2 4 6 8 10 12 14

The period of this function is L = 2. Here's how you can use integrals to go after a Fourier fit on an interval
@0, LD:
Get a good Fourier fit of f@tD: Start with the function and its plot on @0, LD:
L = 2; Clear@f, tD
n = 3; f@t_D = Sin@p tD Ht - 4L;
Clear@approxfD; L = 4;
approxf@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD Plot@f@tD, 8t, 0, L<, PlotStyle ® 88Thickness@0.02D, Blue<<,
fitplot = PlotA8f@tD, approxf@tD<, 8t, 0, endtime<, PlotStyle ® AxesLabel ® 8"t", "f@tD"<D;
88Thickness@0.02D, Blue<, 8Thickness@0.01D, CadmiumOrange<<,
f@tD
1
AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ E; 2
GoldenRatio
3.37978 - 2.35661 Cos@p tD - 0.736414 Cos@2 p tD - 0.285912 Sin@p tD - 1
0.0783657 Sin@2 p tD 1 2 3 4t
5 -1
-2
4
-3
3

2
To try to fit f@tD on @0, LD, you fit with combinations of
Ik2pt
E €€€€€€€€€€€€€€€€€
L €
1
this way:
2 4 6 8 10 12 14 Clear@A, tD
L I k H2 pL t

Nice fit: Ù0 f@tD E- €€€€€€€€€€€€€€€€€€€€ L



ât
A@k_D := NA €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ E;
L
Now move in with the Laplace transform to get a formula for the Clear@k, complexfitterD
m = 5;
solution of m
I k H2 pL t
complexfitter@t_D = ChopA â A@kD E €€€€€€€€€€€€€€€€€€€€
L

E
k=-m

y² @tD + 1.8 y¢ @tD + 8.3 y@tD = approxf@tD

1 Ipt

with y@0D = 4.7 and y¢ @0D = -0.9. -0.31831 - 0.424413 E- €€€2€ I p t - 0.424413 E €€€€€€€€€€
2
- H0.0795775 + 1. IL E-I p t -
3 3Ipt
H0.0795775 - 1. IL EI p t + 0.254648 E- €€€€2 I p t + 0.254648 E €€€€€€€€€€€€€
2 +
Here you go: 0.106103 E -2 I p t
+ 0.106103 E 2Ipt
+ 0.0606305 E
5
- €€€€
2 Ip t
5Ipt
+ 0.0606305 E €€€€€€€€€€€€€
2

Clear@f, t, approxY, approxy, sD Clear@realfitter, tD


b = 1.8; c = 8.3; realfitter@t_D = Chop@ComplexExpand@complexfitter@tDDD
f@t_D = approxf@tD; pt 3pt
ystarter = 4.7; yprimestarter = 0.9; -0.31831 - 0.848826 CosA €€€€€€€€€ E - 0.159155 Cos@p tD + 0.509296 CosA €€€€€€€€€€€€€€ E +
2 2
1 5pt
approxY@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD + 0.212207 Cos@2 p tD + 0.121261 CosA €€€€€€€€€€€€€€ E - 2. Sin@p tD
s2 + b s + c 2
b ystarter + s ystarter + yprimestarterL Check out the fit with a plot:
3.37978€ + 4.7 s - €€€€€€€€€€€€€€€€€€€ 0.898218€ - €€€€€€€€€€€€€€€€€€€€
2.35661 s€ - €€€€€€€€€€€€€€€€€€€€
0.492386 - €€€€€€€€€€€€€€€€€€€€€€€
0.736414 s
9.36 + €€€€€€€€€€€€€€€€€ s p2 +s2 p2 +s2 4 p2 +s2 4 p2 +s2 Plot@8f@tD, realfitter@tD<, 8t, 0, L<,
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
8.3 + 1.8 s + s2 PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
AxesLabel ® 8"t", ""<D;
This is the Laplace transform of the the approximate solution.
To get the formula for the approximate solution, approxy@tD. you 2
1
calculate the inverse Laplace transform of approxY@sD.
1 2 3 4t
The formula for the solution approxy@tD is: -1
-2
approxy@t_D = Chop@Expand@InverseLaplaceTransform @approxY@sD, s, tDDD
-3
0.407202 + 4.11678 E-0.9 t Cos@2.73679 tD + 0.154343 Cos@p tD +
0.0216786 Cos@2 p tD + 2.12415 E-0.9 t Sin@2.73679 tD - 0.3739 Sin@p tD -
0.00535028 Sin@2 p tD The periodic nature of the Fourier fit ruins the fit at the ends, but
There it is! inside @0, LD, the fit is not all that bad.
A simple approximate formula for the solution. áB.5.a)
See it: How do you try to go after a better fit?
approxplot = Plot@approxy@tD, 8t, 0, endtime<, á Answer:
PlotStyle ® 88Thickness@0.01D, Red<<, PlotRange ® All,
AxesLabel ® 8"t", "y@tD"<D; The same way you go after a better fast Fourier fit: You increase m.
y@tD
Try it:
4
Clear@A, tD
3 I k H2 pL t

2 NIntegrateAf@tD E- €€€€€€€€€€€€€€€€€€€€ L

, 8t, 0, L<E
A@k_D := A@kD = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ;
1 L
t Clear@k, complexfitterD
2 4 6 8 10 12 14
-1 m = 13;
Compare with what you got from NDSolve: m
I k H2 pL t
complexfitter@t_D = ChopA â A@kD E €€€€€€€€€€€€€€€€€€€€
L

E
Show@ndsplot, approxplotD; k=-m

59
DE.03.B5
Ipt
- €€€12€ Ipt €€€€€€€€€€
-0.31831 - 0.424413 E - 0.424413 E 2
- H0.0795775 + 1. IL E-I p t - Clear@p, fD
3 3Ipt L
H0.0795775 - 1. IL EI p t + 0.254648 E- €€€€2 I p t + 0.254648 E €€€€€€€€€€€€€
2 + ColumnFormATableA9ExpandAà complexfitter@tD E- €€€€€€€€€€€€€€€€€€€€
L
€ I p H2 pL t
â tE,
5 5Ipt
0.106103 E-2 I p t + 0.106103 E2 I p t + 0.0606305 E- €€€€2 I p t + 0.0606305 E €€€€€€€€€€€€€
2 + 0
7 7Ipt L
0.0397887 E-3 I p t + 0.0397887 E3 I p t + 0.0282942 E- €€€€2 I p t + 0.0282942 E €€€€€€€€€€€€€
2 + L
I p H2 pL t
" must be", à f@tD E- €€€€€€€€€€€€€€€€€€€€

â t=,
9 9Ipt
-4 I p t 4Ipt - €€€€
2 I pt €€€€€€€€€€€€€ 0
0.0212207 E + 0.0212207 E + 0.0165356 E + 0.0165356 E 2 +
11 11 I p t 8p, -m, m<EE
0.0132629 E-5 I p t + 0.0132629 E5 I p t + 0.0108824 E- €€€€€€
2 I p t + 0.0108824 E €€€€€€€€€€€€€€€
2 +
13 13 I p t L 6Ipt
0.00909457 E-6 I p t + 0.00909457 E6 I p t + 0.0077166 E- €€€€€€
2 I p t + 0.0077166 E €€€€€€€€€€€€€€€
2 9L A@-3D, must be, Ù E €€€€€€€€€€€€€
L f@tD â t=
0
Clear@realfitter, tD L 4Ipt
9L A@-2D, must be, Ù E €€€€€€€€€€€€€
L f@tD â t=
realfitter@t_D = Chop@ComplexExpand@complexfitter@tDDD 0
L 2Ipt
pt 3pt 9L A@-1D, must be, Ù E €€€€€€€€€€€€€
L f@tD â t=
-0.31831 - 0.848826 CosA €€€€€€€€€ E - 0.159155 Cos@p tD + 0.509296 CosA €€€€€€€€€€€€€€ E + 0
2 2 L
9L A@0D, must be, Ù f@tD â t=
5pt 0
0.212207 Cos@2 p tD + 0.121261 CosA €€€€€€€€€€€€€€ E + 0.0795775 Cos@3 p tD + L 2Ipt
2 9L A@1D, must be, Ù E- €€€€€€€€€€€€€
L f@tD â t=
7pt 9pt 0
0.0565884 CosA €€€€€€€€€€€€€€ E + 0.0424413 Cos@4 p tD + 0.0330712 CosA €€€€€€€€€€€€€€ E + L - €€€€€€€€€€€€€
4Ipt
2 2 9L A@2D, must be, Ù E L f@tD â t=
0
11 p t
0.0265258 Cos@5 p tD + 0.0217648 CosA €€€€€€€€€€€€€€€€€ E + 0.0181891 Cos@6 p tD + 9L A@3D,
L 6Ipt
must be, Ù E- €€€€€€€€€€€€€
L f@tD â t=
2 0
13 p t
0.0154332 CosA €€€€€€€€€€€€€€€€€ E - 2. Sin@p tD
2 Your eyes lead you to the formula
L I k H2 pL t
1
Check out the fit with a plot: A@kD = €€€€€
L Ù0
f@tD E- €€€€€€€€€€€€€€€€€€€€€
L € â t.

Plot@8f@tD, realfitter@tD<, 8t, 0, L<,


PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
This is the formula that was used in part i) so successfully.
AxesLabel ® 8"t", ""<D; Explanation over.
2 áB.5.b.ii)
1
Not so fast.
4t
-1
1 2 3
Wasn't this supposed to be a math course?
-2
You know very well that a false assumption like
-3 f@tD = complexfitter@tD
can be used to explain anything.
How do you justify this false assumption?
That's almost as good as it can get. If f@0D had been the same as f@LD,
á Answer:
then the trouble near the endpoints would have disappeared.
Good question.
The reason it works is that it is almost true.
Reason: For most functions f@tD with period L, only a bureaucratic
bean-counter armed with a good magnifying glass could ever tell the

áB.5.b.i) The formula difference between f@tD and the complexfitter you get with a very high
L I k H2 pL t
1
A@kD = €€€€€ €
L Ù0
f@tD E- €€€€€€€€€€€€€€€€€€€€€€
L

ât m.
What's the idea behind the formula Try it on
1 L I k H2 pL t •!!!!!!!!!!!!!!!!!!!!!
A@kD = €€€€€
L Ù0
f@tD E- €€€€€€€€€€€€€€€€€€€€€
L € ât f@tD = 1 - Cos@p tD
as used above? Because the period of Cos@tD is 2 p, the period of f@tD is L = 2.
á Answer:
Clear@f, t, xD
•!!!!!!!!!!!!!!!!!!!!!!!!!
The idea: f@t_D = 1 - Cos@p tD ;
L = 2;
You go for the whole ball of wax in one gulp. m = 6;
Clear@k, complexfitter, AD
Given a function f@tD with period L, you go ahead and assume that f@tD 1 I k H2 pL x
A@k_D := NA €€€€€ E NIntegrateAf@xD E- €€€€€€€€€€€€€€€€€€€€
L

, 8x, 0, L<, AccuracyGoal ® 3E;
can be written in a form like this: L
m
I k H2 pL t
m = 3; complexfitter@t_D = ChopA â A@kD E €€€€€€€€€€€€€€€€€€€€
L

E
Clear@k, f, complexfitter, A, LD k=-m
m
Ik2p t
0.900316 - 0.300105 E-I p t - 0.300105 EI p t - 0.0600211 E-2 I p t -
complexfitter@t_D = â A@kD E €€€€€€€€€€€€€€€€
L
0.0600211 E2 I p t - 0.0257233 E-3 I p t - 0.0257233 E3 I p t -
k=-m
6Ipt 4Ipt 2Ipt 2Ipt
0.0142907 E-4 I p t - 0.0142907 E4 I p t - 0.0090941 E-5 I p t -
E- €€€€€€€€€€€€€
L A@-3D + E- €€€€€€€€€€€€€
L A@-2D + E- €€€€€€€€€€€€€
L A@-1D + A@0D + E €€€€€€€€€€€€€
L A@1D + 0.0090941 E5 I p t - 0.00629592 E-6 I p t - 0.00629592 E6 I p t
4Ipt 6Ipt
€€€€€€€€€€€€€ €€€€€€€€€€€€€
E L A@2D + E L A@3D
This time the A@kD's are calculated with NIntegrate.
Once you go with the assumption that f@tD = complexfitter@tD, you gotta Clear@realfitter, tD
realfitter@t_D = Chop@ComplexExpand@complexfitter@tDDD
agree that 0.900316 - 0.600211 Cos@p tD - 0.120042 Cos@2 p tD - 0.0514466 Cos@3 p tD -
0.0285815 Cos@4 p tD - 0.0181882 Cos@5 p tD - 0.0125918 Cos@6 p tD
L I p H2 pL t L I p H2 pL t cycles = 4;
- €€€€€€€€€€€€€€€€€€€€€€ - €€€€€€€€€€€€€€€€€€€€€€
Ù0 complexfitter@tD E L â t = Ù0 f@tD E L â t, Plot@8f@tD, realfitter@tD<, 8t, 0, L<,
PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
AxesLabel ® 8"t", ""<, PlotRange ® AllD;

no matter what p you go with. 1.4


1.2
Peek at what this tells you: 1
0.8
This might take a while.
0.6
0.4
0.2
t
0.5 1 1.5 2

Tell that miserable bean-counter to get out of your life.

60
DE.03.B5

áB.5.c.i) The connection between fast Fourier Fit and Fourier áAnswer:
integral fit The Achilles heel of the Fourier integral fit is the integral
Go with f@tD = t H3 - tL on @0, LD with L = 3 and compare what you get 1
€€€€€
L
f@tD E- €€€€€€€€€€€€€€€€€€€€€
L € ât
I k H2 pL t

L Ù0
from Fourier integral fit and fast Fourier fit.
Clear@f, tD
that must be done to calculate the coefficients. For some functions f@tD,
f@t_D = t H3 - tL;
the only practical possibility is to go with NIntegrate. But the highly
L = 3;
Clear@A, tD
I k H2 pL t
oscillatory nature of
L
Ù0 f@tD E- €€€€€€€€€€€€€€€€€€€€L

ât I k H2 pL t
A@k_D := A@kD = NA €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ E; f@tD E- €€€€€€€€€€€€€€€€€€€€€
L €
L
Clear@k, complexintegralfitter D sometimes makes the integrals impractical even for for NIntegrate.
m = 5;
m
I k H2 pL t
complexintegralfitter @t_D = ChopA â A@kD E €€€€€€€€€€€€€€€€€€€€
L

E
k=-m Fast Fourier fit carries none of this disappointing baggage. It runs
2 2Ipt 4
1.5 - 0.455945 E- €€€€3 I p t - 0.455945 E €€€€€€€€€€€€€
3 - 0.113986 E- €€€€3 I p t -
4Ipt
€€€€€€€€€€€€€ 8 quickly and accurately, provided no impulses are around.
0.113986 E 3 - 0.0506606 E-2 I p t - 0.0506606 E2 I p t - 0.0284966 E - €€€€
3 Ipt
-
8Ipt 10 10 I p t
€€€€€€€€€€€€€ - €€€€€€
3 I p t €€€€€€€€€€€€€€€
0.0284966 E 3 - 0.0182378 E - 0.0182378 E 3
áB.5.c.iii)
n = m + 1;
FastFourierfit@f, L, n, tD Why do folks want to do Fourier integral fit?
2 2Ipt 4
1.48958 - 0.466506 E- €€€€3 I p t - 0.466506 E €€€€€€€€€€€€€
3 - 0.125 E- €€€€3 I p t - á Calculational Answer:
4Ipt 8
€€€€€€€€€€€€€ -2 I p t 2Ipt
0.125 E 3 - 0.0625 E - 0.0625 E - 0.0416667 E- €€€€3 I p t -
8Ipt 10 10 I p t
If the professors demand that the students work by hand, then the
0.0416667 E €€€€€€€€€€€€€
3 - 0.0334936 E- €€€€€€
3 I p t - 0.0334936 E €€€€€€€€€€€€€€€
3

They are almost the same. student has little choice between Fourier integral fit and fast Fourier fit.
Subtract them: Reason:
Expand@complexintegralfitter@tD - FastFourierfit@f, L, n, tDD
2
- €€€€ Ipt 2Ipt
€€€€€€€€€€€€€ 4
- €€€€ Ipt
Doing fast Fourier fit by hand is completely out of the question.
0.0104167 + 0.010561 E 3 + 0.010561 E 3 + 0.0110137 E 3 +
0.0110137 E
4Ipt
€€€€€€€€€€€€€
3 + 0.0118394 E -2 I p t
+ 0.0118394 E 2Ipt
+ 0.0131701 E
8
- €€€€
3 I p t + Doing integrals by hand is not.
8Ipt 10 10 I p t
0.0131701 E €€€€€€€€€€€€€
3 + 0.0152558 E- €€€€€€
3 I p t + 0.0152558 E €€€€€€€€€€€€€€€
3
á Theoretical Answer:
Look at those puny coefficients reflecting how close the fast Fourier
fit is to the Fourier integral fit. In theoretical situations, most good folks want to use the Fourier
Try it again with a bigger m: integral fit because it gives them a specific formula to work with. But
after the theory is developed and calculations begin, then the same
folks usually go with fast Fourier fit.

Clear@k, complexintegralfitter D
m = 10; áB.5.d.i) The advantage of fast Fourier fit over Fourier integral fit
m
I k H2 pL t
€€€€€€€€€€€€€€€€€€€€
€ In their book, "Numerical Methods and Software" (Prentice-Hall, 1989),
complexintegralfitter @t_D = ChopA â A@kD E L E; David Kahner, Cleve Moler and Stephen Nash say
k=-m "Many knowledgeable people feel that [fast Fourier fit] is
n = m + 1; the single most important contribution to computing since
Expand@complexintegralfitter@tD - FastFourierfit@f, L, n, tDD the advent of the stored programming concept."
2
0.00309917 + 0.00311185 E- €€€€3 I p t + 0.00311185 E €€€€€€€€€€€€€
3 +
2Ipt
Fourier integral fit has been around for more than 200 years.
4 4Ipt
0.00315039 E - €€€€
3 Ip t + 0.00315039 E €€€€€€€€€€€€€
3 + 0.00321633 E-2 I p t + Fast Fourier fit has been around less than 50 years and really came
8 8Ipt
0.00321633 E2 I p t + 0.00331238 E- €€€€3 I p t + 0.00331238 E €€€€€€€€€€€€€
3 + into its own with the computer revolution of which you are a part.
10 10 I p t
0.00344268 E- €€€€€€
3 I p t + 0.00344268 E €€€€€€€€€€€€€€€
3 + 0.00361324 E-4 I p t + Why are many compuer-literate folks so quick to de-emphasize
14 14 I p t
0.00361324 E4 I p t + 0.00383251 E- €€€€€€
3 I p t
+ 0.00383251 E €€€€€€€€€€€€€€€
3
+ Fourier integral fit in favor of fast Fourier fit?
16 16 I p t
0.00411247 E- €€€€€€
3 I p t + 0.00411247 E €€€€€€€€€€€€€€€
3 + 0.00447017 E-6 I p t +
20 20 I p t
á Answer:
0.00447017 E6 I p t + 0.00493027 E- €€€€€€
3 I p t + 0.00493027 E €€€€€€€€€€€€€€€
3

How do you explain this striking similarity of the two Fourier fits? The Achilles heel of the Fourier integral fit is the integral
L I k H2 pL t
1
á Answer: €€€€€
L Ù0
f@tD E- €€€€€€€€€€€€€€€€€€€€€
L € ât

The fast Fourier fit tries to fit at equally spaced points on the plot of which must be done to calculate the coefficients of the approximation.
f@tD on @0, LD. Even with Mathematica, these integrals can either be very slow or
impossible. Numerical integration (via the NIntegrate instruction) is
When you go with a high n in FastFourierfit@f, L, n, tD, you are fitting theoretically possible, but the highly oscillatory nature of
I k H2 pL t
so many densely packed points that FastFourierfit@f, L, n, tD is almost f@tD E- €€€€€€€€€€€€€€€€€€€€€
L €

fitting all the points on the plot of f@tD on @0, LD. sometimes makes the integrals impractical even for for numerical
integration.
This nearly replicates the Fourier integral fit of f@tD on @0, LD because
the Fourier integral fit tries to fit all the points on the plot of f@tD on Fast Fourier fit does not care how the function is presented and it
@0, LD. doesn't care about doing any integrals. Fast Fourier works rapidly and
áB.5.c.ii) Practicalities well for any function - other than impulse hits.
Explain the following statement: It is robust and fast.
"Fast Fourier fit is almost always fast and practical; Fourier integral fit Compare them on the square wave:
is sometimes slow and sometimes impractical and even impossible." Clear@f, tD
f@t_D = Sign@Sin@p tDD + 1;
L = 2;

61
DE.03.B5®T1
cycles = 4; 4 cycles
fplot = PlotAf@tD, 8t, 0, cycles L<,
2
PlotStyle ® 88Thickness@0.02D, Blue<<, AxesLabel ® 8"t", "f@tD"<,
1 1.5
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
GoldenRatio
1
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
L 0.5
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2 One Period
f@tD t
4 cycles 2 4 6 8
2
The calculation of the integral fit took a lot longer than the calculation
1.5
of the fast fit.
1
Fast Fourier fit went through this like a hot knife in butter.
0.5
Fourier integral fit went through this like a butter knife cutting steak.
One Period
t
2 4 6 8
áB.5.d..ii)
Go for a fast Fourier fit:
If you are working with hand calculations only, why is Fourier
n = 6; Clear@fastapproxfD
fastapproxf@t_D = FastFourierfit@f, L, n, tD
integral fit your only real choice?
1.08333 - H0.0833333 - 0.622008 IL E-I p t - H0.0833333 + 0.622008 IL EI p t + á Answer:
0.0833333 E-2 I p t + 0.0833333 E2 I p t - H0.0833333 - 0.166667 IL E-3 I p t -
Fast Fourier fit involves solving many linear equations. Solving these
H0.0833333 + 0.166667 IL E3 I p t + 0.0833333 E-4 I p t + 0.0833333 E4 I p t -
H0.0833333 - 0.0446582 IL E-5 I p t - H0.0833333 + 0.0446582 IL E5 I p t equations by hand is just out of the question.
Check it out: This leaves you no choice but Fourier integral fit. That's why you often
Clear@realfitD
realfit@t_D = Chop@ComplexExpand@fastapproxf@tDDD;
see the Fourier integral fit in the old-fashioned courses that emphasize
fastfitplot = PlotA8f@tD, realfit@tD<, 8t, 0, cycles L<, hand calculation.
PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
AxesLabel ® 8"t", ""<,
1
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
GoldenRatio
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
L
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2

4 cycles

2 DE.03 Laplace Transform and Fourier


1.5 Analysis
1 Tutorials
0.5
One Period t
2 4 6 8
T.1) Using Fourier Fit to try to detect periodic forcing
Now do the same thing with the integral Fourier fit: functions that force some undamped oscillators to beat or go
Try numerical integration via NIntegrate. into near or true resonance
Clear@A, tD;
NIntegrateAf@tD E- €€€€€€€€€€€€€€€€€€€€ L
I k H2 pL t

, 8t, 0, L<E áT.1.a.i)
A@k_D := A@kD = NA €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ E;
L Activate this code.
Clear@k, integralfitterD
Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k,
m = 5;
jump, num, numtab, coeffs, t, LD;
m
I k H2 pL t
integralfitter@t_D = ChopA â A@kD E €€€€€€€€€€€€€€€€€€€€

E 1
L
jump@n_D := jump@nD = NA €€€€€€€€€ E;
k=-m 2n
NIntegrate::ncvb : NIntegrate failed to converge to prescribed accuracy after 7 Fvalues@F_, L_, n_D :=
recursive bisections in t near t = 2.58979720715110728`*^-12. N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD;
1. + 0.63662 I E-I p t - 0.63662 I EI p t + 0.212207 I E-3 I p t -
0.212207 I E3 I p t + 0.127324 I E-5 I p t - 0.127324 I E5 I p t
numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D;
This gives an answer, but Mathematica is telling you that it doesn't
2pIkt
Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€
L ,
quite trust the answer.
8k, -n + 1, n - 1<E;
Check it out: coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD,
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD •
Clear@realfitD
N@Sqrt@Length@listDDD
realfit@t_D = Chop@ComplexExpand@integralfitter@tDDD;
integralfitplot = PlotA8f@tD, realfit@tD<, 8t, 0, cycles L<,
FastFourierfit@F_, L_, n_, t_D :=
PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<, Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD;
AxesLabel ® 8"t", ""<,
1 Look at this periodic function f@tD:
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
GoldenRatio Clear@f, tD;
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<, f@t_D = 14.8 H0.35 t - Round@0.35 tDL2 ;
L thigh = 12;
9TextA"One Period", 9 €€€€€ , 0.1=E==E; fplot =
2
PlotAf@tD, 8t, 0, thigh<, PlotStyle ® 88Thickness@0.02D, Blue<<,
1
PlotRange ® All, AxesLabel ® 8"t", "f@tD"<, AspectRatio ® €€€€€ E;
2

62
DE.03.T1
f@tD f@t_D = approxf@tD;
3.5 ystarter = Random@Real, 8-1, 1<D;
3 yprimestarter = Random@Real, 8-1, 1<D;
2.5 1
approxY@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD +
2 s2 + b s + c
1.5 b ystarter + s ystarter + yprimestarterL;
1 approxy@t_D =
0.5 Chop@Expand@InverseLaplaceTransform @approxY@sD, s, tDDD;
t
2 4 6 8 10 12
approxplot = Plot@approxy@tD, 8t, 0, endtime<,
Now look at this fast Fourier fit of f@tD: PlotStyle -> 88Thickness@0.01D, Red<<, PlotPoints -> 2 endtime,
1 AspectRatio -> 1 • GoldenRatio,
L = €€€€€€€€€€€€€€ ;
0.35 PlotRange -> All, AxesLabel -> 8"t", "y@tD"<, PlotLabel -> cD;
n = 7; y@tD
5.00392
Clear@approxfD;
15
approxf@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD
10
fitplot = PlotA8f@tD, approxf@tD<,
5
1
8t, 0, 20<, AspectRatio ® €€€€€ , PlotRange ® All, PlotStyle ® t
2 20 40 60 80 100 120
-5
88Thickness@0.015D, Blue<, 8Thickness@0.01D, CadmiumOrange<<E;
-10
1.24592 - 1.52498 Cos@2.19911 tD + 0.401106 Cos@4.39823 tD -
-15
0.194244 Cos@6.59734 tD + 0.123532 Cos@8.79646 tD -
0.0930221 Cos@10.9956 tD + 0.0794439 Cos@13.1947 tD Rerun several times.
3.5
3 To find even more resonating c's, look again at the good Fourier fit:
2.5 approxf@tD
2
1.24592 - 1.52498 Cos@2.19911 tD + 0.401106 Cos@4.39823 tD -
1.5 0.194244 Cos@6.59734 tD + 0.123532 Cos@8.79646 tD -
1 0.0930221 Cos@10.9956 tD + 0.0794439 Cos@13.1947 tD
0.5
That fairly big coefficient on the Cos@4.39823 tD term tells you that
5 10 15 20
Use what you see to come up with values of c so that the undamped when you put c = 4.398232 , you can count on the undamped forced
forced oscillator oscillator
y² @tD + c y@tD = f@tD
are fried by going into resonance or near resonance (beating) . y² @tD + c y@tD = f@tD
á Answer: to go into resonance or near resonance (beating) .
Take another look at that good Fourier fit: See it happen:
approxf@tD Clear@f, t, approxY, approxy, sD;
1.24592 - 1.52498 Cos@2.19911 tD + 0.401106 Cos@4.39823 tD - b = 0;
0.194244 Cos@6.59734 tD + 0.123532 Cos@8.79646 tD - c = 4.39823 2 ;
0.0930221 Cos@10.9956 tD + 0.0794439 Cos@13.1947 tD endtime = 80;

f@t_D = approxf@tD;
That big coefficient on the Cos@2.19911 tD term tells you that when you ystarter = Random@Real, 8-1, 1<D;
yprimestarter = Random@Real, 8-1, 1<D;
put c = 2.199112 , you can count on the undamped forced oscillator 1
approxY@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD +
y² @tD + c y@tD = f@tD s2 + b s + c
b ystarter + s ystarter + yprimestarterL;
to go into resonance or near resonance (beating) . approxy@t_D =
Chop@Expand@InverseLaplaceTransform @approxY@sD, s, tDDD;
See it happen:
approxplot = Plot@approxy@tD,
Clear@f, t, approxY, approxy, sD;
8t, 0, endtime<, PlotStyle -> 88Thickness@0.01D, Red<<,
b = 0;
PlotPoints -> 2 endtime, AspectRatio -> 1 • GoldenRatio,
c = 2.19911 2 ; PlotRange -> All, AxesLabel -> 8"t", "y@tD"<, PlotLabel -> c D;
endtime = 120; y@tD
f@t_D = approxf@tD; 19.3444
ystarter = Random@Real, 8-1, 1<D; 3
yprimestarter = Random@Real, 8-1, 1<D; 2
1
approxY@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD + 1
s2 + b s + c t
b ystarter + s ystarter + yprimestarterL; 20 40 60 80
-1
approxy@t_D =
Chop@Expand@InverseLaplaceTransform @approxY@sD, s, tDDD; -2
-3
approxplot = Plot@approxy@tD,
8t, 0, endtime<, PlotStyle -> 88Thickness@0.01D, Red<<, To find even more resonating c's, look again at the good Fourier fit:
PlotPoints -> 2 endtime, AspectRatio -> 1 • GoldenRatio,
approxf@tD
PlotRange -> All, AxesLabel -> 8"t", "y@tD"<, PlotLabel -> c D;
y@tD
1.24592 - 1.52498 Cos@2.19911 tD + 0.401106 Cos@4.39823 tD -
4.83608 0.194244 Cos@6.59734 tD + 0.123532 Cos@8.79646 tD -
40
0.0930221 Cos@10.9956 tD + 0.0794439 Cos@13.1947 tD
20 That fairly big coefficient on the Cos@6.59734 tD term tells you that
20 40 60 80 100 120
t when you put c = 6.597342 , you can count on the undamped forced
-20 oscillator
-40 y² @tD + c y@tD = f@tD
Fried. to go into resonance or near resonance (beating) .
In fact, if you take any c near 2.199112 , See it happen:
then you can still count on resonance or near resonance (beating): Clear@f, t, approxY, approxy, sD
b = 0;
Clear@f, t, approxY, approxy, sD; c = 6.59734 2 ;
b = 0;
endtime = 80;
c = 2.19911 2 + Random@Real, 8-0.3, 0.3<D; f@t_D = approxf@tD;
endtime = 120; ystarter = Random@Real, 8-1, 1<D;

63
DE.03.T1®T3
¢
yprimestarter = Random@Real, 8-1, 1<D; with y@0D = 0 and y @0D = 1.
1
approxY@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD + The Laplace transform, Yzeroinput@tD of yzeroinput@tD is
s2 + b s + c
b ystarter + s ystarter + yprimestarterL; Clear@f, t, b, c, Yzerinput, y, ystarter, yprimestarter, sD
approxy@t_D = ystarter = 0;
Chop@Expand@InverseLaplaceTransform @approxY@sD, s, tDDD; yprimestarter = 0;

approxplot = Plot@approxy@tD, 1
Yzeroinput@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD +
8t, 0, endtime<, PlotStyle -> 88Thickness@0.01D, Red<<, s2 + b s + c
PlotPoints -> 2 endtime, AspectRatio -> 1 • GoldenRatio, b ystarter + s ystarter + yprimestarterL
PlotRange -> All, AxesLabel -> 8"t", "y@tD"<, PlotLabel -> c D; LaplaceTransform@f@tD, t, sD
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
y@tD c + b s + s2
43.5249
Two benefits:
1
® This allows you to write down the Laplace transform of
0.5
yzeroinput@tD directly in terms of the Laplace transform of f@tD and the
20 40 60 80
t coefficients b and c with no extra calculation.
-0.5

-1
® And this reveals that the Laplace transform of yzeroinput@tD is the
same as the product of Laplace transform of f@tD and the Laplace
You get the idea . transform of yunitimpulse@tD:
LaplaceTransform@f@tD, t, sD Yunitimpulse@sD
LaplaceTransform@f@tD, t, sD
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
áT.1.a.ii) c + b s + s2
Is the fact that the Laplace transform of yzeroinput@tD is the same as
Why did that work?
the product of Laplace transform of f@tD and the Laplace transform of
á Answer:
yunitimpulse@tD an accident?
When you go with y² @tD + c2 y@tD = 0 ( with c > 0). á Answer:

the natural output consists of combinations of Get ready.


Cos@c tD and Sin@c tD.
When you force y² @tD + c2 y@tD = 0 with these combinations you get In Mathematics there are no accidents.
² 2
y @tD + c y@tD = A Cos@c tD + B Sin@c tD áT.2.a.ii)
which is guaranteed to be in true resonance. Look at this calculation of the convolution of two cleared functions
So when you see an approximate forcing function such as f@tD and g@tD:
Clear@f, g, h, t, s, x, yD
2.0 Sin@2 tD - 0.4 Cos@4 tD + 0.5 Sin@6 tD, t
h@t_D = à g@t - xD f@xD â x
then you can be sure that each of the following undamped forceds 0

t
oscillators is in resonance or near resonance: à f@xD g@t - xD â x
0
y''@tD + 4 y@tD = 2.0 Sin@2 tD - 0.4 Cos@4 tD + 0.5 Sin@6 tD, Calculate the Laplace transform of h@tD:
y''@tD + 16 y@tD = 2.0 Sin@2 tD - 0.4 Cos@4 tD + 0.5 Sin@6 tD, and LaplaceTransform@h@tD, t, sD
LaplaceTransform@f@tD, t, sD LaplaceTransform@g@tD, t, sD
y''@tD + 36 y@tD = 2.0 Sin@2 tD - 0.4 Cos@4 tD + 0.5 Sin@6 tD.
This tells you that the Laplace transform of the convolution
t
h@tD = Ù0 f@t - xD g@xD â x
is the Laplace transform of f@tD times the Laplace transform of g@tD.
T.2) The Laplace transform of yzeroinput@tD is the same as
Use this fact to explain why the Laplace transform of yzeroinput@tD is
the product of Laplace transform of f@tD and the Laplace the same as the product of Laplace transform of f@tD and the Laplace
transform of yunitimpulse@tD transform of yunitimpulse@tD.
á Answer:
áT.2.a.i)
Remember that
Given a forced oscillator diffeq t
y² @tD + b y¢ @tD + c y@tD = f@tD, yzeroinput@tD = Ù0 yunitimpulse@t - xD f@xD â x .
you know yunitimpulset@tD solves This is the same as
y² @tD + b y¢ @tD + c y@tD = 0 t
h@tD = Ù0 f@xD g@t - xD â x
with y@0D = 0 and y¢ @0D = 1.
The Laplace transform,Yunitimpulset@tD of yunitimpulset@tD is with g@t - xD = yunitimpulse@t - xD and h@tD = yzeroinput@tD .
Clear@f, t, b, c, Yunitimpulse , y, ystarter, yprimestarter, sD
f@t_D = 0;
ystarter = 0; According to what was said above,the Laplace transform of
yprimestarter = 1; yzeroinput@tD = h@tD
1 is the product of the Laplace transform of yunitimpulse@tD = g@tD and
Yunitimpulse@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD +
s2 + b s + c the Laplace transform of f@tD.
b ystarter + s ystarter + yprimestarterL
1
€€€€€€€€€€€€€€€€€€€€€€€€€€€€

c + b s + s2
Short and sweet.
T.3) A good way of screwing up your Fourier fits
áT.3.a)
Given a forced oscillator diffeq
y² @tD + b y¢ @tD + c y@tD = f@tD, Activate this code.
Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k,
you know yzeroinput@tD solves jump, num, numtab, coeffs, t, LD;
y² @tD + b y¢ @tD + c y@tD = 0

64
DE.03.T3®T4
1
jump@n_D := jump@nD = NA €€€€€€€€€ E; This plot resulted from feeding L = p into the FourierFit instruction.
2n
Fvalues@F_, L_, n_D :=
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD;
The trouble is that L = p is not a period of f@tD.
The formula for f@tD is:
numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D; f@tD
1 + Cos@1.3 tD Sign@Sin@1.3 tDD
2pIkt
€€€€€€€€€€€€€€€€
Fourierfitters@L_, n_, t_D := TableAE L ,
Calculate the period of f@tD:
8k, -n + 1, n - 1<E;
coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD, Solve@1.3 t == 2 p, tD
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD • 88t ® 4.83322<<
N@Sqrt@Length@listDDD
Set L = 4.83322 and run everything again:
FastFourierfit@F_, L_, n_, t_D := L = 4.83322;
Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD; n = 10;
Look at this plot of a periodic function: Clear@approxfD
approxf@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD
Clear@f, tD;
fitplot = PlotA8f@tD, approxf@tD<,
f@t_D = Cos@1.3 tD Sign@Sin@1.3 tDD + 1 ;
thigh = 12; 1
8t, 0, thigh<, AspectRatio ® €€€€€ , PlotRange ® All, PlotStyle ®
2
fplot = 88Thickness@0.015D, Blue<, 8Thickness@0.01D, CadmiumOrange<<E;
PlotAf@tD, 8t, 0, thigh<, PlotStyle ® 88Thickness@0.02D, Blue<<, 1.05 - 0.1 Cos@1.3 tD + 0.1 Cos@2.6 tD - 0.1 Cos@3.9 tD + 0.1 Cos@5.2 tD -
1 0.1 Cos@6.5 tD + 0.1 Cos@7.8 tD - 0.1 Cos@9.1 tD + 0.1 Cos@10.4 tD -
PlotRange ® All, AxesLabel ® 8"t", "f@tD"<, AspectRatio ® €€€€€ E;
2 0.1 Cos@11.7 tD + 1.73205 ´ 10-7 Sin@1.3 tD + 0.827636 Sin@2.6 tD +
f@tD 0.296261 Sin@5.2 tD + 0.150953 Sin@7.8 tD + 0.066791 Sin@10.4 tD
2
2
1.5
1.5
1
1
0.5
0.5
t
2 4 6 8 10 12
2 4 6 8 10 12
Now look at this attempt at a fast Fourier fit of f@tD:
Lookin' real nice.
To get a good Fourier fit, you've got to set the period L of the Fourier
fit to be equal to the period of the function you are fitting.

L = p;
n = 15;
Clear@approxfD; T.4) Inserting an extra t when the characteristic equation
approxf@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD doesn't give two different solutions
fitplot = PlotA8f@tD, approxf@tD<,
1 áT.4.a.i)
8t, 0, thigh<, AspectRatio ® €€€€€ , PlotRange ® All, PlotStyle ®
2
Here's an oscillator differential equation with starter data:
88Thickness@0.015D, Blue<, 8Thickness@0.01D, CadmiumOrange<<E;
b = 6;
1.14311 + 0.742814 Cos@2 tD + 0.0390951 Cos@4 tD - 0.257364 Cos@6 tD - c = 9;
0.188126 Cos@8 tD + 0.00806777 Cos@10 tD + 0.0504127 Cos@12 tD - Clear@t, yD
0.0679726 Cos@14 tD - 0.145915 Cos@16 tD - 0.0810613 Cos@18 tD + oscdiffeq = y² @tD + b y¢ @tD + c y@tD == 0
0.0115204 Cos@20 tD - 0.00631859 Cos@22 tD - 0.0962819 Cos@24 tD -
9 y@tD + 6 y¢ @tD + y² @tD == 0
0.117143 Cos@26 tD - 0.0408109 Cos@28 tD + 0.415482 Sin@2 tD -
0.25703 Sin@4 tD - 0.0860823 Sin@6 tD + 0.145233 Sin@8 tD + Here's what happens when you use the charcteristic equation to go
0.140967 Sin@10 tD - 0.0168037 Sin@12 tD - 0.0842575 Sin@14 tD + after formulas for the solution of this oscillator differential equation
0.00337488 Sin@16 tD + 0.088743 Sin@18 tD + 0.0464058 Sin@20 tD -
0.0482512 Sin@22 tD - 0.0522351 Sin@24 tD + 0.0307325 Sin@26 tD + with sample starter data
0.0670608 Sin@28 tD y@0D = 1.2 and y¢ @0D = 3.4.
Clear@zD
2
charequation = z2 + b z + c == 0;
1.5 zsols = Solve@charequation, zD
88z ® -3<, 8z ® -3<<
1
Clear@combo, C1, C2D
0.5 combo@t_D = C1 EzsolsP1,1,2T t + C2 EzsolsP2,1,2T t
C1 E-3 t + C2 E-3 t
2 4 6 8 10 12 ystarteq = combo@0D == 1.2
What went wrong? C1 + C2 == 1.2
yprimestarteq = combo¢ @0D == 3.4
How do you fix it?
-3 C1 - 3 C2 == 3.4
á Answer:
Csols = Solve@8ystarteq, yprimestarteq<, 8C1, C2<D
Take another look: RowReduce::luc : Result for RowReduce of badly conditioned matrix
881., 1., -1.2<, 8-3., -3., -3.4<< may contain significant numerical errors.
Show@fitplotD; 88C1 ® -4.20336 ´ 1016 , C2 ® 4.20336 ´ 1016 <<

2
What went wrong?
á Answer:
1.5

1
Look at combo@tD:
combo@tD
0.5
C1 E-3 t + C2 E-3 t
2 4 6 8 10 12

65
DE.03.T4

At first glance there appear to be two degrees of freedom here, but with starter data
because the charactertistic equation has only one solution, you have y@0D = 2 and y¢ @0D = 1.
Clear@zD
only one degree of freedom. This is not enough to allow you to match
charequation = z2 + b z + c == 0;
up with the starter data on y@0D and y¢ @0D. zsols = Solve@charequation, zD
3 3
99z ® - €€€€€ =, 9z ® - €€€€€ ==
áT.4.a.i) Inserting a t 2 2

What can you do to get around this problem? Only one solution of the characteristic equation. If you want an exact
á Answer: formula, then you need to insert the t:
Clear@exactyD
Old DiffEq hands know how to tweak combo@tD. exactsol = DSolve@8oscdiffeq, y@0D == 2, y¢ @0D == 1<, y@tD, tD;
Here's how they do it: exacty@t_D = y@tD •. exactsolP1T
E-3 t•2 H2 + 4 tL
Look at combo@tD:
combo@tD
There's that extra t.
C1 E-3 t + C2 E-3 t If you are willing to settle for a good approximate formula, you look at
Insert a t onto one of the terms: the original differential equation:
Clear@bettercomboD b = 3;
bettercombo@t_D = combo@tD •. C2 E-3 t ® t C2 E-3 t 2 3y
i €€€€
c=j €z ;
C1 E-3 t + C2 E-3 t t k2{
Clear@t, yD;
Try it out:
diffeq = y² @tD + b y¢ @tD + c y@tD == 0
ExpandAll@ 9 y@tD
oscdiffeq •. 8y@tD -> bettercombo@tD, €€€€€€€€€€€€€€€€€€ + 3 y¢ @tD + y² @tD == 0
4
y'@tD -> bettercombo'@tD,
y''@tD -> bettercombo''@tD<D Tweak the damping term b a little bit to get a nearby oscillator:
True tweakedb = 1.0001 b;
Clear@t, yD
The upshot: nearbydiffeq = y² @tD + tweakedb y¢ @tD + c y@tD == 0
bettercombo@tD solves the differential equation and gives you the two 9 y@tD
€€€€€€€€€€€€€€€€€€ + 3.0003 y¢ @tD + y² @tD == 0
4
genuine degrees of freedom you need to match up with the starter data Solve the nearby oscillator diffeq via the characteristic equation:
on y@0D and y¢ @0D. Clear@zD
ystarteq = bettercombo@0D == 1.2; charequation = z2 + tweakedb z + c == 0;
yprimestarteq = bettercombo ¢ @0D == 3.4; zsols = Solve@charequation, zD
Csols = Solve@8ystarteq, yprimestarteq<, 8C1, C2<D 88z ® -1.52136<, 8z ® -1.47894<<
88C1 ® 1.2, C2 ® 7.<< Clear@combo, C1, C2D
combo@t_D = C1 EzsolsP1,1,2T t + C2 EzsolsP2,1,2T t

C1 E-1.52136 t + C2 E-1.47894 t
This gives you the exact formula:
ystarteq = combo@0D == 2
Clear@yformulaD C1 + C2 == 2
yformula@tD = bettercombo@tD •. CsolsP1T
yprimestarteq = combo¢ @0D == 1
1.2 E-3 t + 7. E-3 t t
-1.52136 C1 - 1.47894 C2 == 1
Inserting the extra t did the trick. Csols = Solve@8ystarteq, yprimestarteq<, 8C1, C2<D
88C1 ® -93.2856, C2 ® 95.2856<<
áT.4.a.ii) Clear@approxyD
approxy@t_D = combo@tD •. CsolsP1T
When do you insert an extra t as in part i) above? -93.2856 E-1.52136 t + 95.2856 E-1.47894 t
á Answer:
No extra t.
If there are two different solutions of the characteristic equation, then
Compare the two solutions:
you don't insert any extra t. In fact if you do, you will have a endtime = 12;
guaranteed screw-up. PlotA8exacty@tD, approxy@tD<, 8t, 0, endtime<,
PlotStyle ® 88Blue, Thickness@0.02D<, 8Red, Thickness@0.01D<<,
If the characteristic equation has only one solution (double root), then 1
PlotRange ® All, AxesLabel ® 8"t", ""<, AspectRatio ® €€€€€ E;
2
you need to insert the t as in part i) above.
2

áT.4.a.iii) How important is the issue of the extra t? 1.5

How important is the issue of the extra t?


1
á Answer:
0.5
If you want an exact formula, it's important.
t
If you are willing to settle for a very good approximate formula then 2 4 6 8 10 12

it's not an issue at all. Sharing ink all the way.


Watch this: You can't tell the difference without a scorecard.
b = 3;
2
by
i €€€€
c=j j €z z ; The upshot: The matter of inserting the t is important only when
k2{
Clear@t, yD; theoretical exactness is paramount.
oscdiffeq = y² @tD + b y¢ @tD + c y@tD == 0
9 y@tD
€€€€€€€€€€€€€€€€€€ + 3 y¢ @tD + y² @tD == 0
In practical situations, you can almost always tweak the damping term
4
to get good, practical results.
Here's what happens when you use the characteristic equation to go
after formulas for the solution of this oscillator differential equation

66
DE.03.T4
Clear@s, t, y, YD
áT.4.b.i) Y@s_D = LaplaceTransform@y@tD, t, sD;
InverseLaplaceTransform @Y¢ @sD, s, tD
Use the Laplace transform to explain where the extra t comes from.
-t y@tD
á Answer:
You can explain this sweet little rule as follows:
Here's another oscillator differential equation which needs the extra t: ∞
b = 8;
Y@sD = Ù0 E-s t y@tD â t
∞ ∞
c = 16;
Y'@sD = ¶s HÙ0 E-s t y@tD â tL = Ù0 ¶s HE-s t y@tDL â t
Clear@t, yD;

oscdiffeq = Hy''@tD + b y'@tD + c y@tD == 0L Y'@sD = Ù0 E-s t y@tD H-tL â t
16 y@tD + 8 y¢ @tD + y² @tD == 0 ∞
Y'@sD = Ù0 E-s t H- t y@tDL â t
Here's what happens when you use the characteristic equation to go
after formulas for the solution of this oscillator differential equation
This tells you that Y¢ @sD is the Laplace transform of -t y@tD.
with starter data
Nice, simple calculus.
y@0D = 2 and y¢ @0D = 3.
Clear@zD áT.4.b.iii)
charequation = z2 + b z + c == 0;
zsols = Solve@charequation, zD
Is there a way you can see where the extra t comes from without
88z ® -4<, 8z ® -4<< resorting to the black box of the Laplace transform?
á Answer:
Uh-oh.
The idea for this explanation comes from V. I Arnold's book
Only one solution of the characteristic equation. To see where the extra Ordinary Differential Equations,
Translated from the Russian by Roger Cooke, Springer-Verlag, 1992.
t comes from, go to the Laplace Transform: Yes there is!
Clear@t, Y, approxy, sD
f@t_D = 0; ystarter = 2; yprimestarter = 3; The prototype oscillator differential equation whose characteristic
1
Y@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD +
s2 + b s + c
equation has only one solution is:
b ystarter + s ystarter + yprimestarterL; Clear@oscdiffeq, r, y, tD
y@t_D = Chop@Expand@InverseLaplaceTransform @Y@sD, s, tDDD b = 2 r;
2E -4 t
+ 11 E -4 t
t c = r2 ;
oscdiffeq = y² @tD + b y¢ @tD + c y@tD == 0
Now you can see where the extra t comes from. r2 y@tD + 2 r y¢ @tD + y² @tD == 0
Look at the Laplace transform of the solution y@tD: Check:
Apart@Y@sDD Clear@zD
11 2 charequation = z2 + b z + c == 0;
€€€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€
H4 + sL2 4+s zsols = Solve@charequation, zD
88z ® -r<, 8z ® -r<<

Good.
The inverse Laplace transform of Now tweak this oscillator this way:
2 H-4 tL
€€€€€€€€€
s+4
€ is 2 E Clear@nearbyoscdiffeq, y, h, tD
nearbyoscdiffeq@h_D = y² @tD + H2 r + hL y¢ @tD + r Hr + hL y@tD == 0
and the inverse Laplace transform of r Hh + rL y@tD + Hh + 2 rL y¢ @tD + y² @tD == 0
11 1 H-4 tL
€€€€€€€€€€€€€€€
H4+sL2
€ = € L,
-11 D@H €€€€€€€€€
s+4
sD is 11 t E : When h is very small, then the two differential equations are almost the
1
2 InverseLaplaceTransform A €€€€€€€€€€€€€ , s, tE same.
s+4
ColumnForm@8oscdiffeq, nearbyoscdiffeq@0.00001D<D
2 E-4 t
r2 y@tD + 2 r y¢ @tD + y² @tD == 0
1
11 InverseLaplaceTransform A-DA €€€€€€€€€€€€€ , sE, s, tE r H0.00001 + rL y@tD + H0.00001 + 2 rL y¢ @tD + y² @tD == 0
s+4
11 E-4 t t Now look at formulas for solutions of both:
That's where the t comes from. Clear@yexact, p, qD
exactsol = DSolve@8oscdiffeq, y@0D == p, y¢ @0D == q<, y@tD, tD;
yexact@t_D = y@tD •. exactsolP1T
áT.4.b.ii)
E-r t Hp + Hq + p rL tL
In the last part, knowing that the inverse Laplace transform of Clear@ynearby, p, qD
2
€ is 2 EH-4 tL ,
€€€€€€€€€
s+4
nearbysol =
DSolve@8nearbyoscdiffeq@hD, y@0D == p, y'@0D == q<, y@tD, tD;
you recognized that the inverse Laplace transform of ynearby@t_, h_D = y@tD •. nearbysol@@1DD
11
€€€€€€€€€€€€€€€
H4+sL2
1
€ , sD is - t EH-4 tL .
€ = -11 D@ €€€€€€€€€
s+4 i EH-h-rL t+r t Hq + p rL hp+q+pr y
E-r t j
j- €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ z
z
(That's where the extra t really comes from.) k h h {

Is this a special case of a general rule? Put:


á Answer: Clear@g, xD
g@x_D = -E-x t
You bet your sweet pocket calculator! -E-t x
The rule is this: And notice that ynearby@t, hD is given by:
If Clear@altynearbyD
Hq + p rL Hg@r + hD - g@rDL p
Y@sD is the Laplace transform of y@tD, altynearby@t_, h_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€
h Er t
then the inverse Laplace transform of HE-r t - E-Hh+rL t L Hq + p rL
E-r t p + €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
h
Y¢ @sD is -t y@tD. Check:
It's even programmed into Mathematica: Simplify@ynearby@t, hD - altynearby@t, hDD
0

67
DE.03.T4®G1

Good. áT.5.a)
As h closes in on 0, Late last century, the American mathematician Gibbs noticed
nearbyoscdiffeq@hD closes in on oscdiffeq; theoretically (with no machine help) the same phenomenom you are
seeing here. Lots of folks call this by the name "Gibbs phenomenon."
so What is the Gibbs phenomenon?
ynearby@t, hD closes in on yexact@tD. á Answer:

But Look again:


Hq+p rL Hg@r+hD-g@rDL p Show@fitplotD;
ynearby@t, hD = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
h
€ + €€€€€€€€€€€
EHr tL
,
and as h closes in on 0, this closes in on: 1
p
Hq + p rL g¢ @rD + €€€€€€€€€€€ 0.5
Er t
-r t -r t
E p+E Hq + p rL t 0.5 1 1.5 2
-0.5
This is the same as:
-1
yexact@tD
E-r t Hp + Hq + p rL tL
Increase the quality of the Fourier fit:
So the extra t comes from taking a derivative.
n = 12;
If this argument really appeals to you, Clear@realfitD;
you may have a bright future as a mathematical scientist.
realfit@t_D =
Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD;

T.5) The Gibbs phenomenon newfitplot = Plot@8f@tD, realfit@tD<, 8t, 0, L<,


PlotStyle -> 88Thickness@0.01D, Red<, 8Blue<<D;
DiffEq&Mathematica is pleased to acknowledge that this problem
is based in part on the exposition in Gilbert Strang's book
"Introduction to Applied Mathematics"
(Wellesley-Cambridge Press, 1986).
1
Activate this code. 0.5
Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k,
jump, num, numtab, coeffs, t, LD; 0.5 1 1.5 2
1 -0.5
jump@n_D := jump@nD = NA €€€€€€€€€ E;
2n -1
Fvalues@F_, L_, n_D :=
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD;

Look at the jump f@tD takes in the middle. Notice that the fast Fourier
numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D;
fit overshoots on one side of the jump with a compensating undershoot

2pIkt
Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€
L , on the the other side of the jump.
8k, -n + 1, n - 1<E;
coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD, Gibbs proved theoretically that when you go with a high quality fast
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD •
N@Sqrt@Length@listDDD Fourier fit (big n) of any periodic function f@tD, then you will always
FastFourierfit@F_, L_, n_, t_D :=
get this phenomenon at a jump of f@tD.
Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD;
DE.03 Laplace Transform and Fourier
Look at this plot:
Clear@f, tD;
Analysis
f@t_D = Sign@Sin@p tDD;
L = 2;
Give It a Try!
cycles = 3;

fplot = G.1) Using the Laplace transform to solve some forced


PlotAf@tD, 8t, 0, cycles L<, PlotStyle ® 88Thickness@0.02D, Blue<<,
AxesLabel ® 8"t", "f@tD"<, PlotLabel ® "cycles" cycles, exponential and forced oscillator diffeqs
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
L
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
áG.1.a)
2
f@tD 3 cycles
Use the Laplace transform to come up with the exact formula for the
1 solution of the forced exponential differential equation
0.5
One Period
y¢ @tD - 0.5 y@tD = 8 Cos@2 tD
t
1 2 3 4 5 6 with y@0D = 4.
-0.5
-1 áG.1.b)
Now look at this fast Fourier fit of f@tD shown with f@tD:
n = 8;
Use the Laplace transform to come up with the exact formula for the
Clear@realfitD; forced, damped oscillator coming from
realfit@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD; y² @tD + 0.7 y¢ @tD + 2.8 y@tD = 2 Sin@ 3.2 tD
fitplot = Plot@8f@tD, realfit@tD<, 8t, 0, L<,
PlotStyle ® 88Thickness@0.01D, Red<, 8Blue<<D;
with y@0D = 3.2 and y¢ @0D = -0.6.
Inspect the formula to come up with a formula that describes the
1
long-term behavior of this oscillator.
Give a nice plot.
0.5

0.5 1 1.5 2
áG.1.c.i)
-0.5 Look at this:
-1 Clear@f, F, s, tD;
f@t_D = DiracDelta@t - 2.7D;
F@s_D = LaplaceTransform@f@tD, t, sD

68
DE.03.G1®G2
E-2.7 s coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD,
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD •
Use the integral definition of the Laplace transform to explain the N@Sqrt@Length@listDDD
output.
FastFourierfit@F_, L_, n_, t_D :=
áG.1.c.ii) Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD;

Showcase the Laplace transform method and the Dirac delta function áG.2.a.i)
by coming up with the exact formula for the forced oscillator coming Look at this plot of
from f@tD = 3 HCeiling@ €€€€4t € D - €€€€4t € L:
y² @tD + 0.5 y¢ @tD + 3.1 y@tD = f@tD Clear@f, tD;
with f@tD = 10 DiracDelta@t - 8.5D, y@0D = 8 and y¢ @0D = 2. t t
f@t_D = 3 JCeilingA €€€€€ E - €€€€€ N;
Show off your work with a good plot. 4 4
PlotAf@tD, 8t, 0, 13<, PlotStyle ® 88Thickness@0.01D, Blue<<,
áG.1.d.i) 1
AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ , AxesLabel ® 8"t", "f@tD"<,
Look at this function: GoldenRatio
Clear@f, tD PlotRange ® AllE;
f@t_D = Sin@tD H1 - UnitStep@t - pDL f@tD
3
PlotAf@tD, 8t, 0, 6<, PlotStyle ® 88Thickness@0.015D, Blue<<,
1 2.5
AspectRatio ® €€€€€ , AxesLabel ® 8"t", "f@tD"<E;
3 2
Sin@tD H1 - UnitStep@-p + tDL 1.5
f@tD
1
1
0.8 0.5
0.6
t
0.4 2 4 6 8 10 12
0.2 This function is periodic.
t
1 2 3 4 5 6 Identify the period L of f@tD and plot three cyles of f@tD.
Explain why the formula
f@tD = Sin@tD H1 - UnitStep@t - pDL áG.2.a.ii)
guarantees that Give a fairly decent, but not necessarily great, fast Fourier fit of this
® f@tD = Sin@tD for 0 £ t £ p and function on @0, LD and then plot three cyles of f@tD and your fast
® f@tD = 0 for t > p. Fourier fit.
áG.2.b.i)
Look at this plot of
f@tD = 10 HCeiling@ €€€€3t € D + Floor@ €€€€2t € D - €€€€€€
5t
6
€ L:
Clear@f, tD;
t t 5t
f@t_D = 10 JCeilingA €€€€€ E + FloorA €€€€€ E - €€€€€€€€€ N;
3 2 6

Plot@
áG.1.d.ii) f@tD, 8t, 0, 21<, PlotStyle ® 88Thickness@0.01D, DeepCadmiumRed<<,
AxesLabel ® 8"t", "f@tD"<D;
Stay with the same function f@tD = Sin@tD H1 - UnitStep@t - pDL as in
f@tD
part i) above. 10
Showcase the Laplace transform method to come with the exact
5
formula for the forced oscillator coming from
y² @tD + 0.7 y¢ @tD + 9.1 y@tD = f@tD 5 10 15 20 t
with y@0D = 4 and y¢ @0D = 0.
-5
Show off your work with a good plot.
-10
áG.1.e.i)
This function is periodic.
Plot the new function f@tD described as follows: Identify the period L of f@tD and plot three cyles of f@tD.
® f@tD = t for 0 £ t £ 2 and
® f@tD = 0 for t > 2. áG.2.b.ii)
áG.1.e.ii) Give a fairly decent, but not necessarily great, fast Fourier fit of this
function on @0, LD and then plot three cyles of f@tD and your fast
Stay with the same function f@tD as in part i) above. Fourier fit.
Use the Laplace transform method to come with the exact formula for
the forced oscillator coming from áG.2.c)
y² @tD + 0.7 y¢ @tD + 9.1 y@tD = f@tD Look at this plot of
with y@0D = 4 and y¢ @0D = 0. f@tD = 5 Cos@3 tD - 7 Sin@ €€€€2t € D:
Show off your work with a good plot. Clear@f, tD;
t
f@t_D = 5 Cos@3 tD - 7 SinA €€€€€ E;
2
G.2) Periodic functions and some Fourier fits Plot@f@tD, 8t, 0, 35<,
PlotStyle ® 88Thickness@0.01D, PermanentRedViolet<<,
Activate this code. AxesLabel ® 8"t", "f@tD"<D;
Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k, f@tD
jump, num, numtab, coeffs, t, LD;
10
1
jump@n_D := jump@nD = NA €€€€€€€€€ E;
2n 5
Fvalues@F_, L_, n_D :=
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD; 5 10 15 20 25 30 35
t

-5

numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D;


-10
2pIkt
€€€€€€€€€€€€€€€€
Fourierfitters@L_, n_, t_D := TableAE L ,
8k, -n + 1, n - 1<E;

69
DE.03.G2®G3
This function is periodic. 1
5 cycles

Identify the period L of f@tD as a multiple of p and plot two cyles of


0.8
f@tD.
0.6

0.4
G.3) Using Fourier fit and the Laplace transform to come
0.2
One Period
up with good approximate formulas for some periodically 2 4 6 8 10 12 14
t

forced oscillators Folks like to call those little overshoots and undershoots at the jumps
by the name "Gibbs Phenomena."
Activate this code. For a word on this, see the Tutorials.

Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k, Looks pretty good.


jump, num, numtab, coeffs, t, LD; Now you take over and use the Laplace transform to come up with a
1
jump@n_D := jump@nD = NA €€€€€€€€€ E; pretty decent approximate solution of
2n
Fvalues@F_, L_, n_D := y² @tD + 1.3 y¢ @tD + 5.4 y@tD = f@tD
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD; with y@0D = 2.2 and y¢ @0D = -3.5.

numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D; áG.3.b.i)


2pIkt
Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€
L , Here is the plot of a periodic function:
8k, -n + 1, n - 1<E; Clear@f, tD;
coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD, f@t_D = 0.5 HSign@Cos@p tDD + 1L;
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD • L = 2;
N@Sqrt@Length@listDDD cycles = 3;
fplot = PlotAf@tD, 8t, 0, cycles L<,
FastFourierfit@F_, L_, n_, t_D := PlotStyle ® 88Thickness@0.02D, Blue<<, AxesLabel ® 8"t", "f@tD"<,
Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD; 1
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€ ,
4
áG.3.a) Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
When you go after a reasonably accurate formula for the forced, L
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
damped oscillator coming from f@tD
2
y² @tD + 1.3 y¢ @tD + 5.4 y@tD = f@tD 1
3 cycles
0.8
with y@0D = 2.2 and y¢ @0D = -3.5 0.6
0.4
and 0.2 One Period
5
t
1 2 3 4 6
with f@tD = Ceiling@ €€€€3t € D - €€€€3t € , This f@tD is periodic with period L = 2. Use fast Fourier fit to do a
you first look at the plot of f@tD: reasonably good job of fitting this function with combinations sine
and cosine waves.
Don't be too picky.

Clear@f, tD;
t t áG.3.b.ii)
f@t_D = CeilingA €€€€€ E - €€€€€ ;
3 3 Go with the same f@tD used in part i) and use the formula for the fast
cycles = 4;
L = 3;
Fourier fit you got in part i) together with the Laplace transform to
fplot = PlotAf@tD, 8t, 0, cycles L<, PlotStyle ® slam out an approximate formula for the solution of the forced
88Thickness@0.02D, MidnightBlue<<, AxesLabel ® 8"t", "f@tD"<, oscillator
1
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€ , y² @tD + 0.2 y¢ @tD + 3.7 y@tD = f@tD
4 with y@0D = 1 and y¢ @0D = 2.
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
L
Plot your approximate formula.
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
f@tD
2 áG.3.b.iii)
4 cycles
1
0.8 Look at the formula you got in part ii) above.
0.6
0.4
0.2
What part of the formula reflects the starting data
One Period
2 4 6 8 10 12
t y@0D = 1 and y¢ @0D = 2?
This f@tD is periodic with period L = 3. What part of the formula reflects the steady state behavior of the
Next you go after a reasonably good fast Fourier fit of this function forced oscillator?
and check it out:
L = 3;
Clear@approxfD; áG.3.c)
n = 6;
approxf@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD
Use Fast Fourier fit and the Laplace transform to come up with a good
2pt 4pt approximate formula of the steady state behavior of the forced,
0.458333 - 0.0833333 CosA €€€€€€€€€€€€€€ E - 0.0833333 CosA €€€€€€€€€€€€€€ E -
3 3 damped oscillator coming from
8pt 10 p t
0.0833333 Cos@2 p tD - 0.0833333 CosA €€€€€€€€€€€€€€ E - 0.0833333 CosA €€€€€€€€€€€€€€€€€ E +
3 3
y² @tD + 2.3 y¢ @tD + 6.7 y@tD = f@tD
2pt 4pt with y@0D = 4.3 and y¢ @0D = -2.5
0.311004 SinA €€€€€€€€€€€€€€ E + 0.144338 SinA €€€€€€€€€€€€€€ E + 0.0833333 Sin@2 p tD +
3 3 and with f@tD as specified below:
8pt 10 p t
0.0481125 SinA €€€€€€€€€€€€€€ E + 0.0223291 SinA €€€€€€€€€€€€€€€€€ E Clear@f, tD;
3 3
t t
Check it out: f@t_D = 0.8 AbsA €€€€€ - RoundA €€€€€ EE;
3 3
cycles = 5; fplot = PlotAf@tD, 8t, 0, 10<, PlotStyle ® 88Thickness@0.02D, Blue<<,
fitplot = PlotA8f@tD, approxf@tD<, 8t, 0, cycles L<,
1
PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<, AspectRatio ® €€€€€ , AxesLabel ® 8"t", "f@tD"<E;
4
AxesLabel ® 8"t", ""<, f@tD
1 0.4
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ , 0.3
GoldenRatio 0.2
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<, 0.1
t
L 2 4 6 8 10
9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2 This time you have to be careful about setting the period L.

70
DE.03.G4
And then you said, "Now I see where the resonance came from."
G.4) Fourier analysis What did you mean?
Activate this code before you start. áG.4.a.ii)
Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k, At this point, Cal was totally clueless, and you decided to rub it in a
jump, num, numtab, coeffs, t, LD;
1 bit by saying, "I think I can eliminate the resonance altogther f@tD by
jump@n_D := jump@nD = NA €€€€€€€€€ E; adding
2n
Fvalues@F_, L_, n_D := 2.34375 Cos@2 tD
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD;
to f@tD. Just take a look:"
Clear@y, tD
numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D; ndssol = NDSolve@8y² @tD + 4 y@tD == f@tD + 2.34375 Cos@2 tD,
y@0D == 0, y¢ @0D == 2<, y@tD, 8t, 0, endtime<D;
2pIkt y@t_D = y@tD •. ndssolP1T;
Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€
L ,
adjustedplot =
8k, -n + 1, n - 1<E; PlotAy@tD, 8t, 0, endtime<, PlotStyle ® 88Red, Thickness@0.01D<<,
coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD, 1
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD • PlotRange ® All, AxesLabel ® 8"t", "y@tD"<, AspectRatio ® €€€€€ E;
5
N@Sqrt@Length@listDDD
y@tD
1.5
FastFourierfit@F_, L_, n_, t_D := 1
0.5
Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD; 5 10 15 20 25
t
-0.5
áG.4.a.i) No resonance here.
How did you come up with this idea of filtering out the bad term?
Here's a plot of the forced undamped oscillator
y² @tD + 4 y@tD = f@tD áG.4.b.i)
with y@0D = 0 and y¢ @0D = 2 Later in your life, you are working for Ameritech. One fine morning
and your boss comes into your office saying , "There is a problem with an
with f@tD = 5 Sin@tD6 : oscillator designed in the Columbus office. The oscillator comes from
endtime = 25; Clear@f, y, tD;
y² @tD + H1.2L2 y@tD = f@tD ,
f@t_D = 5 Sin@tD6 ; ndssol = NDSolve@
8y² @tD + 4 y@tD == f@tD, y@0D == 0, y¢ @0D == 2<, y@tD, 8t, 0, endtime<D; with y@0D = 0 and y¢ @0D = 0
ndsy@t_D = y@tD •. ndssolP1T; and with f@tD specified as follows:"
ndsplot = Plot@ndsy@tD, 8t, 0, endtime<, Clear@f, tD;
PlotStyle ® 88Red, Thickness@0.01D<<, AxesLabel ® 8"t", "y@tD"<D; f@t_D = 3 Abs@0.2 t - Round@0.2 tDD;
fplot = PlotAf@tD, 8t, 0, 15<, PlotStyle ® 88Thickness@0.02D, Blue<<,
1
AxesLabel ® 8"t", "f@tD"<, AspectRatio ® €€€€€ E;
5
f@tD
1.4
1.2
1
0.8
0.6
0.4
0.2 t
2 4 6 8 10 12 14

y@tD Your boss says, "Look at this plot to get an idea of what the trouble
is:"
10
endtime = 80;
5 Clear@y, t, DerivativeD;
ndssol = NDSolve@8y² @tD + 1.22 y@tD == f@tD, y@0D == 0, y¢ @0D == 0<,
5 10 15 20 25 t
y@tD, 8t, 0, endtime<, MaxSteps ® 1500D;
-5
y@t_D = y@tD •. ndssolP1T;
-10 ndsplot =
PlotAy@tD, 8t, 0, endtime<, PlotStyle ® 88Red, Thickness@0.01D<<,
This is showing signs of resonance. When you showed this plot to that 1
AspectRatio ® €€€€€ , AxesLabel ® 8"t", "y@tD"<E;
dork Calculus Cal, he said, "Look at the characteristic equation for the 2
y@tD
unforced oscillator 10
y² @tD + 4 y@tD = 0:" 7.5
Clear@zD 5
Solve@z2 + 4 == 0D 2.5
88z ® -2 I<, 8z ® 2 I<< 20 40 60 80
t
-2.5
Cal then continued, "There must be some mistake because the only -5
way you can put this oscillator in resonance is to force it with -7.5
multiples of Cos@2 tD or Sin@2 tD." You say, "Looks like near resonance to me."
You said, "Maybe that's the impression you got from the Tutorials, but And then your boss says, "Just what I was afraid of. We can't tolerate
I don't agree; look at f@tD and a plot:" an amplitude of more than 4 and this oscillator has amplitudes
f@tD
Plot@f@tD, 8t, 0, 3 Pi<,
exceeding 4."
PlotStyle -> 88Thickness@0.01D, Blue<<, Show@ndsplot,
AxesLabel -> 8"t", "f@tD"<D; Graphics@8Thickness@0.01D, Line@880, 4<, 8endtime + 5, 4<<D<D,
Graphics@8Thickness@0.01D, Line@880, -4<, 8endtime + 5, -4<<D<DD;
5 Sin@tD6
y@tD
f@tD
10
5
7.5
4 5
2.5
3
t
20 40 60 80
2 -2.5
-5
1
-7.5
t
2 4 6 8 The boss says: "We can't put a damper on this oscillator. Can you fix
And then you said: "The period of f@tD is L = p ; look at a reasonably this by adding an extra term of the form
good Fourier fit of f@tD:" A Cos@B tD or A Sin@B tD with -0.5 £ A £ 0.5
Chop@ComplexExpand@FastFourierfit@f, p, 9, tDDD to f@tD ?"
1.5625 - 2.34375 Cos@2 tD + 0.9375 Cos@4 tD - 0.15625 Cos@6 tD

71
DE.03.G4®G5
Remembering that little session with Cal in the Mathematica lab back Clear@f, tD;
at school, and noticing that the period of f@tD is L = 5, you look at: Sin@tD2
f@t_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ;
N@Chop@ComplexExpand@FastFourierfit@f, 5, 12, tDDDD 2 + Cos@4 tD
0.75 - 0.611411 Cos@1.25664 tD - 0.0711294 Cos@3.76991 tD - cycles = 4;
0.0281083 Cos@6.28319 tD - 0.0165499 Cos@8.79646 tD - PlotAf@tD, 8t, 0, 6<, PlotStyle ® 88Thickness@0.02D, Blue<<,
0.0122039 Cos@11.3097 tD - 0.0105972 Cos@13.823 tD 1
AxesLabel ® 8"t", "f@tD"<, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ E;
And then you say: "I'm not sure, but I'll give it my best shot." f@tD
GoldenRatio

Do it.
0.5
áG.4.b.ii) 0.4

This morning, your boss comes into your office saying, "We have 0.3

another problem oscillator. It comes from 0.2


y² @tD + H1.6L2 y@tD = f@tD , 0.1
with y@0D = 0 and y¢ @0D = 0 1 2 3 4 5 6
t
and with f@tD specified as follows:" Intent on getting a decent fast Fourier fit with as little thought as
Clear@f, tD;
f@t_D = Sign@Cos@0.5 p tDD + 1;
possible, Cal copies and pastes some code:
fplot = PlotAf@tD, 8t, 0, 12<, PlotStyle ® 88Thickness@0.02D, Blue<<, L = 1; n = 5; Clear@t, realfastfitD
realfastfit@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD
1
AxesLabel ® 8"t", "f@tD"<, AspectRatio ® €€€€€ E; 0.199184 + 0.0143339 Cos@2 p tD - 0.0709849 Cos@4 p tD -
3
f@tD
0.0592728 Cos@6 p tD - 0.0556396 Cos@8 p tD - 0.24815 Sin@2 p tD -
2 0.0886425 Sin@4 p tD - 0.0380883 Sin@6 p tD - 0.0170081 Sin@8 p tD
1.5 Smiling in satisfaction, Cal plots f@tD and his fast Fourier fit:
1
PlotA8f@tD, realfastfit@tD<, 8t, 0, 6<,
0.5
PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
t
2 4 6 8 10 12 1
AxesLabel ® 8"t", ""<, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ E;
"Take a look:" GoldenRatio
endtime = 60; 0.6
Clear@y, t, DerivativeD;
0.5
ndssol = NDSolve@8y² @tD + 1.62 y@tD == f@tD, y@0D == 0, y¢ @0D == 0<,
0.4
y@tD, 8t, 0, endtime<, MaxSteps ® 2000D;
y@t_D = y@tD •. ndssolP1T; 0.3
Plot@y@tD, 8t, 0, endtime<, PlotStyle ® 88Red, Thickness@0.01D<<, 0.2
AxesLabel ® 8"t", "y@tD"<D; 0.1
t
1 2 3 4 5 6

Cal is dumbfounded (as always).


Step in and tell Cal what he did wrong and then fix it so it looks as
good as it can.

y@tD
20
áG.5.b)
10
Here's a new periodic function:
Clear@f, tD;
t t t
10 20 30 40 50 60 f@t_D = €€€€€ - FloorA €€€€€ E;
2 2
-10 L = 2;
cycles = 4;
-20 PlotAf@tD, 8t, 0, cycles L<,
And then your boss said, "We can't tolerate an amplitude of more than PlotStyle ® 88Thickness@0.02D, Blue<<, AxesLabel ® 8"t", "f@tD"<,
2.0 as t runs from 0 to 60. Try to work your magic again to fix this this 1
PlotLabel ® "cycles" cycles, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
by adding an extra term of the form GoldenRatio
Epilog ® 98Red, Thickness@0.02D, Line@880, 0<, 8L, 0<<D<,
A Cos@B tD or A Sin@B tD with -1.5 £ A £ 1.5 L
to f@tD." 9TextA"One Period", 9 €€€€€ , 0.1=E==E;
2
What do you say and what do you do? f@tD 4 cycles
1

0.8
G.5) Mistakes, experiments and opinions
0.6
Activate this code. 0.4
Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k,
jump, num, numtab, coeffs, t, LD; 0.2
One Period
1 t
jump@n_D := jump@nD = NA €€€€€€€€€ E; 2 4 6 8
2n
Fvalues@F_, L_, n_D := Now look at these plots which compare the plot of f@tD to plots of
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD; FastFourierFit@f, L, n, tD:
Clear@t, n, realfastfitter, comparisonplotD;
realfastfitter@t_, n_D :=
numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D;
Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD;
2pIkt
comparisonplot@n_D := Plot@8f@tD, realfastfitter@t, nD<, 8t, 0, 2 L<,
Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€
L , PlotStyle ® 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
8k, -n + 1, n - 1<E; PlotRange ® 8-0.1, 1.1<,
coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD, AspectRatio ® 1, AxesLabel ® 8"t", ""<, PlotLabel ® nD;
Part@InverseFourier@listD, Drop@numtab@nD, 1DDD • Table@comparisonplot@nD, 8n, 2, 10, 2<D;
N@Sqrt@Length@listDDD

FastFourierfit@F_, L_, n_, t_D :=


Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD;

áG.5.a)
That nitwit Calculus Cal starts to plot this periodic function:

72
DE.03.G5
I k H2 pL t
NIntegrateAf@tD E - €€€€€€€€€€€€€€€€€€€€
L €
, 8t, 0, L<E
2
A@k_D := €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ;
1 L
0.8 Clear@k, complexintegralfitter D;
m = 3;
0.6
m
I k H2 pL t
0.4 integralfitter@t_D = ChopA â A@kD E €€€€€€€€€€€€€€€€€€€€
L

E
k=-m
0.2
0.31831 - 0.95493 I E-I p t + 0.95493 I EI p t - 0.31831 E-2 I p t -
1 2 3 4 t 0.31831 E2 I p t + 0.95493 I E-3 I p t - 0.95493 I E3 I p t

4 Convert it to sines and cosines:


1 realintegralfitter@t_D = Chop@ComplexExpand@integralfitter@tDDD
0.8 0.31831 - 0.63662 Cos@2 p tD - 1.90986 Sin@p tD + 1.90986 Sin@3 p tD
0.6 And the corresponding fast Fourier fit:
0.4 n = m + 1;
0.2 fastfitter@t_D = FastFourierfit@f, L, n, tD
0.25 + H0.75 - 0.75 IL E-I p t + H0.75 + 0.75 IL EI p t - H0.25 + 0.25 IL E-2 I p t -
1 2 3 4 t
H0.25 - 0.25 IL E2 I p t - H0.75 - 0.75 IL E-3 I p t - H0.75 + 0.75 IL E3 I p t
6 Convert it to sines and cosines:
1
realfastfitter@t_D = Chop@ComplexExpand@fastfitter@tDDD
0.8 0.25 + 1.5 Cos@p tD - 0.5 Cos@2 p tD - 1.5 Cos@3 p tD - 1.5 Sin@p tD -
0.6 0.5 Sin@2 p tD + 1.5 Sin@3 p tD
0.4 See both along with f@tD:
0.2 Plot@8f@tD, realfastfitter@tD, realintegralfitter@tD<, 8t, 0, L<,
PlotStyle -> 88Thickness@0.02D, Blue<,
1 2 3 4 t
8Thickness@0.01D, CadmiumOrange<, 8Thickness@0.01D, Red<<,
AspectRatio -> 1,
8 AxesLabel -> 8"t", ""<D;
1
0.8
4
0.6

0.4 2

0.2
0.5 1 1.5 2 t
1 2 3 4 t
-2

The plot of f@tD is blue.


The plot of the fast Fourier fit is orange.
The plot of the Fourier integral fit is red.
Raise m = n + 1 and do everything again:

m = 8;
10
L = 2;
1
Clear@A, integralfitter,
0.8 realintegralfitter, realfastfitter, fastfitter, k, tD;
I k H2 pL t
0.6
NIntegrateAf@tD E- €€€€€€€€€€€€€€€€€€€€ L

, 8t, 0, L<E
0.4 A@k_D := €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ;
L
0.2 Clear@k, complexintegralfitter D;
m
1 2 3 4 t integralfitter@t_D = ChopA â A@kD E €€€€€€€€€€€€€€€€€€€€
L

E
I k H2 pL t

k=-m
Grab and animate at various speeds.
0.31831 - 0.95493 I E-I p t + 0.95493 I EI p t - 0.31831 E-2 I p t - 0.31831 E2 I p t +
What do these plots depict? 0.95493 I E-3 I p t - 0.95493 I E3 I p t + 0.106103 E-4 I p t + 0.106103 E4 I p t +
Does the Gibbs phenomenon show up? 0.31831 I E-5 I p t - 0.31831 I E5 I p t + 0.106103 E-6 I p t + 0.106103 E6 I p t -
0.31831 I E-7 I p t + 0.31831 I E7 I p t - 0.0212207 E-8 I p t - 0.0212207 E8 I p t
áG.5.c.i) Fast Fourier versus Fourier integral
Convert it to sines and cosines:
What is the inherent advantage of using fast Fourier fit instead of the realintegralfitter@t_D = Chop@ComplexExpand@integralfitter@tDDD
Fourier integral fit? 0.31831 - 0.63662 Cos@2 p tD + 0.212207 Cos@4 p tD + 0.212207 Cos@6 p tD -
0.0424413 Cos@8 p tD - 1.90986 Sin@p tD + 1.90986 Sin@3 p tD +
áG.5.c.ii) 0.63662 Sin@5 p tD - 0.63662 Sin@7 p tD

Here's a periodic function: And the corresponding fast Fourier fit:


Clear@f, tD; n = m + 1;
f@t_D = Sin@p tD H3 - Sin@p tDL Sign@Cos@2 p tDD; fastfitter@t_D = FastFourierfit@f, L, n, tD
1 0.264376 - 0.793128 I E-I p t +
PlotAf@tD, 8t, 0, 4<, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ ,
GoldenRatio 0.793128 I EI p t - 0.321714 E-2 I p t - 0.321714 E2 I p t +
PlotStyle ® 88Thickness@0.01D, Blue<<, AxesLabel ® 8"t", "f@tD"<E; 1.13716 I E-3 I p t - 1.13716 I E3 I p t + 0.163531 E-4 I p t + 0.163531 E4 I p t +
f@tD 0.15597 I E-5 I p t - 0.15597 I E5 I p t + 0.117812 E-6 I p t + 0.117812 E6 I p t -
4 0.550901 I E-7 I p t + 0.550901 I E7 I p t - 0.0918169 E-8 I p t - 0.0918169 E8 I p t
3
Convert it to sines and cosines:
2
realfastfitter@t_D = Chop@ComplexExpand@fastfitter@tDDD
1
0.264376 - 0.643429 Cos@2 p tD + 0.327063 Cos@4 p tD + 0.235624 Cos@6 p tD -
t 0.183634 Cos@8 p tD - 1.58626 Sin@p tD + 2.27432 Sin@3 p tD +
1 2 3 4
-1 0.311941 Sin@5 p tD - 1.1018 Sin@7 p tD
-2 See both along with f@tD:
Plot@8f@tD, realfastfitter@tD, realintegralfitter@tD<,
This function is periodic with period L = 2. 8t, 0, L<, PlotStyle ® 88Thickness@0.02D, Blue<,
Here is a Fourier integral fit: 8Thickness@0.01D, CadmiumOrange<, 8Thickness@0.01D, Red<<,
L = 2; AspectRatio ® 1, AxesLabel ® 8"t", ""<D;
Clear@A, integralfitter,
realintegralfitter, realfastfitter, fastfitter, k, tD;

73
DE.03.G5®G6
ystarter = 0; yprimestarter = 0; Clear@Yzeroinput, sD
4 1
Yzeroinput@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ HLaplaceTransform@f@tD, t, sD +
3 s2 + b s + c
2 b ystarter + s ystarter + yprimestarterL
1 LaplaceTransform@f@tD, t, sD
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
c + b s + s2
0.5 1 1.5 2 t
-1 This tells you that the Laplace transform of yzeroinput@tD is
1
-2
€€€€€€€€€€€€€€€€€€€€€€€€€€€
s2 + b s + c
€ times the Laplace transform of f@tD.
For this reason, some folks like to call
The plot of f@tD is blue. 1
The plot of the fast Fourier fit is orange.
H@sD = €€€€€€€€€€€€€€€€€€€€€€
s2 + b s +c

The plot of the Fourier integral fit is red. by the name "transfer function."
Are the results from the integral fit and the fast fit the same? Are they Clear@HD
1
significantly different? H@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€
s2 + b s + c
How do you account for this? 1
€€€€€€€€€€€€€€€€€€€€€€€€€€€€

What do you think would happen if you raised m = n + 1 to a much c + b s + s2
larger number? Again, the big point is that the Laplace transform of yzeroinput@tD is
How does your experience with these calculations mesh with what just:
you said in part i)? H@sD LaplaceTransform@f@tD, t, sD
LaplaceTransform@f@tD, t, sD
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
c + b s + s2
And you get this without an explicit calculation of yzeroinput@tD.
áG.6.a)
How is the transfer function
1
H@sD = €€€€€€€€€€€€€€€€€€€€€€€€€€
s2 + b s + c
related to the characteristic equation for the unforced oscillator
coming from
y² @tD + b y¢ @tD + c y@tD = 0?

How are singularities of H@sD related to roots of the characteristic


equation?

What information do you get about an unforced oscillator when you


know that all the singularities of its transfer function H@sD have
negative real parts?

1
áG.6.b.i) The transfer function H@sD = €€€€€€€€€€€€€€€€€€€€€€€€€
s2 + b s + c
€ is the Laplace
G.6) The transfer function is the Laplace transform of
transform
yunitimpluse@tD
of yunitimpulse@tD
The Laplace transform of yzeroinput@tD is the transfer
Given the forced oscillator:
function times the Laplace transform of the forcing function Clear@y, t, f, b, cD
oscdiffeq = y² @tD + b y¢ @tD + c y@tD == f@tD
Given an oscillator
c y@tD + b y¢ @tD + y² @tD == f@tD
y² @tD + b y¢ @tD + c y@tD = f@tD
with given starting data, lots of folks solve for y@tD by putting You get yunitimpulse@tD as the solution of:
Clear@y, t, f, b, cD
y@tD = yzeroinput@tD + yunforced@tD. unforcedoscdiffeq = y² @tD + b y¢ @tD + c y@tD == 0
Here c y@tD + b y¢ @tD + y² @tD == 0
yzeroinput@tD with y@0D = 0 and y¢ @0D = 1.
solves The Laplace transform of yunitimpulse@tD is::
y² @tD + b y¢ @tD + c y@tD = f@tD ystarter = 0; yprimestarter = 1;
with y@0D = 0 and y¢ @0D = 0 Clear@Yunitimpulse, sD
and 1
Yunitimpulse@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€
yunforced@tD s2 + b s + c
HLaplaceTransform@0, t, sD + b ystarter + s ystarter + yprimestarterL
solves 1
y² @tD + b y¢ @tD + c y@tD = 0 €€€€€€€€€€€€€€€€€€€€€€€€€€€€
c + b s + s2

with the given starting data. This is a good fringe benefit because it tells you that you can
write down the Laplace transform of yunitimpulse@tD without
Coming up with the formula for yunforced@tD is always easy; it's just going to all the trouble of calculating yunitimpulse@tD.

algebra which Mathematica can always handle. How is the Laplace transform of yunitimpulse@tD related to the transfer
function H@sD of the unforced oscillator diffeq
Coming up with a precise formula for yzeroinput@tD is where all hell y² @tD + b y¢ @tD + c y@tD = 0?
can break loose because of intractable integrals or intractable Laplace
transforms. Engineers know how to make an end-run around this What function has H@sD as its Laplace transform?
potential roadblock. They go with the oscillator diffeq: áG.6.b.ii)
Clear@y, t, f, b, cD
oscdiffeq = y² @tD + b y¢ @tD + c y@tD == f@tD Is it true that the Laplace transform of the solution of
c y@tD + b y¢ @tD + y² @tD == f@tD Clear@y, t, f, b, cD
And then they write down the Laplace transform of yzeroinput: oscdiffeq = y² @tD + b y¢ @tD + c y@tD == f@tD
c y@tD + b y¢ @tD + y² @tD == f@tD

74
DE.03.G6®G7
with y@0D = 0 and y¢ @0D = 0 is áG.7.b) Using the definition of the Laplace transform
the Laplace transform of yinitimpulse@tD times the Laplace transform
of f@tD? The second problem on the Electrical Engineering assignment is to
find the Laplace transform of the function y@tD given by
áG.6.b.iii) y@tD = Sin@tD for 0 £ t £ p
Remember the convolution integral method. In this method you get but
yzeroinput@tD by calculating this convolution integral: y@tD = 0 for p < t.
t
yzeroinput@tD = Ù0 yunitimpulse@t - xD f@xD â x. Fats' reaction: Do this integral by Mathematica:
Clear@Y, y, s, tD
Let Mathematica calculate the Laplace transform of yzeroinput@tD: p

Clear@yzeroinut, yunitimpulse, t, f, xD Y@s_D = à Sin@tD E-s t â t


0
t
yzeroinput@t_D = à yunitimpulse@t - xD f@xD â x; 1 E-p s
€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€
0 1 + s2 1 + s2
LaplaceTransform@yzeroinput@tD, t, sD And then say you looked it up in a table."
LaplaceTransform@f@tD, t, sD LaplaceTransform@yunitimpulse@tD, t, sD Explain why Fats is right.
How does this calculation jibe with what you said in part ii above?
áG.7.c) Differentiating the Laplace transform
G.7) Mathematica Fats and the Laplace transform The third problem on the Electrical Engineering assignment is to find
the Laplace transform of the function f@tD given by
Some of the problems discussed here were taken from actual student
assignments in an
f@tD = t E-3 t Sin@4 tD
electrical engineering course in Linear Signals and Systems at a Fats' reaction:
well-known university.
Clear@F, sD
Given a wide berth by the fraternity and sorority crowd because he F@s_D = LaplaceTransform@t E-3 t Sin@4 tD, t, sD
constantly chews snuff right in the lab, "Mathematica Fats" is not at 8 H3 + sL
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
2
the social center of the Mathematica lab. Maybe this has something to H16 + H3 + sL2 L
do with his habit of popping Life Savers and drinking coffee without "To make this look like it was done by hand, look at this:" says Fats.
spitting out his Copenhagen snuff. You know the type. But recently Clear@g, tD
LaplaceTransform@t g@tD, t, sD
Fats has become very popular with the electrical engineering crowd,
-LaplaceTransform H0,0,1L @g@tD, t, sD
and in fact has become one of the most popular residents of the
Mathematica lab. "This tells you that the Laplace transform of t g@tD is minus the
The reasons: derivative of the Laplace transform of g@tD.
® Fats knows mathematics; Now say you looked up this in a table:
® Fats knows Mathematica; in fact he learned a lot of mathematics by LaplaceTransform@E-3 t Sin@4 tD, t, sD
4
exploring Mathematica, and €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

16 + H3 + sL2
® Fats knows how to use Mathematica to fake hand work.
Now differentiate with respect to s and multiply by -1 to get the
This makes him especially useful to the students in Electrical
Laplace transform of
Engineering 313 (Signals) whose professor demands that they do all

of their work by hand. f@tD = t E-3 t Sin@4 tD."


Today you are sitting in on one of Fats' sessions in the lab. Do it and check yourself with Mathematica.
áG.7.a) Trig identities áG.7.d) The Laplace transform of the convolution is the product of
The first problem on the Electrical Engineering assignment is to find the Laplace transforms.
the Laplace transform of the function f@tD given by The next problem on the EE 313 homework set is to find the inverse
f@tD = Sin@t + aD. Laplace transform of:
Fats' reaction: Clear@Y, sD
Clear@F, s, t, aD 1
F@s_D = LaplaceTransform@Sin@t + aD, t, sD Y@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
Hs2 + 1L Hs2 + 4L
Cos@aD + s Sin@aD
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ 1
1 + s2 €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

H1 + s2 L H4 + s2 L
One student asks, "How do I make this look as if it were done by
Some of the engineering students are clueless. Fats says, "That prof
hand?"
probably wanted you to do some miserable algebra. Let's surprise the
Fats says, "Apply a trig identity like this:
prof. Look at this."
handstep1 = Chop@TrigExpand@Sin@t + aDDD
Clear@f, g, h, t, s, x, yD
Cos@tD Sin@aD + Cos@aD Sin@tD t
And then replace Sin@tD and Cos@tD by their Laplace transforms: h@t_D = à f@t - xD g@xD â x
0
LaplaceTransform@Sin@tD, t, sD t

1 à f@t - xD g@xD â x
€€€€€€€€€€€€€€€€ 0
1 + s2
LaplaceTransform@h@tD, t, sD
LaplaceTransform@Cos@tD, t, sD
s LaplaceTransform@f@tD, t, sD LaplaceTransform@g@tD, t, sD
€€€€€€€€€€€€€€€€
1 + s2 Fats goes on: "This tells you that the Laplace transform of the
Which you write up as if you looked them up in a table." convolution
handstep1 •. 8Sin@tD -> LaplaceTransform@Sin@tD, t, sD, t
h@tD = Ù0 f@t - xD g@xD â x
Cos@tD -> LaplaceTransform@Cos@tD, t, sD<
Cos@aD s Sin@aD is the Laplace transform of f@tD times the Laplace transform of g@tD.
€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€€€€€€€€€
1 + s2 1 + s2 That's cool.
Taking a fresh dip and placing it between his cheek and gum, Fats So you can get the inverse transform of
says, "You know this is really a problem from high school trig." 1
Y@sD = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€
Hs2 +1L Hs2 +4L

Now you try one. by looking up the inverse transforms of
1 1
€€€€€€€€€€€€
s2 +1
and €€€€€€€€€€€€
s2 +4
Fake a hand calculation of the Laplace transform of Cos@t - 5.2D.
in a table like this :
Clear@f, tD;
1
f@t_D = InverseLaplaceTransform A €€€€€€€€€€€€€€€€ , s, tE
s2 + 1
Sin@tD

75
DE.03.G7®G8
Clear@g, tD A student says, "What's that?"
1
g@t_D = InverseLaplaceTransform A €€€€€€€€€€€€€€€€ , s, tE Fats says, "It's the same as Y@sD:"
s2 + 4
1 Simplify@Apart@Y@sDD - Y@sDD
€€€€€ Sin@2 tD
2 0
And now the function y@tD whose Laplace transform is Y@sD is just: Then Fats says to look at this:
Clear@y, tD LaplaceTransform@Ek t , t, sD
t
1
y@t_D = à f@t - xD g@xD â x €€€€€€€€€€€€€€€€€
0 -k + s
Sin@tD 1
€€€€€€€€€€€€€€€€€€€€ - €€€€€ Sin@2 tD Now you take over. Explain where the inverse Laplace transform of
3 6
Y@sD comes from.
Check:
Together@LaplaceTransform@y@tD, t, sDD áG.7.g) Periodic impulses
1
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
H1 + s2 L H4 + s2 L
€ Another problem is to find the inverse Laplace transform of
Es
This is the same as: Y@sD = €€€€€€€€€€€€
Es -1

Es
Y@sD InverseLaplaceTransform A €€€€€€€€€€€€€€€€ , s, tE
1 Es - 1
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
€ Es
H1 + s2 L H4 + s2 L InverseLaplaceTransform A €€€€€€€€€€€€€€€€€€€ , s, tE
-1 + Es
Now you try one. No dice.
The students run to Fats who says: "Not surprising; look at this:"
Clear@xD
Use the same method to come up with the inverse Laplace Transform 1
SeriesA €€€€€€€€€€€€€ , 8x, 0, 9<E
of 1-x
s 1 s
Y@sD = €€€€€€€€€€€€€€€€€€€€€€€€€€€
Hs+2L Hs2 +3L
€ = €€€€€€€€€
€ €€€€€€€€€€€€€€€€
s+2 Hs2 +3L
€ 1 + x + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + O@xD10
So
s
E
€€€€€€€€€€€€
Es -1

1
= €€€€€€€€€€€€€€€
1-E-s
= 1 + E-s + E-2 s + E-3 s + . . . E-k s + . . .
Fats continues: "Now look at this:"
Clear@s, t, kD
LaplaceTransform@DiracDelta@tD, t, sD
1
LaplaceTransform@DiracDelta@t - 1D, t, sD
E-s
LaplaceTransform@DiracDelta@t - 2D, t, sD
E-2 s
LaplaceTransform@DiracDelta@t - 3D, t, sD

E-3 s
áG.7.e) Mathematica Fats and Calculus Cal
LaplaceTransform@DiracDelta@t - 10D, t, sD
There is some pressure to have Calculus Cal join Fats' group. But try E-10 s
as they might, the students could not convince Calculus Cal to get Taking a new dip of snuff and a huge slug of coffee, Fats licks his lips
anywhere near Mathematica Fats. Cal knows that when he blurts out and says , "It should now be clear what periodic impulse has
something really stupid such as Es
€€€€€€€€€€€€
Es -1

"If F@sD is the Laplace transform of f@tD and G@sD is the Laplace 1
= €€€€€€€€€€€€€€€
transform of g@tD, then 1-E-s
= 1 + E-s + E-2 s + E-3 s + . . . E-k s + . . .
F@sD G@sD
for its Laplace transform."
is the Laplace transform of
f@tD g@tD,"
What does Fats mean?
then Fats will eat him up and spit him out with his spent snuff.
Fats goes on to say, "I think a rather slick answer to this problem is
Just to keep yourself at a big distance from Cal, say why Cal's idea
DiracDelta@Sin@p tDD."
that if F@sD is the Laplace transform of f@tD and G@sD is the Laplace
Is Fats right?
transform of g@tD, then F@sD G@sD is the Laplace transform of f@tD g@tD is
The characters Mathematica Fats and Calculus Cal are based on real
really stupid. people.
What function has F@sD G@sD for its Laplace transform?
áG.7.f) Partial fractions G.8) Critically damped oscillators
The next problem on the EE 313 homework set is to find the inverse
áG.8.a)
Laplace transform of:
Clear@Y, s, tD Here's a damped oscillator whose characteristic equation has only one
6 s2 + 22 s + 18 solution:
Y@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
Hs + 1L Hs + 2L Hs + 3L Clear@rD;
18 + 22 s + 6 s2 Clear@y, yoriginal, tD
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ originaloscillator = y''@tD + H2 rL y'@tD + r2 y@tD == 0
H1 + sL H2 + sL H3 + sL
Fats' first reaction is: r2 y@tD + 2 r y¢ @tD + y² @tD == 0
Clear@zD
InverseLaplaceTransform @Y@sD, s, tD
charequation =
3 E-3 t + 2 E-2 t + E-t originaloscillator •. 8y''@tD -> z2 , y'@tD -> z, y@tD -> 1<;
Fats says, "Here's how to make it look like a hand calculation:" zsols = Solve@charequation, zD
Apart@Y@sDD 88z ® -r<, 8z ® -r<<
1 2 3
€€€€€€€€€€€€€ + €€€€€€€€€€€€€ + €€€€€€€€€€€€€ Here's a formula for the exact solution of this oscillator with starting
1+s 2+s 3+s
data
Fancy folks call this the partial fraction decomposition of Y@sD. y@0D = p and y¢ @0D = q.
Partial fractions are a big deal in old-fashioned calculus courses.

76
DE.03.G8®G9
Clear@p, qD; Explain this:
originalsol =
DSolve@8originaloscillator, Even though the formulas for all three were radically different in
y@0D == p, y'@0D == q<, y@tD, tD; character, all three plot out approximately the same.
Clear@yoriginalD; áG.8.b.iii)
yoriginal@t_D = y@tD •. originalsol@@1DD
E-r t Hp + Hq + p rL tL
Here are the three formulas that you plotted out above:
ychangedamp@t, 0.0001D
Why are you not surprised by the extra t on the right?
97.2936 E-0.75871 t - 100.486 E-0.74139 t
áG.8.b.i) ycritical@tD
E-3 t•4 H-3.19219 - 1.71269 tL
Here is a damped oscillator whose characteristic equation has only Chop@ComplexExpand@ychangedamp@t, -0.0001DDD
one solution: -3.19219 E-0.74995 t Cos@0.00866011 tD - 197.749 E-0.74995 t Sin@0.00866011 tD
Clear@ycriticalD;
3 One of these actually oscillates (just a wee bit) and the others do not.
r = €€€€€ ; Which one actually oscillates (in theory)?
4
criticaloscillator = y² @tD + H2 rL y¢ @tD + r2 y@tD == 0
9 y@tD 3 y¢ @tD
áG.8.b.iv)
€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€€€€€ + y² @tD == 0
16 2 Lots of folks say that a damped oscillator whose characteristic
Clear@p, qD
criticalsol = equation has only one solution is "critically damped" in the sense that
DSolve@8criticaloscillator, y@0D == p, y¢ @0D == q<, y@tD, tD; ® If the damping term is decreased, then the resulting oscillator
ycritical@t_D = y@tD •. criticalsolP1T actually oscillates.
3p
E-3 t•4 Jp + J €€€€€€€€€ + qN tN
4
® If the damping term is increased, then the resulting oscillator is
Change the damping term a wee bit and keep everything else the same "overdamped" because it does not oscillate at all.
and you get: Why do you think folks say this?
Clear@ychangedampD
changedamposcillator = y² @tD + H2 r + hL y¢ @tD + r2 y@tD == 0
9 y@tD 3
€€€€€€€€€€€€€€€€€€ + J €€€€€ + hN y¢ @tD + y² @tD == 0
16 2
changedampsol =
DSolve@8changedamposcillator,
y@0D == p, y'@0D == q<, y@tD, tD;

ychangedamp@t_, h_D = y@tD •. changedampsol@@1DD

•!!! •!!!!!!!! •!!! •!!!!!!!!!!


E €€€€4 H-3-2 h-2 h 3+h L t II3 + 2 h - 2 h 3 + h M p + 4 qM
1

- €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
•!!! •!!!!!!!!!! +
4 h 3+h
•!!! •!!!!!!!! •!!! •!!!!!!!!!!
E €€€€4 H-3-2 h+2 h 3+h L t II3 + 2 h + 2 h 3 + h M p + 4 qM
1

€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
•!!! •!!!!!!!!!!
4 h 3+h

When you make h = 0.0001, you get:


ychangedamp@t, 0.0001D G.9) Recovering the expansion of a function from its
-14.4335 E-0.75871 t H2.96556 p + 4 qL + 14.4335 E-0.74139 t H3.03484 p + 4 qL
When you make h = -0.0001, you get: Laplace transform
Chop@ComplexExpand@ychangedamp@t, -0.0001DDD
áG.9.a.i)
1. E-0.74995 t p Cos@0.00866011 tD + 86.5982 E-0.74995 t p Sin@0.00866011 tD +
115.472 E-0.74995 t q Sin@0.00866011 tD By now, you know that you can bypass a lot of grubby calculation
Compare all three formulas: provided you deal exclusively in Laplace transforms. This may seem
ychangedamp@t, 0.0001D strange, but it's not at all dangerous because the Laplace transform of
-14.4335 E-0.75871 t H2.96556 p + 4 qL + 14.4335 E-0.74139 t H3.03484 p + 4 qL a function carries the full DNA of the function.
ycritical@tD For instance, if you have the Laplace transform Y@sD of a function y@tD,
3p
E-3 t•4 Jp + J €€€€€€€€€ + qN tN
you can recover the values of y@0D and y¢ @0D directly from Y@sD
4
without inverting. For instance, to recover y@0D, you just calculate
Chop@ComplexExpand@ychangedamp@t, -0.0001DDD
y@0D = Limit@s Y@sD, s ® ∞D
1. E-0.74995 t p Cos@0.00866011 tD + 86.5982 E-0.74995 t p Sin@0.00866011 tD +
115.472 E-0.74995 t q Sin@0.00866011 tD
And, once you have y@0D you just calculate
Account for the change in character of the formulas. y¢ @0D = Limit@s2 Y@sD - s y@0D, s ® ∞D

áG.8.b.ii) Try these out on this sample Y@sD:


Now go with random p and q and see how the three formulas plot out: Clear@y, s, t, YD;
2 H4 + sL
p = Random@Real, 8-5, 5<D; Y@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
q = Random@Real, 8-5, 5<D; PlotA8ychangedamp@t, 0.0001D, 9 + Hs - 5L2
2 H4 + sL
ycritical@tD, Chop@ComplexExpand@ychangedamp@t, -0.0001DDD<, €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

8t, 0, 15<, PlotStyle ® 88Thickness@0.04D, Yellow<, 9 + H-5 + sL2
8Thickness@0.02D, Black<, 8Thickness@0.01D, Red<<, To recover y@0D without inverting Y@sD, look at
1
AxesLabel ® 8"t", ""<, PlotRange ® All, AspectRatio ® €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ E; y@0D = Limit@s Y@sD, s ® ∞D
GoldenRatio
ExpandAll@Together@s Y@sDDD
t 8s 2 s2
2 4 6 8 10 12 14 €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
€ + €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

-0.5 34 - 10 s + s2 34 - 10 s + s2
-1 By going with quotients of the dominant terms, you can pick off
-1.5 y@0D = Limit@s Y@sD, s ® ∞D
-2

€ , s ® ∞E
2
8 2s
-2.5
= LimitA €€€€€
s
€ + €€€€€€€€€
s2
-3

Rerun several times. =0 + 2 = 2

77
DE.03.G9®G10
¢
To recover y @0D without inverting Y@sD, look at áG.9.a.iii)
y¢ @0D = Limit@s2 Y@sD - s y@0D, s ® ∞D :
Together@s2 Y@sD - s y@0DD •. y@0D ® 2
Look at this:
Clear@y, s, tD;
-68 s + 28 s2
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
€ LaplaceTransform@y''@tD, t, sD
34 - 10 s + s2
s2 LaplaceTransform@y@tD, t, sD - s y@0D - y¢ @0D
By going with quotients of the dominant terms, you can pick off
y¢ @0D = Limit@s2 Y@sD - s y@0D, s ® ∞D Once you have your hands on y@0D and y¢ @0D, what limit involving
Y@sD, y@0D and y¢ @0D
-68 s + 28 s 2
= LimitA €€€€€€€€€€€€€€€€€€€€€€€€€€€€€ , s ® ∞E do you calculate to calculate y² @0D?
34 -10 s + s2 No explanation is asked for.
, s ® ∞E = 28.
2
28 s áG.9.a.iv)
= LimitA €€€€€€€€€€€€
s2
Look at this:
Check: Clear@y, s, tD
Clear@y, tD; LaplaceTransform@y'''@tD, t, sD
y@t_D = InverseLaplaceTransform @Y@sD, s, tD; s LaplaceTransform@y@tD, t, sD - s2 y@0D - s y¢ @0D - y² @0D
3
y@0D == 2
y¢ @0D == 28 Once you have your hands on y@0D , y¢ @0D, and y² @0D,what limit
True involving
True Y@sD, y@0D , y¢ @0Dand y² @0D
This checks. do you calculate to calculate the third derivative yTagBox@H3LD @0D ?
Now you do one. No explanation is asked for.
Here is the Laplace transform of a function y@tD: This part is for only those participants
Clear@Y, sD; who have a knowledge of series expansions.

3 s5 + 12 s3 - 15 s At this point, it becomes clear that, given Y@sD, you could go on and
Y@s_D = €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
1 + 3 s2 + 3 s4 + s6 on to slam out as many of the values of the higher derivatives at 0
-15 s + 12 s3 + 3 s5
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
1 + 3 s2 + 3 s4 + s6
€ y@0D, y¢ @0D, y² @0D, yTagBox@H3LD @0D, yTagBox@H4LD @0D,yTagBox@H5LD @0D, . .
TagBox@HkLD
Calculate the limits .y @0D, . . .. .
y@0D = Limit@s Y@sD, s ® ∞D as you like. After you have these, you have as much of the expansion
and of y@tD in powers of t as you like:
y¢ @0D = Limit@s2 Y@sD - s y@0D, s ® ∞D Clear@y, tD;
Series@y@tD, 8t, 0, 6<D
to come up with y@0D and y¢ @0D without inverting the Laplace 1 1 1 1
y@0D + y¢ @0D t + €€€€€ y² @0D t2 + €€€€€ yH3L @0D t3 + €€€€€€€€ yH4L @0D t4 + €€€€€€€€€€€ yH5L @0D t5 +
transform. Then invert the Laplace transform to check your 2 6 24 120
calculations. 1
€€€€€€€€€€€ yH6L @0D t6 + O@tD7
720
Clear@y, tD;
Series@y@tD, 8t, 0, 12<D

1 1 1 1
áG.9.a..ii) Explanations y@0D + y¢ @0D t + €€€€€ y² @0D t2 + €€€€€ yH3L @0D t3 + €€€€€€€€ yH4L @0D t4 + €€€€€€€€€€€ yH5L @0D t5 +
2 6 24 120
1 y H7L @0D t7 y H8L @0D t8 y H9L @0D t9 y H10L @0D t10
Look at this calculation which was explained in the Basics: €€€€€€€€€€€ yH6L @0D t6 + €€€€€€€€€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ +
720 5040 40320 362880 3628800
Clear@y, s, tD; yH11L @0D t11 yH12L @0D t12
LaplaceTransform@y'@tD, t, sD €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ + €€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€ + O@tD13
39916800 479001600
s LaplaceTransform@y@tD, t, sD - y@0D This tells you that if you assume that y@tD has an expansion in powers
Putting of t and you assume that all the higher derivatives of y@tD are legal for
Y@sD = LaplaceTransform@y@tD, t, sD, the Laplace transform, then you can recover the expansion of y@tD in
this calculation tells you that powers of t. And this gives you a hint of why Laplace transforms can

s Y@sD - y@0D = LaplaceTransform@y¢ @tD, t, sD = Ù0 E-s t y¢ @tD â t be inverted. And it gives you a hint of why you can leave the Laplace
So transform world anytime you like.

y@0D = s Y@sD - Ù0 E-s t y¢ @tD â t
no matter what s is. G.10) Using Fourier fit to slam out trig identities
Take the limit as s ® ∞ to get
∞ Activate this code.
y@0D = Limit@s Y@sD - Ù0 E-s t y¢ @tD â t, s ® ∞D Clear@FastFourierfit, Fourierfitters, F, Fvalues, n, k,
jump, num, numtab, coeffs, t, LD;
= Limit@s Y@sD, s ® ∞D - 1
jump@n_D := jump@nD = NA €€€€€€€€€ E;
∞ 2n
Limit Ù0 E-s t y¢ @tD â t, s ® ∞D Fvalues@F_, L_, n_D :=
N@Table@F@L tD, 8t, 0, 1 - jump@nD, jump@nD<DD;

= Limit@s Y@sD, s ® ∞D - 0
(because E-s t collapses as s gets large and positive) numtab@n_D := numtab@nD = Table@k, 8k, 1, n<D;

2pIkt

= Limit@s Y@sD, s ® ∞D Fourierfitters@L_, n_, t_D := TableAE €€€€€€€€€€€€€€€€


L ,
8k, -n + 1, n - 1<E;
This explains why you can calculate coeffs@n_, list_D := Join@Reverse@Part@Fourier@listD, numtab@nDDD,
y@0D = Limit@s Y@sD, s ® ∞D Part@InverseFourier@listD, Drop@numtab@nD, 1DDD •
Now look at this calculation which was also explained in the Basics: N@Sqrt@Length@listDDD

Clear@y, s, tD FastFourierfit@F_, L_, n_, t_D :=


LaplaceTransform@y''@tD, t, sD Chop@Fourierfitters@L, n, tD . coeffs@n, Fvalues@F, L, nDDD;
2 ¢
s LaplaceTransform@y@tD, t, sD - s y@0D - y @0D
This tells you that áG.10.a.i)

s2 Y@sD - s y@0D - y¢ @0D = Ù0 E-s t y'' @tD â t. Look at these little experiments:
Adapt the explanation above to explain why, once you have your
hands on y@0D, you can calculate
y¢ @0D = Limit@s2 Y@sD - s y@0D, s ® ∞D :

78
DE.03.G10
2= n
áExperiment 1: f@tD = Sin@tD2 1
0.5
Clear@f, tD
f@t_D = Sin@tD2 ; 1 2 3 4 5 6
L = 2 p; -0.5

8n, Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD< -1


n = 3;
8n, 1, 8<
Clear@fitterD;
81, 0<
fitter@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD;
82, 0.5<
83, 0.5 - 0.5 Cos@2 tD< Plot@8f@tD, fitter@tD<, 8t, 0, L<,
84, 0.5 - 0.5 Cos@2 tD< PlotStyle -> 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
85, 0.5 - 0.5 Cos@2 tD< PlotRange -> All, PlotLabel -> n "= n"D;
86, 0.5 - 0.5 Cos@2 tD<
87, 0.5 - 0.5 Cos@2 tD< 3= n
1
88, 0.5 - 0.5 Cos@2 tD<
0.5
Compare:
1 2 3 4 5 6
N@Expand@TrigReduce@f@tDDDD -0.5
0.5 - 0.5 Cos@2. tD -1
n = 4;
áExperiment 2: f@tD = Cos@tD4 : Clear@fitterD;
Clear@f, tD fitter@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD;
f@t_D = Cos@tD4 ;
Plot@8f@tD, fitter@tD<, 8t, 0, L<,
L = 2 p;
PlotStyle -> 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
8n, Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD< PlotRange -> All, PlotLabel -> n "= n"D;
8n, 1, 8<
81, 1.< 4= n
82, 0.5< 1
83, 0.375 + 0.625 Cos@2 tD< 0.5
84, 0.375 + 0.5 Cos@2 tD< 1 2 3 4 5 6
85, 0.375 + 0.5 Cos@2 tD + 0.125 Cos@4 tD< -0.5
86, 0.375 + 0.5 Cos@2 tD + 0.125 Cos@4 tD< -1
87, 0.375 + 0.5 Cos@2 tD + 0.125 Cos@4 tD< n = 5;
88, 0.375 + 0.5 Cos@2 tD + 0.125 Cos@4 tD< Clear@fitterD;
fitter@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD;
Compare:
N@Expand@TrigReduce@f@tDDDD Plot@8f@tD, fitter@tD<, 8t, 0, L<,
0.375 + 0.5 Cos@2. tD + 0.125 Cos@4. tD PlotStyle -> 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
PlotRange -> All, PlotLabel -> n "= n"D;

5= n
áExperiment 3:f@tD = Sin@tD8 1
0.5
Clear@f, tD
f@t_D = Sin@tD8 ; 1 2 3 4 5 6
L = 2 p; -0.5

8n, Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD< -1


n = 6;
8n, 1, 12<
Clear@fitterD;
81, 0<
fitter@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD;
82, 0.5<
83, 0.210938 - 0.210938 Cos@2 tD< Plot@8f@tD, fitter@tD<, 8t, 0, L<,
84, 0.28125 - 0.5 Cos@2 tD< PlotStyle -> 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<,
85, 0.273437 - 0.429687 Cos@2 tD + 0.15625 Cos@4 tD< PlotRange -> All, PlotLabel -> n "= n"D;
86, 0.273438 - 0.4375 Cos@2 tD + 0.226562 Cos@4 tD<
87, 0.273438 - 0.4375 Cos@2 tD + 0.21875 Cos@4 tD - 0.0546875 Cos@6 tD< 6= n
1
88, 0.273437 - 0.4375 Cos@2 tD + 0.21875 Cos@4 tD - 0.0625 Cos@6 tD<
0.5
89, 0.273438 - 0.4375 Cos@2 tD + 0.21875 Cos@4 tD - 0.0625 Cos@6 tD + 0.0078125
810, 0.273437 - 0.4375 Cos@2 tD + 0.21875 Cos@4 tD - 0.0625 Cos@6 tD + 0.007812 1 2 3 4 5 6
811, 0.273437 - 0.4375 Cos@2 tD + 0.21875 Cos@4 tD - 0.0625 Cos@6 tD + 0.007812 -0.5

812, 0.273438 - 0.4375 Cos@2 tD + 0.21875 Cos@4 tD - 0.0625 Cos@6 tD + 0.007812 -1

Compare: áG.10.a.ii)
N@Expand@TrigReduce@f@tDDDD Run this new experiment:
0.273438 - 0.4375 Cos@2. tD + 0.21875 Cos@4. tD - 0.0625 Cos@6. tD +
Clear@f, tD;
0.0078125 Cos@8. tD
f@t_D = Cos@tD20 ;
Do you have any hunch about what's going on here, or are you L = 2 p;
clueless? 8n, Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD<
If you have a hunch, then say what your hunch is. 8n, 1, 12<
81, 1.<
If you are sure you know what's going on, then explain in full. 82, 0.5<
Click for a tip. 83, 0.333334 + 0.666666 Cos@2 tD<
84, 0.250488 + 0.5 Cos@2 tD<
To get a good clue, you might want to look at plots like these: 85, 0.20577 + 0.403566 Cos@2 tD + 0.390663 Cos@4 tD<
Clear@f, n, tD; 86, 0.185438 + 0.352104 Cos@2 tD + 0.314562 Cos@4 tD<
f@t_D = Sin@tD5 ; 87, 0.178371 + 0.329962 Cos@2 tD + 0.269878 Cos@4 tD + 0.221788 Cos@6 tD<
L = 2 Pi; 88, 0.176559 + 0.322571 Cos@2 tD + 0.249512 Cos@4 tD + 0.177429 Cos@6 tD<
89, 0.176235 + 0.320723 Cos@2 tD + 0.242443 Cos@4 tD + 0.157099 Cos@6 tD + 0.10
n = 2; 810, 0.176199 + 0.320396 Cos@2 tD + 0.240631 Cos@4 tD + 0.150032 Cos@6 tD + 0.0
Clear@fitterD;
811, 0.176197 + 0.32036 Cos@2 tD + 0.240307 Cos@4 tD + 0.14822 Cos@6 tD + 0.076
fitter@t_D = Chop@ComplexExpand@FastFourierfit@f, L, n, tDDD;
812, 0.176197 + 0.320358 Cos@2 tD + 0.240271 Cos@4 tD + 0.147896 Cos@6 tD + 0.0
Plot@8f@tD, fitter@tD<, 8t, 0, L<, Compare:
PlotStyle -> 88Thickness@0.02D, Blue<, 8Thickness@0.01D, Red<<, N@Expand@TrigReduce@f@tDDDD
PlotRange -> All, PlotLabel -> n "= n"D;

79
DE.03.G10
0.176197 + 0.320358 Cos@2. tD + 0.240269 Cos@4. tD +
0.147858 Cos@6. tD + 0.0739288 Cos@8. tD + 0.0295715 Cos@10. tD +
0.0092411 Cos@12. tD + 0.00217438 Cos@14. tD + 0.000362396 Cos@16. tD +
0.000038147 Cos@18. tD + 1.90735 ´ 10-6 Cos@20. tD
What's your opinion on the reason that this experiment didn't turn out
the way the experiments in part i) above turned out?
Modify this experiment so that it does turn out the way the
experiments in part i) above turned out.
áG.10.a.iii)
Go with f@tD = Sin@tD12.
And look at:
Clear@f, tD;
f@t_D = Sin@tD12 ;
N@Expand@TrigReduce@f@tDDDD
0.225586 - 0.386719 Cos@2. tD + 0.241699 Cos@4. tD - 0.107422 Cos@6. tD +
0.0322266 Cos@8. tD - 0.00585938 Cos@10. tD + 0.000488281 Cos@12. tD
Use Fourier fit to slam out the same trig identity.
áG.10.a.iv)
Go with f@tD = Sin@5 tD Sin@3 tD.
And look at:
Clear@f, tD;
f@t_D = Sin@5 tD Sin@3 tD;
N@Expand@TrigReduce@f@tDDDD
0.5 Cos@2. tD - 0.5 Cos@8. tD
Use fast Fourier fit to slam out the same trig identity.
áG.10.a.v)
Go with f@tD = Cosh@I tD
And look at:
Clear@f, tD;
f@t_D = Cosh@I tD;
N@Expand@TrigReduce@f@tDDDD
Cos@tD
Use Fourier fit to slam out the same trig identity.

áG.10.a.vi)
Go with f@tD = Sinh@I tD
And look at:
Clear@f, tD;
f@t_D = Sinh@I tD;
N@Expand@f@tD, Trig ® TrueDD
1. I Sin@tD
Use Fourier fit to slam out the same trig identity.

80

You might also like