Professional Documents
Culture Documents
The Maple® O.D.E. Lab Book
The Maple® O.D.E. Lab Book
Lab Book
Springer
New York
Berlin
Heidelberg
Barcelona
Budapest
Hong Kong
London
Milan
Paris
Santa Clara
Singapore
Tokyo
Darren Redfern Edgar Chandler
The Maple®
O.D.E. Lab Book
With 50 Figures
DOS Diskette Included
Springer
Darren Redfern Edgar Chandler
Practical Approach Corporation Scottsdale Community College
151 Frobisher Drive, Suite C-210 9000 E. Chaparral Road
Waterloo, ON N2V 2C5 Scottsdale, AZ 85250
Canada USA
987654321
ISBN-13: 978-0-387-94733-4 e-ISBN-13: 978-1-4612-2402-0
DOl: 10.1007/978-1-4612-2402-0
We would like to gratefully dedicate this project to our families and
colleagues who, over the years, have been very supportive and helpful,
providing much appreciated guidance and direction.
Contents
1. Introduction 1
How This Lab Book Is Organized 2 • Using the
Diskette 2 • Where to Go for More Information 3 •
Acknowledgments 3
3. First-Order ODEs 25
Defining and Solving First-Order ODEs 25 • Explicit vs.
Implicit Solutions 28 • Activities for §3 31
vii
viii • Contents
5. Graphical Methods 45
Direction Fields 46 • Some Examples 49 • Activities
for §5 53
Bibliography 154
Index 157
Introduction
CHAPTER
1
2 • Chapter 1. Introduction
Email: info~practical.on.ca
darren~practical.on.ca
WWW: http://www.practical.on.ca
Acknowledgments
A hearty thank you goes out to those colleagues who provided their time
and expertise to the project. Included in their ranks are Ian McGee, Jerry
Marsden, David Doherty, Bruce Barber, and David Raimondo.
Getti ng Started
CHAPTER
with Maple
This chapter is intended to familiarize you with how Maple works, how
expressions and commands are entered in Maple, and how to make sense
of the results.
There are dozens of areas that could be covered in a chapter such
as this. Instead of introducing all these aspects of Maple, we restrict our
focus to those general areas that have a direct bearing on the computations
performed in the rest of this supplement. For a broader overview of Maple's
functionality, refer to the materials mentioned in the Where to Go for More
Information section of Chapter 1.
More ODE-specific commands are detailed in the chapters where they
are first used. In this chapter we restrict ourselves to exploring the basic
structure of Maple expressions and operators, and the mechanics of how
to invoke commands.
Starting Maple
On systems which support command line interfaces (e.g., UNIX, DOS),
Maple is typically started by entering the command maple at the prompt.
Systems with more advanced graphical user interfaces (e.g., Macintosh,
NeXT, Windows, Amiga) have a Maple program icon that activates the
application.
4
Basic Maple Syntax • 5
> x
Sometimes problems arise when beginners (or even experts) enter input
lines.
As detailed above, if the input is an incomplete statement, Maple does
not perform any calculations, but provides you with another input prompt
directly below the line just entered. This behavior can happen naturally
when an input is so long that it stretches over several lines, but most often
it is because a semicolon or colon was omitted. (Beginning users often
mistake this lack of activity for inability to perform the calculation.) Simply
add a terminator on the new line and hit Enter.
> expand«x+l)~4)
6 • Chapter 2. Getting Started with Maple
> .
•
When there is a syntax error in the input, Maple prints a syntax error
message. A caret (-) marks where Maple's interpreter first ran into trouble.
It is then up to you to correct the error.
If your input is syntactically correct but contains another type of mis-
take, Maple issues an error message. Be warned, however, that Maple's
error messages occasionally are rather obtuse, failing to indicate exactly
what you did wrong or how you should go about fixing it.
> divide(x-2+1);
Calling Sequence:
divide(a. b. 'q')
Parameters:
Basic Maple Syntax • 7
Synopsis:
- divide checks if the polynomial b divides a over the rationals. If so, true
is returned; otherwise false is returned.
- If the division is successful and there is a third argument 'q',then the
value of the quotient is assigned to q. In the case of an unsuccessful
division the name q will not be affected.
Examples:
> divide(x-3-y-3, x-y, 'q');
true
> q;
2 2
y + x y + x
Most help pages have fields (i.e., FUNCTION, CALLING SEQUENCE, etc.)
identical to the above.
Unlike our earlier stated rule, requests for help information do not need
to be terminated by a colon or semicolon.
If you are unsure of a command name, try reading ?intro and ?in-
dex. On windowing versions of Maple there is typically a Help Topic
Browser (usually accessed through the Help Menu) that allows you to
navigate through the many different command names available. Refer to
your platform-specific Maple documentation for more details.
Another basic consideration that often confuses new users is the ad-
dition of blank spaces in Maple input. For the most part, blank spaces
can be added at will and are automatically removed by Maple's parser if
redundant, but there are a few rules and exceptions. For example, blank
spaces cannot be added to the middle of a number or a command name.
> 1 234 567 / 89;
syntax error, unexpected number:
1 234 567 / 89;
If you wish, use the continuation character (\) to organize large numbers.
This character is simply ignored by the parser whenever it is encountered.
8 • Chapter 2. Getting Started with Maple
31
> 3/7;
3
7
> -39/13;
-3
Rationals are automatically put into their lowest terms.
Floating-point Numbers
Decimal representations of numerical values are expressed as you would
expect, and appear as the results of many of Maple's numerical proce-
dures. As well, numerical values can be represented in base 10 or scientific
notation.
Mixing and Matching Different Number Types • 9
> 2.3;
2.3
> -123.45678;
-123.45678
> .143 * 10-(-44);
.143000000010- 44
> Float(3141, -3);
3.141
> 1.234e10;
.123410 11
Mathematical Constants
While integers, rationals, and floating-point numbers can be thought of as
constants of a sort, Maple also supports many other common mathematical
constants. The list includes:
Pi Jr,3.1415926535 ...
exp(1) e, natural log base
I r-r
infinity 00
-infinity -00
gamma Euler's constant
Catalan Catalan's constant
true, false boolean values
Maple is case sensitive, so be sure to use proper capitalization when
stating these constants. The names Pi and pi are not equivalent!
retain values in their exact form throughout many calculations. There is,
however, one situation where exact values are converted to approxima-
tions: when you mix and match types in an expression. The following
examples illustrate this idea.
> 1/3 + 2;
7
3
> 1/3 + 2.0;
2.333333333
Placing even one floating-point value in a large exact expression causes
complete conversion to floats.
> 1/2 + 2/3 + 3/5 + 5/7 + 7/11 + 1.2;
4.317316017
Strings
A string in Maple consists of a number of characters of any sort surrounded
by backquote characters ('). Following are two examples of Maple strings.
> 'This is a Maple string';
x + 5/9
Special characters (+, ., /, etc.) and blank spaces may be included any-
where in a string, as long as the backquote characters are present. If the
backquote characters are not present, then these special characters are
treated as normal Maple operators.
> directory/filename;
directory
filename
Maple Expressions • 11
> invert.src;
invertsrc
A name in Maple is a special type of string, which typically contains a
letter (a-z, A-Z) followed by zero or more letters, digits (0-9), and under-
scores C). There is no practical limit to the length of names; they can have
over 500,000 characters. Names are case sensitive. The name MyName is
distinct from myname. One difference between names and strings is that
names do not need to be enclosed with backquotes, unless the name con-
tains special characters that you do not wish to be evaluated. The following
are some examples of valid Maple names.
> MyVariable;
My Variable
> hello;
hello
> 'greatest common divisor';
Maple Expressions
Expressions are extremely important structures in Maple. All Maple ob-
jects are, at one level or another, made up entirely of expressions. At its most
basic level, an expression consists of a single value, unknown, or string.
Conversely, Maple expressions can consist of thousands upon thousands
12 • Chapter 2. Getting Started with Maple
1 2 1 2
25 x + 36 Y
Maple echoes these expressions in a "pretty" form, the quality of which
depends upon the capabilities of your monitor.
Order of Operations
In expressions, the precedence of operators follows the standards found in
most other areas of computation. If there are any ambiguities, use paren-
theses, 0, to specify the order of operations.
> 2+3*4-5;
9
> (2+3)*4-5;
15
Sets and Lists • 13
-5
It is a good idea to use parentheses whenever there is any chance of am-
biguity. If a set of parentheses is redundant, Maple's parser eliminates it
during computation.
Expression Sequences
Another common data structure in Maple is the expression sequence. An
expression sequence is one or more Maple expressions separated by com-
mas. Most Maple commands require an expression sequence as input, and
many return a result that includes an expression sequence.
The simplest way to create an expression sequence is to enter it as such.
> 1, 2, 3, 4, 5;
1,2,3,4,5
> a+b, b+c, c+d, e+f, f+g;
a + b, b + c, c + d, e + (,f + g
Alternatively, there are two automatic ways to generate an implicit expres-
sion sequence. First, the $ operator can be used alone to create sequences
containing multiples of one element, or in conjunction with the ellipsis
operator (.. ), to create well-ordered sequences.
> a$6;
a,a,a,a,a,a
> $1. .6;
1,2,3,4,5,6
1,4,9,16,25,36
Now that you have learned how the create expressions and expression
sequences, it is time to put those skills to use creating the next level of
14 • Chapter 2. Getting Started with Maple
Maple objects: sets and lists. These two data types lend organization to
Maple objects, although the exact manner in which they do so varies.
Sets
A set is a non-ordered collection of expressions. Any valid Maple expres-
sion can be contained in a set. Sets are often used as input to Maple com-
mands and are frequently contained in Maple output. A set is written as
an expression sequence surrounded by braces, n. One important thing
to remember about sets is that repetitive elements are automatically re-
moved. The first of the following three examples demonstrates this "non-
repetitive" rule.
> {1, 1, 2, 3, 2};
{1,2,3}
> {a*x, blue, -234.456, 'Maple Tutorial'};
{b, a, c, e, f, d}
> {1, 2, 3, 4, 5} intersect {2, 4, 6, 8, 10};
{2,4}
Sets and Lists • 15
{x2,x3}
true
Lists
Though similar in syntax, lists and sets have significant differences. Both
sets and lists are created from expression sequences, but lists are enclosed
with right and left brackets, [], as opposed to braces. As well, lists are
well-ordered objects, meaning that when you specify a list in Maple the
ordering that you indicated is preserved. A third fundamental difference is
that duplicate elements are valid within a list. The following are examples.
> [1,2,3,4,5,4,3,2,1];
[1,2,3,4,5,4,3,2,1]
> [a, d, c, b, e];
[a, d, c, b, e]
> [{c,a,t}, {d,o,g}, {m,o,u,s,e}];
In the last example, the three sets are elements of the list enclosing them.
While the ordering of the elements within the sets may vary, the ordering
of the three sets themselves remains constant.
While the union, intersect, and minus operators do not work on lists,
the commands op and nops may be used to access and manipulate elements
of a list. (Recall that Maple's on-line help facility can be used to access
information on new commands such as ops and nops.)
> listl := [a, exp(3), 1,2/3];
~ 2
listl := [a, e-', 1, 3"]
> nops(listl);
4
16 • Chapter 2. Getting Started with Maple
Command Names
Learning about Maple expressions and other data types, such as lists and
sets, has led to their most common use: as parameters in commands. There
is a wealth of built-in commands stored in the Maple library. Each com-
mand is called in the following manner:
commandname(parameterl, parameter2, ... , parametern );
The following is an example of a command call to plot, which plots
the function y = x 2 - 4 with a horizontal (x) range of -5 .. 5 and a vertical
(y) range of -5 .. 10.
[Note: not all commands that start with a capital letter are inert (e.g., D,
C, GAMMA).]
Again, remember that Maple is case sensitive, which means that factor,
Factor, and FaCTor are all different in Maple. Whether they are used as
command names or variable names, Maple considers them three separate.
The following are examples of more valid calls to Maple commands.
> isprime(10889);
true
3x2 -10x+2
> sin(Pi/2);
x 2 +3x-l0
> realroot(x-3+37*x-21, 1/100);
1
realroot(x 3 + 37 x - 21, 100}
> readlib(realroot);
proc(poly, widthgoal} ... end
> realroot(x-3+37*x-21, 1/100);
9 73
[[16' 128]]
Once a command has been loaded into memory, it does not need to be
reloaded during the current Maple session.
Functions in Packages
Maple contains over a dozen specialized sets of commands called packages
(e.g., linalg, liesymm, etc.). The routines in these packages are not automat-
ically loaded, nor can they be accessed with the readlib command. Most of
these packages will not be used in this book, but it is a useful to know how
to access them nonetheless. The first method of accessing these commands
is to use the with command, which loads in pointers to all the commands in
a particular package. Then, when any command in that package is called, it
Assignments and Equations • 19
24
> numtheory[divisors] (20);
Assignments
You have previously learned how to create expressions, special data types,
and Maple command calls; but these objects are transitory until you ac-
tually assign their values (or results) to some holder or variable. For ex-
ample, if you create a list containing the first ten prime numbers in order
and do not assign this to a variable name, then each time you wish to use
that structure within a Maple command or larger data structure, you must
recreate it from scratch. If, instead, you assign the list, with the := operator,
20 • Chapter 2. Getting Started with Maple
to a variable name, say first10primes, then you can easily use it in other
calculations or as input to other Maple commands.
fi,rstl0primes:= [2,3,5,7,11,13,17,19,23,29]
6469693230
Bear in mind that when you make an assignment, the expression to the right
of := is first evaluated, and then that value is assigned to the name on the
left of := until you tell Maple differently. Maple only remembers the most
recently assigned value for any variable-if you assign the variable x to 5
and then later assign it to 7.5, only the latter assignment is remembered.
As well, you must use caution when choosing names for assigned vari-
ables. Maple allows you to choose almost any name for a variable, includ-
ing names that are used as Maple commands. If you redefine a Maple
command name through an assignment, the standard meaning of that
command is temporarily lost and this can cause many unpredictable er-
rors within your session. To be sure that you are not using any predefined
names, try a Maple help command (i.e., ?name) for the variable name be-
fore you use it. One particular set of names to which Maple does not allow
you to assign values are keywords. Keywords are special words used by
Maple in its programming language, and are all in the following table.
and by do done elif
else end fi for from
if m intersect local mmus
mod not od option options
or proc quit read save
stop then to umon while
Equations
The most important thing to realize about equations is that they are not
the same as assignments. Equations are simply mathematical expressions
that show relationships between certain variables and values; they do not
infer any explicit values on the variables they contain. For example:
Assignments and Equations • 21
> x =Y+ 3;
x=y+3
> x;
x
> y;
y
The variables x and yare still unassigned.
The = operator is most frequently seen in either input to a Maple
command or output from a Maple command. One common family of
commands that makes extensive use of the = operator is the solve family
(i.e., solve, rsolve, dsolve, etc.). These commands take equations of various
forms and try to find a solution for a given set of variables.
For example, solve takes a set of linear or nonlinear equations and tries
to find a closed-form solution.
> sols := solve({x + y = 3,x - Y = 1}, {x, y});
sols := {y = 1,x = 2}
> x, y;
x,y
As you can see, the solution that you get is a set of equations for the specified
variables. If there are multiple solutions, they are all presented. Be aware
that x and y have not been assigned to the values 2 and 1, respectively.
If you wish to make such an assignment, use the assign command, which
takes an equation or set of equations and changes each equation to an
assignment.
> assign(sols);
> x, y;
2,1
> x := 'x'; y := 'y';
x:=x
y:=y
22 • Chapter 2. Getting Started with Maple
Double Quote
The double quote operator (") is perhaps the easiest quote to remember.
Double quote recalls previous output in a Maple session. One double quote
recalls the most recent output, two ("") recall the second most previous
result, and three (" '''') recall the third most previous output. You cannot
go further back than three outputs.
Using double quote remains very straightforward when in command
line mode. Even if you use the colon terminator to suppress the display of
output from a particular command, the double quote operator can be used
to display that previously suppressed output.
Another way of looking at the double quote operator is as a short-
term replacement for assignment. In most cases, it is better to immediately
assign that output to some variable name (which allows you to refer to it
any time later in that session).
> expand((x-2)-3*(x-l));
x4 - 7 x 3 + 18 xl - 20 x +8
> factor(II);
X4 - 7 x 3 + 18 x 2 - 20 x +8
xl + 3x - 2
Backward Quote
The backward quote operator (') is used to enclose Maple strings. While
only strings with special characters (e.g., /, *, !) need backward quotes
around them, it is recommended that you get in the habit of using them on
all your strings.
Activities for §2 • 23
Single Quote
Single (forward) quotes can be used to unassign a variable that was previ-
ously assigned to a value.
> x := 3;
x:=3
> x := 'x';
x:=x
Activities for §2
1. The library contains the core of Maple's mathematical capabilities.
A complete description of every library routine is available by using
Maple's on-line help facility.
Print the contents of the output for the following command:
?Iibrary
2. Evaluate each of the following numerical expressions:
Factor:
3 2 sin(x).J 2 3x2 + 2
y=x -5x +2x+3,y= --,Y= 20-x ,Y= 2 4
x x -
6. In the graph ofy = x 3 -6x2 + 7x+2, there are two local extreme points
(called the local minimum and local maximum). Graph this function
and estimate the x and y coordinates of both these points. Improve
on your estimates by using the subs command (refer to the on-line
help page for syntax) to find the greatest or least value of y in each
neighborhood.
Hint: It is useful to first define the function using f:= x"3 - 6*XL ....
Use trial and error to improve your estimates.
Can you think of any ways (using graphs) that you could get a
better initial estimate of the local maximum and local minimum?
First-Order ODEs
CHAPTER
In this chapter you will use the following functions and commands for the
first time:
25
26 • Chapter 3. First-Order ODEs
> D(y)(x);
D(y)(x)
o
Differential equations can be created using scalars and Maple's stan-
dard arithmetic operators: +, -, *, /, and A.
D(Fred)(Wilma) = 2 Fred(W;lma)
Wilma + TC
Using the diff(y(x), x) form to represent an ODE has the advantage that
the result ultimately returned for y(x) can easily be substituted back into
the ODE to verify that it is indeed a valid solution. 1 Because this sort of
verification is not possible with the D(x)(y) format, the diff(y(x), x) format
is used in the remainder of this book whenever possible.
Maple displays unevaluated calls to diff using the partial derivative no-
tation, a, instead of the standard derivative notation, d. This happens be-
cause Maple uses the same command, diff, to compute both partial deriva-
tives and standard derivatives. To maintain consistency, we use the partial
derivative notation throughout all parts of this book.
sol:= - Cl t 2 + 4 - Cl
> subs(y(t) = sol, deq);
~ ( Cl t 2 + 4 Cl) = 2 t L Cl t 2 + 4 _Cl )
at - - t2 + 4
Now, on the surface, this result doesn't tell you much; but if you sim-
plify both sides of the equation, you get
> simplify(II);
Because the resulting equation is an identity (i.e., true for all possible
values of the variable), the solution checks for all values of the constant
_C1.
The general solution, which is a one-parameter family of solutions, can
be shown graphically. The following plot command shows five different
members of the family of solutions obtained above.
2Several other Maple commands create variables or constants with names starting with
the underscore character. It is not recommended that you independently create any such
names.
28 • Chapter 3. First-Order ODEs
y(t) = t 2 +4
Notice that this particular solution is one member of the family of original
solutions above, in particular, the one where the constant _C1 = 1.
y( t
)-_ Jsin(t) (-sin(t) + _Cl) , y()t __
-
Jsin(t) (- sin(t) + _Cl)
sin(t) sin(t)
2) Imposing an initial condition on the equation.
> so11 := dsolve({deq1, y(Pi/2) = 1}, yet));
1.- () _
so1 .- y t -
J -(sin(t). -()2) sin(t)
sm t
This solution must be carefully checked, to see if it satisfies all of the
given conditions.
> subset = Pi/2, so11);
1
y( 2: rr) =
J i
-(sin( 1f) - 2) sin(! rr)
. (1 )
sm 2:rr
> simplify (") ;
1
y( 2:rr) = 1
y2-2xcry y-3
xy2 cry-~'
d 2 ._ (y(x)2 - 2x)
eq .- ( )2
xy X
(* y(x))
=
y(x) - 3
x2
> dsolve(deq2, y(x»;
y(x) _ ~ + ~ = _Cl
x x y(x)
> dsolve(deq2, y(x), explicit);
3 1 1 /
y(x) = 2: + 2: _Cl X + 2:" 9 + 6 _Cl X + _Cl 2 x 2 - 8 x,
In some cases, Maple cannot solve explicitly for y(x) but may be able
to solve for x(y). Consider the following ODE, which is linear in x but not
in y.
Maple is unable to solve explicitly for y(x). In this case, the dsolve command
tells you so by returning a result containing Rootof functions. However,
if you redefine the ODE so that x is the dependent variable and y is the
independent variable, Maple can successfully solve for x(y).
> deq4 := y*D(x)(y) + x*y-2 + x ~ y = 0;
Now examine the plot of the result for five different values of the arbitrary
constant _C1.
> plot ({seq(subs CC1=k, rhs(II)), k=-2 . . 2)}, y=-2 . . 2, x=-10 .. 10);
Activities for §3
1. a. Find the general solution for the following ODE which is linear in
y.
&y 2
- -y=t
at
b. Plot, simultaneously, five members of this family of solutions, where
the arbitrary constant takes on the following values: -2, -1,0,1,2.
c. Manually identify and label each of the five graphs with the appro-
priate value of the constant.
2. Find a general solution for each of the following first-order ODEs.
When possible, find explicit solutions.
a. ~ + 2x = 2y
32 • Chapter 3. First-Order ODEs
b. 2xy Z+ 3x 2 + y2 = 0
c. X2 Z+ 3xy = xy3
d. ~
= l:s~~
e. sin(8)ar + (rcos(8) - 8 + 3)a8 = 0
f• ay_x2+~
ax -y x
First-Order ODEs
In this chapter you will use the following commands from earlier chapters:
33
34 • Chapter 4. Applications of First-Order ODEs
m av =F
at
Try an example:
Suppose that an airliner is cruising at an altitude of 10,000 feet when
the cargo door falls off. The door weighs 152 pounds. Ignore its horizontal
motion at the moment it becomes free of the plane. Assume that air resis-
tance (denoted by kv, where k is a constant) is proportional to the velocity
at any time t. The first-order ODE which describes the motion of the door
1S
152 av
- - = 152-kv
32 at
Since the downward motion of the cargo door begins with an initial velocity
of zero, the initial condition of v(O) = 0 holds. You can solve for velocity
as a function of time.
> solv := simplify(dsolve({deqv, v(O)=O}, vet)));
-1 + e(-4/19kt)
solv := v(t) = -152 k
You can now define the first-order ODE which describes the rate of change
of distance with respect to time
Falling, Floating, or Accelerating Objects • 35
tl := 70.53947200
> 't2' := fsolve(rhs(subs(k=2, solx)) = 10000, t);
t2 := 133.9539474
> 't5' := fsolve (rhs (subs (k=5, solx)) = 10000, t);
t5:= 329.8973684
Notice that, as expected, for larger values of k (which represent greater
air resistance), it takes longer for the door to reach the ground. This makes
sense. Now graph solx over the first 350 seconds for several different values
of k. Notice the colon (:) at the end of the next command line.
> curves := seq(subs(k=i, rhs(solx)), i = [0.1, 1, 2, 5]) :
> plot({curves} , t = 0.. 350, x = 0 . 10000);
.
10000
8000
6000
x
4000
2000
Away from the origin these graphs all appear to be linear. Why is that?
Look at them in greater detail nearer to the origin. This gives a much better
picture of the motion near the beginning of the fall.
Falling. Floating. or Accelerating Objects • 37
200
150
x
100
50
Thus, it is apparent that for smaller values of k the graph of x(t) gets
steeper faster. This means that near the beginning of the fall the door ac-
celerates faster (i.e., the velocity is increasing at a quicker pace) for smaller
values of k. Later in the fall, the velocities for all values of k are nearly
constant (the graphs of x(t) appear linear for large values of t), with the
greater limiting velocities occurring for smaller values of k.
In a second example, a car weighs 1,500 pounds and its air resistance
has been determined to be 8/5 times its velocity. We want to find the con-
stant force required to accelerate the car from 40 to 60 feet/second in a
period of 18 seconds.
Begin by assuming that mass times acceleration (~) equals the sum of
all forces acting on the car. Let F pounds represent the unknown constant
force, and write the differential equation for this system in Maple.
> deq2 := 1500/32*diff(v(t), t) = F - 8/5*v(t);
375 a 8
deq2 := -8- (at v(t)) = F - "5 v(t)
38 • Chapter 4. Applications of First-Order ODEs
5 (64) 5
soI2:= V(t) = gF+e-18'73 t (-gF+40)
133.7115172
So, about 134 pounds of force is required to accelerate the car from 40 to
60 feet/second in 18 seconds.
~F
8
Thus the limiting velocity is five-eighths of the constant force applied.
To look at this another way, have Maple print a chart of results for
large values of tat F = 134. First, set the appropriate values and simplify
the resulting expression.
> F := 134;
F:= 134
> s012 := simp1ify(s012);
335 175 ( 64 )
sol2 := v(t) = - - - - - e -18'75 t
4 4
Falling, Floating, or Accelerating Objects • 39
Ma pIe does not contain a simple command to print out such a chart of
values, so you must create one to fit your needs. The following procedure,
printchart, l takes four parameters:
1. A list containing the values to be evaluated and displayed. The results
are displayed in the order they are specified. (In this particular case,
the list is [t, rhs(soI2)].)
2. The variable that you are substituting for. (In this case, t.)
3. The range of values over which you wish to substitute. (In this case,
1 . .751.)
4. The incremental value for the above range. (In this case, 50.)
> printchart := proc(values, var, numrange, increment)
> local i,j,k,fmtstr;
> fmtstr:= cat(seq('% lOs " k=l .. nops(values)));
> for i from lhs(numrange) by increment to rhs(numrange) do
> printf(fmtstr, seq(convert(evalf(subs (var=i,
> values[j]), 5), string), j=l .. nops(values)));
> lprint();
> od;
> end:
Don't spend too much time dwelling on how printchart was programmed.
It is a rather basic Maple procedure, but we don't go further into program-
ming at this time.
Before this command is used, save it to file so that it can be used again
in later chapters.
> save printchart, 'chart.m';
o 40.000
50. 75.811
100. 82.309
150. 83.489
IThe printchart command is included in The Practical Approach Utilities for Maple. The
version given here is a skeleton of that larger command, with less error checking and fewer
alternate parameter sequences.
40 • Chapter 4. Applications of First-Order ODEs
200. 83.703
250. 83.741
300. 83.748
350. 83.750
400. 83.750
450. 83.750
500. 83.750
The limiting velocity is about 83.75 feet per second when 134 pounds of
constant force is applied to a 1500 pound car. Also observe that (5/8) * 134
is 83.75, confirming the earlier result.
The air resistance in this problem is eight-fifths of the velocity, and the
limiting velocity turns out to be five-eighths of the constant force applied.
It appears that when the constant of proportionality for air resistance is
a positive constant B, the limiting velocity is the reciprocal of B times the
constant force F.
Try to verify this conjecture. First, reset the variables t and F.
> t := 't': F := 'F':
> deq2 := 1500/32*D(v)(t) = F - B*v;
375
deq2 := -8- D(v)(t) = F - B v
Mixture Problems
A tank initially holds 40 pounds of salt dissolved in 200 gallons of water.
Another brine solution is pumped into the tank at the rate of 5 gallons per
Mixture Problems • 41
gallons 3 pounds .
5. . -5 II = 3 pounds per mmute.
mmute ga on
Now solve this ODE subject to the initial condition A(O) = 40.
> 5013 := dsolve({deq3, A(0)=40}, A(t));
Have Maple construct a chart showing the amount of salt present in the
tank at several different values of time.
> printchart([t, evalf(rhs(so13))], t, 0 .. 200, 20);
0 40.
20. 71.478
40. 90.570
60. 102.15
80. 109.17
100. 113.43
120. 116.02
140. 117.58
160. 118.53
42 • Chapter 4. Applications of First-Order ODEs
180 . 119.11
200. 119.46
It appears that the limiting amount of salt as time increases without bound
is about 120 pounds. This can be verified by graphing A(t} . But first, reset
the variable t.
> t : = 't':
> plot({rhs(so13), 120}, t=0 .. 200, O.. 140);
140
120r-------------~======----
100
40
20
Activities for §4
1. An aircraft carrier which weighs 44,000 tons is moving away from
dock through the entrance of a bay at a speed of 4 feet per second.
Upon reaching the open sea, the captain increases the thrust to to a
constant 68 tons. As the ship passes through the water, it experiences
a resistance of 10,400v pounds, where v is the velocity of the carrier.
a. Find the velocity of the carrier on the open sea as a function of time.
b. Determine the limiting velocity as time increases without bound and
check it by building a table for 0 :::: t :::: 2000.
c. How long will it take the carrier to reach 85% of its limiting velocity?
Activities for §4 • 43
d. Graph the velocity function for t ::: 0, showing its intersection with
the horizontal line representing 85% of the limiting velocity.
2. Sue, a medical doctor, and her husband George, a mathematician, are
fishing from a boat when Sue hooks a 5 pound trout. George, also
an avid photographer, grabs his camera and starts taking pictures. But
George gets so excited he drops the camera into the water. George
knows the camera weighs 1 pound and the buoyancy of the water is
twice the square of the velocity of the sinking camera. He also has a
fishing net with a handle extending to 24 feet. George quickly calculates
how much time he has to grab the net and snare the camera before it
is out of reach. How much time does he have? (Unfortunately, before
George can retrieve the camera, Sue plays the trout up to the side of
the boat, but loses it off the hook.)
3. Newton's Law of Cooling states that the rate at which the temperature
of an object changes (~;) is proportional to the difference between the
temperature of the object (T) and the temperature of the surrounding
medium (To). That is
aT
- = k(T(t) - To),
at
where t is time and k is a constant.
When a baked potato is removed from an oven at 350° into a 75°
room, it cools to 200° in 5 minutes.
a. Find the temperature of the potato at any time t minutes.
b. If a potato is edible at 90°, how long must you wait for it to cool
down?
c. Build a numerical table showing times and temperatures, for times
between zero and twice the time it takes the potato to reach eating
temperature, using increments of 5°.
d. Graph the temperature function over the same interval in the pre-
vious question, showing its intersection with the horizontal line at
90°.
4. All the fish are found to be dead in a small lake which holds 2500 units
of water. (Each unit is 1025 gallons.) The US Environmental Agency
44 • Chapter 4. Applications of First-Order ODEs
studies the situation and finds that there are 2 tons of a chemical pol-
lutant in the lake, put there by a nearby industrial plant. The plant
agrees to clean the lake water with a cleaning operation that removes
the pollutant at a rate of 5 units per day with 90% efficiency.
a. Find the amount (A(t) tons) of chemical pollutant in the lake at any
time t (in days) after the plant begins the cleaning process.
b. If fish can survive when the chemical pollutant is reduced to 100
pounds, find the number of years required before fish can be re-
introduced into the lake.
c. Build a numerical table showing the amount of pollutant in both
tons and pounds from t = 0 until 450 days after fish can survive
in the lake. Use increments of 200 days.
d. Graph the amount of pollutant from t = 0 until 150 days after fish
can survive in the lake, showing the intersection of that function
with the horizontal line showing the 100 pound level of pollutant.
Graphical
CHAPTER
Methods
In this chapter you will use the following commands from earlier chapters:
subs
45
46 • Chapter 5. Graphical Methods
Direction Fields
The topic of direction fields assumes that you start with a first-order ODE
of the form y' = F(x, y), where x and yare the independent and dependent
variables, respectively. At every point P(x, y) within the domain of F, the
function F can be evaluated to obtain a numerical value, denoted by F(P).
Represent a solution to the ODE by y = f(x) and interpret the numerical
value F(P) graphically.
Notice that F(P) = y' = f'(x), which is equivalent to the numerical
slope of the tangent line to the graph at every point P for which the function
F is defined.
If you actually sketch small line segments at a large number of points
in the plane (each line segment having the slope of the tangent to the graph
of a solution), you get a direction field. You can even sketch a particular
solution that passes through any fixed point (which would be given as
either initial or boundary conditions) by following the flow of the tangent
segments across the cartesian plane. Of course, such tasks are tedious and
time consuming without the help of computers. Now get Maple to graph
the direction field for the first-order ODE, y' = x 2 y.
deql := -
a y(x) = x2 y
ax
> with(DEtools):
> DEplot(deql, y(x), x=-2 .. 2, y=-2 .. 2);
Direction Fields • 47
Notice that the slopes of all the line segments are positive in quadrants
I and II (i.e., where y > 0), while they are negative in quadrants III and
IV (i.e., where y < 0). Check the definition of deq1 again to see why this
ISso.
In order to graph specific solutions (called flow lines), one or more
initial conditions must be specified. Graph the direction field for the same
ODE and show four different flow lines through the points listed below.
l1Iit/II//"
I 1I / I / ---'+----.
1 I / / ......
-;::::::+:~~
" ' 1 1 / . /..,
1 I 1 I I ~"' ..fik~f-<-.-.
, 1 I I h!V -'~'-'I-I'f--
!II/,
/ I /.!v./
./.: -~~:t:::::::
~
/ ..-::; '----I:........~
deq2 := -
a y(x) = 2x - y
ax
Graph four flow lines using the same initial values as above.
Again, you see four representatives from the family of solutions to the
ODE. Make up other examples on your own and experiment with different
sets of initial conditions.
Some Examples
Let's revisit some examples from Chapter 4 using this new graphical tech-
nique for obtaining an approximation to each solution.
The following first-order ODE was used to find the velocity as a func-
tion of time for a 152 pound door falling off an airplane at 10,000 feet
with wind resistance set at k = 2.
152 av = 152 _ 2v
32 at
8 '
60
v(t)
40
19 a
deqv2 := -4 (- v(t)) = 152 - v
at
14 ..-------------------------------~----~
120
100
v(t)
80
60
40
It appears that the limiting velocity is increased to about 140 feet per
second when the wind resistance is lowered to 1. Now increase the wind
resistance to k = 5.
19 a
deqv3:= - (- v(t)) = 152 - 5v
4 at
52 • Chapter 5. Graphical Methods
40
3
v(t)
20
where A(t) represents the number of pounds of salt in the tank at t minutes.
To obtain a graphical solution, first define the differential equation and use
DEplot as follows.
a
deqA:= -A(t) = 3 - - A
1
at 40
Activities for §5 • 53
Activities for §5
1. An aircraft carrier which weighs 44,000 tons is moving away from
dock through the entrance of a bay at a speed of 4 feet per second.
Upon reaching the open sea, the captain increases the thrust to to a
constant 68 tons. As the ship passes through the water, it experiences
a resistance of 10, 400v pounds, where v is the velocity of the carrier.
a. Use the DEplot command to obtain a graphical solution showing
the ship's velocity as a function of time.
b. Estimate the ship's limiting velocity.
2. Sue, a medical doctor, and her husband George, a mathematician, are
fishing from a boat when Sue hooks a 5 pound trout. George, also
an avid photographer, grabs his camera and starts taking pictures. But
George gets so excited he drops the camera into the water. George
54 • Chapter 5. Graphical Methods
knows the camera weighs 1 pound and the buoyancy of the water is
twice the square of the velocity of the sinking camera. He also has a
fishing net with a handle extending to 24 feet. George quickly calculates
how much time he has to grab the net and snare the camera before it
is out of reach. How much time does he have? (Unfortunately, before
George can retrieve the camera, Sue plays the trout up to the side of
the boat but loses it off the hook.)
a. Use the DEplot command to obtain a graphical solution showing
the camera's velocity as a function of time (for t = 0 .. 0.2 seconds).
b. Estimate the camera's limiting velocity.
3. Newton's Law of Cooling states that the rate at which the temperature
of an object changes (~~) is proportional to the difference between the
temperature of the object (T) and the temperature of the surrounding
medium (To). That is,
aT
- = k(T(t) - To),
at
where t is time and k is a constant.
When a turkey is removed from an oven at 300 0 into a 70° room,
k = -0.08.
a. Use the DEplot command to obtain a graphical solution showing
the temperature as a function of time. Be sure to use a large enough
time interval to clearly show the limiting temperature of the turkey.
4. All the fish are found to be dead in a small lake which holds 2500 units
of water. (Each unit is 1025 gallons.) The US Environmental Agency
studies the situation and finds that there are 2 tons of a chemical pol-
lutant in the lake, put there by a nearby industrial plant. The plant
agrees to clean the lake water with a cleaning operation that removes
the pollutant at the following rate:
Linear Differential
Equations
In this chapter you will use the following commands from earlier chapters:
56
Chapter 6. Homogeneous Linear Differential Equations • 57
n
> A := matrix([[l, 2, 3], [1, 1, 1], [-8, 5,0]]);
A:=[j ~
To evaluate the determinant of A use the det command.
> det(A);
18
The same type of operations can be performed on a matrix whose elements
are not predefined.
> B := matrix(2, 2, E));
Now back to the specific example. Given a set of functions, you can deter-
mine whether or not they are linearly independent by examining the Wron-
skian determinant. Consider the following functions defined for x > 0:
x 2 3x lnx
3x In(X)]
3 I
xl
o -XI
> detWm := det(Wm);
detWm:= 9 - 6 In(x)
Are the three functions linearly independent on the domain (x > O)?
On any interval? To answer this, first solve for the zeros of the determinant
ofW.
> solve(detWm = 0, x);
> evalf(II);
4.481689070
The determinant of W has only one real zero, so the three functions given
above are linearly independent over any interval of positive real numbers.
Now, consider solving homogeneous linear differential equations with
constant coefficients. Consider the following third-order homogeneous lin-
ear ODE:
(m - 3)(2m - 3)(m + 2) = 0
or solve for the three distinct roots directly.
Chapter 6. Homogeneous Linear Differential Equations • 59
a3 a2 a
deq := 2 (ax 3 y(x)) - 5 (ax 2 y(x)) - 9 (ax y(x)) + 18 y(x) = 0
> factor(auxeqn2);
(2m + 1) (m + 3)2 (m - 2)3 = 0
> solve(auxeqn2, m);
-1
2' -3, -3,2,2,2
There are repeated real roots to the auxiliary equation, so the general
solution is
auxeqn3:= 3m 3 -10m 2 + 7m + 10 = 0
> factor(auxeqn3);
(3 m + 2) (m 2 - 4m + 5) = 0
> solve (auxeqn3 , m);
-2
3,2 + i,2 - i
Observe that there is one real root and a pair of complex conjugate
roots. The general solution is
x(t) = c1 e--Y
21
+ e2 t (c2 sin(t) + c3 cos(t))
Chapter 6. Homogeneous Linear Differential Equations • 61
detWm :=
73 e(-2/3t) (e(2t))2
-9" .
sm(t)2 -
73 e(-2/3t) (e(2t))2
9" cos(t)2
73 e(lO/3t)
detWm := _
9
You can see by inspection that detWm =I 0 for any real number t.
Thus, the three solutions are indeed linearly independent.
This chapter concludes with examples of homogeneous linear ODE's
with non-constant coefficients.
> deq4 := x-2*diff(y(x) , x$2) + x*diff(y(x) , x) + y(x) = 0;
2 a a
deq4 := x 2 (-2 y(x))
ax + x (-ax y(x)) + y(x) = 0
62 • Chapter 6. Homogeneous Linear Differential Equations
You can also plot this solution and verify that the initial conditions
y( 1) = 2 and y' (1) = -1 are satisfied on the graph.
> plot (rhs(so14), x = 0 .. 5);
1.5
0.5
o 2 x
-0.5
-1
Solution of deq4
ITo represent a specific value at an nth derivative, use (D@@n). For example, to represent
y"(O) = 5 use (D@@2)(y)(O) = (5).
Activities for §6 • 63
Activities for §6
1. Prove that the functions cos{lnx) and sin(lnx) are linearly independent
on any interval of positive real numbers.
2. Are the functions cos2x and (sinx)2 linearly independent on the in-
terval [0, 21l"]? Justify your answer by citing appropriate theorems or
definitions.
3. Are the functions x+exp x, exp (-2x) - 3x, and 3 exp x+exp (-2x) lin-
early independent? Justify your answer by citing appropriate theorems
or definitions.
4. Find the general solution for each of the following differential equa-
tions.
a. xiv - lOx'" + 46x" - 114x' + 117x = 0
b. 2yvi - 15yv + 25yiv + lOy'" - 60y" + 53y' - 15y = 0
5. Find the general solution to the second-order ODEx 2 y" -4xy' +6y = o.
Check your solution by substituting back into the differential equation
and simplifying.
6. Find the particular solution to the second-order ODE x 2 y" - 4xy' +
6y = 0 with the initial conditions y(l) = 3 and y'(1) = -2. Graph
your solution on an appropriate interval and verify graphically that
the initial conditions are satisfied.
7. Find the general solution to the second-order ODE (1 - t 2 )x" - 2tx' +
6x = O. Determine the domain of the solution.
64 • Chapter 6. Homogeneous Linear Differential Equations
In this chapter you will use the following commands from earlier chapters:
ao(x) . y(n) + at (x) . y(n-l) + ... + an-l (x) . y(1) + an(x) . y = F(x),
where the a;(x) and F(x) are continuous functions on some interval, I, of
reals.
The general solution of this type of equation can be written in the form
y = Yc +yP' where Yc is the complementary solution from the homogeneous
equation and YP is the particular solution with no arbitrary constants.
Consider the following example.
> deql := diff(y(x) , x$2) - 4*diff(y(x) , x) + 3*y(x) = 4*exp(x);
a2 a
deql := (ax 2 y(x)) - 4 (ax y(x)) + 3y(x) = 4ex
65
66 • Chapter 7. Non-homogeneous Linear Differential Equations
o
Thus, Yc is a solution to the related homogeneous differential equation.
> simp1ify(subs(y(x) = yp, 1hs(deq1)));
So, you can conclude that the solution 5011 checks out. Graphing the
solution, the initial conditions can be verified.
> plot (rhs(so12), t = -1 . . 2, -2 .. 5);
-1 1.5 2
a3 a2 a
deq3 := (ax 3 y(x)) - 5 (ax 2 y(x)) - 2 (ax y(x)) + 24y(x) = x2 - 2
X2 - 2= X2 - 2
So, the general solution checks out again. If initial conditions y(1) = 5,
y' (1) = 3, and y" (1) = 6 are known, you can solve for a unique solution
as follows.
sol3 :=
113 1 1 1081 e(3x) 289 e(4x) 61
y(x) = -1728 + 144 x + 24 x 2 + 135 (e)3 - 64 (e)4 + 40 (e)2 e(-2x)
Now graph this solution and check that the initial conditions are satisfied
at x = 1.
10
8
6
Y
4
0 0.5 x 2
-2
-4
a2
deq4 := x 2 (-2 y(x))
a
+ 3 x (ax- y(x)) - 3 y(x) = x 2 - 4x
ax
> so14 := dso1ve(deq4, y(X))j
1 1 C2
sol4 := y(x) = :5 x 2 - x In(x) + 4" x + _Cl x + -x 3
> simp1ify(subs(y(x) = rhs(so14), deq4))j
x (x - 4) = x 2 - 4x
Activities for §7
1. Consider the ODE x"(t) - x'(t) - 2x(t) = 5te2t •
a. Solve the ODE and verify your general solution by substitution.
b. Solve for the unique solution to the ODE with initial conditions of
x(O) = -5 and x'(O) = 5.
c. Plot that solution for -1 ::: t ::: 1, and notice the point (0, -5) on
the graph, thereby verifying that the initial condition is satisfied.
2. Consider the ODE y"'(x) - 3y"(x) - 4y'(x) + 12y(x) = sinx.
a. Solve the ODE and verify your general solution by substitution.
b. Solve for the unique solution to the ODE with initial conditions of
y(O) = 0, y'(O) = -5, and y"(O) = 10.
c. Plot that solution for -1 ::: x ::: 1, and notice the point (0,0) on
the graph.
d. Give a written explanation of why the graph satisfies each of the
initial conditions. Include in the explanation a discussion of slope
and concavity at the point (0,0).
3. Consider the ODE t 2 x" (t) + tx' (t) + (t 2 - ! )x(t) = d.
a. Solve the ODE and verify your general solution by substitution.
b. Solve for the unique solution to the ODE with initial conditions of
x(5) = 0 and x'(5) = 2.
c. Plot that solution for 0 ::: t ::: 10, and notice the point (5,0) on the
graph.
70 • Chapter 7. Non-homogeneous Linear Differential Equations
Linear Differential
Equations
In this chapter you will use the following commands from earlier chapters:
Many standard textbook techniques for solving linear ODEs are unnec-
essary when using a sophisticated symbolic computing system like Maple.
Maple computes most closed-form exact solutions directly, without us-
ing techniques like reduction of order, finding integrating factors, finding
complementary and particular solutions separately, variation of parame-
ters, undetermined coefficients, etc. And, if any of these techniques are used
within the algorithms Maple employs, the external users need not be aware
or concerned. Another advantage of Maple is that it can find general or
unique solutions when initial conditions are known.
The significance of these facts is profound. The modern student should
concentrate on the basic concepts and principles of ordinary differential
equations, on methods of setting up differential equations to solve specific
applications, and on interpreting the results in the context of the original
problem. If a student or a professional can model an applied problem as an
ordinary differential equation which has a symbolic solution, a computer
71
72 • Chapter 8. Applications of Linear Differential Equations
The units used can vary between the British (pounds, slugs, feet, and
seconds), metric cgs (dynes, grams, centimeters, and seconds), or metric
mks (newtons, kilograms, meters, and seconds). The British system is used
in this manual and the downward direction continues to be defined as
positive. Remember that, in the British system, acceleration due to gravity
is 32 feet per second per second (i.e., g = 32\t).
sec
e m = 12/32 slug
ea=O
Since the displacement is 8/12 ft. when 12 lbs. of force is applied,
12 = (8/12) k (by Hooke's Law), and thus k = 18. F(t) = O.
So, the differential equation which defines this system is
> deq := 12/32*diff(x(t), t$2) + 18*x(t) = 0;
3 a2
deq := 8" (at 2 x(t)) + 18 x(t) = 0
The initial conditions for this problem are x(O) = 6/12 or 112 andx'(O) = O.
> sol := dsolve({deq, x(O) = 1/2, D(x)(O) = O}, x(t));
1
sol := x(t) = "2 cos( 4 v'3 t)
Graph this solution and verify the initial conditions. Also, you want to
determine the amplitude, period, and frequency of the resulting motion.
> plot(rhs(sol) , t = 0 .. 3, -1 .. 1);
-1
You can see from the graph that the motion seems to complete one
cycle or period in a little less than one second.
74 • Chapter 8. Applications of Linear Differential Equations
period:=.9068996827
> frequency := l/period;
frequency := 1.102657790
Thus, the weight moves with a frequency of about 1.1 oscillations per
second while the amplitude is 0.5 or 1/2 foot.
Suppose the same system (weight and spring) is given an initial velocity
of 3 feet per second downward after first being pulled 6 inches downward.
What would be the new period, frequency, and amplitude?
The differential equation is the same as before, just the initial conditions
have changed to x(O) = 112 and x'(O) = 3.
> so12 := dso1ve({deq, x(O) = 1/2, D(x)(O) = 3}, x(t));
-1
You observe that the second solution appears to have the same period
(the time between high peaks) and frequency, but the amplitude has been
increased.
> period2 := evalf(2*Pi/(4*sqrt(3)));
period2 := .9068996827
> frequency2 := 1/period2;
frequency2 := 1.102657790
The amplitude is given by the square root of the sum of the squares of
the coefficients of the sine and cosine functions in 5012 above.
> amplitude2 := sqrt((1/4*sqrt(3))-2 + (1/2)-2);
.
amplttude2 := 41 v'7
> amplitude2 := evalf(");
amplitude2 := .6614378278
So, by giving an initial velocity of 3 feet per second downward, the fre-
quency stays the same (about 1.1 oscillations per second) but the amplitude
increases to about 0.66 feet.
1 a2 1 a
deq3 := "8 (at 2 x(t)) + :2 (at x(t)) + 12 x(t) = 0
76 • Chapter 8. Applications of Linear Differential Equations
1.5
-1
You can now observe damped oscillating motion from the graph. The
quasi-period (the time elapsed between high points) appears to be between
0.6 and 0.7 seconds.
> qperiod : = evalf(2*Pi/(2*sqrt(23)));
qperiod:= .6550673513
The variable damping function is
> dampf : = sqrt(16/23 + 1)*exp(-2*t);
1
dampf := 23 .J897 e(-2t)
Free, Damped Motion • 77
and you can show how this factor dampens the oscillations by displaying
it with the original function. The graphs of dampf and -dampf create an
envelope which is shown below.
> plot({rhs(so13), dampf, -dampf}, t=O .. 2, -1 .. 1);
In yet another case, when the resistance is very great, the weight does
not oscillate but moves slowly toward the equilibrium. This is known as
being overdamped.
Instead of giving the damping constant as 0.5, assume it is an unknown,
a, and find all values of a for which overdamped motion will result. The
differential equation is now (1/8) . x"{t) + a . x/{t) + 12 . x{t) = 0 and the
auxiliary equation can be entered as
eq := m 2 + 8 a m + 96 = 0
The roots of this equation are
> eqroot := solve(eq, m);
> eva1f(sqrt(6));
2.449489743
1 a2 a
deq4:= -8 (-2 x(t))
at + 3 (-
at x(t)) + 12x(t) = 0
Graphing this displacement function should verify that there are no oscil-
lations.
0.2
02 04 t 06 08
Olr---~--~~~====~~--
-0.2
-0.4
-0.6
-0.8
-1
1 2 a + a (-
a
deq5 := -8 (2 x(t))
at at x(t)) + 12 x(t) = 0
-1
You can see from this graph that when the value of a is increased, the
time it takes to get closer to the equilibrium is indeed longer. The following
table compares the four values of a with the time required for the weight
to be within one inch of equilibrium (as estimated from the graph).
a t
3 0.5
5 1
10 2
25 5
Activities for §8 • 81
Activities for § 8
1. A 12 pound weight stretches a spring 8 inches. The weight is then
released from rest 6 inches below the equilibrium position.
a. Construct a table showing the position and weight at t seconds,
where t varies from 0 to 2 seconds by increments of 0.25 seconds.
b. Construct a table showing the velocity of the weight at each of the
values of t in the table of in Question 1. In each case indicate the
direction of motion (either up or down).
c. After resetting the symbol t to be an unassigned variable (with the
command t := 't'), graph both the displacement and the velocity
functions for 0 :5 t :5 2.
d. For 0 :5 t :5 2, find all times (correct to 5 digits) when the weight
passes through the equilibrium position.
and Systems of
Differential Equations
In this chapter you will use the following commands from earlier chapters:
dsolve, .-
.-, limit, plot, combine, rhs, printchart
Forced Motion
We now turn our attention to the situation where the oscillating system
has an external force applied to it. Consider the case where the external
force is periodic and can be represented by F(t) = Fo cos(bt) for constants
Fo and b.
Suppose a 64 lb. weight is attached to a spring whose spring constant
is 1/4 lb.lfoot. The system has a damping constant of 1/5, with initial
conditions x(O) = -1/2 and x'(O) = o. If an external force of F(t) = cos( ~)
is applied to the system, find the displacement as a function of time.
> deq := 64/32*diff(x(t), t$2) + 1/5*diff(x(t), t) +
> 1/4*x(t) = cos(1/2*t);
a2 1a 1 1
deq := 2 (at 2 x(t)) + :5 (at x(t)) + 4" x(t) = cos("2 t)
83
84 • Chapter 9. More Applications and Systems of Differential Equations
30 7 3 10 7 . 3 10. 7 3
- 7 cos( 20 t) cos( 20 t) +7 cos( 20 t) sm( 20 t) +7 sm( 20 t) cos( 20 t)
30 . 7 . 3 10 . 7 17 170. 7 . 17
+7 sm( 20 t) sm( 20 t) + 203 sm( 20 t) cos( 20 t) + 203sm( 20 t) sm( 20 t)
100 1 40 . 1
sssol := - 29 cos( 2: t) + 29sm( 2: t)
These parts can be graphed to see what effect they have on the total solu-
tion.
Notice that because the transient solution gets closer and closer to zero,
the steady-state solution determines the final motion of the system.
o
Now, graph all three functions together and identify the transient, the
steady-state, and the final solution.
86 • Chapter 9. More Applications and Systems of Differential Equations
In this table, values of t are in the first column, values of the transient
part are in the second column, values of the steady-state part are in the
third column, and the last column contains values of the total solution.
Notice that for small values of t, the transient part has a large effect on the
total solution, while, for large values of t, the transient part is almost zero
and the steady-state part dominates the system.
(D - 4)x(t) + (D -l)y(t) = et
Now define these differential equations in Maple as a system named
sys. Notice that the equations are separated by a comma. But first, the
symbol t must be reset as an unassigned variable.
>t:= 't';
t:= t
> sys := 2*D(x)(t) - 3*x(t) + D(y)(t) - yet) =
> 2* t, D(x)(t) - 4*x(t) + D(y)(t) - yet) = exp(t);
sys :=
Notice that the solutions for both x(t) and y(t) are returned, which can
be accessed as 501[1] and 501[2].
> 501[2];
5
y (t) = -
2-
Cl e
t
-
5(t)
-
2
e -
-
Cl + e t - C2 - 8t + 2 + -45 e t - 1t
- e
2
t
1 5
sol := {x(t) = -2 e(-t) + e(-t) (2 e t t - 2 et _ _ e(2t) + -),
2 2
y(t) = -13 e t -
5 1
8 t + 2 - - e t t}
- e(-t) -
442
Graph this pair of solutions and identify each function by the initial con-
ditions.
-4 4
-4
Activities for §9
1. An 8 pound weight is attached to a spring with a constant of 12 lb.lft.
The weight is pushed up to 1 foot above the equilibrium position be-
fore being released with no initial velocity. The system experiences air
resistance in the amount of 3/2 times the velocity and an external force
of F(t) = 12 cos 2t is applied to the system.
a. Find the displacement as a function of time. Be sure to use the com-
bine(rr r trig) command to simplify the solution.
b. Graph the solution on the interval 0 :::: t :::: 6.
c. Identify and define the transient (trsol) and steady-state (sssol) parts
of the solution.
d. Graph both the transient and steady-state parts on the interval 0 ::::
t :::: 6.
(D + l)x(t) + (D - l)y(t) = 5t
a. Find the general solutions of the system.
b. Find the particular solutions for x(t) and y(t) that satisfy the initial
conditions x(O) = 5 and y(O) = O.
c. Graph these solutions together on at least two different intervals.
Identify each of x(t) and y(t) on:
• one small interval close to the origin
• another larger interval showing points further away from the
origin
d. Notice that both of these particular solutions are made up of two
parts which are easily distinguishable: one part a quadratic poly-
nomial and the other part involving exponential functions. Discuss
how this affects the graphs of each on both sides of the origin.
Phase Planes
CHAPTER
In this chapter you will use the following command from earlier chapters:
DEplot
ax
- = f(t,x,y)
at
ay
at = g(t, x, y),
ax
at = f(x,y)
ay
at = g(x v\
J. ,
91
92 • Chapter 10. Phase Planes
At each point P in the xy-plane, the function values f(P) and g(P) de-
termine a two-dimensional vector < f(P),g(P) >. All such vectors in the
plane make up the phase plane for the autonomous system. When initial
conditions are known, such as x(O) = a and y(O) = b, then the particular
solution through the point (a, b) is called an orbit.
A graph of several orbits of an autonomous system on the phase plane
is called a phase portrait. This portrait reveals much about the stability of
a system of autonomous differential equations.
Maple graphs both phase planes and phase portraits with the DEplot
command. This command is found in the DEtools package which must first
be loaded into the Maple session.
> with(DEtools):
Consider the following example and notice the particular manner in which
each function is defined in the Maple session.
ay
-ax
at
= x, - = cos y -
at
O.02x
a a
A:= [at x(t) = x(t), at y(t) = cos(y(t)) - .02x(t)]
The following command generates the phase plane for this autonomous
system.
5 /';'------------------------------
-----~ ------
---- -----------.:--
..................... ~----~---...-------------
"""'"-
-...-...-------..:
................. """---- --~-----------
!//'///-------------
I~/;'----~--------------
!I/~~~~~~~~~~~~-~--
u 2 . 4 x 8 10 12 14
Phase plane
5 /'-----------------------------
------------
-.... --------
-.-,------...-- --
--.....-......------.---
---------
....
/;'----._------------------------
I ,/./ ---.~-.-------------
/ / ""yo.,..., .-'--'~~~------ ..--.-----~
/ '/,." /.,..,-'--.--------~-.--
1~<~//~~~~~~~~-~
--------
2 4 x 8 10 12 14
5 / .....--------~-----
4
~........-........... ------------- -------
--"""'---- -- --------
.................. ' -...........
10 12 14
ax av
- =v,- = -9x.
at at
The phase plane along with the orbit through the point (x = 2, v = 0)
for this system is obtained with the following commands.
> B := [diff(x(t),t) = v(t), diff(v(t),t) = -9*x(t)];
a a
B := [at x(t) = v(t), at v(t) = -9 x(t)]
ax
- = -alX + blxy
at
a a
C:= [at x(t) = -.8x(t) + .7x(t)y(t), at y(t) = .9y(t) - .6x(t)y(t)]
Chapter 10. Phase Planes • 97
In this phase portrait, the horizontal axis (x) is the fox population, the
vertical axis (y) represents the rabbit population, and the three orbits result
from the three different sets of initial conditions.
a2 x
-
at2
ax
+0.4- -cosx =
at °
If the mass is sliding on a table top, friction results in the slowing and
eventual stopping of the harmonic motion. Let x feet be the displace-
ment of the mass from the equilibrium position at time t seconds and
at velocity of v feet per second.
a. Substitute v for x' in this ODE to obtain an autonomous system.
b. Graph the phase portrait for this system with the following initial
conditions.
t = O,x = 0, and v = °
t = 0, x = 0, and v = -1
] t = 0, x = 0, and v = 2
Operations
In this chapter you will use the following commands from earlier chapters:
Basic Concepts
Maple is a powerful and efficient tool for performing matrix calculations
and related applications. The commands needed for these calculations are
100
Basic Concepts • 101
contained in the linear algebra package, linalg, which can be loaded using
the with command.
> with(linalg);
Note the many linear algebra commands to which you now have access.
We begin by defining two matrices and one column vector and per-
forming some basic operations. In this chapter, the matrix(m, n, L) format
is used for defining a matrix or vector, where m is the number of rows, n
is the number of columns, and L is a list of the m*n entries.
102 • Chapter 11. Matrix Operations
V:= [-n
A and B have been defined as 3 x 3 matrices and V as a 3 x 1 column
vector. Standard mathematical operations (addition, multiplication, inver-
sion, transposition, etc. ) can be performed on matrices through the use of
linalg commands created specifically for each of these operations.
> C := matadd(A, B) ;
2
10 ]
c:=[! -3 13
2 5
> IA := inverse(A);
]
-18 -1 24
IA:= [ 1r \4 !l3
77
-3
77
"7
1
14
-V
77
> multiply(A, IA);
[ ]
1 0 0
0 1 0
0 0 1
Basic Concepts • 103
> evalm(2*C);
4 20]
-6 26
4 10
> multiply(B, V);
> TM := transpose(M);
17 -12
TM:=[ -13
19
-8
42
10 ]
-18
72
Maple can also compute the determinant of any square matrix.
> det(A);
154
> det(M);
-8008
Functions and/or expressions can be used as entries in matrices.
> X ;= matrix(3, 1, [x-2, 2*x, exp(-x)]);
X:= [ ;: ]
e(-x)
3x2 + 8 x - 5 e( -x) ]
[ _2x2 + 12e(-x)
5 x 2 + 6 x - e( -x)
In Maple, &* 0 represents the identity matrix for any dimension. If you
wish to use the identity matrix extensively, it is easier to assign an alias,
like the symbols Id, to represent the identity.
104 • Chapter 11. Matrix Operations
i,Id
Another way of performing certain standard operations on matrices
is by representing them as matrix expressions within the evalm (evaluate
and a matrix) command. Since matrix multiplication is non-commutative
(i.e., A . B =J. B· A), the non-commutative operator &* must be used when
performing matrix multiplications within the evalm command.
> evalm(A + B);
[ ]
3 2 10
1 -3 13
4 2 5
> evalm(2*");
[ 6
2
8
-6
4
4
20
26
10 ]
> evalm(A &* Id);
[ 3 4
-2 0
5 3
-5
12
-1
]
[-n
> evalm(V &* Id);
Y:~ [ ~ ]
> evalm(B &* Y);
[ -2y+15z
3x-3y+z
-x - y+6z ]
Basic Concepts • 105
-17
adjB:= [ -19
-3 43]
15 45
-6 2 6
> detB := det(B);
detB:= -52
> invB := evalm(l/detB*adjB);
invB := [~ {~s
26 26
it]
26
The last result should be the inverse of matrix B. This can be checked in
two separate ways:
1. Multiply invB times B.
> multiply (invB, B);
1 00]
[ 010
001
2. Use the inverse command to find the inverse of B directly.
> inverse(B);
it ]
26
-n
> M := matrix(3, 3, [1, 0, 4, 4, 1, -2, 5, 0, 2]);
10
[
M:= ; ~
The characteristic matrix of M (which is the first step in finding the other
values) is calculated as follows.
> charmat(M, lambda);
)..-1 o
[ -4 )..-1
-5 o
Any unassigned symbol or name, such as x or a, can be used in place of
lambda. Maple automatically transforms the Greek name lambda into the
appropriate symbol.
The characteristic polynomial of matrix M is obtained by finding the
determinant of the characteristic matrix.
> det(");
charvals := 1,6,-3
In this particular case, there are three distinct eigenvalues which can be
accessed as charvals[1] , charvals[2], and charvals[3].
There is a characteristic vector of the matrix M corresponding to each
characteristic value. A characteristic vector is a non-zero matrix solution
to the matrix equation M X = A X, where X is a 3 x 1 column matrix. You
must solve for X for each value of charvals found above.
> nullspace(charmat(M, charvals[l]»;
no, 1, on
> nullspace(charmat(M, charvals[2]»;
{[-1,~,1J}
Of course, Maple has an eigenvects command which provides sets of char-
acteristic vectors directly.
> eigenvects(M);
The output of the eigenvects command is a set of lists of the form [e, m,
{v}], where e is a characteristic value, m is its multiplicity (in this example,
108 • Chapter 11. Matrix Operations
cved:= [ !]
> cvec2 := matrix(3, 1, [10/3, 1, 25/6]);
cvee2:= [ ~J
> cvec3 := matrix(3, 1, [-1,3/2, 1]);
cvec3 := [ -~321 J
> evalm(M &* cvecl charvals[l] * cvecl);
UJ-[!]
So, the matrix equation M X = A X is satisfied for X = cvec1 and A =
charvals[1]. The verifications for the other two characteristic vectors fol-
low.
> evalm(M &* cvec2 charvals[2] * cvec2);
Activities for §11 • 109
Thus, all three characteristic vectors check. Check one more thing; as stated
above, each characteristic vector found is a basis for an eigenspace, so that
k • v is also an characteristic vector for any constant k. A representation
for the arbitrary vector in the space defined by cvec3 is defined as vector
cvecx below.
> cvecx := evalm(k * cvec3);
cvecx := [ -_32kkk ]
So, for any number k, the vector cvecx checks as a characteristic vector.
Activities for § 11
1. Use these matrices in the following problems.
A=U
-3
-1
1
2
7
-1 l B=[
-1
9
2
1
-3
0
q. c=Ul
-2
X= [ l~x
1-x
]
a. Find A + 2B.
b. Find A x B.
c. Find the inverse of A x B.
d. Find A times its inverse.
110 • Chapter 11. Matrix Operations
a. A =[ 6
-2
-5
9 l
[ 1
-4 0 6
b. A= 2 4 -4
2 0 7
1
2 -3 1
c. A = [ 2 -3 0
6 -45 12
Matrix
CHAPTER
Methods of
Solution
In this chapter you will use the following commands from earlier chapters:
where the coefficients are real constants. Such a system can be expressed
as a matrix equation DX = A X, with the following definitions of matrices
A, X, and DX.
X = [ x(t)
y(t)
]
,
DX = [ x/(t) ]
y/(t)
X' = 3x + 4y
y' = 12x - 5y
111
112 • Chapter 12. Matrix Methods of Solution
Now, define the matrices; but first you must load the linalg package.
> with(linalg):
Warning. new definition for norm
Warning. new definition for trace
> A := matrix(2. 2. [3. 4. 12. -5J);
A:= [1~ _~ ]
> X := matrix(2. 1. [x. yJ);
X:= [ ~ ]
DX:= [ ~~ ]
[ ~~ ] - [ 13 ;x~~Yy ]
Assume there are solutions of the form x(t) = c eat and y(t) = d eat, where
a, c, and d are constants. To write the solutions in vector form, you must
define one more matrix.
> V := matrix(2. 1. [c. dJ);
V:= [ ~ ]
[ Xy ] =[ e(a t) c ]
e(at) d
Notice that the derivative of the vector X can be expressed as DX = a V ~t.
By substitution, the first matrix equation above can be written as a V eat =
A V ~t. This simplifies to A V = a V, where A is the 2 x 2 coefficient
Chapter 12. Matrix Methods of Solution • 113
-9,7
> eigenvects(A);
V1 := [ !]
and when a = -9,
> V2 := matrix(2, 1, [1, -3]);
> xt := 5015[1,1];
xt := c1 e(7t) + c2 e(-9t)
114 • Chapter 12. Matrix Methods of Solution
> yt := s01s[2,1];
yt := c1 e(7t) - 3 c2 e(-9t)
x = c1 V1 e a1t + c2 V2 ea2t
where c1 and c2 are arbitrary constants.
This method can be extended to solve larger systems. Using this matrix
method, solve the system
A:=
[
-2
-~
5 5]
4 5
-3 2
Find the characteristic values with the corresponding characteristic vectors.
> eigenva1s(A); eigenvects(A);
2,3, -1
Chapter 12. Matrix Methods of Solution • 115
-5 -3 ]
[2,1, {[-5, -5, I]}], [3, 1, {[I, 1, On], [-1,1, {[ 2' 2' 1 }]
VI:= [ fJ
Corresponding to the eigenvalue 2:
> V2 := matrix(3, 1, [-5, -5, 1]);
V2:= [=n
Corresponding to the eigenvalue 3:
> V3 := matrix(3, 1, [1, 1, 0]);
V3:=UJ
The general solutions are given by the following matrix equation.
> X := evalm(c1*V1*exp(-1*t) + c2*V2*exp(2*t) + c3*V3*exp(3*t»;
X:= [
_i c1 e(-t) -
-~ c1 e(-t) -
5 c2 e(2t) + c3 e(3t)
5 c2 e(2t) + c3 e(3t)
J
c1 e( -t) + c2 e(2 t)
You now have the solutions for x(t}, y(t}, and z(t}.
> xt := X[1, 1]; yt := X[2, 1]; zt := X[3, 1];
Activities for § 12
Solve each of the following linear systems of differential equations and
check the general solutions.
1. x' = 6x+5y
y' = -2x - 5y
2. x' = 3x
y' = -8x+2y
3. x' = 5x+4y
y' =x+2y
4. x' = -x + 4y - 2z
y' = -3x+4y
z' = -3x + y + 3z
5. x' = -x+7y-z
y' = y
z' = 15y - 2z
Isoclines
CHAPTER
In this chapter you will use the following commands from earlier chapters:
Assuming a first-order ODE of the form y' = F(x, y), curves of the form
F(x, y) = k (for some arbitrary constant k) are called isoclines. They are
of particular importance because every member of the family of solutions
to a differential equation passes through the isocline with the same slope.
This holds because for any value of k, F(x, y) = k => y' = k.
Have Maple graph several isoclines for the ODE y' = 2x - y. The
isoclines are of the form 2 x - y = k, which when solved for y gives y =
2x- k.
iso:= 2x - k
Notice that the isoclines in this example are all lines with slope of 2 and
y-intercept of -k.
117
118 • Chapter 13. Isoclines
The isoclines for the ODE y' = x 2 y are more interesting. They are x 2 y =
k, which implies that y = klx 2 for different values of k. The following
commands show the isoclines for k = -3, -1/2, 2, and 4, overlaid with
the original direction field.
As you enter these commands, pay special attention to the commands
that end with a colon (instead of a semi-colon), which suppresses unwanted
output. You may also note that the results of the plotting commands are as-
signed to variable names. This allows you to use the related plot structures
in later commands.
> with(DEtools): with(plots):
> deq := diff(y(x), x) = x-2*y(x);
deq := -
a y(x) = x 2 y(x)
ax
> deqfield := DEplot(deq, y(x), x=-2 .. 2, y=-2 .. 2,
> stepsize=O.l):
> deqiso := plot({seq(k/x-2, k=[-3,-1/2,2,4])}, x=-2 .. 2,
> y=-2 .. 2):
Activities for §13 • 119
The display command from the plots package combines the two plots
into one.
> display({deqfield, deqiso});
From the graph, is it plausible that the slopes along each isocline are
constant?
Find the isocline where k = -3. Are the slopes along that isocline all
-3?
Find the isocline where k = -1/2. Are the slopes along that isocline all
-1I2?
Find the isocline where k = 2. Are the slopes along that isocline a1l2?
Find the isocline where k = 4. Are the slopes along that isocline all 4?
Activities for § 13
For each of the following first-order ODEs:
• Graph the direction field over an appropriate interval and suppress the
output. (Some experimenting might be necessary.)
• Graph at least three isoclines and suppress the output.
120 • Chapter 13. Isoclines
• Graph both the direction field and the isoclines together by using the
display command. Label each isocline with the proper value of k.
1.y'=~
2. y' = !r
x
3. y' = sinx - y
4. y' = x 2 +y2
Series
CHAPTER
Solutions
In this chapter you will use the following commands from earlier chapters:
121
122 • Chapter 14. Series Solutions
The Maple default for the order of the series is 6. This order can be changed
by manipulating the global variable Order.
> Order := 12:
> so12 := dsolve({deq, y(0)=2, D(y)(0)=1}, y(x), type=series);
2 3 1 4 2 5 1 6 15 7 3 8 49 9
sol2 := y(x) = 2 +x - 3x - 4 x -"5 X - 10 x - 56 x - 56 x - 240 x -
19 10 51 11 O( 12)
560 X - 30S X + X
2 3 1 4 2 5
polyl := 2 +X - 3X - 4 x -"5 x
> poly2 := convert (rhs(so12), polynom);
2 3 1 4 2 5 1 6 15 7 3 8 49 9 19 10
poly2 := 2 +x - 3x - 4 x -"5 x - 10 x - 56 x - 56 x - 240 x - 560 x
51 11
- 30S x
While it may appear on the surface that the only difference between the
series found in sol and the polynomial poly is the order term, there is much
Chapter 14. Series Solutions • 123
more going on here than meets the eye. The internal data structures for
series and polynomials are very different. To see this, use the op command
to view their structure.
> op(rhs(sol));
-2 -1 -2
2,0,1,1, 3,3, 4,4, 5,5,0(1),6
> op(poly1);
From the table, you can see the close agreement between the numerical
values of the two polynomials when x is close to zero. But you can also
see that they differ more and more as x takes on values further away from
zero. Now compare these polynomials graphically.
124 • Chapter 14. Series Solutions
2~
From the graph, you can verify the earlier observations. The point
being made is that a series solution is more accurate close to the point
about which the series is expanded. Also, note from the graph that the
initial conditions appear to be satisfied (i.e., y(O) = 2 and y'(O) = 1) on
both graphs.
Now consider an ODE for which Maple cannot find an exact solution,
but can give a series representation to the solution. The ODE is first-order,
allowing you to do a field plot and compare that with a graph of the series
solution.
> deq := diff(y(x), x) = 2*x - cos(y(x»;
deq := -
a y(x) = 2x - cos(y(x))
ax
> dsolve(deq, y(x));
Maple cannot give an exact solution. Try doing a field plot of the system
with the initial condition y(O) = -1.
> with(DEtools):
Chapter 14. Series Solutions • 125
> Order := 6:
> sol := evalf(dsolve({deq, yeO) = -l}, y(x), type=series));
sol := + 1.227324357 x 2 -
y(x) = -1. - .5403023059 X .3179645107 x 3 _
.02821284205 x4 + .1344648441 x 5 + O(x 6 )
Do the curves in the last two graphs appear to be the same? Do they
both satisfy the initial condition of y(O) = -1? To get a closer comparison
of these two graphs, combine them on one set of axes. Note again the use
of colons to suppress intermediate output.
> with(plots) :
> A := DEplot(deq, y(x), -2 .. 2, {[O,-i]}):
> B := plot(poly, x=-2 .. 2, y=-2 .. 2):
You must now use the display command which is in the plots package.
-2
deq2 := ~
at x(t) = x(t) +t sin(2 t)
6 . ) 29 t
+ 25 sm(t) cos(t + 25 e
Find series solutions for two different orders: 6 and 12.
128 • Chapter 14. Series Solutions
sol3 := x(t) = 1+ t + ~ t2 + ~ t3 + ;4 :0
t4 - t5 + O(t 6 )
> Order := 12:
> so14 := dsolve({deq2, x(O) = 1}, x(t), type=series);
1253549536117118
poly4 := 1 + t + "2 t +"6 t + 24 t - 40 t - 80 t + 336 t + 2688 t
859 9 859 10 4261 11
362880 t - 3628800 t + 39916800 t
Now construct a table of values and compare the exact solution in the
second column with the series approximations in the last two columns.
First, the printchart commands, saved in an earlier session, must be read
into Maple.
> read 'chart.m';
> printchart([t, evalf(so12), evalf(poly3), evalf(poly4)], t,
> -2.5 .. 2.5,0.5);
-2.5 .92805 18.715 .500e-1
-2.0 .13221 4.8667 . 7478e-1
-1.5 -.23604 .5758 -.23772
-1.0 .3588e-1 .10000 . 35877e-1
-.5 .54005 .54088 .54005
0 1.0000 1. 1.
.5 1.7348 1.7352 1.7349
1.0 3.3135 3.3166 3.3134
1.5 5.9258 5.7836 5.9253
2.0 9.4108 7.8000 9.4022
Activities for §14 • 129
Notice that the values of the 11 th degree polynomial (in the last column) are
much better approximations to the exact solution (in the second column)
than the values from the 5 th degree polynomial (in the third column).
Finally, graph the exact solution together with the two series approxi-
mations.
2 3
Compare these graphs with the numerical data generated above and
identify the three functions.
You can also plot these three graphs over different ranges to observe
that the 11 th degree polynomial is significantly closer to the exact solution
over a larger interval than the 5th degree polynomial.
Activities for § 14
1. For each of the following, find at least two series solutions with dif-
ferent orders. Use the convert command to rewrite each solution as a
130 • Chapter 14. Series Solutions
polynomial and graph the polynomials on the same axes over an ap-
propriate interval containing the origin. Verify visually that the initial
conditions are satisfied.
a. y" - xy' + x 2 y = 0, y(O) = 1, y'(0) = -3
b. y" - xy' + x 2 y = In (x + 1), y(O) = 2, y'(O) = 1
c. (x - 3)y" + y' - 2x 2 y = 0, y(O) = 0, y'(O) = -2
d. y" - (3x - 2)y' - 2y = 0, y(O) = 0, y'(O) = 2
2. For each of the following, find series solutions for the following ODEs
with orders 6 and 12. Have Maple build a table of values for x between
-3 and 3 with an increment of 0.5, showing the values of both series
solutions at those x values.
a. (x 2 - l)y" + 2y' - 4xy = 0, y(O) = 5, y'(0) = -2
b. y" - (x 2 + x)y' - 6xy = 0, y(O) = 1, y'(O) = 3
3. For each of the following ODEs, find exact solutions and two series
solutions with different orders. Graph all these solutions on the same
axes and identify each.
a. x' = t2 - 2x, x(O) =3
b. x' = x + 5 sin t - t, x(O) = 1
4. For each of the following, graph both the slope field (with DEplot) and
the series approximation of the solution with order 10. Combine these
graphs as shown in this chapter and estimate the largest interval on the
x-axis for which the series solution provides a good approximation of
the actual solution.
a. y' = siny + xcosx, y(O) = °
b. y' = exp (-y) + 2x, y(O) =°
Numerical
CHAPTER
Methods
In this chapter you will use the following commands from earlier chapters:
dsolve, plot
131
132 • Chapter 15. Numerical Methods
Use the assign command to assign to the symbols y(x) the exact solution
just found. You can then evaluate and graph this expression by using its
name.
> assign(II);
> plot(y(x) , x = -7 .. 7, Y = -2 .. 8);
-6 -4 -2 2 x 4 6
-2
Notice the solution is periodic with period 2n, and is also symmetric
with respect to the y-axis.
The following commands result in Runge-Kutta approximations from
x = 0 to x = 2, and they also display the values in a chart. The exact value
is in the third column and the approximation is in the second column.
> F := (x,y) -> sin(x) * y;
F := (x, y) --+ sin(x) y
Chapter 15. Numerical Methods • 133
> h := 0.2: xO := 0: yO := 1:
> printlevel := 0:
Then, by using the plot command with a list of values [Xl, Yl, ... , X n, Yn],
save the plot of the estimated result as the variable B.
134 • Chapter 15. Numerical Methods
3
Y
2
Before continuing, you must reset the values of y(x), n, and printlevel.
> y(x) := 'y(x)': n := 'n': printlevel := 1:
a2 a
deq := 5 (a
x
2 y(x)) - (x + 3)(-
ax
y(x)) + x 2 y(x) = 0
Use the dsolve command with the type=numeric option and the initial
conditions y(O) = 0, y'(0) = 1. Notice that the output of this command is
assigned to F; it is a procedure which can be evaluated and graphed like a
function.
This output can be used to determine the value of the solution at any point
or at any sequence of points.
a
[x = -3, y(x) = -.557413491899462210, ax y(x) = -1.08831101456095936]
[
x = -2, y(x) = -1.08886312606435998,
~ y(x) = -.00786695359308297454]
ax
[x = -1,y(x) = -.766268482242866589, -y(x) a = .569546416982045334]
ax
a
[x = 0, y(x) = 0, - y(x) = 1.]
ax
a
[x = 1, y(x) = 1.41033180568169247, ax y(x) = 1.93722410727395777]
a
[x = 2, y(x) = 3.93990469726372528, ax y(x) = 2.89549628660927283]
a
[x = 3, y(x) = 5.29634448025473947, ax y(x) = -2.18101035668896692]
a
[x = 4, y(x) = -5.04657127348778456, ax y(x) = -18.6076999164779266]
Have Maple plot the numeric solution to this ODE with the plots[odeplot]
command.
136 • Chapter 15. Numerical Methods
Now, carefully compare the numerical results obtained earlier with the
graph for consistency (e.g., F(l) ;:::::: 1.41 [point] and F'(l) ~ 1.9 [slope]).
deqn
a y(t) = t + y(t)2
:= -
at
Problems with Numerical Methods • 137
't
v~
(-3 r( ~)2 31/3 BesselY( -f'~ t 3/2 ) +
r(~)2J5/6_4]f
Besse
IJ( -2 ~ t3/2))
3' 3
y(t)=-
-3
re)23 1/3
J
B
esse
lye 23/2 )
J,J t
r( ~)2 35/6-4]f
+ Besse IJ(1.3' ~3 t 3/2)
> dsolve({deqn, y(0)=1}, yet), laplace);
Try the Runge-Kutta method used earlier in this chapter. First, define
the function, the step size, and the initial values to and Yo.
> F := (t,y) -> t + y-2;
F := (t, y) ~ t + y2
> h := 0.1: to := 0: yO := 1:
> printlevel := 0:
.8000000000,6.170817449
.9000000000,10.04952752
1.000000000,17.40476190
There is a huge discrepancy from the numerical approximations provided
by the Runge-Kutta method.
Now try one more method: the type=numeric option of the dsolve
command.
> F := dsolve({deqn, y(O)=l}, yet), type=numeric);
Error, (in F)
rkf45 is unable to achieve requested accuracy
Again, these values disagree with those provided by both the other meth-
ods. The results can be summarized in a table as follows.
Which are the correct values? Because these methods do not seem at
all trustworthy, you must conclude that they fail when t is close to 1. To
determine why failures of this type happen is beyond the scope of this
book. However, it is hoped that you can recognize such problems when
they occur. Approximate values that vary wildly from one step to another
are common indicators of an instability that renders the results useless.
Transform
In this chapter you will use the following commands from earlier chapters:
I dsolve, solve
There are several ways that Maple can assist with using Laplace trans-
forms to solve ODEs.
First, Maple can be used to solve ODEs the same way it would be done
by hand using the laplace and invlaplace commands, which are found in
the inttrans package:
• Take the Laplace transform of both sides of the ODE.
• Solve for the Laplace transform of the dependent variable.
• Take the inverse Laplace transform of both sides of the resulting equa-
tion.
A second method of using the Laplace transform in Maple is to use the
method=laplace option in the dsolve command. This option is most useful
140
Chapter 16. The Laplace Transform • 141
a3 a2 a
deq:= (-3 y(t)) - 3 (-2 y(t)) - ( - y(t)) + 3y(t) = 8 te(-2t)
at at at
Now take the Laplace transform of both sides of the differential equation.
> with(inttrans):
> leq := laplace (deq, t, s);
Define and substitute a set of initial conditions into the equation above
(Ieq).
sol ._ _ 5 s4 + 3 s3
- 43 s2 - 48 s + 12
.- s5 + s4 - 9 s3 - 13 s2 + 8 s + 12
Now solve for the solution to the differential equation by using the in-
vlaplace command.
142 • Chapter 16. The Laplace Transform
deqso/.= -71
- et + -33- e(3t) _ 19 8 te(-2t) ___
_ e(-t) _ _ 184 e(-2t)
. 36 200 8 15 225
Graph this solution over the interval [-5/2,2]. Verify that the initial con-
ditions are satisfied from the graph.
> plot(deqsol, t=-5/2 .. 2);
Solution to deq
When the initial conditions are included, the laplace option of the
dsolve command gives the solution directly.
> sol := dsolve({deq, y(O) -5, D(y)(O) = 2, (D@@2)(y)(O) = -4},
> y(t), method=laplace);
so/·= y(t)
71 et + --
= -- 33 e(3t) - 19 e(-t) _ _
-
8 te(-2t) ___
184 e(-2t)
. 36 200 8 15 225
In many applications, you frequently encounter discontinuous functions
which can be described as being either on or off. For example, an external
force applied to a mechanical oscillating system or a voltage acting on a
circuit may be turned off after a short period of time. To describe this
behavior mathematically, Maple uses what is called the Heaviside step
Chapter 16. The Laplace Transform • 143
function. First use the on-line help to see the definition of the Heaviside
function.
> ?Heaviside
Calling Sequence:
Dirac(t)
Dirac(n, t)
Heaviside(t)
Parameters:
t algebraic expression
n - nonnegative integer
Synopsis:
- The Dirac and Heaviside functions are distributions. The Dirac(t) delta
function is defined as zero everywhere except at t = 0 where it has a
singularity. It also has the property that
Int(Dirac(t),t = -infinity .. infinity) = 1
- Derivatives of the Dirac function are denoted by the two-argument Dirac
function. The first argument denotes the order of the derivative. For
example, diff(Dirac(t), t$n) will be automatically simplified to Dirac(n, t
) for any integer n.
- The Heaviside(t) function is defined as zero for t < 0, 1 for t > 0 and is
not defined at O. It is related to the Dirac function by diff(Heaviside(t),
t) = Dirac(t).
- These functions are typically used in the context of integral transforms
such as laplace(), mellin() or fourier() or the solving of differential
equations. They are also used to represent piecewise continuous functions
with conversion routines available.
t<O
Heaviside(t) = { ~: t>0
144 • Chapter 16. The Laplace Transform
t < a
Heaviside(t - a) = { ~: t> a
Now examine the graphs of a few examples to get a better idea of what
this step function looks like.
2
y
-2 -1 2
-1
-2
Heaviside(t)
2
y
-2 2 4 6 8
-1
-2
Heaviside(t - 4)
y
2
-2 2 4 6 8
-1
-2
Heaviside(t - 4) + 3
146 • Chapter 16. The Laplace Transform
3
Y
2
-2 2 4 6 8
-1
-2
3 Heaviside(t - 4)
0, t < 0
f(t) = { 5, 0~t ~ 1
0, t> 1
f := 5 Heaviside(t) - 5 Heaviside(t - 1)
The first term in f is 0 when t is less than 0 and 5 when t is to the right of
o. The second term is 0 when t is less than 1 and is 5 when t is to the right
of 1. When these terms are subtracted in this order, the resulting function
has a value of 5 when t is between 0 and 1 and a value of 0 elsewhere. To
check this, graph these terms.
> plot (5*Heaviside(t), t -2 .. 4, Y -2 . . 8, style=POINT,
Chapter 16. The Laplace Transform • 147
> symbol=DIAMOND) ;
6
y
4
-2 -1 2 t 3 4
-2
5 Heaviside(t)
6
y
4
-2 -1 2 t 3 4
-2
5 Heaviside(t - 1)
148 • Chapter 16. The Laplace Transform
6
Y
4
-2 -1 2 t 3 4
-2
5 Heaviside(t) - 5 Heaviside(t - 1)
deq2 :=
3 ( a2 y(t))
2
+ 2 (~y(t)) + 5 y(t) = 5 Heaviside(t) - 5 Heaviside(t - 1)
at at
Solve this ODE using the method=laplace option with the following initial
conditions.
> init2 := yeo) = 0, D(y)(O) = 0;
1
- Heaviside(t - 1) + Heaviside(t - 1) e(-1/3t+1/3) cos( 3" v'l4 (t - 1))
Solution to deq2
6
y
4
2 4 6 8 10
Graph of g
deq3 :=
2
3 ( a 2 y(t)) + 2 (~y(t)) + 5 y(t) = 5 Heaviside(t)
at at
- 5 Heaviside(t - 1) + 5 Heaviside(t - 3) - 5 Heaviside(t - 4)
+ 5 Heaviside(t - 6) - 5 Heaviside(t - 7)
Solve this ODE with the same initial conditions as before.
> so13 := dsolve({deq3, init2}, yet), method=laplace);
1
- Heaviside(t - 1) + Heaviside(t - 1) e(-1I3t+l/3) COS(3".J14 (t - 1))
Solution to deq3
152 • Chapter 16. The Laplace Transform
Does this graph look as you expected? Describe the behavior you ob-
serve, giving your reasons.
y(O) =1
c. y(O) = 0, y'(0) = 0 and y" + 5y' + 2y = H, where
0, t < 0
H = { 8, 0< t ::: 1
0, t> 1
y(O) = O,y'(O) = 0
0, t < 0
]= { 5, 0 < t ::: 5
0, t> 5
y(O) = O,y'(O) = 0
e. y(O) = 0, y'(O) = 0 and 2y" + 5y = K, where
0, t < 0
{
K = 6, 0 < t ::: 2
0, t> 1
y(O) = 0, y'(O) = 0
Bibliography
155
156 • Bibliography
157
158 • Index