Professional Documents
Culture Documents
Barry Croke
Semester 1, 2016
Based on notes written by Lilia Ferrario, Linda Stals and Dayal
Wickramasinge
Contents
1 Introduction
1.1 Mathematical models . . . . . . . . . . .
1.1.1 Setting up a mathematical model
1.2 Basic concepts and definitions . . . . . .
1.3 Solutions of DEs . . . . . . . . . . . . .
1.3.1 Particular solution of a DE . . .
1.4 Initial Value Problems . . . . . . . . . .
1.5 Geometrical meaning of y 0 = f (x, y). . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2
2
2
3
5
6
7
8
2 Mathematical models
2.1 Matlab . . . . . . . . . . . . . .
2.2 Population dynamics . . . . . . .
2.3 Newtons law of cooling/warming
2.4 Spread of disease . . . . . . . . .
2.5 Chemical reactions . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10
10
11
13
17
19
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
22
22
22
26
28
29
29
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
35
35
35
35
37
38
39
43
45
46
47
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
52
52
52
52
53
55
55
61
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5.4
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
82
. 82
. 82
. 83
. 83
. 83
. 84
. 84
. 84
. 85
. 86
. 86
. 86
. 92
. 98
. 103
. 103
. 104
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5.5
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
63
64
65
70
72
78
106
106
106
107
108
111
113
114
116
118
120
122
127
131
132
132
132
133
8.2
.
.
.
.
.
.
.
134
134
135
135
135
136
137
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
138
138
138
138
146
151
152
153
154
158
160
161
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
162
162
163
165
166
169
170
172
173
174
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
176
176
177
177
179
179
182
184
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
13 Special functions
198
13.1 Bessels Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 198
13.1.1 Bessel functions of the first kind and Gamma functions . 199
13.1.2 Bessel functions of the 2nd kind . . . . . . . . . . . . . . 205
14 Numerical solution of ODEs
14.1 Taylors theorem . . . . . . . . . . . . . . . . . . . . .
14.1.1 Taylors theorem for a function of two variables
14.1.2 Example: Taylors series . . . . . . . . . . . . .
14.1.3 Example: Initial Value Problem . . . . . . . . .
14.2 Eulers method . . . . . . . . . . . . . . . . . . . . . .
14.2.1 Example: Eulers method . . . . . . . . . . . .
14.3 Runge-Kutta methods . . . . . . . . . . . . . . . . . .
14.3.1 Second order Runge-Kutta . . . . . . . . . . .
14.3.2 Fourth order Runge-Kutta . . . . . . . . . . . .
14.3.3 Examples: Runge-Kutta method . . . . . . . .
14.4 System of equations . . . . . . . . . . . . . . . . . . .
14.4.1 Application: galactic dynamics . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
206
206
207
207
208
209
210
220
220
221
221
224
229
1
1.1
Introduction
Mathematical models
Mathematical models
Mathematical models of a wide range of systems, (in ecology, economics,
biology, physics, engineering, physiology, sociology etc) have become part of our
everyday lives; from decisions made in business dealing with millions of dollars
to decisions at home about whether to cycle to uni based on weather predictions.
To model systems can be an extremely complex procedure. The variables
describing the process need to be identified and the relationships between them
established, and to a degree, the process needs to be isolated and variables with
negligible influence need to be excluded. Clearly no model is then a perfect representation of the real life system, but they can be a very good approximation.
1.1.1
Modelling process
(a) Identify the most relevant quantities describing the process. Identify any
assumptions made and establish relationships between the quantities.
(b) Define symbols to denote the quantities, variables and constant, and set
up the mathematical equations (or assumptions you have made).
(c) Solve the equations and interpret the results in terms of the original process.
(d) Check the results are reasonable and whether they match with any experimental data.
Refer to Figure 1.
Building a model
Equations which are very complicated may be too complex to solve and
thus interpretation becomes difficult. On the other hand, models which are too
simplistic do not represent the process well and may not be very reliable in their
interpretation. So a reasonable balance needs to be found.
1.2
d2 y
dy
a
=0
2
dx
dx
or
= x 2y
x y
which is a Partial Differential Equation (PDE).
dy
d2 y
a
=0
dx2
dx
or
dn y
dn1 y
dy
+
a
(x)
+ + a1 (x)
+ a0 (x)y = F (x)
n1
dxn
dxn1
dx
and
d2 y
dy
+y
= sin x
dx2
dx
are non-linear because of the cos y term and the ydy/dx term respectively.
Linearisation
Although most phenomena in nature are nonlinear, linear equations are much
easier to analyse. For this reason, in cases when nonlinear equations are difficult
to analyse, these can be studied through a process known as linearisation. We
will see this later in the course.
=
=
=
dy
dx ,
dy
dx ,
dy
dx ,
d y
y 00 = dx
2,
d2 y
(2)
y = dx
,
2
d2 y
2
D y = dx2 ,
d y
y (n) = dx
n
dn y
Dn y = dx
n
1.3
dx
dt
x
=
d2 x
dt2
... d3 x
x = 3
dt
Solutions of DEs
dy
= 6xy 1/2
dx
on the interval < x < .
Lets verify this. By substituting the solution into the differential equation
and by explicit differentiation we obtain:
d 94 x4
dy
=
= 9x3
dx
dx
and
1/2
9 4
6xy 1/2 = 6x
x
= 9x3 .
4
Since the left-hand-side comes up to be the same as the right-hand-side, it
dy
is true that y = 49 x4 is a solution to dx
= 6xy 1/2 .
5
(y > 0)
dy
= x
dx
d
0,
dx
0,
= x.
9 x2 .
Particular solution of a DE
Solution curves
Differential equations in general have many solutions. This shouldnt surprise us, since integration introduces arbitrary constants. For example, take the
differential equation
1
dy
=x+
dx
2
with solutions:
x
x2
+ +C
y(x) =
2
2
where C is a constant. Some of the solutions are shown in Figure 2.
A function like the one above involving an arbitrary constant C is called
a general solution of a first order differential equation. Geometrically, these
solution curves are infinitely many curves, one for each C. We call this a family
of curves.
If we choose a specific C we obtain what is called a particular solution of
that equation. For example, if we take C = 0, we get:
y(x) =
x2
x
+ .
2
2
20
15
10
-4
-2
0
x
1.4
2=
1 1
+ + C.
2 2
7
By doing so, we fix the value of the constant C, since the above equation is
satisfied if C = 1. Thus, the solution to the IVP is:
y(x) =
1.5
x2
x
+ + 1.
2
2
Direction fields
Given a differential equation:
dy
= f (x, y).
dx
A solution curve is a function y(x) whose slope at (x, y) is given by dy/dx =
f (x, y). The direction field is formed by a grid of arrows which are tangential
to the solution curves. These arrows are centred at (x, y) and have slope dy/dx.
By looking at the direction field, one can have an idea of what the solution
curves look like, since the tangent line to a solution curve at each point is given
by the direction field at that point (see Figure 3).
Figure 3: Construction of one arrow of the vector field of the differential equation
dy/dx = f (x, y). The curve y = f (x) is a solution curve through (x0 , y0 )
Mathematical models
Numerical simulation
The main focus of the course will be the analytical solution of ordinary
differential equations, however we will also use a computer package to obtain
numerical results. The numerical results will largely be used to interpret and
verify the analytical solutions. Towards the end of the course we will look at
some examples where numerical techniques must be used because the differential
equation are too difficult to solve analytically.
2.1
Matlab
Matlab
The computer package that we will be using is Matlab. Matlab is available
on the Information Commons computers. It is possible to buy the student
version of Matlab at the Co-op bookstore, for example, if you want it on your
home computer, but hopefully that will not be necessary. Most of the coding
exercises will be short.
dsolve in Matlab
dsolve in Matlab allows you to find the symbolic solution to some ODEs.
While this approach may be used to check your assignment solutions, it is not
an approach that will be addressed in the course. In the course you will be
expected to check your solutions by substituting them back into the original
ODE.
In other words, you may use dsolve to check your answers if you want, but
you must also use the substitution method.
ODE solvers in Matlab
To solve equations of the form
dy
= f (y, t), y(t0 ) = y0 ,
dt
in Matlab we will usually use [T,Y] = ode45(F,TimeSpan,Y0,Options)
(1)
2.2
Population dynamics
11
0.6
0.5
0.4
0.3
0.2
0.1
0
0.5
1.5
2.5
12
3.5
%p l o t t h e s o l u t i o n
plot (t , p)
t i t l e ( ' Simple P o p u l a t i o n Model ' )
xlabel ( ' t ' )
ylabel ( 'p ' )
5000
4000
3000
2000
1000
0
0.5
1.5
2.5
t
3.5
4.5
2.3
13
Let T (t) be the temperature of the body at time t and the constant Tm be
the temperature of the surrounding medium, then
dT
= k(T Tm ),
dt
where k < 0 is the rate at which the heat is absorbed (or emitted) by the object.
Temperature and heat
Assumption 3 (Heat). Rate of change of heat content = cm Rate of change
of temperature, where c is the specific heat of the material (c is measured in
Jkg1 C1 ) and m is the mass.
Let Q be the rate of change of heat with time (measured in Watts). Let T
be the temperature. Then
dT
Q = cm .
dt
Some examples of c are given below;
Substance
Aluminium
Copper
Stainless Steel
Wood
Concrete
Water (at 20o )
c
896
383
461
2385
878
4187
Heat transfer
Convective heat is transfered to its surroundings according to the equation
hS(T Tm ),
where S is the surface area from which is lost, in units m2 , and h > 0 is the
convective heat transfer coefficient.
The following table gives some values of h for a plate of length 0.5m over
which airflow, given in m/s, passes
14
h
4.5
12
75
b
b
b
b
:
Heating Element
S
S
Let
T (t) = temperature of water at time t,
T0 = initial temperature of water = 15o ,
Tf = final temperature of water = 60o ,
m = mass of water = 250 kg,
q = rate of energy supplied by the element = 3600 W,
S = surface area of the tank = 3.06 m,
h = convective heat transfer = 12,
c = specific heat of material = 4200 Jkg1 C1 .
We make the following assumptions
The water is well stirred so the temperature is homogeneous throughout
the tank (i.e. the temperature is not dependent on the spatial coordinates).
The heat is lost according to Newtons law of cooling.
The thermal constants remain constant (which may not be true for large
temperature changes).
15
Assumption 4 (Hot water tank). Rate of change of heat = Rate of heat produced by the element - Rate of heat lost to the surroundings.
Rate of change of heat = cm dT
dt .
Rate of heat produced by the element = q.
Rate of heat lost to surroundings = hS(T (t) Tm ).
Hence the equations modelling the water tank are
cm
dT
= q hS(T (t) Tm ).
dt
T (0) = T0 ,
hS
m
where = q+hST
, = cm
.
cm
(We have assumed that the temperature of the surronding material Tm is
the same as the initial temperature of the water T0 .)
Using separation of variables gives the following analytical solution
T = T0 et +
(1 et ).
Returning back to the hot water tank problem we get the following values
for and .
hS
12 3.06
=
= 3.4971 105 .
cm
4200 250
q + hSTm
3600 + 12 3.06 15
=
=
= 3.9531 103 .
cm
4200 250
=
From
T = T0 et + (1 et ),
1 T0
t = ln
.
T
1 15
t = ln
= 17566 sec = 4.88 hrs.
60
The numerical results shown in Figure 7 also agree with these results.
16
2.4
Spread of disease
17
T (C)
45
40
35
30
25
20
15
3
t (hrs)
Example 10 (Simple disease model). Set the population size to be 100 and
assume that there is initially one infective. How does the growth of the disease
depend on the infection rate k? Plot the results for k = 0.01, k = 0.02 and
k = 0.04 on the same graph.
See Figure 8
Matlab code to implement the disease model
M-file (xdot.m)
% d i s e a s e models
% define
function
global k
rhs =
t h e r i g h t hand s i d e f u n c t i o n
rhs = xdot ( t , x )
n
kx ( n+1x ) ;
global k n
% s e t t h e v a r i a b l e s needed by xdot
k = dk ;
n = dn ;
% s o l v e t h e ODE
[ t , x ] = ode45 ( @xdot , ts , x0 ) ;
Main routine
% s e t the parameters
n = 1 0 0 ; x0 = 1 ;
% evaluate the s o l u t i o n at these points
ts = [ 0 : 0 . 1 : 2 0 ] ;
% f i n d the s o l u t i o n f o r k = 0.01
[ t1 , x1 ] = disease_model ( n , x0 , 0 . 0 1 , ts ) ;
% f i n d the s o l u t i o n f o r k = 0.02
[ t2 , x2 ] = disease_model ( n , x0 , 0 . 0 2 , ts ) ;
% f i n d the s o l u t i o n f o r k = 0.04
[ t3 , x3 ] = disease_model ( n , x0 , 0 . 0 4 , ts ) ;
% p l o t the s o l u t i o n
p l o t ( t1 , x1 , t2 , x2 , t3 , x3 )
t i t l e ( ' Spread o f D i s e a s e ' )
xlabel ( ' t ' )
ylabel ( 'x ' )
l e g e n d ( ' k =0.01 ' , ' k = 0 . 0 2 ' , ' k = 0 . 0 4 ' , ' L o c a t i o n ' , ' SouthEast ' )
2.5
Chemical reactions
19
Spread of Disease
120
100
80
60
40
20
k=0.01
k = 0.02
k = 0.04
0
10
t
12
14
16
18
20
= k1 Ca ,
= k1 Ca k2 Cb ,
= k2 Cb .
As we will see later in the course, the analysis of systems of ODEs is more
complicated, and more interesting, than the analysis of a single ODE. However,
the method of coding these systems in Matlab is very similar to what we have
already been using.
Figure 9 shows the change in concentration over time.
Matlab code to model the chemical concentration
M-file (Cdot.m)
% 3 s p e c i e s Chemical R e a c t i o n
% d e f i n e t h e r i g h t hand s i d e f u n c t i o n
20
f u n c t i o n rhs = Cdot ( t , C )
k_1 = 1 ; k_2 = 2 ;
rhs=[k_1 C ( 1 ) ; k_1 C ( 1 )k_2 C ( 2 ) ; k_2 C ( 2 ) ] ;
Main routine
% s e t the i n i t i a l c o n d i t i o n s
C0 = [ 5 ; 0 ; 0 ] ;
% evaluate the s o l u t i o n over t h i s i n t e r v a l
ts= [ 0 : 0 . 1 : 1 0 ] ;
% s o l v e t h e ODE
[ t , C]= ode45 ( @Cdot , ts , C0 ) ;
% p l o t the s o l u t i o n
p l o t ( t , C ( : , 1 ) , ' b+ ' , t , C ( : , 2 ) , ' r . ' , t , C ( : , 3 ) , ' g ' )
t i t l e ( ' Chemical R e a c t i o n ' )
xlabel ( ' t ( hrs ) ' )
y l a b e l ( 'C ( mol ) ' )
l e g e n d ( 'A ' , 'B ' , 'C ' )
Chemical Reaction
5
A
B
C
4.5
4
3.5
C (mol)
3
2.5
2
1.5
1
0.5
0
5
t (hrs)
21
10
3.1
=
,
x 6= 1
1x
1 y2
ln |1 x| =
1
ln |1 y 2 | + C,
2
y 6= 1
2 ln |1 x| = ln |1 y 2 | + 2C,
ln
|1 x|2
= D,
|1 y 2 |
|1 x|2
= eD = K 2 ,
|1 y 2 |
where D = 2C
22
(1 x)2
= K 2
(1 y 2 )
(1 x)2 = (1 y 2 ),
6= 0.
Here, can take any real value, positive or negative but not zero! So
(x 1)2
+ y2
6= 0.
Solution curves
The solution curves are ellipses if > 0 and hyperbolas if < 0. We have
plotted some of these solution curves in Figures 10, 11 and 12.
Solution of Implicit Function
4
3
2
1
0
1
2
4
4
1
x
Figure 10: Typical members of the solution family [(x 1)2 /] + y 2 = 1 of the
differential equation (1 y 2 )dx = y(1 x)dy.
Direction Field
5
4
3
2
1
0
1
2
3
4
5
4
1
x
Figure 11: Vector field of the differential equation (1 y 2 )dx = y(1 x)dy.
the equations x = 1, y = 1 and y = 1 are all solutions of the given DE and also
satisfy the conditions (1, y0 ), (x0 , 1), and (x0 , 1). None of these can be obtained
from our general solution, although x = 1 can be included by permitting = 0.
In this case, only y = 1 and y = 1 appear as singular solutions of the given DE.
All this is a consequence of the fact that the differential equation is non-linear.
Matlab code to draw the direction field
% s e t the a x i s range
a x i s ([ 4 6 4 4 ] )
% c a l c u l a t e gradient at these points
% ( want t o a v o i d v a l u e s o f x = 1 , y = 0 )
[ x , y ] = meshgrid ( [ [ 4 : . 5 : . 9 ] [ 1 . 1 : . 5 : 6 ] ] , [ [ 4 : . 5 : . 5 ] [0.5:0.5:4]]) ;
% f i n d t h e s l o p e o f t h e f u n c t i o n a t each p o i n t
dydx = (1y . 2 ) . / ( y .(1 x ) ) ;
% p l o t the s o l u t i o n
q u i v e r ( x , y , ones ( s i z e ( x ) ) , dydx . / abs ( dydx ) , 0 . 5 )
t i t l e ( ' Direction Field ' )
24
1
0
1
2
3
4
4
1
x
Figure 12: Vector field and solutions of the differential equation (1 y 2 )dx =
y(1 x)dy.
25
3.2
Radioactive decay
Carbon in the atmosphere as CO2 (carbon dioxide) consists mostly of the
inert isotopes 12 C and 13 C with a small amount of radioactive 14 C.
14
C is produced in the upper atmosphere when N (nitrogen) is altered
through the effects of cosmic radiation bombardment. Being unstable it will
convert back to N after a period of time.
Living organisms absorb carbon from the atmosphere and so have 12 C, 13 C
and 14 C in the same ratio. After death, no more 14 C is absorbed. The old 14 C
slowly decays away, so the ratio of 14 C to 12 C slowly decreases.
If we know how this ratio decreases, we can use this to detect how long ago
the remains of something that was alive died, (e.g. bone, wood, rope, some
jewelry such as amber and coral).
Radioactive material decays at a rate directly proportional to the current
amount of material. This gives us a differential equation
dx
= kx
dt
where x > 0 is the amount of 14 C, t is the time measured in years and k is
the constant of proportionality. The growth rate is negative, expressing the fact
that we are looking at decay.
The general solution can be found by separating the variables:
dx
=
Z x
dx
=
x
ln(x) =
x =
kdt
Z
k dt
kt + C 0
0
ekt+C = Cekt
where C = eC .
ekt1
26
x0
2
1
.
2
ln 2
.
k
Thus, the length of time for a radio-active material to decay to half its initial
amount depends only on the constant k (not on the initial amount x0 ). The
constant k varies from substance to substance. The length of time it takes for
half of a radio-active substance to decay is called halflife of the substance. Thus:
t1 = halflife =
ln(2)
k
so
k=
ln 2
.
halflife
So, the amount of radio-active substance left at any time t will be given by
x = x0 e
ln 2
t
halflife .
Application: Halflife
ln 2
ln 2
=
= 1.2055 104 .
halflife
5750
27
40
2
x0 = x0 .
100
5
2
x0 .
5
Solving this equation for t gives the time for the 14 C to fall to 40% of its initial
value:
ln(2) ln(5)
= 7, 601 years.
t=
1.2055 104
It looks like an interesting archeological discovery!
4
x = x0 ekt = x0 e1.205510
3.3
Population growth
We can apply the theory of differential equations to the study of how populations of life forms (people, bacteria ...) change in time.
Given no limiting conditions, such as predators or insufficient food or resources, it is generally true that a population will increase more rapidly as the
population becomes larger (there are more individuals available to procreate;
this might also ignore such factors as aging however).
The simplest assumption is that the rate of increase is proportional to the
population p(t) at any given time t, that is:
dp
= kp(t)
dt
Where the constant k is the relative growth rate. that is, if B is the birth
rate and D the death rate (both per head of population per unit time) then
k = (B D).
This is a very simple mathematical model of a biological system. However,
in modelling a real life system we usually have the problem that there are an
enormous number of factors that affect the system to a greater or lesser degree
and which should really be included in the model for a realistic and accurate
representation. On the other hand, if we include every possible factor we can
think of, we would end up with a mathematical system that would be impossible
to solve. Therefore we need to make assumptions about which factors are the
most important and which ones have negligible effect and can safely be ignored.
So, one normally starts with a very simple model (like the one above) and then
can introduce less important factors one or two at a time to see how they affect
the model.
This is what we have done above with our population model. We have
ignored all factors which might influence the growth rate other than the two
most obvious and simple ones. Some of the many factors we have ignored are:
Climatic effects, such as drought, which can make make birth and death
rates change with time.
28
Overcrowding, which may make the death rate rise or birth rate drop as
the population gets high.
There may be predators which eat our subjects. A change in the size of a
predator population will affect the death rate.
Our subjects may themselves be predator. A change in size of a prey
population will affect the birth and death rates.
Epidemics.
etc., etc., etc.
Later on in the course, we will build a more sophisticated model which take
some of these effects into account.
3.4
Compound Interest
Suppose that w(t) > 0 is the wealth in an account at time t and that r(t) is
the interest rate, with interest compounded continuously. Then
dw
= r(t)w.
dt
Using separation of variables we get
Z
w(t) = w(0) exp
r(s) ds .
3.5
29
Figure 14: Canberra saw the future Lake Burley Griffin when the Molongo River flooded in 1956 (Picture courtesy of Reflections of Canberra:
http://www.act.gov.au/reflectionscd/reflect/intro.htm).
(interestingly, these safety levels are different for those who swim in the ACT
and those who swim in NSW).
We will formulate a simple model of this lake, and consider the concentration
of pollutant in the water as our dependent variable (the actual levels of pollution
are extremely complex involving chemical reactions, the temperature profile
written in the water column, the sediment at the bottom etc, but we will have
to ignore these).
The lake has a volume of 28.3 106 m3 and a mean flow rate of 4 106 m3
per month (for the summer months) and an average rate of 10 106 m3 per
month.
We would like to ascertain that if the authorities suddenly stopped all polluted flow into the lake, how long will it take for the concentration of pollutant
to decrease to 10% of its current level.
Model formulation
We have a schematic model shown in Figure 15.
Model assumptions
We need to make some assumptions on which our model will be based:
the lake is well stirred and the pollutant uniformly mixed throughout the
lake.
the flow rate out of the lake is equal to the flow rate into the lake - that
is the volume of the lake is constant.
30
Let m = m(t) be the mass of the pollutant in the lake at time t, V be the
volume of the lake (which is constant) and F be the volume of mixture leaving
the lake per time interval.
Define c to be the concentration of the pollutant in the mixture, then
c=
m
,
V
Pollution equations
We need to establish the fundamental equation describing this process which
relates the change in mass of the pollutant to the water flows. We use the
31
conservation of mass. Let m denote the change of the pollutant mass in the
time interval t (ie from time t to t + t).
From the diagram in Figure 16 we have found that if no pollutant enters the
lake then m = FV m t. This can be re-written as:
m
F m
=
.
t
V
If we now let t 0 we establish
F m
dm
=
,
dt
V
which is a differential equation describing the continuous change of the mass
of a pollutant with time. We would like an equation describing the change of
concentration of the pollutant, so we will use c = m/V from above and change
the dependent variable in the differential equation as follows.
Since
m
c=
V
then
dc
1 dm
=
dt
V dt
so, from above we get
1 F
F c
dc
=
cV =
dt
V
V
V
and we have an equation for the rate of change of the concentration with respect
to time.
It is easy to solve the above DE using the technique of separation of variables.
dc
=
dt
dc
=
Z c
1
dc =
c
ln c =
Fc
V
F
dt
V Z
F
dt
V
F
t + const.
V
So we obtain:
Ft
Ft
c = e( V +const) = econst e V .
Using the initial condition c0 = econst , (c0 is the concentration at time
t = 0) we have:
Ft
c = c0 e V .
32
Ft
= c0 e V
Ft
= e V
=
=
Ft
V
28.3 106
V
ln 10 =
ln 10 = 0.54
F
10 106 12
years.
t =
F /c
c0 e V
V
ln(2.5) = .22
F
years
(When the flow rate is low, F = 4 106 m3 per month, t increases to t = .54
years).
Formulation of the model with pollution entering the lake
We can easily extend this model to include pollution flowing into the lake.
We will assume that the concentration of the pollution entering the lake is
constant and denote it cin . Using the symbols and methods of the previous
formulation we have
m = cin F t cF t,
33
since the flow into the lake is assumed equal to the flow out of the lake.
If we now let t 0, we have
dm
= cin F cF
dt
and using again the change of variable c = m/V :
F
F
dc
= cin c .
dt
V
V
Make sure you can do this formulation (it is slightly different from the previous one) and then solve this differential equation using the separation of variables technique as we did for the previous example.
Under what conditions does this concentration increase to a steady-state
solution (t ), and what is this steady-state value?
34
4.1
Differentials
Exact equation
Definition 10 (Differential). If a function of u two variables x and y, u(x, y),
u
has continuous partial derivatives u
x and y over a simply connected region R
of the xy-plane, its differential is:
du =
u
u
dx +
dy.
x
y
u
x
and
N (x, y) =
u
.
y
u(x, y) = xy = constant.
4.1.2
and
M
y
are continuous over a simply connected region R of the xy-plane, then the differential equation
M (x, y)dx + N (x, y)dy = 0
is exact if and only if
N
M
=
.
x
y
35
Proof of theorem
We prove the above statements in order.
First, suppose that the differential equation M (x, y)dx + N (x, y)dy is exact
and lets see whether N/x = M/y.
We know that if the DE is exact, then
du = M (x, y)dx + N (x, y)dy
but also
du =
Therefore:
M (x, y) =
u
u
dy +
dx.
y
x
u
,
x
N (x, y) =
u
.
y
Thus,
M
2u
2u
N
=
=
=
y
yx
xy
x
Here, we could exchange the order of differentiation in the mixed derivatives because of our assumption of continuity. Thus, the only if part of the
theorem is satisfied.
Now we can prove that when N/x = M/y is satisfied, then we can find
a function u(x, y) such that du = M (x, y)dx + N (x, y)dy with M = u/x and
N = u/y.
To do this, we start with M (x, y) = u/x and integrate M (x, y) with
respect to x, holding y fixed. This gives
Z x
u(x, y) =
M (z, y) dz + k(y)
x0
=
M (z, y) dz + k(y)
y
y x0
Z x
dk(y)
=
M (z, y) dz +
y x0
dy
Z x
M (z, y)
dz + k 0 (y)
=
y
x
Z x0
N (z, y)
=
dz + k 0 (y)
z
x0
= N (x, y) N (x0 , y) + k 0 (y).
36
Note that we used the fact that M/y is continuous so that we could
interchange the integration with respect to x and the differentiation with respect
to y. We also used our original assumption N/x = M/y.
Thus, u/y will be equal to N (x, y), as required, provided that k 0 (y) =
N (x0 , y), that is:
Z
y
k(y) =
N (x0 , z) dz.
y0
u(x, y)
u(x, y)
dx +
dy = M (x, y)dx + N (x, y)dy.
x
y
Thus, this establishes the if part of the theorem and the proof is complete.
A general solution of the DE is:
u(x, y) = constant.
4.2
General solutions
37
4.2.1
N = 3x 4y + 1.
So:
M
y
N
x
=
=
(2x + 3y 2)
=3
y
(3x 4y + 1)
=3
x
Since the two partial derivatives are equal, then the DE is exact.
A general solution is given by:
Z
u(x, y) =
M dx + k(y)
Z
=
(2x + 3y 2) dx + k(y)
=
dk
= 3x 4y + 1.
dy
dk
= 4y + 1
dy
and
k = 2y 2 + y+constant.
Therefore, a general solution of the DE (check by differentiating!) is:
u(x, y) = (x2 + 3yx 2x) 2y 2 + y+constant = 0.
38
4.2.2
dx
dt
dy
dt
1+
where ~r = (x, y) is the position vector of a given particle and ~v = (dx/dt, dy/dt)
the velocity at a given point.
If y(x) is the path of a particle, then, since
dy
dy dx
y
=
/
=
dx
dt dt
x
y satisfies the first-order DE:
dy
2xy
y 2 x2
= 2
/
1
+
dx
(x + y 2 )2
(x2 + y 2 )2
which can be written as:
2xy
y 2 x2
dx
+
1
+
dy = 0.
(x2 + y 2 )2
(x2 + y 2 )2
Hence,
M (x, y) =
2xy
(x2 + y 2 )2
N (x, y) = 1 +
y 2 x2
.
(x2 + y 2 )2
Z
u(x, y) =
M (x, y) dx + k(y).
2xy
dx + k(y).
(x2 + y 2 )2
39
dv = 2xdx
so that
Z
2xy
dx
(x2 + y 2 )2
=
=
so
u(x, y) =
dv
y
=
v2
v
y
2
x + y2
y
y
+ k(y).
x2 + y 2
y
=
2
+ k(y)
y
y
x + y2
(x2 + y 2 ) 2y 2
dk(y)
=
+
(x2 + y 2 )2
dy
2
2
x y
dk(y)
= 2
+
.
2
2
(x + y )
dy
By comparing this to
N=
we find:
y 2 x2
u(x, y)
=1+ 2
y
(x + y 2 )2
x2 y 2
dk(y)
y 2 x2
+
=1+ 2
.
2
2
2
(x + y )
dy
(x + y 2 )2
So that
dk(y)
= 1.
dy
Thus
Z
k(y) =
dk(y)
dy = y + const.
dy
y
+ y + const.
x2 + y 2
40
Figure 17: Some solution curves for a fluid flow past a cylindrical obstacle.
41
Then, if we take the symmetric fluid flow past a circular cylinder, we can
map it (in the complex plane) into the fluid flow past an asymmetric aerofoil.
In other words, under the appropriate transformation, a cross section of a fluid
around a cylinder transforms (or maps) in the complex plane onto a curve that
is shaped like the cross section of an aeroplane wing. See Figure 18. This curve
is called Joukowski aerofoil. This makes it possible to study the characteristics
of the air flow around an aeroplane wing. As I said, since such transformation
is done in the complex plane, I will not show you here how it is done.
Joukowski aerofoils have been used to build aircrafts, and even nowadays
aerodynamic engineers use these mathematical solutions as a frame of reference
to which they can compare, for validation, their more modern aircraft designs.
Note: Nikolai Joukowski (1847-1921) was the founder of aeromechanics in
Russia.
Joukowski Airfoil
1.5
0.5
-0.5
-1
-1.5
-2
-1
42
4.3
Integrating factors
Consider the DE
ydx + xdy = 0.
Here,
M = y
M
N
= 1 6=
= 1.
y
x
N = x;
x
y
dx + 2 dy = 0,
2
x
x
we get
M =
y
x2
N=
1
;
x
M
1
1
N
= 2 =
= 2.
y
x
x
x
1
,
x2
F (x, y) =
1
,
y2
F (x, y) =
1
,
xy
F (x, y) =
x2
1
.
+ y2
(F Q)
x
F
Q
= Q
+F
.
x
x
43
Now, this appears to be a rather difficult equation to solve to find F (x, y)!
However, we can find a solution to this equation in some special cases.
Thus, we look for an integrating factor that depends on one variable only,
either x or y. Lets start with F (x, y) = F (x). In this case:
P
F
P
+F
y
y
P
F
y
1 F
F x
F
Q
+F
x
x
F
Q
Q
+F
x
x
1 P
Q
.
Q y
x
=
=
and
We can calculate the RHS of the last equation quite easily. If, by doing so,
we get something that depends only on x, then our DE does have an integrating
factor F (x) and we can proceed as follows:
Z
Z
1 dF
1 P
Q
dx =
dx
F dx
Q y
x
Z
Q
1 P
dx
ln F =
Q y
x
And:
F (x) = e(
1
Q
Q
[ P
y x ] dx) .
We could have tried with an integrating factor F (x, y) = F (y). In this case,
we would get
(F P )
y
P
F
+F
P
y
y
P
F
P
+F
y
y
1 dF
F dy
Z
1 dF
dy
F dy
ln F (y)
(F Q)
x
F
Q
Q
+F
x
x
Q
F
and
x
1 Q P
P x
y
Z
1 Q P
dy
P x
y
Z
1 Q P
dy.
P x
y
=
=
=
=
=
=
1
P
P
[ Q
x y ] dy ) .
44
4.3.1
N = x2 y x;
N
M
= 1 6=
= 2xy 1.
y
x
Lets try with a function F (x). To use the same notation that we used before
to look for integrating factors, lets set
P (x, y) = 2x2 + y,
Q
1 P
Q y
x
Q(x, y) = x2 y x.
1
(2x2 + y) (x2 y x)
x2 y x
y
x
1
[1 2xy + 1]
x2 y x
2(xy + 1)
x(xy + 1)
2
.
x
=
=
=
=
2
x
dx)
2
= e(2 ln |x|) = e(ln x ) = x2 .
We can now multiply our DE by the integrating factor that we have just
found to get:
x2 (2x2 + y)dx + x2 (x2 y x)dy
2
(2 + yx
)dx + (y x
)dy
Now this DE is exact and can be solved in the usual manner. Here
M (x, y) = 2 +
y
x2
N (x, y) = y
1
.
x
y
2x
+ k 0 (y)
y
x
1
= + k 0 (y).
x
=
1
+ k 0 (y) =
x
k 0 (y) =
k(y)
1
x
y
y2
+ const.
2
So,
u(x, y) = 2x
y2
y
+
+ const
x
2
y
y2
+
+ const = 0.
x
2
Note: By multiplying by the integration factor, we have lost the solution x = 0!!
So, we have to be careful when we change the original DE to make it exact.
4.3.2
= K(t)
K 0 (t)
= X(t) + H(t),
where X(t) is the total production per year, K(t) is the capital stock (building
and equipments), and H(t) is the flow of foreign aid per year.
In the first equation we assume the production is proportional to the capital
stock. In the second equation we assume the total growth of capital per year
is equal to internal savings plus foreign aid. The internal savings are, inturn,
proportional to the production. The proportionality constants and are
positive.
To write the above system as a single differential equation, let H(t) = H0 et ,
where 6= . Then
dK
= K + H0 et ,
dt
46
or
(K + H0 et )dt dK = 0.
Let P = K + H0 et and Q = 1.
This equation is not exact. Check! So we need to find an integrating factor.
Try
Z
1 P
Q
F (t) = exp
dt
Q K
t
Z
= exp
dt
=
exp(t).
H0
e()t + k(K).
Now,
u
K
= et + k 0 (K)
= N
= et .
H0
e()t + c = 0,
or
K = cet +
4.3.3
H0
et .
47
This is another example of fluid flow. Consider the trajectories of a twodimensional flow given by the following system of DEs:
dx
dt
dy
dt
x2 y 2
2xy
where ~r = (x, y) is the position vector of a given particle and ~v = (dx/dt, dy/dt)
the velocity vector at a given point.
If y(x) is the path of a particle, we can write
dy
dy dx
y
=
/
= .
dx
dt dt
x
Thus, y satisfies the first-order DE:
2xy
dy
= 2
dx
x y2
which can be re-written as:
2xydx + (y 2 x2 )dy = 0
hence,
N (x, y) = y 2 x2 .
M (x, y) = 2xy,
N
= 2x.
x
6=
= e
P
[ Q
x y ] dy
1
P
1
2xy [2x2x] dy
= eR
= eR
4x
2xy
2
y
dy
dy
= e
= e2 ln |y|
= eln y
= y 2 .
Since the integrating factor is a function of y only, the DE can be reduced
to the exact form by multiplying it by F (y) = 1/y 2 .
2xy
(y 2 x2 )
dx
+
dy
y2
y2
2x
x2
dx + 1 2 dy
y
y
48
0.
2x
y
N (x, y) =
x2
y2
.
Lets integrate M (x, y) with respect to x to find a general solution u(x, y):
Z
2x
u(x, y) =
dx + k(y)
y
x2
=
+ k(y).
y
Lets now differentiate with respect to y:
u(x, y)
y
x2
+ k 0 (y)
y y
x2
= 2 + k 0 (y).
y
But u(x, y)/y = N (x, y), so by comparing N = 1 xy2 with what we have
just found we get:
x2
x2
0
+
k
(y)
=
1
y2
y2
0
k (y) = 1
k(y)
y + const.
x2
+ y + const
y
Some of the solution curves are shown in Figures 19, 20, 21 and 22.
The next figures show some astronomical applications of flow of matter along
dipolar field lines.
49
Figure 19: Some solution curves for a fluid flow along dipole-like field lines
50
Figure 21: The ultra-massive, ultra-magnetic (109 Gauss) white dwarf star
EUVE J0317-855. Note the plasma trapped to flow along the magnetic field
lines of the star (courtesy of http://www.rkm.com.au).
Figure 22: Pulsar light-house effect. Charged particles flow along the dipolar
magnetic field lines producing radiation
51
5.1
dy
dx .
5.2
Homogeneous equations
dy
dx ,
|y| =
y
Ce
p(x) dx+C 0
R
p(x) dx
52
4x dx
= Ce2x
y 0
-2
-4
-6
-8
-1.5
-1
-0.5
0
x
0.5
1.5
Figure 23: Some solution curves of the first order linear differential equation
dy/dx + 4xy = 0.
5.3
Non-homogeneous equations
thus:
[p(x)y r(x)] dx + dy = 0.
The good news is that this DE has an integrating factor! Set
P = p(x)y r(x),
Q = 1.
= e(
R
= eR
= e
= e
1
Q
Q
[ P
y x ] dx)
P
y
dx
[p(x)yr(x)]
y
p(x) dx
dx
p(x) dx
[y + p(x)y]
= r(x)
= r(x)e
p(x) dx
p(x) dx
h R
i0
[y 0 + p(x)y] = ye p(x) dx .
h R
i0
R
ye p(x) dx = r(x)e p(x) dx .
54
5.3.1
R
p(x) dx
Z
r(x)e
p(x) dx
3 dx
dx + const
then
y(x)
= e
R
3 dx
= e3x
Z
Z
xe
dx + const
3x
xe dx + const .
e3x dx
3
3
1
e3x
e3x
1
e3x =
= x
x
.
3
9
3
3
And the general solution becomes:
y(x) =
5.3.2
x 1
+ Ce3x .
3 9
Art Forgery
When Belgium was liberated in World War II, the hunt for Nazi collaborators
started. During the hunt, the Dutch painter H.A. Van Meegeren was arrested
in May 1945 and charged for selling a 17th century painting to Goering. This
painting, Woman taken in Adultery (see Figure 24) was allegedly executed by
the very famous Dutch painter Jan Vermeer. The sentence for treason was
death.
55
It was in July of the same year that Van Meegeren surprised the art world by
claiming not only that he had never sold Woman taken in Adultery to Goering,
but also that this painting was his own. And, as if this were not enough, he
stated that the very famous painting Disciples at Emmaus was also his own creation. He continued saying that he had forged another four paintings attributed
to Vermeer and two attributed to de Hooghs.
Most people believed that Van Meegeren was trying to save his head by
lying, but then he started reproducing in his prison cell a very famous painting
by Vermeer: Jesus Among the Doctors (Figure 25). This convinced most of
the skeptics and therefore the charge of treason was changed to that of forgery
carrying a one year prison sentence. At this point, Van Meegeren refused to age
the painting so that his aging secrets wouldnt be divulged to the whole world.
Van Meegeren was convicted in October 1947 and died in the same year of heart
attack.
Because of this refusal, the art world appointed an international panel made
up by chemists, physicists and art historians to settle once and forever the
question of whether these famous paintings were genuine or just forgeries.
At the end of their studies, the panel decided that the painting were not
genuine 17th century paintings, but forgeries. In particular, the analysis of the
pigments (colours) revealed the use of cobalt blue, which is a modern pigment,
totally unknown in the 17th century. They also found traces of phenoformaldehyde (discovered only in the 19th century) that Van Meegeren used to age his
paintings. This chemical was mixed into his pigments and then, by putting the
canvas in the oven, it hardened into bakelite, making the painting look old and
cracked.
56
However, even after all this, most art critics refused to believe that the
famous and beautiful Disciples at Emmaus (Figure 26) was a fake. Thus, the
noted art historian Bredius certified it as an authentic Vermeer and was sold to
the Rembrandt Society for US$ 170,000. This was a lot of money.
Finally, in 1967, scientists at Carnegie Mellon University took the matter
into their own hands. This is how they proved that Disciples at Emmaus was a
fake.
All paintings contain white lead. This pigment has been used by artists for
thousands of years. We know that all rocks on Earth contain a certain amount
of uranium, which decays into other radio-active substances, which, in turn, also
decay until they reach the lead stage, which is not radio-active. The uranium
has a half-life of more than 4 billion years and this element keeps on feeding the
radio-active decay chain.
The white lead used by artists contains a small amount of Pb210 , which is
a radioactive isotope of lead with half-life of only 22 years. Lead is extracted
from ores containing uranium and other elements produced by the decaying
of uranium, such as Radium 226 (Ra226 ), whose half-life is 1,600 years. Ra226
decays into Pb210 . The amount of Pb210 in the ore is in radio-active equilibrium
with the amount of Ra226 . This means that in the ore the amount of Ra226
decaying into Pb210 is the same as the amount of Pb210 decaying into inert
lead. During the process of extraction of lead from the ore (smelting), up to
95% of the radium and all its descendents are removed. Thus, Pb210 is not
in radioactive equilibrium with Ra226 and thus starts decaying very fast, until
balance is reached again between Pb210 and the residual amount of Ra226 (about
57
5% of original).
Now we want to calculate the amount of Pb210 present in the painting in
terms of the original amount present when it was manufactured.
If y(t) is the amount of lead Pb210 per gram of white lead at time t, y0 is the
amount of lead Pb210 at time t0 (manufacturing time) and r(t) is the number
of disintegration of Ra226 per minute per gram of white lead paint at time t. If
k the constant of decay for Pb210 , then:
dy(t)
= ky(t) + r(t).
dt
This is a first order non-homogeneous linear differential equation of the type:
y(t)0 + p(t)y(t) = r(t).
whose solution is:
y(t) = e
R
p(t) dt
Z
r(t)e
p(t) dt
dt + const .
In our problem, p(t) = k. Also, since the half-life of Ra226 is much much
longer that of Pb210 (1,600 years against 22), we can take r(t) constant over
a period of about 300-400 years, which is the maximum age which could be
58
hr
k
i
+ const ekt0 .
h
ri
const = ekt0 y0 .
k
=
=
h
ri
r
+ ekt0 y0 ekt
k h
k
r
r i k(tt0 )
+ y0
e
.
k
k
The value of k is known and we can measure the values that y(t) has today.
So, if we know y0 we can then determine t t0 and establish whether this is
closer to 300 or 0! But we do not know the value of y0 .... So, what do we do
now?
We said that in the ore, the amount of Pb210 is in radio-active equilibrium
with Ra226 , therefore there is no change in the amount of lead that is created
and is disintegrated. This means that in the ore, at the time of manufacturing
of the pigment:
dy
= ky0 + r0 = 0
r0 = ky0 .
dt t=0
Different ores contain different amounts of Ra226 . This amount depends on
where on Earth this ore was mined. The quantity r0 can vary from about 0.15
to 140 disintegrations per minute per gram of white lead.
Therefore, although we cannot deduce an accurate age of the painting, we
still can find out whether the painting is a fake by calculating the value of ky0
if we assume that the painting is, say, 300 years old. Set t t0 = 300 in our
solution and solve for ky0 :
r i 300k
r h
+ y0
e
y(t) =
k
k
ky0 = ky(t)e300k r e300k 1 .
59
The measured values of ky and r are 8.5 and 0.8 respectively. Thus, since
k = 3.151 102 , we get ky0 = r0 = 98, 150 disintegrations per minute per
gram of white lead, which is a huge value, well above what is expected in lead
ores (0.15-140). In fact, even the very rare ores with uranium contents of up to
3% would give a maximum of about 30,000 disintegrations per minute per gram
of white lead.
The Disciples at Emmaus is a fake.
The numerical simulation shown in Figure 27 also shows that the initial lead
content must be very high to get the current reading.
Matlab code to model the lead content given different initial conditions
M-file
% decay model
% d e f i n e t h e r i g h t hand s i d e f u n c t i o n
f u n c t i o n rhs=ddecay ( x , y )
r = 0.8;
k = 3 . 1 5 1 E 2;
rhs = ky+r ;
Main routine
hold
g r i d on
% s e t t h e time i n t e r v a l
ts = 1 : 1 0 : 3 0 0 ;
% define a set of i n i t i a l conditions
y0 = 1 0 0 0 : 5 0 0 0 0 0 : 1 0 0 0 0 0 0 0 ;
% solve equation fo r d i f f e r e n t i n i t i a l conditions
n = l e n g t h ( y0 )
for i = 1:n
y0 ( i )
[ t , y ] = ode45 ( @ddecay , ts , y0 ( i ) ) ;
plot (t , log10 (y) )
end
% l a b e l the p l o t s
t i t l e ( ' Change i n l e a d c o n t e n t with d i f f e r e n t i n i t i a l conditions ' )
xlabel ( ' t ' )
60
log10(y)
50
100
150
t
200
250
300
5.3.3
Radiation Transfer
Consider radiation of intensity I that is propagating along the xaxis through
matter in an astronomical object. This matter absorbs the radiation impinging
on it at a rate I per unit volume and also emits blackbody radiation according to Plancks law at a rate B per unit volume. See Figure 28. Here, is
the density of the matter, its opacity and B is the Planck function. All these
quantities are functions of x. The intensity of radiation I satisfies the equation:
dI
= (I B).
dx
which can be written as:
dI
+ I = B.
dx
To find the general solution, we note that the differential equation is nonhomogeneous, of the type:
dy
y 0 + p(x)y = r(x)
y0 =
dx
61
Z
r(x)eh dx + const
p(x) dx.
p(x) =
and
r(x) = B
dx
Z
Be
dx
dx + const .
= ex [Bex + const]
= B + const ex .
If the incident radiation is I(0) = I0 , then
I0 = B + const const = I0 B.
So, the solution is:
I(x)
= B + (I0 B)ex
= I0 ex + B 1 ex .
62
(2)
5.4
Bernoulli equations
In some cases, it is possible to convert non-linear DEs into linear DEs. The
most famous of these reducible equations is Bernoulli Equation:
y 0 + p(x)y = g(x)y a
where a is any real number.
You can see immediately that if a = 0 or a = 1 the DE is linear, otherwise
it is not. In this case, we set
u(x) = [y(x)]1a .
(1 a)y a y 0
(1 a)(g py 1a )
(1 a)(g pu)
(1 a)g + (a 1)pu
63
thus:
u0 + (1 a)pu = (1 a)g
which is now linear and can be solved through the method we saw earlier for
non-homogeneous linear DEs.
5.4.1
64
y(x) 0
-1
-2
-0.5
0.5
1.5
5.4.2
Figure 31: The rabbits in Australia are an example of a fast growing population!
The rabbit is well suited to Australia - from as few as 24 rabbits bred by
Thomas Austin near Winchelsea, Victoria (1859) we had easily more than a
billion rabbits by 1900!
We modify our model to allow for larger populations. One way to do this is
to add a term to represent overcrowding.
dx
= kx bx2 ,
dt
(the idea being that the average number of encounters of two individuals per
unit time is proportional to x2 ).
This is the logistic equation. This equation is not linear (because of the x2
term) and can be solved either by using the technique of separation of variables
or by noting that it is of the Bernoullis type. We will use the latter.
We can rewrite the last equation as
x0 kx = bx2 .
Here, the independent variable is the time t and the dependent variable is
the population of rabbits x, p(t) = k, and g(t) = b and a = 2. We have to
make a change of variable. We set
u(t) = [x(t)]1a = x1 .
So:
u0 + (1 a)pu = (1 a)g
66
u0 + ku = b.
k dt
Z
be
k dt
dt + C
Z
= ekt b ekt dt + C
b kt
= ekt
e +C
k
b
+ Cekt .
=
k
1
x
1
=
u
so
b
k
1
,
+ Cekt
where C is a constant.
The interesting property of this equation is that the so-called braking term
bx2 stops the population of rabbits (or humans, for that matter!) to grow to
infinity. In fact, initially small populations (0 < x(0) < k/b) increase monotonically to k/b, whilst large populations (x(0) > k/b) decrease monotonically to
k/b. The term k/b is also called the carrying capacity of the ecological system
and reflects the fact that any ecological system can support only a certain number of inhabitants (rabbits in this case). Once the population has reached the
carrying capacity, the population should hold steady (neither grow nor shrink).
See Figure 32 for the solution curves.
But what about people? In Figure 33 we can compare solution curves obtained with the simple exponential law and with the logistic equation. The data
are from the USA census.
Separation of variables to find the general solution of the Logistic
Equation
The logistic equation can be solved also by using the separation of variables
method. Lets see how.
The logistic equation is
dx
= kx bx2 .
dt
If we write m = k/b, we can rewrite the last equations as
dx
x
= kx 1
.
dt
m
67
then:
dx
x 1
Z
dx
x 1
x
m
= kdt,
Z
x
m
=
kdt.
Figure 33: Some solution curves for exponential law and logistic equation compared to data from the USA census.
69
where A = eC .
Now we can solve for x:
x = (m x)Aekt
= mAekt xAkt
x(1 + Aekt )
= mAekt
mA
.
=
A + ekt
b
k
1
+ Dekt
where D is a constant.
The result is the same as before. Which method do you think is easier to
apply?
5.5
Electric circuits
Electric circuits
This is a very brief introduction to electric circuits. In the electric circuits
world, the most important laws are Kirchoffs laws. So, we will talk about voltages, currents, resistors, capacitors, etc. But first of all... What is a current?
A current is the rate of flow of charges measured in coulomb per unit time
crossing a certain surface, such as the cross-section of a wire. That is:
I=
dQ
.
dt
Current is measured in amperes and the time is in seconds. 1 ampere corresponds to the flow of one coulomb per second. Charges are carried by electrons
70
(negative charge of 1.6 1019 coulomb) and protons (of equal but positive
charge).
Charges flow between two points (thus producing a current) because of the
difference in voltage between these two points. The voltage is measured in volts
with a voltmeter.
The simplest electric circuit is a series circuit and consists of a source of
electric energy (electromotive force), such as a generator or battery and a resistor
which uses energy (e.g. a light bulb).
If we close the circuit, the current I through the resistor will cause a voltage
drop. This means that the electric potential at the two ends of the resistor
is different. The voltage drop ER across the resistor is proportional to the
instantaneous current I.
Definition 14 (Ohms law).
ER = RI.
where the constant of proportionality R is called the resistance and is measured
in ohms.
Physically, a resistor is a device often made of carbon which has a certain
specified resistance (20, 50, 100 whatever ohms).
Electric circuits also have inductors and capacitors.
The voltage drop EL across an inductor is proportional to the time rate of
change of current through it:
dI
EL = L
dt
where the constant of proportionality L is called the inductance of the inductor
and is measured in henrys. An inductor often consists of a coil of wire.
A capacitor stores energy and the voltage drop is proportional to the instantaneous charge Q on the capacitor:
Q
C
EC =
I(t) =
then
EC =
1
C
I( )d.
t0
Now that we know about the various elements, we can determine the current I in a circuit by solving the equations resulting from the applications of
Kirchoff s voltage law and Kirchoff s current law.
Definition 15 (Kirchoffs voltage law). Kirchoff s voltage law states that the
algebraic sum of the voltage drops around any closed loop of a circuit is zero.
71
5.5.1
Example: RL-Circuit
Figure 35: The current flowing into a node must the same as the current flowing
out
73
or
dI
RI
E(t)
+
=
.
dt
L
L
To find the general solution, we note that the differential equation is nonhomogeneous, of the type:
y 0 + p(t)y = r(t)
with the general solution
y(t) = e
Z
r(t)e dt + const
R
where h = p(t) dt. Note that in our problem, the independent variable is now
the time t, not x!
Since
R
E(t)
p(t) =
and r(t) =
.
L
L
Then general solution is given by
Z
R
E R R dt
R
dt
L
L
I(t) = e
e
dt + const
L
Z
E Rt
R
t
L
L
= e
e dt + const .
L
E0
E0
t
R
L
+ const e
=
.
R
R
R
We call the term ER0 the steady-state solution and the term const e L t the
transient part of the solution. In practical terms, this means that after a certain
time, the current will be constant equal to ER0 , independently of the initial value
of the current I0 . Before reaching the steady-state, a circuit is in the transient
74
state. These transient periods in electric circuits occur because elements such
as inductors and capacitors store energy. This means that a variation in electromotive force cannot have an instant circuit response, since inductor currents
and capacitor voltages delay such a response.
t
The transient part decays on a time scale t = L/R, because of the term e t
in the solution. The quantity t = L/R is called the inductive time constant of
the circuit.
If the value of the current at t = 0 is I(0) = I0 , then the solution to the
initial value problem
L
dI
+ RI = E(t)
dt
I(0) = I0
R
E0
+ const e L t
R
which gives
I0 =
E0
+ const
R
const = I0
E0
.
R
E0
+ I0
R
E0
+ I0
R
=
=
R
E0
e L t
R
t
E0
e t .
R
sin(t)e L t dt.
This
R integral can be solved through integration by parts (Remember:
U V V dU ).
75
U dV =
0.02
0.04
0.06
0.08
0.1
0.12
0.14
Figure 37: Some solution curves for the current I(t) in a RL circuit obtained
with different initial conditions and a constant electromotive force.
76
Set
U = sin(t),
dV = e L t
so:
dU = cos(t),
V =
L Rt
eL .
R
And:
Z
sin(t)e
R
Lt
dt
=
=
Z
R
L
L Rt
t
L
sin(t)e
e L cos(t) dt
R
R
Z
R
R
L
L
e L t cos(t) dt.
sin(t)e L t
R
R
dV = e L t
so:
dU = sin(t),
V =
L Rt
eL
R
and:
Z
e
R
Lt
cos(t) dt
Z
L Rt
L Rt
L
e L ( sin(t)) dt
= cos(t) e
R
R
Z
R
L Rt
L
cos(t)e L t +
e L sin(t) dt
=
R
R
Z
R
R
L
L
=
cos(t)e L t +
e L t sin(t) dt.
R
R
Now, the integral on the RHS is identical to the integral we started with, so
we can solve for this integral as follows:
Z
R
R
L
sin(t)e L t dt =
sin(t)e L t
R
Z
R
R
L L
L
t
t
L
L
cos(t)e +
e sin(t) dt ,
R R
R
Z
R
L2 2
L Rt
L
t dt
L
L
1+
= e
sin(t)
cos(t) ,
sin(t)e
R2
R
R
Z
R
R [R sin(t) L cos(t)]
sin(t)e L t dt = Le L t
.
R2 + L2 2
Well, we have the solution of our integral, at last!!
Now we must remember where we started. It was:
Z
R
R
E0
I(t) = e L t
sin(t)e L t dt + const .
L
77
2
2
sin x cos x =
+ p
sin x p
cos x
2 + 2
2 + 2
p
2
2
=
+ sin(x ),
= arctan
= L
and
= arctan
L
.
R
We get the form that is usually seen in electrical engineering applications, that
is:
R
E0
I(t) =
sin(t ) + const e L t .
R2 + 2 L2
We note again that as t the exponential term goes to zero on a timescale t and the current will oscillate harmonically. In this case the steady-state
solution is the first term in the equation (which is oscillatory) while the transient
part is given by the exponential term.
When L = 0, the phase-angle = 0 and the oscillations of the current I(t)
are in phase with those of the electromotive force E(t) (in general they are not).
We show in Figure 38 one of these solution curves.
5.5.2
Example: RC-Circuit
+
I
dt
RC
R
78
=
=
dE(t)
dt
1 dE(t)
.
R dt
1.5
0.5
10
15
20
25
30
35
-0.5
-1
Figure 38: A solution curve for the current I(t) in a RL circuit obtained with a
periodic electromotive force.
79
Z
r(t)e dt + const
p(t) dt.
1
RC
the general solution is given by
p(t) =
I(t)
and
1
RC
e RC t
1
R
Z
dt
1
R
r(t) =
1 dE(t)
R dt
Z
dE R 1 dt
e RC dt + const
dt
dE 1 t
RC
dt + const .
e
dt
t
1
const e RC .
R
dE(t)
= E0 cos(t).
dt
And the solution becomes:
Z
R 1
dE R 1 dt
RC
dt 1
RC
e
dt + const
I(t) = e
R
dt
Z
1
1
RC
t E0
t
RC
= e
cos(t)e
dt + const .
R
80
This can be solved using the method of integration by parts (I omit the
evaluation of the integral here!!). The general solution is:
t
E0 C
1
I(t) = p
sin(t ) + const e RC , = arctan
.
RC
1 + (RC)2
We have again that as t the exponential term (the transient term) will
go to zero and the current will oscillate harmonically.
81
6.1
Definition 17 (Second order linear differential equation). The following differential equation:
y 00 + p(x)y 0 + q(x)y = r(x)
which we can also write as
dy
d2 y
+ p(x)
+ q(x)y = r(x)
dx2
dx
is a second order linear differential equation. This equation is linear in the
dependent variable y and its derivatives.
As in first order linear DEs, second order linear DEs are homogeneous if
r(x) = 0 and non-homogeneous if r(x) 6= 0.
6.1.1
Linear combinations
Theorem 2 (Linear combination of solutions). Let y1 and y2 be linearly independent solutions to the homogeneous equation:
y 00 + p(x)y 0 + q(x)y = 0.
Then any linear combination
c1 y1 + c2 y2
with c1 and c2 are constants is also a solution of the DE.
Proof
Since y1 (x) and y2 (x) are solution of
y 00 + p(x)y 0 + q(x)y = 0
then
y1 (x)00 + p(x)y1 (x)0 + q(x)y1 (x)
0,
0.
If we multiply the first equation by c1 and the second by c2 and add, we get:
c1 y1 (x)00 + c2 y2 (x)00 + p(x) [c1 y1 (x)0 + c2 y2 (x)0 ]
+q(x) [c1 y1 (x) + c2 y2 (x)] = 0
Note that this theorem does not hold for non-homogeneous linear equations
(or non-linear equations)!
82
6.1.2
Example 21 (Linear combination of solutions). Consider the following homogeneous linear differential equation
y 00 6y 0 + 9y = 0.
The functions
y1 (x) = e3x
and
y2 (x) = xe3x
6.1.3
General solution
General solutions
A general solution of a first order differential equation had an arbitrary
constant c in it and an Initial Value Problem had one initial condition y(0) = y0 .
This initial condition allowed us to determine the constant c and thus to obtain
the solution to the IVP.
In second order linear differential equations, a general solution consists of a
linear combination of two suitable solutions y1 and y2 :
y(x) = c1 y1 (x) + c2 y2 (x)
where c1 and c2 are two arbitrary constants.
6.2
IVP
For second order homogeneous linear differential equations an initial value
problem consists of the DE together with two initial conditions:
y 00 + p(x)y 0 + q(x)y = 0,
y(x0 ) = K0
and y 0 (x0 ) = K1 .
With these initial conditions we can find the values of the constants c1 and
c2 and thus a particular solution to the DE.
83
6.2.1
Example 22. Consider again the second order homogeneous linear differential
equation we saw in the previous example now with two initial conditions:
y 00 6y 0 + 9y = 0,
y(0) = 0,
y 0 (0) = 1.
Solution
The general solution is
y(x) = c1 e3x + c2 xe3x .
Since:
y 0 (x) = 3c1 e3x + c2 e3x (1 + 3x)
we can determine the value of the constants from the initial conditions:
y(0) = c1 = 0.
y 0 (0) = 3c1 + c2 = c2 = 1.
c1 = 0,
c2 = 1.
6.3
6.3.1
Basis solutions
Definition 18 (Basis solutions). A basis of solutions of a second order homogeneous linear differential equation
y 00 + p(x)y 0 + q(x)y = 0
on a certain interval I is a pair of linearly independent solutions y1 (x) and y2 (x)
of the DE on I.
A general solution is obtained through any linear combination of y1 (x) and
y2 (x):
y(x) = c1 y1 (x) + c2 y2 (x).
A particular solution of the equation is then obtained by assigning values to
the constants c1 and c2 .
Remember: two functions y1 and y2 are linearly dependent on an interval
I if there exist two constants c1 and c2 , not both zero, such that
c1 y1 (x) + c2 y2 (x) = 0.
84
6.3.2
= u0 y1 + uy10
y200
u y1 + u
(2y10
+ py1 ) +
u(y100
py10
+ qy1 )
0,
0.
By assumption, y1 is a solution of the DE, so the last term in the equation above
must be equal to zero. Well have:
u00 y1 + u0 (2y10 + py1 ) = 0.
Lets divide by y1 :
u00 + u0
2y10 + py1
= 0.
y1
2y10 + py1
v = 0.
y1
=
dx.
v
y1
Z
ln |v| = 2 ln |y1 | p dx.
85
v = exp ln |y1 |
R
e p dx
p dx =
.
y12
Z
=
p dx
dx.
y12
Thus
Z
y2 (x) = y1 (x)
6.3.3
p dx
y12
dx.
6.4
6.4.1
Characteristic equation
Consider the differential equation
y 00 + ay 0 + by = 0
where, a and b are now constants. If we can find two linearly independent
solutions y1 and y2 , then we can write a general solution in the form:
y = c1 y1 (x) + c2 y2 (x)
86
since ex can never be zero, we can divide the above expression by this function
to obtain:
2 + a + b = 0.
This is called the characteristic equation or the auxiliary equation of the DE,
which is satisfied when
a + a2 4b
a a2 4b
,
2 =
1 =
2
2
so that the functions
y1 (x) = e1 x ,
y2 (x) = e2 x
y2 (x) = e2 x
Solution
The characteristic equations is:
2 + 5 + 4 = 0.
Using the quadratic formula:
a + a2 4b
,
1 =
2
2 =
a2 4b
2
we obtain:
1 = 1,
2 = 4
a + a2 4b
a a2 4b
1 =
,
2 =
2
2
it is obvious that we get only one solution: 1 = 2 = = a2 and
y1 (x) = ex .
To obtain a second linearly independent solution y2 (x) we can use the method
of reduction of order which gives:
Z R p(x) dx
e
dx.
y2 (x) = y1 (x)
y1 (x)2
In our case, y1 = ex and p(x) = a, so:
Z R a dx
e
x
y2 (x) = e
2 dx
[ex ]
Z ax
e
x
= e
dx,
eax
Z
= ex dx
=
since =
xex .
a
2
y2 (x) = xe2x
a a2 4b
a + a2 4b
2 =
1 =
2
2
then it has complex roots.
Before proceeding, we have to remember that
i2 = 1
or
i = 1.
and (Eulers formula)
eiy = cos y + i sin y
and
a + a2 4b
a a2 4b
1 =
,
2 =
2
2
89
as follows:
1
=
=
=
=
=
a2 4b
2
p
a + i2 (4b a2 )
2
a + i 4b a2
2
a i 4b a2
+
2
r 2
a
a2
+i b .
2
4
a +
For 2 :
r
a2
a
2 = i b .
2
4
If we now set =
q
b
a2
4
and = a2 :
1 = + i
and
2 = i.
= e(+i)x
= ex (cos(x) + i sin(x))
and
v2 = e2 x
= e(i)x
= ex (cos(x) i sin(x)).
The above two solutions satisfy the DE, however they are complex.
We can find two real solutions by taking suitable linear combinations of the
above two solutions as follows. The first is obtained by adding the solutions and
dividing by 2:
v1 + v2
y1 =
= ex cos(x)
2
and the other by subtracting the two solutions and dividing by 2i:
y2 =
v1 v2
= ex sin(x).
2i
Note that y1 and y2 are the real and imaginary parts of e1 x (or of e2 x ).
Therefore we can summarise our results as follows. If the characteristic
equation has roots which are complex conjugates, 1 = + i and 2 = i,
then a general and real solution is given by:
y(x) = y1 (x) + y2 (x) = ex (A cos(x) + B sin(x))
90
4 +
16 20
= 2 + i,
2
2 =
16 20
= 2 i.
2
91
% s e t t h e time i n t e r v a l
ts = 0 : 0 . 1 : 3 ;
% define a set of i n i t i a l conditions
y0 = [ 1 ; 1 ] ;
% s o l v e the equation
[ t , y ] = ode45 ( @dsecond1 , ts , y0 ) ;
plot (t , y (: ,1) )
t i t l e ( ' C h a r a c t e r i s t i c Equation Example ' )
xlabel ( ' t ' )
ylabel ( 'y ' )
Figure 40 shows the solution if y(0) = y 0 (0) = 1.
Characteristic Equation Example
1.2
0.8
0.6
0.4
0.2
0.2
0.5
1.5
t
2.5
6.4.2
Undamped system
An elastic string or spring obeys Hookes law. An elastic string can only be
stretched (when it is slack the tension is zero). A spring can be stretched or
92
Figure 41: The tension of a stretch string. a is the natural length and y is the
extension.
For a particle of mass m attached to the end of an elastic string in equilibrium
under gravity:
mg = T0 = kd.
For motion under gravity:
m
d2 y
dt2
= mg T
= mg k(y + d)
Figure 42: The tension of a string with a mass m attached to the end. d is the
extension of the spring in equilibrium.
94
Or:
y(t) = C cos(0 t ),
C=
A2 + B 2 ,
tan =
B
.
A
dy
= cy 0
dt
where v is the velocity and c the (positive) damping constant. This approximation is reasonable for small velocities.
The forces acting on the body of mass m are:
Ftot = Fgrav T + Fdamp .
Thus:
my 00 = ky cy 0 ,
95
Homepage > ESA Science missions > Our Missions > Under development > Exploring
jump to:
Search
this section
8-Jan-2003 ESAs
Advanced Search
96
Figure 44: Artists impression of the Rosettas lander on the surface of Comet
Wirtanen (Rosetta is an ESA space mission: http://sci.esa.int/).
or:
y 00 +
c 0
k
y + y = 0.
m
m
2m 2m
2m 2m
2 = .
1 , 2 .
(3) Under-damping
c2 < 4mk
Overdamping
If the damping constant c is large enough, then c2 > 4mk and we have two
distinct real roots with general solution:
y(t) = c1 e()t + c2 e(+)t .
For t > 0 both exponents are negative, since > 0 and > 0 and 2 =
k/m < 2 so that both terms tend to zero as t increases. This means that
for t large enough, the mass will be at rest at the equilibrium position y = 0
and there will be no oscillatory motion.
2
Critical damping
If c2 = 4mk, then = 0 and 1 = 2 = and the general solution is:
y(t) = (c1 + c2 t) et .
The exponential function can never be zero so y(t) can be equal to zero only
if c1 + c2 t = 0. This can happen at most once. But if the initial conditions are
such that c1 and c2 are both positive (or negative), then y is never equal to zero
and thus the body never passes through the equilibrium point. This case is a
borderline case between non-oscillatory motion and oscillatory motion (thats
why it is called critical).
97
Under-damping
If the damping constant is so small that c2 < 4mk, then the roots of the
characteristic equation are complex conjugate:
1 = + i ,
where
2 = i
4mk c2
=
2m
k
c2
m 4m2
and = c/2m.
The corresponding general solution is:
y(t)
and
y = Cet
Euler-Cauchy equation
Definition 19 (Second order Euler-Cauchy equation). Consider the linear differential equation
x2 y 00 + axy 0 + by = 0
where a and b are constants. This is the Euler-Cauchy equation.
By looking at this DE, one may guess that a solution of the type y = xm
could solve it, since differentiation of y = xm gives y 0 = mxm1 and further
differentiation gives y 00 = m(m 1)xm2 . So, if we multiply y 00 by x2 and y 0 by
x the loss in the exponent will be compensated by the power of x.
We assume that x > 0. Results for x < 0 can be found by an appropriate
change of variable.
So, lets substitute
y(x) = xm
into the DE:
x2 [m(m 1)xm2 ] + ax[mxm1 ] + bxm = m(m 1)xm + amxm + bxm = 0
98
0.5
10
20
t
30
40
-0.5
-1
so:
m(m 1) + am + b = 0.
This gives the auxiliary equation:
m2 + (a 1)m + b = 0
with roots:
m1 =
(a 1) +
(a 1)2 4b
,
2
m2 =
(a 1)
(a 1)2 4b
.
2
3 +
32 + 16
= 1,
2
m2 =
32 + 16
= 4.
2
1a
2
100
c2
x4
1a
2
We can find the second solution using the reduction of order method.
We set:
y2 (x) = uy1 (x)
so:
y20 (x) = u0 y1 + uy10 ,
00 2
u x y1 + u
x(2xy10
+ ay1 ) +
u(x2 y100
axy10
+ by1 )
0.
The last bit is equal to zero, since y1 is a solution to the DE. So we are left
with:
u00 x2 y1 + u0 x(2xy10 + ay1 ) = 0.
1a
1a (a+1)
2
2 x
1
u00
=
u0
x
ln |u0 | = ln x
1
u0 =
x
u = ln x
Therefore, since y2 = uy1 , the second solution is
y2 (x) = ln x y1 (x) = x
1a
2
ln x
101
in the above
This equation has a double solution for m = 2. Therefore, the two solutions
are:
ln x
1
y2 = 2 ,
x > 0.
y1 = 2 ,
x
x
The general solution is:
y(x) =
c1
ln x
+ c2 2
x2
x
x>0
m2
We can now find two real solutions by taking suitable linear combinations
of the above two solutions as follows.
The first is obtained by adding the solutions and dividing by 2:
y1 = x cos( ln x)
and the other by subtracting the two solutions and dividing by 2i:
y2 = x sin( ln x).
A general solution (for x > 0) is:
y(x) = x [A cos( ln x) + B sin( ln x)]
where A and B are arbitrary constants.
102
4 + 42 20
4 42 20
m1 =
= 2 + i,
m2 =
= 2 i.
2
2
And a general solution (for x > 0) is:
y(x) =
1
[A cos(ln x) + B sin(ln x)]
x2
6.5
Wronskian
or
103
y2 (x) = k2 y1 (x)
y2 (x) = xex
xex
2x
2x
= e2x 6= 0
x
x = e (1 + x) xe
e + xe
since the wronskian is not zero, the two solutions are linearly independent and
the general solution is:
y(x) = c1 ex + c2 xex
where c1 and c2 are constants.
Existence of a general solution
Theorem 5 (Existence of a general solution). If p(x) and q(x) are continuous
over an open interval I, then the homogeneous linear differential equation
y 00 + p(x)y 0 + q(x)y = 0
has a general solution on I.
104
General solution
Theorem 6 (General solution). If p(x) and q(x) are continuous over an open
interval I, then every solution y(x) of the homogeneous linear differential equation
y 00 + p(x)y 0 + q(x)y = 0
on I, has the form:
y(x) = c1 y1 (x) + c2 y2 (x)
where c1 and c2 are constants and y1 and y2 are a basis of solutions on I
and the differential equation does not have any other singular solutions which
cannot be obtained from a general solution.
105
7
7.1
106
Particular solution
A particular solution of the non-homogeneous DE is obtained by giving values to the constants c1 and c2 .
7.2
107
if r(x) consists of the sum of several of the functions listed in the table,
then choose for yp the sum of the functions in the corresponding lines
of the second column.
(d) Since we want yp00 + ayp0 + byp = r(x), then we set the corresponding
coefficients of LHS and RHS equal to each other and form a system of
linear equations.
(e) By solving the system of linear equations we find the coefficients of yp .
The good thing in all this is that if you choose the wrong form of yp this
method will lead to a contradiction.
The table below gives the form of a particular solution yp when the DE has
constant coefficients.
Term in r(x)
Choice for yp
kex
Cex
kxn (n = 0, 1, )
Kn xn + Kn1 xn1 + + K1 x + K0
k cos(x)
K cos(x) + M sin(x)
k sin(x)
ke
ke
7.2.1
K cos(x) + M sin(x)
cos(x)
sin(x)
[K cos(x) + M sin(x)]
[K cos(x) + M sin(x)]
1 = i 2,
2 = i 2.
108
3K3 x2 + 2K2 x + K1 ,
yp00
6K3 x + 2K2 .
2K2
6K3 + 2K1
2K2 + 2K0
y
y0
=0
2
2
2 +
1
=0
2
2
109
yp00
9,
18K2 + 9K1
0,
.0
14
).
9
110
14
).
9
7.3
111
= y2 r
y20 u0 y1 y20 v 0 y2
u0 (y1 y20 y2 y10 )
u0 W (y1 , y2 )
= y2 r
= y2 r.
Thus:
u0 =
y1 u0 y10 + y1 v 0 y20
y1 r
y10 u0 y1 y10 v 0 y2
v 0 (y1 y20 y2 y10 )
v 0 W (y1 , y2 )
y1 r
y1 r.
y2 (x)r(x)
,
W (y1 (x), y2 (x))
112
v0 =
y1 (x)r(x)
.
W (y1 (x), y2 (x))
7.3.1
y2 (x) = sin(x).
y2 cos x
sin x
=
y20 sin x cos x
= cos2 x + sin2 x = 1
sin2 x
1 cos2 x
y2 r
=
=
= sec x + cos x
W (y1 , y2 )
cos x
cos x
and:
v0 =
y1 r
= cos x tan x = sin x.
W (y1 , y2 )
113
Z
v(x) =
sin x dx = cos x.
7.4
yh (x) + yp (x)
Forced Oscillations
We have already seen that the free motion of a mass-spring system is dictated
by the homogeneous linear DE:
my 00 + cy 0 + ky = 0
where y is the displacement of the body from the rest position, m is the mass
of the body, my 00 is the force of inertia, cy 0 is the damping force and ky is the
spring force.
We can model forced motions by adding the contribution of an external force
r(t) acting on the body:
my 00 + cy 0 + ky = r(t).
The term r(t) is called the input term or driving force. The solution is called
an output or a response of the system to the driving force.
Particularly interesting are those inputs that are period (periodic inputs), so
we will look at the case where the driving force is:
r(t) = F0 cos(t)
(F0 > 0,
> 0).
a sin(t) + b cos(t),
yp00
2 a cos(t) 2 b sin(t).
cb = F0
(k m 2 )b
0.
We can use Cramers rule (if you have forgotten how to use this rule, have
a look at 6.6 of Kreyszig) to solve this linear system:
F0 c
2
0
(k m )
(k m 2 )F0
=
.
a=
2
(k m 2 )2 + 2 c2
(k m ) c
c
(k m 2 )
b =
(k m 2 ) F0
c
0
(k m 2 ) c
c
(k m 2 )
F0 c
=
.
2 )2 + 2 c2
(k
2 2
2 2
which is OK provided
p that (k m ) + c 6= 0.
Now set 0 = k/m so we get (check!):
a = F0
m(02 2 )
,
m2 (02 2 )2 + 2 c2
b = F0
115
c
.
m2 (02 2 )2 + 2 c2
m( 2 2 )
F0
m(02 2 )
= F0 2 02
=
,
2
2
2
2
) + c
m (0 2 )2
m(02 2 )
c
F0 2 2
= 0.
m (0 2 )2 + 2 c2
F0
m2 (02
=
=
As you can see, what we have here is the superposition of two harmonic
oscillations with frequencies 0 /2 cycles per second (the natural frequency of
the system) and /2 cycles per second of the input.
Since k = m02 , the amplitude of yp can be written as:
a=
F0
,
k
where
=
1
1
2 .
F0
t sin(0 t).
2m0
40
20
10
20
30
40
50
-20
-40
We see that as the time t goes by, yp (t) becomes larger and larger! This
means that if there is very little damping (c 0), the system may undergo
vibrations so large that can destroy it (see Figure 46). For structures (e.g.
buildings, bridges) this can have very dangerous implications so that engineers
and architects must watch out for resonance.
Two very famous cases when resonance proved to be disastrous are:
(a) Broughton Suspension Bridge (near Manchaster, England) in 1831. A
column of soldiers marching on the bridge setup a periodic force whose
frequency was too close to one of the natural frequencies of the bridge, so
the bridge collapsed. These days soldiers break steps when they cross a
bridge.
(b) Tacoma Narrows Bridge (Washington) in 1940. This bridge was opened
on the 1st of July 1940 and from the very first day it started oscillating
vertically (it was nicknamed Galloping Gertie and people used to travel
117
7.4.2
Figure 49: Satellite and Space Shuttle are not linked and travel at different
altitudes and thus speeds.
In such a linked system, the tether linking the satellite to the Shuttle can:
compress and stretch, causing the satellite to bounce up and down (longitudinal oscillations) (see Figure 51)
move in a circular (skip-rope) motion. (see Figure 51)
develop wave-like motions (transverse oscillations) (see Figure 52).
Furthermore, the satellite may start rocking back and forth about its attachment point (pendulous motion). See Figure 52.
All the motions listed above have their own frequencies, which depend on
the length and tension of the tether. If the frequencies are all different, they do
119
Figure 50: Satellite and Space Shuttle are linked and travel at different altitudes, but at the same speed. Thus, a tension is created in the tether (http://
science.ksc.nasa.gov/shuttle/missions/sts-75/mission-sts-75.html).
not cause any harm, but if some of them become close to each other, we can
have resonance.
The oscillations could be caused by the motion of the satellite or Shuttle.
Also, the conductive tether system produces an electrical current, which, in
turn, produces a magnetic field around the tether. This field will interact with
the Earths magnetic field, resulting in a force that may produce skip-rope type
oscillations.
Obviously, it is very important to keep control of a tethered satellite, thats
why much study has gone into identifying the different types of possible motions
and the methods used to control them.
7.4.3
Application: Beats
Beats
Something else happens when 0 .
Consider the IVP given by the general solution of forced mechanical oscillations:
y(t) = C cos(0 t ) +
F0
cos(t),
2 )
m(02
y(0) = 0, y 0 (0) = 0.
120
F0
sin(t).
m(02 2 )
121
= C cos() +
0
which gives:
C cos()
C0 sin()
=
=
F0
,
m(02 2 )
0.
So:
C=
= 0,
Therefore:
y(t) =
F0
.
2 )
m(02
F0
[cos(t) cos(0 t)]
2 )
m(02
2F0
sin
m(02 2 )
0 +
0
t sin
t .
2
2
Now, since
0 , then 0 is small and the period of the term
sin 02 t is large (P = 2/(0 )/2) and we obtain an oscillation of the
type shown in Figure 53. Forced undamped oscillations with 0 produce
the phenomenon called beats.
7.4.4
Damped oscillations
Consider again:
my 00 + cy 0 + ky = F0 cos(t)
with general solution:
y(t) = yh (t) + yp (t)
where yh (t) is the general solution of the corresponding homogeneous DE.
We saw earlier in this course that in the case of underdamping this is given
by:
yh (t) = et (A cos( t) + B sin( t))
where:
c
=
2m
r
and
122
k
c2
.
m 4m2
0.5
50
100
150
200
250
300
-0.5
-1
We have also already seen that a particular solution yp (t) to the non-homogeneous
DE with c 6= 0 is:
yp (t) = a cos(t) + b sin(t)
where the coefficients a and b are:
a = F0
m(02 2 )
,
m2 (02 2 )2 + 2 c2
b = F0
m2 (02
c
.
2 )2 + 2 c2
C ()
p
a2 + b2 = p
tan
b
c
=
.
a
m(02 2 )
m2 (02
2 )2 + 2 c2
One can see that the solution consists of two terms: the first term (yh (t))
represents damped oscillations and depends only on the parameters of the system and initial conditions. The damping factor et 0 when t . For this
reason, this term is called the transient part of the solution. The second term
(yp (t)) is due to the external force r(t) = F0 cos(t). Note that yp (t) is out of
phase with r(t) by an angle which is called the phase angle or phase lag since
it measures the lag of the output behind the input. Also, the magnitude of r(t)
is different from the magnitude of yp (t) by a factor C /F0 :
1
p
m2 (02
2 )2 + 2 c2
0.06
0.04
0.02
10
12
14
-0.02
Figure 54: Behaviour of yh (t) (magenta curve), yp (t) (blue curve) and y(t) =
yh (t) + yp (t) (red curve) as a function of time t. As you can see, y(t) converges
to yp (t) at sufficiently large values of t.
124
For a given system (for which m, k and c are fixed), it may be interesting
to see how this would react to a certain sinusoidal input of frequency . For
this purpose, one can graph the amplitude C of the output as a function of .
This graph is called the frequency response curve or resonance curve.
If the input frequency = 0, then the applied force is constant (F0 cos(t) =
F0 ), there is no motion in the steady-state and C () = F0 /(m0 ) = F0 /k.
Also, if , then C () 0 since the inertia of the system doesnt
allow a response to vibrations that are too rapid.
Lets study further the amplitude term C () of the steady-state term by
looking for the maximum value obtained by this term.
We can do so by taking the derivative of C () and then by setting it equal
to zero:
"
#
d
F0
dC ()
p
=
=0
d
d
m2 (02 2 )2 + 2 c2
which gives:
F0 (4m2 0 2 + 4m2 3 + 2c2 )
2
(m 0 4 2m2 0 2 2 + m2 4 + 2 c2 )3/2
= 0.
Thus:
2m2 (02 2 ) + c2 = 0
which is verified when
r
=0
or
02
c2
.
2m2
0.5
1
omeg
1.5
126
7.5
Modelling: RCL-circuit
d2 I
dI
I
+R
+
= E0 cos(t).
2
dt
dt
C
127
my 00 + cy 0 + ky = F0 cos(t)
Displacement y
Mass m
Damping constant c
Spring modulus k
Driving force
F0 cos(t)
1
C
Derivative E0 cos(t) of
electromotive force
This differential equation has the same form as that seen in the context of
a mechanical system!! The analogy between mechanical and electrical systems
is given in Table 1.
Note that since:
Z
dQ
dI
d2 Q
I=
,
= 2,
I dt = Q,
dt
dt
dt
then
Z
dI
1
+
I dt
dt
C
dQ
d2 Q Q
R
+L 2 +
dt
dt
C
dQ Q
d2 Q
+
L 2 +R
dt
dt
C
RI + L
E0 sin(t)
E0 sin(t)
E0 sin(t).
In practical electrical engineering problems, the current I(t) is more important than Q(t), so we will work with
L
dI
I
d2 I
+R
+
= E0 cos(t).
dt2
dt
C
To solve this DE we must find a general solution to the corresponding homogeneous DE and a particular solution to the non-homogeneous DE:
I(t) = Ih (t) + Ip (t).
The corresponding homogeneous DE is:
d2 I
R dI
I
+
+
=0
2
dt
L dt
LC
with characteristic equation:
2 +
1
R
+
=0
L
CL
128
with roots:
q
1 =
R
+
2L
R2
4L
C
2 =
2L
2L
R2
4L
C
2L
4L
C
4L
C
If we set:
q
R2 4L
R
C
,
=
=
2L
2L
then 1 = + and 2 = and the general solution is:
Ih (t) = c1 e()t + c2 e(+)t .
As you can see, both exponents are negative, since > 0, > 0 and
2 = 2 1/LC < 2 . Thus, in all three cases, the general solution Ih (t) 0
as t .
A particular solution Ip (t) to the non-homogeneous can be found using the
method of undetermined coefficients. A look at the usual table tells us to use:
Ip (t) = a cos(t) + b sin(t).
Calculate the derivatives:
Ip0 (t) = (a sin(t) + b cos(t)),
Ip00 (t) = 2 (a cos(t) b sin(t)).
Substitute these into the DE, then collect the cosine terms and set them
equal to E0 cos(t). Then take the sine terms and set them equal to zero:
a
C
b
2
L (b) + R(a) +
C
L 2 (a) + Rb +
E0
0.
E0 S
,
R2 + S 2
b=
129
E0 R
.
R2 + S 2
1
.
C
p
E0
a
S
a2 + b2 =
,
tan = = .
2
2
b
R
R +S
1.5
0.5
0.005
0.01
t
0.015
0.02
-0.5
-1
-1.5
Figure 57: Transient current (red curve), steady-state current (blue curve) and
sum of the two currents (magenta curve) in a RLC circuit with sinusoidal electromotive force. You can see that after a very short time the current will oscillate
at the input frequency.
130
Finally, if the system is under-damped (R2 < 4L/C), then the frequency
response curve has a maximum at (like in mechanical systems):
r
1
R2
max =
.
LC
2L2
So, if a periodic voltage E(t) with the same frequency max were impressed
on the circuit, the electrical system would be in resonance.
7.6
dp
d2 p
+v 2,
dt
dt
dp
d2 p
dp
d2 p
+ n 2 = + p + u + v 2 ,
dt
dt
dt
dt
or
d2 p
dp
+ (m u) ( )p = ( + ).
dt2
dt
So, as with our previous examples, the solution will be oscillatory and we
can look at different choice of parameters to determine if the market will be
stable or unstable.
(n v)
131
8.1
8.1.1
y
n
2
3
00
00
00
00
y1
y
y
y
n
2
3
W (y1 , y2 , , yn ) =
6= 0.
..
..
..
..
..
.
.
.
.
.
(n1)
(n1)
(n1)
(n1)
y
yn
y
y
1
132
8.1.2
Constant coefficients
If a linear DE has constant coefficients:
y (n) + an1 y (n1) + an2 y (n2) + a1 y 0 + a0 y = 0
then it has the characteristic equation:
(n) + an1 (n1) + an2 (n2) + a1 + a0 = 0
and to find the solutions of the DE we must determine the roots of the characteristic equation.
This will generally require a numerical root-finding method.
Real and distinct roots
If all the n roots are real and distinct, then the general solution is given by:
y(x) = c1 e1 x + c2 e2 x + cn en x .
and
y2 (x) = xex .
y2 (x) = xex ,
ym (x) = xm1 ex .
Complex roots
If there are simple complex roots, they occur in conjugate pairs, that is, if
= + i is a root, then = i is also a root and the two corresponding
linearly independent solutions are:
y1 (x) = ex cos(x)
and
y2 (x) = ex sin(x).
Finally, if there are multiple complex roots (say three for example) the corresponding six linearly independent solutions are:
y1 (x)
= ex cos(x),
y3 (x)
= xex cos(x),
y5 (x)
2 x
= x e
y2 (x) = ex sin(x),
y4 (x) = xex sin(x),
cos(x),
133
y6 (x) = x2 ex sin(x).
8.1.3
8.1.4
y 0 (x0 ) = K1 ,
y 00 (x0 ) = K2 ,
8.2
yp00
= Aex (x2 4x + 2)
yp000
= Aex (x2 + 6x 6)
135
1
3 = 6A A = .
2
x2 x
e .
2
8.2.3
x2 x
e .
2
Variation of parameters
The method of variation of parameters also extends to nth order non-homogeneous
DEs:
y (n) + pn1 (x)y (n1) + pn2 (x)y (n2) + p1 (x)y 0 + p0 (x)y = r(x).
A particular solution on I to the non-homogeneous equation with continuous
coefficients is given by the formula:
Z
Z
W1 (x)r(x)
W2 (x)r(x)
yp (x) = y1 (x)
dx + y2 (x)
dx
W (x)
W (x)
Z
Wn (x)r(x)
+ + yn (x)
dx
W (x)
where y1 , y2 , yn are linearly independent solutions on I of the corresponding
homogeneous DE and W is their Wronskian. The Wj with j = 1 n are obtained from W by replacing the j th column of W with the column [0 0 0 1]T .
You can see that when n = 2 we have:
y y2
,
W (y1 , y2 ) = 10
y1 y20
0
W1 =
1
y2
= y2 ,
y20
y
W2 = 10
y1
0
= y1 ,
1
which is the result that we found earlier for second order linear non-homogeneous
DEs.
136
8.2.4
y 0 (x0 ) = K1 ,
y 00 (x0 ) = K2 ,
137
9
9.1
Modelling: predator-prey
Model description
Consider two populations of animals, one of which preys the other. For
example, foxes and rabbits (or snakes and toads as shown in Figures 58 and
59). The population of foxes at time t will be denoted x(t) and the population
of rabbits at time t will be denoted y(t).
We will assume plenty of space and food for the rabbits, so that in the
absence of foxes they would grow exponentially. The foxes use rabbits as their
food sources, so in the absence of rabbits they would decline exponentially.
Thus, if there were no interaction between the two species we would have:
dx
dt
dy
dt
kx
my
where k is the death rate of foxes and m is the birth rate of rabbits.
Now we assume that the interaction of rabbits and foxes is jointly proportional to both populations, that is, it is proportional to xy.
dx
dt
dy
dt
kx + bxy
my cxy
or:
dx
dt
dy
dt
= x(k + by)
= y(m cx)
here, b and c are also constants. These are the Lotka-Volterra Predator-Prey
equations.
9.1.2
Matlab implementation
Lets enter the Predator-Prey equations in Matlab:
% P r e d a t o r Prey model
138
Figure 58: Prairie Rattlesnake (a predator?). Credit: U.S. Fish and Wildlife
Service U.S. Fish and Wildlife Service/photo by Photographer Bill Iko
Figure 59: Wyoming Toad in the grass (a prey?). Credit: U.S. Fish and Wildlife
Service U.S. Fish and Wildlife Service/photo by Photographer:Amy Hopperstad
139
% d e f i n e t h e r i g h t hand s i d e f u n c t i o n
f u n c t i o n rhs = pred_prey ( t , z )
global k b m c
rhs =[z ( 1 ) (k+bz ( 2 ) ) ; z ( 2 ) ( mcz ( 1 ) ) ] ;
We will replace the symbolic constants k, m, b and c by numeric ones. We
can choose: k=1; m=1; b=0.01; c=0.01;
We can now plot the solutions
% s e t the i n i t i a l c o n d i t i o n s
z0 = [ 4 0 ; 4 0 ] ;
% evaluate the s o l u t i o n at these points
ts= [ 0 : 0 . 1 : 1 0 ] ;
% s e t the parameters
global k m b c
k=1; m=1; b = 0 . 0 1 ; c = 0 . 0 1 ;
% s o l v e t h e ODE
[ t , z]= ode45 ( @pred_prey , ts , z0 ) ;
% p l o t the s o l u t i o n
plot (t , z (: ,1) )
t i t l e ( ' Changes i n Fox P o p u l a t i o n ' )
xlabel ( ' t ' )
y l a b e l ( ' Foxes ' )
The plot is shown in Figure 60.
Lets see what happens to the rabbits population. All we need to do is use
the following few lines
% p l o t the s o l u t i o n
plot (t , z (: ,2) )
t i t l e ( ' Changes i n Rabbit P o p u l a t i o n ' )
xlabel ( ' t ' )
y l a b e l ( ' Rabbits ' )
The plot is shown in Figure 61.
If we want to plot the behaviour of both populations together on the same
plot, then once again only have to make a minor modification
% p l o t the s o l u t i o n
plot (t , z (: ,1) , t , z (: ,2) )
t i t l e ( ' Rabbits and Foxes o v e r time ' )
xlabel ( ' t ' )
140
250
Foxes
200
150
100
50
5
t
10
250
Rabbits
200
150
100
50
5
t
10
(40 and 40) as we started with. If they reach the same values (at the same
time), then the entire process will repeat cyclically forever.
We can shed some light on this by making a graph of y against x (this is a
parametric graph, where t is the parameter).
% p l o t the s o l u t i o n
plot (z (: ,1) , z (: ,2) )
x l a b e l ( ' Foxes ' )
y l a b e l ( ' Rabbits ' )
This graph, in Figure 63, does indeed go round in a closed loop, verifying
the cyclic nature of the process.
Lets see what happens if we start with different initial conditions.
% evaluate the s o l u t i o n at these points
ts= [ 0 : 0 . 1 : 1 0 ] ;
% s e t the parameters
global k m b c
k=1; m=1; b = 0 . 0 1 ; c = 0 . 0 1 ;
% try d i f f e r e n t i n i t i a l conditions
for i = 1:5
142
250
200
150
100
50
10
t
12
14
16
18
20
143
300
250
Rabbits
200
150
100
50
50
100
150
Foxes
200
250
300
144
% s o l v e t h e ODE
[ t , z]= ode45 ( @pred_prey , ts , [ 1 0 i 10 i ] ) ;
% p l o t the s o l u t i o n
plot (z (: ,1) , z (: ,2) )
h o l d on
end
x l a b e l ( ' Foxes ' )
y l a b e l ( ' Rabbits ' )
h o l d off
600
500
Rabbits
400
300
200
100
100
200
300
Foxes
400
500
600
% f i n d t h e s l o p e o f t h e f u n c t i o n a t each p o i n t
dydt = y . ( mcx ) ;
dxdt = x .( k+by ) ;
% p l o t the s o l u t i o n
q u i v e r ( x , y , dxdt . / abs ( dxdt ) , dydt . / abs ( dydt ) , 0 . 2 5 )
a x i s tight
t i t l e ( ' Direction Field ' )
xlabel ( 'x ' )
ylabel ( 'y ' )
By using the hold option we can combine the direction field and contour plot
as shown in Figure 66.
Direction Field
550
500
450
400
350
300
250
200
150
100
50
50
100
150
200
250
300
x
350
400
450
500
550
Figure 65: Vector field for the population of rabbits y against population of
foxes x plotted with dfieldplot.
9.2
Analytic approach
Direction Field
550
500
450
400
Rabbits
350
300
250
200
150
100
50
50
100
150
200
250
300
Foxes
350
400
450
500
550
Figure 66: Vector field for the population of rabbits y against population of
foxes x plotted with DEplot.
147
set of values of the constants. For all we know, if we took different values we
might get a totally different behaviour! An analytic approach. if possible, would
probably work for all possible values of the constants.
Equilibrium points
Let us first ask about equilibrium points. What we are looking for is any
solution of the form x(t)=constant, and y(t)=constant. For such a solution
dy
we must have dx
dt = 0 and dt = 0. Substituting these in the Predator-Prey
equations gives:
x(k + by)
0,
y(m cx)
0.
These equations are not linear, so the usual Gaussian elimination techniques
cannot be used. Usually, non-linear systems cant be solved easily, but these
can be solved.
From the first one, we have either
x=0
or
(k + by) = 0.
First case, x = 0.
Substituting this in the second equation gives y = 0 (since m 6= 0). The
equilibrium point is at
x = 0,
y = 0.
This says that if we start with no foxes and no rabbits, we will go on having no
foxes and no rabbits!
Second case, (k + by) = 0.
Since b 6= 0, we can solve this to get y = k/b. If we substitute this in the
second equation we get
k
(m cx) = 0
b
which gives
m
m cx = 0
x= .
c
So, we have one more equilibrium point:
x=
m
,
c
y=
148
k
.
b
We would expect this to be the point in the middle of the closed curves in
the Figure. If we use the value that we used before (k = 1, m = 1, b = 0.01, c =
0.01), we get x = 100, y = 100, which is right!
Lets try now to solve this system (when x 6= 0 and y 6= 0).
dx
dt
dy
dt
= x(k + by)
= y(m cx).
This gives:
y(m cx)
dy
=
,
dx
x(k + by)
which is separable!
So:
and so:
dy
(m cx)
y
=
dx
x
(k + by)
m cx
k + by
dy =
dx
y
x
Z
Z
k + by
m cx
dy =
dx
y
x
Z
Z
Z
Z
k
m
dy + b dy =
dx c dx
y
x
and
k ln y + by = m ln x cx + A
or
by k ln y + cx m ln x = A.
This equation cannot be solved explicitly for y. Nevertheless we will see that
the curves are closed!
The last equation is of the form H(x, y) = A, where H is the function
H(x, y) = by k ln y + cx m ln x.
When we ask for a solution of H(x, y) = A, we ask for all points (x, y) at
which the height of this graph (surface) is A. We could get this by slicing the
surface with a horizontal plane at height A. We need a contour plot!
% s e t the parameters
k=1; m=1; b = 0 . 0 1 ; c = 0 . 0 1 ;
% d e f i n e t h e g r i d i n t h e xy domain
[ x , y ] = meshgrid ( [ 0 : 2 0 : 4 0 0 ] , [ 0 : 2 0 : 4 0 0 ] ) ;
% f i n d the curves
149
H= byk l o g ( y )+cxm l o g ( x ) ;
% p l o t the contour
contour3 (x , y , H , 30) ;
t i t l e ( ' Contour P l o t ' )
xlabel ( 'x ' )
ylabel ( 'y ' )
z l a b e l ( 'H ' )
Contour Plot
4
4.5
5
5.5
6
6.5
7
7.5
400
300
400
300
200
200
100
y
100
0
150
0,
0.
m
,
c
y=
k
.
b
This is the global minimum of the function H(x, y). All contours (the solution curves) will be concentric closed curves encircling this point.
9.2.1
Experimental evidence
Predator-Prey experiments
Figure 69: Lynx furs return from the Northern Department of the Hudson Bay
Co. Adapted from DAncona (1954). (http://animaldiversity.ummz.umich.
edu/accounts/lynx/l._canadensis.html)
9.3
y3
y3
..
. . . . . . . . . . . . . . . . . . . . . . . . . ...
.
an1 an2 an3 ann
y0
yn
n
or
y0 = Ay.
Here, we will talk a lot about eigenvalues and eigenvectors, so I will remind
you of what they are.
152
Figure 70: Oscillations in the populations of paramecia and yeast. Adapted from
DAncona (1954). (http://www-chem.st.usm.edu/japgroup/nlcd/intro.
html)
9.3.1
Overview
Let A be a n n matrix and consider the equation:
Ax = x
where is a real or complex scalar to be determined and x is a vector also to
be determined.
Apart from the trivial solution x = 0 valid for every , a value of that
satisfies the above equation and for which x 6= 0 is called an eigenvalue of A
and the vector x corresponding to this eigenvalue is called eigenvector of A. We
can re-write the above equation as:
(A I)x = 0.
These are n linear algebraic equations in the n unknowns x1 , x2 , , xn (the
components of the vector x). And I is the n n unit matrix:
1 0 0 0
0 1 0 0
0 0 1 0 .
................
0 0 0 1
153
In components:
(a11 )x1 + a12 x2 + a13 x2 + + a1n xn = 0
a21 x1 + (a22 )x2 + a23 x2 + + a2n xn = 0
a31 x1 + a32 x2 + (a33 )x2 + + a3n xn = 0
................................................
an1 x1 + an2 x2 + an3 x2 + + (ann )xn = 0
Characteristic equation
For the equations
(A I)x = 0
to have a solution x 6= 0, the determinant of (A I) must be zero. This
determinant is called the characteristic determinant of A.
2 2 matrix example
In the case of a 2 2 matrix this becomes:
a a12
det(A I) = 11
a21
a22
=
=0
=0
Circuit model
Example 37 (Electrical network). Find the currents I1 (t) and I2 (t) in the
network shown in Figure 71 assuming that all charges and currents are equal
to zero at t = 0, which is when the switch is closed. Use the following values:
L = 1 henry, R1 = 4 ohms, R2 = 6 ohms C = 0.25 farad and E = 12 volt.
154
Solution
From Kirchhoffs voltage law, the loop on the left yields:
L
dI1
+ R1 (I1 I2 ) = E.
dt
I20
0.4I10
+ 0.4I2
0.
155
I20
In matrix form:
J0 = AJ + g
where
J=
I1
I2
,
A=
4.0
1.6
4.0
1.2
,
g=
12.0
4.8
.
Ax = x
(A I)x = 0.
(4 )(1.2 ) + 4 1.6
= 2 + 2.8 + 1.6 = 0
with eigenvalues 1 = 2 and 2 = 0.8.
The corresponding eigenvectors are obtained from
(A I)x = 0.
In components:
(4.0 )x1 + 4.0x2
1.6x1 + (1.2 )x2
= 0,
= 0.
Set = 2:
(4.0 + 2.0)x1 + 4.0x2
1.6x1 + (1.2 + 2.0)x2
= 2.0x1 + 4.0x2 = 0
= 1.6x1 + 3.2x2 = 0
156
Jp = a =
3
0
=0
=0
= 2c1 + c2 + 3,
= c1 + 0.8c2 .
with solution c1 = 4, c2 = 5.
157
I1
I2
3
t
9.4
1.2
0.8
0.6
0.4
0.2
=
=
=
y2
y 00 = y3
y (3) = y4
..
.
0
yn1
0
yn
=
=
=
y (n1) = yn
yn
pn1 (x)y (n1) pn2 (x)y (n2) p1 (x)y 0 p0 (x)y
+r(x)
pn1 (x)yn pn2 (x)yn1 p1 (x)y2 p0 (x)y1 + r(x)
That is, y0 = Ay + g, or
0
1
0
y10
0
0
1
0
y2
0
0
0
.. =
..
..
..
.
.
.
.
0
yn1
0
0
0
yn0
p0 (x) p1 (x) p2 (x)
159
0
0
0
..
.
0
0
0
..
.
y1
y2
..
.
yn1
yn
0
0
..
.
0
r(x)
9.4.1
= y2 ,
= y3 ,
= y4 ,
= 6y4 7y3 6y2 + 8y1 .
In matrix form:
0
y10
y20 0
0 =
y3 0
8
y40
1
0
0
6
1
det(A I) =
0
0
8
6 7
0
1
0
7
y1
0
y2
0
1 y3
6
y4
0
= 4 6 3 + 7 2 + 6 8 = 0
1
6
with solutions 1 = 1, 2 = 1, 3 = 2, 4 = 4.
These are the four eigenvalues of A. To find the corresponding eigenvectors,
we must solve (A I)x = 0. In components:
x1
8x1
+x2
x2
6x2
+x3
x3
7x3
1
1
1
2
1
x1 =
1 , x = 1
1
1
+x4
+(6 )x4
= 0,
= 0,
= 0,
= 0.
to the eigenvalues 1 = 1, 2 = 1, 3 = 2,
1
2
x3 =
4 ,
8
160
1
4
x4 =
16 .
64
y = c1 x1 et + c2 x2 e + c3 x3 e2t + c4 x4 e4t .
In components:
y1
y2
y3
y4
9.5
= c1 et + c2 et + c3 e2t + c4 e4t
= c1 et + c2 et + 2c3 e2t + 4c4 e4t
= c1 et + c2 et + 4c3 e2t + 16c4 e4t
= c1 et + c2 et + 8c3 e2t + 64c4 e4t
161
10
10.1
Phase plans
Lets consider now homogeneous systems of two differential equations with
constant coefficients. Thus, if A is a 2 2 matrix, then the system
y0 = Ay
can be written, in components,
y10
y20
= a11 y1 + a12 y2 ,
= a21 y1 + a22 y2 .
dy2
dt
dy1
dt
a21 y1 + a22 y2
a11 y1 + a12 y2
every point (y1 , y2 ) has a unique tangent except for the point (0, 0) where the
RHS becomes 0/0. Thus the point (0, 0) in the phase plane is a critical point of
the system of DEs.
The characteristic equation of :
y10
y20
= a11 y1 + a12 y2
= a21 y1 + a22 y2
is given by:
2 (a11 + a22 ) + (a11 a22 a12 a21 ) = 0.
The long-term behaviour of the solution (t ) depends on the roots 1
and 2 of the characteristic equation above (positive, negative, complex, etc.).
We will see in the following examples that the nature of the roots will lead to six
types of critical points, called improper nodes, proper nodes, degenerate nodes,
saddle points, centre points and spiral points.
We will also classify the point as being stable or unstable according to the
following definitions.
A point C is a stable critical point if for every disk D of radius > 0 centred
on the critical point there is a disk D of radius > 0 such that every trajectory
passing through a point in D at a certain t = t1 has all its points in D at
t > t1 (see figure, left panel).
A critical point C is asymptotically stable (or stable and attractive) if every
trajectory approaches the critical point as t (see Figure 74, right panel).
Finally, a critical point C is unstable if it is not stable!
162
10.1.1
Improper node
Consider the system:
y10
y20
1
det(A I) =
3
= y1 2y2 ,
= 3y1 4y2 .
2
= (1 ) (4 ) + 6 = 2 + 3 + 2 = 0.
4
2x2
(4 )x2
= 0,
= 0.
2t
In components:
y1 (t)
y2 (t)
= c1 et + 2c2 e2t ,
= c1 et + 3c2 e2t .
Figure 75 shows the phase portrait of some of the trajectories. The straight
lines correspond to the trajectories obtained by setting c1 = 0 and c2 = 0. Note
163
Improper node
10
y2(t)
-5
-10
5
y1(t)
10
-5
-10
that the trajectories are moving toward the origin. For this reason the origin is
called an asymptotically stable improper node.
Consider now the system:
y10
y20
det(A I)
7
=
6
= 7y1 2y2 ,
= 6y1 y2 .
2
= (7 ) (1 ) + 12
1
= 2 6 + 5 = 0.
The roots of the characteristic equation are 1 = 1 and 2 = 5, that is, now
they are real, distinct and positive.
The eigenvectors are obtained from (A I)x = 0. In components:
(7 )x1
6x1
2x2
(1 )x2
= 0,
= 0.
y = c1 x1 et + c2 x2 e .
In components:
y1 (t) = c1 et + c2 e5t ,
y2 (t) = 3c1 et + c2 e5t .
Figure 76 shows the phase portrait of some of the trajectories. The straight
lines correspond again to the trajectories obtained by setting c1 = 0 and c2 = 0.
Note that the trajectories are now moving away from the origin. For this reason
the origin is called an unstable improper node.
Improper node
10
y2(t)
-10
-5
5
y1(t)
10
-5
-10
10.1.2
Saddle points
Consider the system:
y10
y20
3
det(A I) =
2
= 3y1 2y2 ,
= 2y1 2y2 .
2
= (3 ) (2 ) + 4 = 2 2 = 0.
2
165
The roots of the characteristic equation are 1 = 1 and 2 = 2, that is, they
are real, distinct and of opposite sign.
The eigenvectors are obtained from (A I)x = 0. In components:
(3 )x1
2x1
2x2
(2 )x2
= 0,
= 0.
y = c1 x1 et + c2 x2 e .
In components:
y1 (t) = c1 et + 2c2 e2t ,
y2 (t) = 2c1 et + c2 e2t .
Figure 77 shows the phase portrait of some of the trajectories. The origin
is unstable, since although there are trajectories that pass arbitrarily near it,
these then move away from it. There are only two trajectories that approach the
origin, but these are the only ones. In this case, the origin is called an unstable
saddle point.
10.1.3
Spiral point
Consider
det(A I)
y10
y20
1
=
2
= y1 + 2y2 ,
= 2y1 y2 .
2
= (1 ) (1 ) + 4
1
= 2 + 2 + 5 = 0.
The roots of the characteristic equation are 1 = 1 + 2i and 2 = 1 2i, that
is, they are complex roots, but not pure imaginary (well see this case later).
The eigenvectors corresponding to the eigenvalues 1 = 1 + 2i and 2 =
1 2i are, respectively:
1
1
1
2
x =
, x =
.
i
i
Thus, the solution is:
y = c1 x1 e(1+2i)t + c2 x2 e
166
(12i)t
Saddle point
y2(t)
2
-4
-2
2
y1(t)
-2
-4
In components:
y1 (t) = c1 e(1+2i)t + c2 e(12i)t ,
y2 (t) = ic1 e(1+2i)t ic2 e(12i)t .
As in the case of single DEs, we can write the solution in terms of cos and
sin by using Eulers formula as follows.
y1 (t)
= c1 e(1+2i)t + c2 e(12i)t
= c1 et [cos(2t) + i sin(2t)] + c2 et [cos(2t) i sin(2t)]
= et [cos(2t) (c1 + c2 ) + i sin(2t) (c1 c2 )]
= et [A cos(2t) + B sin(2t)] .
Figure 78 shows the phase portrait of some of the trajectories. The origin is
a stable spiral point. In general, spiral points are unstable if a11 > 0 and stable
if a11 < 0.
Spiral point
10
y2(t)
-10
-5
5
y1(t)
10
-5
-10
= y1 + 2y2 ,
= 2y1 y2 .
Multiply the first equation by y1 and the second by y2 then add them up:
y1 y10 = y12 + 2y1 y2
y2 y20 = 2y1 y2 y22
y1 y10 + y2 y20 = (y12 + y22 ).
Lets now use polar coordinates (r, ) and set r2 = (y12 + y22 ). Thus
1 dr2
= y1 y10 + y2 y20
2 d
then:
1 dr2
= r2 .
2 d
168
e
=e
r = ce
= ce
which gives the equation of a spiral in polar coordinates once we set c equal to
any real number.
10.1.4
Centre point
Consider
The roots of the characteristic equation are 1 = i and 2 = i, that is, they
are pure imaginary.
The corresponding eigenvectors are, respectively:
2+i
2i
x1 =
, x2 =
.
1
1
Thus, the solution is:
y = c1 x1 eit + c2 x2 e
it
In components:
y1 (t) = c1 (2 + i)eit + c2 (2 i)eit .
y2 (t) = c1 eit + c2 eit .
We can write again the solution in terms of cos and sin by using Eulers
formula as follows.
y1 (t)
And:
y2 (t)
where we have again A = (c1 +c2 ) and B = i(c1 c2 ). If c1 and c2 are complex
conjugates the solutions are real.
Figure 79 shows the phase portrait of some of the trajectories. This shows
that the trajectories are ellipses centred around the origin. As you can see, in
this case, the origin is stable, but not asymptotically stable, since the solutions
never approach zero. Thus, the origin is called a stable centre point (or vortex).
Centre point
10
y2(t)
-10
-5
5
y1(t)
10
-5
-10
10.1.5
Proper node
In case of equal roots, the general solution is of the form (well see this later):
y = c1 xet + c2 xtet + uet .
The trajectories for this case are very different depending on whether the
term tet is present or not. Consider first the simpler case when this term is
not there. Illustrative of this case is the following system:
y10
y20
= y1 ,
= y2 .
= c1 et ,
= c2 et .
Figure 80 shows the phase portrait of some of the trajectories which are
all straight lines of equation y2 = cc12 y1 . Note that the trajectories are moving
toward the origin. The origin is called a stable proper node.
Proper node
10
y2(t)
-10
-5
5
y1(t)
10
-5
-10
= y1 ,
= y2 .
171
10.1.6
Degenerate node
Consider the system:
y10
y20
= 23 y1 + y2 ,
= 41 y1 12 y2 .
3
1
2
det(A I) =
1
1
4
2
3
1
1
=
+
+ + = 2 + 2 + 1.
2
2
4
The characteristic equation has a double root = 1.
The corresponding eigenvector is:
2
x=
.
1
Since in this case the general solution is given by (well see why later)
y = c1 xet + c2 xtet + uet .
We must find u. Therefore, we must solve
(A I)u = x
for u. Since = 1, then:
3
2 + 1
(A + I)u =
41
1
21 + 1
u1
u2
=
In components:
12 u1 + u2
14 u1 + 12 u2
=2
=1
2
3
.
2
1
.
Figure 81 shows the phase portrait of some of the trajectories. Note that
the trajectories are all moving toward the origin. The origin is called a stable
degenerate node (although in many books this is also called improper node).
If the eigenvalue had been a positive double root, we would have obtained a
similar phase portrait, but with the trajectories moving away from the centre,
thus giving rise to an unstable degenerate node.
Degenerate node
10
y2(t)
-10
-5
5
y1(t)
10
-5
-10
10.2
Summary
Given the homogeneous systems of differential equations with constant coefficients:
y0 = Ay,
If A is a 2 2 matrix, then the system can be written, in components,
y10
y20
= a11 y1 + a12 y2 ,
= a21 y1 + a22 y2 .
173
Centre
(or vortex)
Stable
Complex roots
1 = + i, 2 = i
Spiral point
Stable if < 0
Unstable if > 0
Saddle point
Unstable
Improper node
Proper node
Stable if 1 = 2 < 0
Unstable if 1 = 2 > 0
Degenerate node
(or improper)
Stable if 1 = 2 < 0
Unstable if 1 = 2 > 0
We have seen that the roots 1 and 2 of the characteristic equation determine the type of critical point and whether this is stable or not. Thus, we can
summarise our results in Table 2.
10.3
No basis
We have seen that it is possible for a matrix A to have a double eigenvalue
1 = 2 (by the way, this could happen with a matrix of any size). In the
example given above, we determined one solution y(1) = xet by finding the
eigenvector x corresponding to the eigenvalue , then we calculated a second
solution y(2) by taking:
y(2) = xtet + uet .
(u is currently unkown)
We justify now why this works.
Consider the following homogeneous systems of differential equations with
174
constant coefficients:
y0 = Ay.
Thus:
y(2)
Then, since Ax = x:
xet + uet
= Auet .
= Au
= x.
By solving the above system for u, one can determine the second solution
y(2) .
Now, if A is a n n matrix (n > 3) with a triple eigenvalue, then a second
solution is given by (as before):
y(2) = xtet + uet .
And a third solution can be obtained by taking:
y(3) =
1 2 t
xt e + utet + vet
2
with v satisfying:
(A I)v = u.
175
11
11.1
Nonlinear systems
Definition 22 (Autonomous). A differential equation where y is the dependent
variable and t is the independent variable is said to be autonomous if it has the
form:
dy
= some function of y but not of t.
dt
Similarly, an autonomous system of two DEs is of the form:
dy1
dt
dy2
dt
In other words,
dy1
dt
dy2
dt
f1 (y1 , y2 ),
f2 (y1 , y2 ).
The vast majority of physical systems are autonomous, since the laws of
physics are time-independent. Nonautonomous systems may arise because of
the introduction of forcing terms (such as the time dependent electromotive
force in electrical circuits).
Autonomous systems give rise to time-independent phase portraits which can
be successfully used to interpret at least qualitatively the behaviour of systems
of DEs. This is particularly important for nonlinear systems, since these are
often impossible to solve analytically.
Many of the stability results that we saw in the previous sections can be
applied to nonlinear systems, provided that these are not strongly nonlinear
(that is, the nonlinear component of the system is small compared to the linear component). In this section well see how to apply qualitative methods to
autonomous nonlinear systems with isolated critical points (a critical point y0
is said to be isolated if there is a neighbourhood of y0 in which y0 is the only
critical point). We will also assume that y0 is always at the origin, since if
y0 = (a, b) we can always apply the translation:
y1 = y1 a,
y2 = y2 b
176
11.2
Linearisation
Consider the system of nonlinear DEs:
y10
= f1 (y1 , y2 ),
y20
= f2 (y1 , y2 ).
Let (0, 0) be a critical point of this system and f1 and f2 continuous with
continuous partial derivatives in a neighbourhood of (0, 0).
Then we can expand f1 and f2 about this point and write the system as:
y0 = Ay + h(y1 , y2 ).
In components:
y10
y20
Example
y1 (y2 1)
(3)
4 y12 y22
(4)
= y1 (y2 1)
4 y12 y22
to get the following equilibrium points (0, 2) and ( 3, 1). Let us firstly look
at (0, 2).
177
= x1 (x2 + 1) = x1 x2 + x1
=
= x1 (x2 3) = x1 x2 3x1
=
dx1
= (x1 + 3)x2 = x1 x2 + 3x2
dt
2
dx2
2
= 4 x1 + 3 (x2 + 1) = x21 2 3x1 x22 2x2 .
dt
When x1 0 and x2 0,
0
3
0
x Ax =
x.
2 3 2
The determinant
of (AI) is (+2)+6, so the eigenvalues of A are 1 5i.
dx1
= (x1 3)x2 = x1 x2 3x2
dt
2
dx2
2
= 4 x1 3 (x2 + 1) = x21 + 2 3x1 x22 2x2 .
dt
178
When x1 0 and x2 0,
3
x.
2
0
x Ax =
2 3
0
5
4
3
2
y2
1
0
1
2
3
4
5
5
0
y1
Figure 82: Solution of the nonlinear system of ODES given in (3) and (4)
11.3
11.3.1
Applications
Application: Macroeconomics Model
A macroeconomics model
Consider the following model for the national income identity
Y (t) = C(t) + I(t) + D(t),
where
I(t) = K 0 (t) is the investment,
Y (t) = b0 + b1 K(t) is the real income (b0 , b1 > 0),
179
0 < c1 , c2 .
Finally, take the percentage growth rate of real demand for money as the
growth rate of nominal money supply minus the inflation rate. We will assume
the real interest rate is the constant b1 , so the inflation rate is R(t) b1 . If the
growth rate of nominal money supply is c0 > 0,
M0
M
= c0 (R(t) b1 )
c1 Y M
= c0
b1
c2
b0 c1
b1 c1
1
=
c0 + b1
K + M.
c2
c2
c2
180
Combining the national income identity and demand for money we get the
following system of differential equations
K0
M0
= b0 (1 a1 ) + [b1 (1 a1 ) a2 ] K,
b1 c1
1
b0 c 1
M
KM + M 2 .
=
c0 + b1
c2
c2
c2
1 + 2 K,
1 M 2 KM + 3 M 2 ,
where 1 = b0 (1 a1 ), 2 = b1 (1 a1 ) a2 , 1 = c0 + b1
3 = c12 .
(5)
b0 c1
c2 ,
2 =
b1 c1
c2
and
Equilibrium Points
From the first equation, we see that K 0 = 0 when
K=
1
.
2
2 1 + 1 2
3 2
= 3/50X,
Y0
In matrix form, the system that approximates the solution around the equilbrium point is
z 0 = Az,
where
z=
X
Y
and A =
3/50
773/1125
181
0
.
773/90
As the system has one positive and one negative eigenvalue, we know the
equilbrium point is a saddle point and is unstable.
We follow a similar procedure to determine the behaviour around the second
1
equilbrium point K =
2 = 200/3 and M = 0.
Set X = K 200/3 and Y = M and substitute into Equation (5) to get
X0
3/50X,
Y0
13.5
13
12.5
12
11.5
11
60
62
64
66
68
70
K
72
74
76
78
80
Figure 83: Solution of the econometrics example around the equilibrium point
K = 200/3 67 and M = 773/60 12.9
11.3.2
Undamped pendulum
Consider a pendulum consisting of a bob of mass m attached to a rod of
length L, as shown in Figure 84. If is the angle the pendulum makes with
the vertical and g is the gravitational constant, the differential equation that
governs the motion of the pendulum, if air and rod resistance are neglected, is:
mL00 + mg sin = 0.
182
If we divide by mL we get:
00 + k sin = 0,
k=
g
.
L
This is a nonlinear second order differential equation for which the solution
cannot be given in terms of elementary functions. Consequently, the motion
of the pendulum can be studied only through numerical work and phase plane
analyses.
Nevertheless, when is very small, we can write sin and we get:
00 + k = 0
with solution:
= y2 ,
y20
= k sin y1 .
183
Both RHSs are equal to zero when y2 = 0 and k sin y1 = 0. Thus there are
infinitely many critical points at (n, 0), where n = 0, 1, 2, .
Consider first (0, 0) and linearise the system by expanding in Maclaurin
series:
1
sin y1 = y1 y13 + y1 .
6
The linearised system at (0, 0) is:
y10
y20
= y2 ,
= ky1 .
In matrix form:
y0 = Ay =
0
k
1
0
y.
y10 = ( )0 = 0 = y2 ,
1
sin(y1 + ) = sin y1 = y1 + y13 y1 .
6
The linearised system at is:
y10
y20
= y2 ,
= ky1 .
In matrix form:
y0 = Ay =
0
k
1
0
y
Damping
Lets see now what happens if we introduce a damping term which is proportional to the angular velocity 0 :
00 + c0 + k sin = 0.
184
y(t) 0
-1
-2
-8
-6
-4
-2
0
x(t)
Here, c is the damping constant (> 0) and k = g/L. Set now = y1 and
0 = y2 as before. So we obtain:
y10
= y2 ,
y20
= k sin y1 cy2 .
Both RHSs are again equal to zero when y2 = 0 and k sin y1 = 0. Thus
there are infinitely many critical points at (n, 0), where n = 0, 1, 2, .
Consider first (0, 0) and linearise by taking sin y1 y1 .
The linearised system at (0, 0) is:
y10
y20
= y2 ,
= ky1 cy2 .
In matrix form:
0
y = Ay =
The eigenvalues of A are:
1
det(A I) =
k c
0
k
1
c
y.
= (c + ) + k = 2 + c + k = 0,
with roots:
c2 4k
c
.
=
2
2
This result is very similar to that for the motion of a mass on a spring! Lets
see all the various possibilities:
185
(1) If c = 0, = i k, which is the result we obtained earlier in the case of
no damping. The critical point (0, 0) is a stable centre point.
(2) If c2 < 4k the roots are complex conjugates and the critical point (0, 0) is
a stable spiral point (the real part is negative, since c > 0). The motion
is underdamped.
(3) If c2 > 4k the roots are distinct, real and negative (since c > c2 4k),
and the critical point (0, 0) is a stable improper node. The motion is
overdamped.
(4) If c2 = 4k the roots are equal and negative and the critical point (0, 0) is
a stable degenerate node. The motion is critically damped.
Since the sin function is periodic, this result will also hold for n = 2, 4, .
Consider now the critical point (, 0). As earlier, we apply again the translation:
y1 = ,
y10 = ( )0 = 0 = y2 ,
1
sin(y1 + ) = sin y1 = y1 + y13 y1 .
6
The linearised system at (, 0) is:
y10
y20
= y2 ,
= ky1 cy2 .
In matrix form:
y0 = Ay =
The eigenvalues of A are:
1
det(A I) =
k c
0
k
1
c
y.
= (c + ) k = 2 + c k = 0
with roots:
c
c2 + 4k
=
.
2
2
Lets see again all the various possibilities:
(2) If c 6= 0, since c < c2 + 4k we have two real roots of opposite sign. Thus,
the critical point (, 0) is a saddle point.
186
y(t) 0
-1
-2
-3
-10
-5
0
x(t)
10
We note again that since the sin function is periodic this result will also hold
for n = 1, 3, .
See Figure 86.
In the pendulum application, with and without damping, we have seen that
there are two critical (equilibrium) points. The equilibrium point corresponding
to (0, 0) can be identified with the pendulum position at rest pointing downward, while the equilibrium point corresponding to (0, ) can be identified with
the pendulum position at rest pointing upward. It is therefore quite easy to visualise why we found that the stable critical point was (0, 0) and that any small
perturbation applied to the pendulum away from this point would be damped
out with the pendulum returning to rest as t . Conversely, one can also
as easily imagine that a small perturbation applied to the pendulum away from
(0, ) would cause the pendulum to leave its rest position and converge to (0, 0).
187
12
12.1
Introduction
Most non-constant coefficient DEs cannot be solved in closed form in terms
of standard analytical functions. As early as 1676, Newton considered the possibility of representing the solution by infinite series - there are many types of
series (e.g. Fourier series, Power series etc.). We consider power series.
The series method is sometimes useful also to obtain solutions to non-linear
DEs (but it is not always easy to find the coefficients in the power series expansion in this case).
The limit of the sequence
2
a0 + a1 (x x0 ) ,
a0 ,
a0 + a1 (x x0 ) + a2 (x x0 ) ,
is written
an (x x0 )
...
n=0
whenever it exists. This series is called a power series expansion about the point
x0 . Any power series has a radius of convergence such that the series
converges for |x x0 | <
diverges for |x x0 | <
If we set
f (x) =
an (x x0 )
|x x0 | <
n=0
f (n) (x0 )
n!
188
d2 y
dy
+ Q(x)
+ R(x)y = 0
dx2
dx
We look for power series solutions about some point x0 . The nature of solution
depends on whether x0 is
an ordinary point
a singular point
R(x)
x0 is an ordinary point is the coefficients Q(x)
P (x) and P (x) of the equation in
standard form (i.e. with the coefficient of y equal to unity) are analytic at x0 .
By this we mean that they have a Taylor series expansion which converges in
some interval about x0
Q(x)
2
= a0 + a1 (x x0 ) + a2 (x x0 ) + ...
P (x)
R(x)
2
= b0 + b1 (x x0 ) + b2 (x x0 ) + ...
P (x)
Otherwise, x0 is a singular point.
R(x)
P (x)
equation,
Q(x)
1
= ,
P (x)
x
R(x)
2
=1 2
P (x)
x
x = 0 is a singular point because both these functions are certainly not analytic
at x = 0. In Legendres equation,
Q(x)
2x
=
,
P (x)
1 x2
( + 1)
R(x)
=
P (x)
1 x2
X
n
y=
an (x x0 ) = a0 y1 (x) + a1 y2 (x)
n=0
189
where y1 (x), y2 (x) are linearly independent power series solutions with a radius
of convergence that is at least equal to the minimum of the radii of convergence
R(x)
of Q(x)
P (x) and P (x) .
Solution about an ordinary point
Look for solution in the form of a power series about x = x0 .
2
y = a0 + a1 (x x0 ) + a2 (x x0 ) + ... =
an (x x0 )
n=0
n1
+ ... =
nan (x x0 )
n1
n=1
nan (x x0 )
n1
n=0
y 00 = 2a1 + ... + n (n 1) (x x0 )
n2
+ ... =
n2
n (n 1) an (x x0 )
n=2
nan (x x0 )
n1
n=1
P
P
n2
m
n (n 1) an (x x0 )
=
(m + 2) (m + 1) am+2 (x x0 )
(setting n = m + 2)
n=2
m=0
(n + 2) (n + 1) an+2 (x x0 )
(re-labelling dummy
n=0
index m)
change the independent variable from x to t where (x x0 ) = t transforms
the point of expansion from x = x0 to t = 0. This makes the algebra easier.
EX: Solve the equation (1 x2 )y 00 6xy 0 4y = 0 near the ordinary point
x = 0. Note: x = 1 are the only singular points in the finite plane).
6x
Q(x)
=
,
P (x)
1 x2
Set y =
an xn , y 0 =
n=0
X
n=0
Q(x)
4
=
P (x)
1 x2
nan xn1 , y 00 =
n=0
n=0
n(n 1)an xn 6
n=0
X
n=0
190
nan xn 4
X
n=0
an xn = 0
n=0
[n(n 1) + 6n + 4] an xn = 0
n=0
n=0
(n + 4) (n + 1) an xn = 0
n=0
n(n 1)an x
n=0
n2
(n + 2) (n 1) an2 xn2 = 0
n=2
The coefficient
of each power must be zero. n = 1, 1 irrelevant. n 2 : an =
n+2
a
a recurrence relation Note that the subscripts in this relation
n2
n
differ by two indices, so we expect two sequences in terms of a0 and a1 .
a2 = 24 a0
a3 = 35 a1
n 2 : an = n+2
n an2
a4 = 64 a2 =
a2k =
=
64
4 2 a0
a5 =
2k+2
2k a2ks
75
5 3 a1
a2k+1 =
2k+2 2k
64
2k 2k2 ... 4 2 a0
= (k + 1) a0
"
y = a0 1 +
#
(k + 1) x
2k
23+3
2k+1 a2k1
2k+3 2k+1
75
2k+1 2k1 ... 5 3 a1
2k+3
3 a1
"
+ a1 x +
k=1
X
2k + 3
k=1
#
x
2k+1
Note 1: There are two arbitrary constants in the solution Note 2: The
nearest singular points are at x = 1. So, from the general theory of LDEs,
convergence is guaranteed at least up to |x| < 1. In fact, convergence occurs
only in this region as can be shown by elementary convergence tests for series.
Airys Equation
Sir George Airy (1801-1892), Astronomer and Mathematician came up with
the following equation in connection with the diffraction of light:
y 00 xy = 0
There is no analytical solution and the equation is solved using power series.
Note that x = 0 is an ordinary point.
The solution is oscillatory for negative x and of exponential nature for positive x.
191
2 R(x)
P (x)
are both
R(x)
= B0 + B1 (x x0 ) + ...
P (x)
which means that very close to x0 , the coefficients in the normalised equations
(i.e. DE with y 00 as the leading term) diverge as
Q(x)
A0
+ A1 + ...
P (x)
x x0
B1
B0
R(x)
+
+ ...
2
P (x)
(x x0 )
(x x0 )
One of the goals of this section is to establish the nature of the solutions near
such a singular point. We will see that depending on the equation, we could get
one or two solutions that remain bounded as x x0 or none at all!
When the solutions do diverge, it is possible to establish the nature of the
divergence.
Consider Bessels equation
x2 y 00 + xy 0 + x2 2 y = 0
R(x)
2
=1 2
P (x)
x
Q(x)
1
= ,
P (x)
x
x=0 is singular.
x
Q(x)
= 1,
P (x)
x2
192
R(x)
= 2 + x2
P (x)
x0
R(x)
1
= lim
P (x) x0 x
193
L[Axr ] = 0 if r satisfies r (r 1) + p0 r + q0 = 0.
F (r) = r2 + (p0 1) r + q0 = 0 - THE INDICIAL EQUATION.
q
2
Roots of the indicial equation are r1 , r2 = 0.5 (p0 1) (p0 1) 4q0 .
Three cases for roots: real distinct, real equal or complex conjugate pair
Note: for an equation of Euler type
x2 y 00 + p0 xy 0 + q0 y = 0
if y(x) is a solution, so is y(x). For is we change x x in DE, we obtain
(x)
dy(x)
d2 y(x)
+ p0 (x)
+ q0 y(x) = 0
d(x)2
d(x)
d2 y(x)
dy(x)
+ p0 x
+ q0 y(x) = 0
dx2
dx
If y1 = f (x)(x > 0) is a solution, so is y2 = f (x)(x < 0). So all we
need is to solve the DE for x > 0, and the gneral solution (given real values) is
y = f (|x|), (x > 0 and x < 0).
x2
y = C1 |x|
r2
+ C2 |x| ,
x>0
x > 0 or x < 0
Example: x2 y 00 2xy 0 + 2y = 00
Indicial equation: r (r 1) 2r + 2 = 0 (r 1) (r 2) = 0 - both roots
are positive.
2
y = C1 |x| + C2 |x|
Note: Even though x = 0 is a regular singular point, the solution remains finite
at x = 0. In fact, all solutions pass through the original so the initial restriction
x 6= 0 was unnecessary in this case.
Example: 2x2 y 00 + 3xy 0 = 0
2r (r 1) + 3r 1 = 0 2r2 + r 1 = (2r 1) (r + 1) = 0
Now r1 = 21 , r2 = 1 i.e. one root negative. Solution is thus
1
y = C1 |x| 2 +
C2
, x > 0, x < 0
|x|
194
r
r ln x
x =
e
= er ln x ln x = xr ln x
r
r
x>0
x > 0, x < 0
y = C1 |x|
1/2
+ C2 |x|
x>0
ln |x|,
x > 0, x < 0
C1
|x|
C2
C1
+ 2 ln x,
2
x
x
+
C2
2
|x|
ln |x|,
x>0
x > 0, x < 0
Here the solutions are oscillatory, but converge or diverge as x = 0 is approached depending on the constants in the indicial equation (i.e. if is positive
or negative).
195
12.1.2
an x =
n=0
an xn+r
a0 6= 0
n=0
y =
an (n + r) xn+r1
n=0
00
y =
an (n + r) (n + r 1) xn+r2
n=0
x2 y 00 + xp(x)y 0 + q(x)y = 0
x2
X
an (n + r) xn+r1
an (n + r) (n + r 1) xn+r2 + x (p0 + p1 x + ...)
n=0
n=0
X
an xn+r = 0
+ (q0 + q1 x + ...)
n=0
n=0
n=0
n=0
r
r+1
xr : [r (r 1) + p0 r + q0 ] a0 = 0
For arbitrary a0 , the indicial equation is:
F (r) = r (r 1) + p0 r + q0 = 0
This equation will provide two roots and potentially two solutions of the above
type with coefficients a1 , ... of the series chosen so that the coefficients of xr+1
... vanish.
Depending on the roots of the quadratic, the general solution will a combination of one of the following types
|x|
X
n=0
an xn ,
|x| ln |x|
an xn ,
n=0
X
n=0
196
a n xn ,
a0 6= 0
an xn+r = 0
It turns out that depending on the nature of the real roots, it will not always
be the case that the remaining coefficients can be set to zero by solving the
recurrence relations consistently (we will illustrate this by example). But there
will always be one solution of this type for the larger of these roots.
Theorem If (> 0) is the minimum of the radii of convergence of the Taylor
series for p(x) and q(x), then the LDE has a solution of one of the above types,
where the power series incorporated in the solutions converge at least for |x| < .
In this course, we focus on on the real root case. The other cases can be
dealt with similarly.
Now it can be shown that in the real root case, there will always be at least
one solution of the type
X
r
y = |x|
an xn
n=0
In fact, suce a solution always exists, where r = r1 , the larger of the two real
roots of the indicial equations (see the following theorem).
THEOREM 5.6.1:
Suppose that the indicial roots r1 and r2 of x2 y 00 + xp(x)y 0 + q(x)y = 0 given
by the solution of F (r) = r(r 1) + p0 r + q0 = 0 are real, and that r1 r2 .
Suppose that is the minimum of the radii of convergence of p(x), q(x).
Then in either < x < 0 or 0 < x < , there is always one series solution
of the standard Frobenius form
"
#
X
r1
n
y1 (x) = |x|
1+
an (r1 )x
n=1
X
r2
n
an (r2 )x
1+
y2 (x) = |x|
n=1
bn (r1 )xn
n=1
cn (r2 )xn
n=1
The coefficients an , bn , cn , (which may be zero) are to be found by substituting the appropriate form of solution into the DE.
Note: the leasing constants in the series components have been nromalised
to unity when appropriate.
197
13
Special functions
13.1
Bessels Functions
p0 = 1,
Indicial equation: r (r 1) + r 2 = 0.
We consider solutions for x > 0 (the domain of interest in most physical
problems). There is at least one solution of the form
y=
ak xr+k
k=0
y0 =
ak (r + k) xr+k1
k=0
y 00 =
ak (r + k) (r + k 1) xr+k2
k=0
ak (r + k) (r + k 1) xr+k +
k=0
ak (r + k) xr+k +
k=0
ak xr+k+2
k=0
2 ak xr+k = 0
k=0
h
i
X
2
ak (r + k) 2 xr+k +
ak2 xr+k = 0
k=0
k=2
The coefficient of x is given by the indicial equation (must always be the case):
a0 r2 2 = 0 r = ,
which gives distinct roots providing that 6= 0. The coefficient of xr+1 is given
by
h
i
2
a1 (r + 1) 2 = 0 a1 = 0
The coefficient of xr+k is given by
h
i
2
ak (r + k) 2 = ak2
k = 2, 3, 4, ...
1
ak2
k (k + 2)
198
x2
x4
+
...
2 (2 + 2) 2 (2 + 2) 4 (4 + 2)
x2
x4
= a0 x 1 2
+
...
2 (1 + ) 24 2! (1 + ) (2 + )
#
"
k 2k
X
(1)
x
= a0 x 1 +
22k k! (1 + ) (2 + ) ... (k + )
k=1
If is not an integer (the general case of rooths not difference by an integer), the second root of the indicial equation (r = ) gives a second linearly
independent solution.
This is obtained by replacing by in the above derivation, yielding
#
"
k
X
(1) x2k
= b0 x
1+
22k k! (1 ) (2 ) ... (k )
k=1
1
2n n!
k
X
1 n
(1) x2k
y1 (x) = Jn (x) = n x 1 +
2 n!
22k k! (1 + n) ... (k + n)
k=1
"
#
n
n+2
n+4
(x/2)
(x/2)
(x/2)
=
+
...
n!
1! (1 + n)! 2! (n + 2)!
Jn (x) = (x/2)
X
k=0
(1)
2k
(x/2)
k! (k + n)!
X
k=0
n = 0, 1, 2, ...
k
(1)
2k
(x/2)
k! (k + n)!
x4
x6
x2
+
+ ...
J0 (x) = 1
4
64 2304
x
x2
x4
x6
J1 (x) =
1
+
+ ...
2
8
192 1296
x4
x6
x2 1 x2
+ ...
J2 (x) =
2 2 24 768 46080
Which gives values at x = 0 of J0 (0) = 1, J1 (0) = 0, J2 (0) = 0, and derivatives of J00 (0) = 0, J10 (0) = 21 , J20 (0) = 0.
Jn are all non-singular at the origin.
Graphs of J0 (x), J1 (x), ... represent decaying sinusoids, and we can see this
(very crudely) by comparing
1 0
2
00
(1)
y + y + 1 2 y =0
x
x
with
2
1 0
y + y + 1 2 y =0
a
a
00
(2)
1
2a
1/2
2
1
= 1 2 2
a
4a
* the wave characteristics of Bessel functions seem very much like the shapes
of water waves generated by dropping a pebble into a pond. The equations of
hydrodynamics show that waves having the shapes of Bessel functions do arise.
200
(1) =
R
0
xz1 ex dx
ex dx = 1
=
ey y 1/2 dy
2
0
Substituting y = x2 gives
Z
=2
Z
ex dx
Z
Z Z
a
2
2
2
1
=4
ex dx
ey dy = 4
e(x +y ) dxdy
2
0
0
0
0
Change to polar coordinates: x = r cos , y = r sin . This gives
(x, y)
drd = rdrd
dxdy =
(r, )
2
Z /2 Z
Z /2 Z
2
2
1
=4
er rdrd = 2
er d r2 d =
2
0
0
0
0
Hence (1/2) =
The values of (z) are available in tabulated form for 0 < z 1. The
recurrence relation can then be used to evaluate (z) for any other positive z.
Thus:
3
1
1
1
1
!=
=
=
2
2
2
2
2
3
5
3 1
1
3 1
!=
=
=
2
2
2 2
2
2 2
...
7
7 5 3 1
1
7 5 3 1
!=
=
2
2 2 2 2
2
2 2 2 2
201
(z + 1)
z
1
2
1
= 2
=
2
12
and then (z) for 2 < z < 1 using values in 1 < z < 0. This defines (z)
for all z except for negative INTEGRAL values.
xz1 ex dx
(z) =
z>0
(z + 1)
z<0
z
Z x
e
0+ = lim+
dx = +
x1z
z0
0
a
Z a x
Z a
e
1
ex
a
a 1 z
dx >
dx > e
dx = e
x
1z
1z
x1z
z
0 x
0 x
0
(z) =
Z
0
k
X
(1) x2k
y1 (x) = a0 x 1 +
22k k! (1 + ) ... (k + )
k=1
we now use the Gamma function to extend the definition of Bessel functions to
any order. We do this by setting
a0 =
1
2 ( + 1)
202
X
k=0
(1)
2k
(x/2)
k! (k + + 1)
x>0
y(x) = a0 x 1 2
+
...
2 1! (1 + ) 24 2! (1 + ) (2 + )
to show that
r
2
x5
2
x3
+
... =
sin x
x
J1/2 (x) =
x
3!
5!
x
r
r
2
2
x2
x2
J1/2 (x) =
1
+
... =
cos x
x
2!
4!
x
p
(This does not give the factor 2/. It is obtained from the definition of the
constant a0 = 1/ [2 ( + 1)] in the Bessel functions, and by use of the identities
involving the Gamma function).
r
1
1
2
=
1 =
1
1/2
1/2
2 2
2 2 +1
r
1
1
=
=
21/2 21
21/2 12 + 1
x X
k=0
x 2k
(1)
k! (k + + 1) 2
x 1/2 X
x>0
k
x 2k
(1)
x>0
2
k! k + 12 + 1 2
k=0
"
#
2
4
x 1/2
1
(x/2)
(x/2)
+
...
=
2
32
1! 25
2! 72
"
#
1/2
2
4
(x/2)
(x/2)
(x/2)
= 1 1 1 3 1 1 + 5 3 1 1 ...
1! 2 2 2
2! 2 2 2 2
2 2
J1/2 (x) =
203
"
#
2
4
x 1/2
1
(x/2)
(x/2)
= 1 1
1
+
...
2
1! 23
2! 52 23
2 2
"
#
2
4
(x/2)
2 x 1/2
(x/2)
1
=
+
...
2
1! 32
2! 25 32
r
2
x3
x5
=
x
+
...
x
3!
5!
2
x
1/2
cos x
2
x
1/2
sin x
x X
k=0
x 2k
(1)
k! (k + + 1) 2
x>0
Note 1: With the above definition, and our interpretation of the Gamma
function for negative argument, it can be verified that
n
Jn = (1) Jn
n = 0, 1, 2, ...
Y (x) can then be used instead of J (x) as the second linearly independent
solution. For example,one would not use J1/2 (x), but rather Y1/2 (x).
When is an integer (roots differ by an integer) the method of Frobenius
(cases 2 and 3 discussed in theorem) can be used to derive a second set of
linearly independent solutions. They can also be obtained by the following
limiting process which gives us Bessels functions of the 2nd kind of integral
order, Y0 (x), Y1 (x), ....
For integral , we define Yn (x) as the limit
Yn (x) = lim
using LH
opitals rule.
Unlike the Jn (x) functions, the Yn (x) functions are unboudned as x 0.
The functions Yn (x) are readily available in tabulated form. With this definition, for any , the general solution form any is
y(x) = C1 J (x) + C2 Y (x)
remainder
Notes to be completed
205
14
Motivation
As you already know, an Initial Value Problem consists of :
0
x
= f (t, x)
,
x(t0 ) = x0
where f is a prescribed function of 2 variables and (t0 , x0 ) is a point through
which the solution should pass.
A solution of this IVP is a function x(t) such that
dx(t)
= f (t, x(t))
dt
for all t in some neighbourhood of t0 and x(t0 ) = x0 .
In this section we will see some methods for calculating numerical solutions
of differential equations. These methods are very useful since most differential
equations cannot be solved analytically, or even if analytic solutions exist these
may be too complicated to be used.
The methods that we are going to see are step-by-step methods. We start
with x(t0 ) = x0 and then we proceed by calculating approximate values of the
solution x(t) at:
t1 = t0 + h,
t2 = t1 + h,
t3 = t2 + h,
t4 = t3 + h
where h has a certain assigned value and is called the stepsize. These approximate values can be obtained with a Taylor series expansion.
14.1
Taylors theorem
Taylors theorem
If the function f (x) has the (n + 1)st derivative f (n+1) (t) exists for all t in an
interval containing c and x, then the Taylor series expansion around the point
c is:
n
X
1 (k)
f (c)(x c)k + En (x)
f (x) =
k!
k=0
1
f (n+1) ()(x c)n+1 .
(n + 1)!
206
n
X
1 (k)
f (x)hk + En (h)
k!
k=0
and:
En (h) =
1
f (n+1) ()hn+1
(n + 1)!
(i)
n
X
1
h
+k
f (x, y) + En (h, k)
i!
x
y
i=0
where
1
En (h, k) =
(n + 1)!
(n+1)
h
+k
f (a + h, b + k),
x
y
0 1.
Here:
(0)
h
+k
f (x, y) = f (x, y)
x
y
(1)
f
f
(x, y)
+k
f (x, y) = h
+k
h
x
y
x
y
(2)
2f
2f
2f
h
+k
f (x, y) = h2 2 + 2hk
+ k 2 2 (x, y)
x
y
x
xy
y
14.1.2
f
= x sin(xy),
y
2f
= y 2 cos(xy),
x2
207
2f
= xy cos(xy) sin(xy),
xy
2f
= x2 cos(xy).
y 2
If n = 1, then
cos[(x + h)(y + k)] = cos(xy) hy sin(xy) kx sin(xy) + E1 (h, k).
14.1.3
h2 00
h3
h4
x (t) + x000 (t) + xiv (t) +
2!
3!
4!
= sin t x0 cos x + 2t
x000
xiv
If we stop here, the terms not included start with h5 and they form the
so-called truncation error in our procedure.
The algorithm is the following:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% taylor
% Find t h e Taylor e x p a n s i o n o f
% c o s ( t ) s i n ( x ) +t 2 about t h e p o i n t
% ( t , x ) . h i s the step s i z e .
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f u n c t i o n y = taylor ( t , x , h )
xp = c o s ( t )s i n ( x )+t 2 ; % f i r s t d e r i v
xpp = s i n ( t )xp c o s ( x ) +2t ; % s e c o n d d e r i v
208
14.2
Eulers method
Eulers method
Note that if we use the approximation:
x(t + h) = x(t) + hx0 (t)
then the numerical method is called the Euler method or the Euler-Cauchy
method.
Geometrically, this method approximates the curve f (x, t) with a polygon
whose first straight line segment is tangent to the exact solution curve at t0 . The
good thing about Eulers method is that it doesnt require any differentiation
of f .
The truncation error is proportional to hn , where n is the lowest power of
the terms in the Taylor series that are not included in the calculations. For
example, for the Euler-Cauchy method, the truncation error is proportional to
h2 (since we stop the expansion with the first derivative). For a fixed interval
t = t2 t1 in which we want to solve a given DE, the number of steps is
209
x(0) = 1.
Integrate over the interval [0, 0.4] with steps of stepsize h = 0.05. Solve the
problem analytically and present a table with the numerical and analytical results
and the error.
Solution
Write the problem as:
x0 = f (t, x) = t2 x
x(0) = 1.
= xn + hf (tn , xn )
= xn + 0.05(t2n xn )
=
0.95xn + 0.05t2n .
We start with:
t0 = 0,
x0 = 1
t0 + 0.05 = 0.05,
x1
t1 + 0.05 = 0.1,
x2
t2 + 0.05 = 0.15,
x3
210
= t3 + 0.05 = 0.2,
x4
t4 + 0.05 = 0.25,
x5
= t5 + 0.05 = 0.3,
x6
= t6 + 0.05 = 0.35,
x7
= t7 + 0.05 = 0.4,
x8
x(0) = 1.
x(0) = 10.
The following shows some the Matlab to implement the Euler method.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% euler
% Implement t h e E x p l i c i t E u l e r method
%
% Pre C o n d i t i o n :
%
f = f ( t , x ) i s t h e r i g h t hand s i d e
%
h i s the step s i z e
%
m i s t h e number o f s t e p s t o be taken
%
x0 i s t h e i n i t i a l c o n d i t i o n a t time t = 0
%
% Post C o n d i t i o n
%
x i s t h e s o l t u i o n a t t =0, h , 2h e t c .
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f u n c t i o n x = euler ( f , h , m , x0 , t0 )
% r e c o r d t h e s o l u t i o n a t t h e g i v e n time
% ( taking the s t a r t i n g c o n d i t i o n s i n t o account )
y = z e r o s (m , 1) ;
% record the s t a r t i n g c o n d i t i o n s
y ( 1 ) = x0 ;
t = t0 ;
% l o o p through and update t h e s o l u t i o n s based on t h e AdamsB a s h f o r t h
% formula
f o r i = 1 : ( m1)
y ( i+1)= y ( i )+hf ( t , y ( i ) ) ;
t = t+h ;
end
% r e t u r n t h e s o l u t i o n s t a r t i n g from t = t 0
x = y;
212
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main p a r t o f t h e code
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% s t a r t i n g time
a = 0;
% end time
b = 10;
% step s i z e
c = 7;
h = ( ba ) /2 c ;
% p o i n t s a t which t h e s o l u t i o n w i l l be e v a l u a t e
t = (a : h : b) ';
m = length (t) ;
% d e f i n e the exact s o l u t i o n
g = inline ( ' 10 exp (2 t ) ' ) ;
% d e f i n e t h e r i g h t hand s i d e
f = inline ( ' 2x ' , ' t ' , ' x ' ) ;
% s o l v e t h e ODE
x = euler ( f , h , m , g ( a ) , a ) ;
% p l o t the r e s u l t
p l o t ( t , g ( t ) , ' g ' , t , x , ' r+ ' )
xlabel ( ' t ' )
ylabel ( 'x ' )
Figure 89 shows the solution when h = 10/25 .
Figure 90 shows (the absolute value of) the difference between the analytical
and numerical solutions.
According to the theory, if we double h the error should be divided by 2.
Figures 91, 92 and 93 shows how the error changes as h is decreased.
Stability
The ODE solvers in Matlab use numerical techniques to find approximate
solutions. In general, you will not need to write your own numerical solvers
like we just did for Eulers method. The ODE solvers available in packages
like Matlab are well written and robust. However, it is still important to
understand how the solvers work and what their limitations are.
Lets make a very minor modification to the previous example. Instead of
213
10
9
8
7
6
5
4
3
2
1
0
5
t
10
214
Error (c = 5)
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0
5
t
10
Figure 90: Difference between the numerical and analytical solutions when h =
10/25 .
215
Error (c = 6)
0.7
0.6
0.5
0.4
0.3
0.2
0.1
5
t
10
Figure 91: Difference between the numerical and analytical solutions when h =
10/26 .
216
Error (c = 7)
0.35
0.3
0.25
0.2
0.15
0.1
0.05
5
t
10
Figure 92: Difference between the numerical and analytical solutions when h =
10/27 .
217
Error (c = 8)
0.16
0.14
0.12
0.1
0.08
0.06
0.04
0.02
0
5
t
10
Figure 93: Difference between the numerical and analytical solutions when h =
10/28 .
218
solving
x0 = 2x
x(0) = 10,
x0 = 20x
x(0) = 10,
with h = 10/25 .
As shown in Figure 94, the error in the numerical approximation is of order
1023 . This is not an error in the code, it is a consequence of the stability of
Eulers method.
23
12
x 10
10
8
6
4
2
0
2
4
5
t
10
Figure 94: Difference between the numerical and analytical solutions when h =
10/25 if f (x) = 20x.
Stability theory is concerned with the consequences of round off errors and
it states that h must be smaller than a certain value before Eulers method will
work properly, and that value depends on the ODE you are solving. Sometimes
the value of h must be so small that the method is no longer practical. Many
other ODE solvers also have this stability issue, although different solvers place
different conditions on h. That is why Matlab offers you a number of different
types of solvers.
219
14.3
14.3.1
Runge-Kutta methods
Second order Runge-Kutta
Runge-Kutta methods
Consider the following IVP:
x0
= f (t, x)
.
x(t0 ) = x0
The snag with the previous method is that we must calculate all those derivatives (x0 , x00 , x000 , xiv , ), then all these functions need to be programmed.
This can all be avoided by means of clever combinations of values of f (t, x).
Consider again the Taylor expansion:
x(t + h) = x(t) + hx0 (t) +
h3
h4
h2 00
x (t) + x000 (t) + xiv (t) +
2!
3!
4!
Let the partial derivatives be denoted with the subscripts x and t, e.g.
fx , f
t = ft . Thus:
x0
00
ft + fx x0 = ft + fx f
x000
f
x
= x(t) + hf +
= x+
1 2
h (ft + f fx ) + O(h3 )
2!
h
h
f + [f + hft + hf fx ] + O(h3 ).
2
2
Now we can get rid of the partial derivatives with the help of the first few
terms in the Taylor series in two variables. Since
f = x0
x
x
=
t
h
x f h
then
f (t + t, x + x) f (t + h, x + hf )
= f (t, x) + ft t + fx x + O(h2 )
= f + hft + hf fx + O(h2 ).
Now we insert this expansion into the expression for x(t + h):
1
1
x(t + h) = x + hf + hf (t + h, x + hf ) + O(h3 ).
2
2
220
h
h
f (t, x) + f (t + h, x + hf ).
2
2
F1
F2
1
(F1 + F2 )
2
= hf (t, x)
= hf (t + h, x + F1 )
14.3.3
F1
F2
F3
F4
1
(F1 + 2F2 + 2F3 + F4 )
6
= hf (t, x)
= hf t + h2 , x + 12 F1
.
= hf t + h2 , x + 12 F2
= hf (t + h, x + F3 )
221
x(0) = 1.
F1
F2
F
3
F4
F1
F3
F4
1
(F1 + 2F2 + 2F3 + F4 )
6
= hf (t, x)
= hf t + h2 , x + 12 F1
.
= hf t + h2 , x + 12 F2
= hf (t + h, x + F3 )
values are:
= hf (t, x) = 0.05(0 1) = 0.05
= hf t + h2 , x + 21 F1
1
= 0.05fh 0 + 0.05
2 , 1 + 2 (0.05)i
2
1 21 (0.05) = 0.048719
= 0.05 0.05
2
= hf t + h2 , x + 21 F2
1
= 0.05 h0 + 0.05
2 , 1 + 2 (0.048719) i
2
1 21 (0.048719) = 0.048751
= 0.05 0.05
2
= hf (t + h, x + F3 )
= 0.05fh (0 + 0.05, 1 0.048751)
i
2
= x(t) +
1
(F1 + 2F2 + 2F3 + F4 )
6
1
(0.050000 + 2(0.048719)
6
+2(0.048751) + (0.047437))
1+
0.951271.
222
F1
F2
F3
h
i
2
= hf (t, x) = 0.05 (0.05) 0.951271 = 0.047439
= hf t + h2 , x + 12 F1
1
= 0.05fh 0.05 + 0.05
2 , 0.951271 + 2 (0.047439)
i
2
1
= 0.05 0.05 + 0.05
0.951271
(0.047439)
2
2
= 0.046096
= hf t + h2 , x + 12 F2
.
1
= 0.05 h0.05 + 0.05
2 , 0.951271 + 2 (0.046096)
i
2
= 0.05 0.05 + 0.05
0.951271 12 (0.046096)
2
= 0.046130
= hf (t + h, x + F3 )
= 0.05fh (0.05 + 0.05, 0.951271 0.046130)
i
2
1
(F1 + 2F2 + 2F3 + F4 )
6
1
0.951271 + (0.047439 + 2(0.046096)
6
+2(0.046130) + (0.044757))
= x(t) +
=
=
0.905163.
Now we use this value x(t+h) = 0.905163 and x+h = 0.05+0.05 to calculate
the new functions F1 , F2 , F3 and F4 . Here we go again:
h
i
F
=
hf
(t,
x)
=
0.05
(0.05)
0.905163
= 0.044758
h
1
F2 = hf t + 2 , x + 2 F1
1
0.05 2
0.905163
(0.047439)
= 0.043358
=
0.05
0.1
+
2
2
h
1
F3 = hf t + 2 , x + 2 F2
.
1
= 0.05 h0.1 + 0.05
2 , 0.905163 + 2 (0.043358)
i
2
F4 = hf (t + h, x + F3 )
223
1
(F1 + 2F2 + 2F3 + F4 )
6
1
0.905163 + (0.044758 + 2(0.043358)
6
+2(0.043393) + (0.041963))
= x(t) +
=
=
0.861792.
Now we use this value x(t + h) = 0.861792 and t + h = 0.1 + 0.05 to calculate
the new functions F1 , F2 , F3 and F4 . This goes on and on until t = 0.4.
We can now compare the numerical solution with the analytical solution:
x(t) = t2 2t + 2 et .
At time t = 0.4, the numerical solution is 0.689680 while the analytical solution
is 0.689680. So both answers agree to 6 decimal places. Recall that the error
for Eulers method was 0.009929.
Runge-Kutta methods - coding example
Lets go back to the example we looked at previously.
Example 45 (Runge-Kutta method). Apply the Runge-Kutta method to the
following IVP:
x0 = 2x
x(0) = 10.
The Runge-Kutta method is a fourth order method, meaning that as h is
halved we would expect the error to be divided by 24 = 16. Figures 95, 96, 97
and 98 shows that is the case.
14.4
System of equations
0
y
= g(t, x, y)
.
x(t
)
= x0
y(t0 ) = y0
The formula to advance the solution is:
x(t + h)
y(t + h)
1
(F1 + 2F2 + 2F3 + F4 ) ,
6
1
= y(t) + (G1 + 2G2 + 2G3 + G4 ) .
6
= x(t) +
224
Error (c = 5)
x 10
7
6
5
4
3
2
1
0
5
t
10
Figure 95: Difference between the numerical and analytical solutions when h =
10/25 .
225
Error (c = 6)
x 10
5
t
10
Figure 96: Difference between the numerical and analytical solutions when h =
10/26 .
226
2.5
Error (c = 7)
x 10
1.5
0.5
5
t
10
Figure 97: Difference between the numerical and analytical solutions when h =
10/27 .
227
1.4
Error (c = 8)
x 10
1.2
0.8
0.6
0.4
0.2
5
t
10
Figure 98: Difference between the numerical and analytical solutions when h =
10/28 .
228
where
14.4.1
F1
F2
G2
F3
G3
F4
hf (t, x, y),
G1 = hg(t, x, y)
h
1
1
hf t + , x + F1 , y + G1
2
2
2
h
1
1
hg t + , x + F1 , y + G1
2
2
2
h
1
1
hf t + , x + F2 , y + G2
2
2
2
h
1
1
hg t + , x + F2 , y + G2
2
2
2
hf (t + h, x + F3 , y + G3 )
G4
hg (t + h, x + F3 , y + G3 ) .
Galactic dynamics
=R
2
3 R
dt
2
d z
=
dt2
z
where is the potential of our Galaxy and Lz = R2 d
dt (d/dt is the angular
velocity), is the angular momentum about the zaxis, which is conserved.
The above is a system of two second order differential equations and cannot
be solved analytically. Lets now re-write this system in terms of four first order
differential equations:
0
R
=U
0
Lz
U
=R
3 R
0
z
=W
W 0 =
z
where U and W are the velocities in the R and z direction respectively.
Now we need the initial conditions. These can be obtained experimentally;
the astronomer measures the components of the velocity of a star by observing
it with various techniques. The Doppler shift in spectral lines will give the U
component of velocity while the W and V components are found by measuring
how far a star has moved over a certain period of time with respect to background stars on a photographic or CCD plate. If the stars observed are all in
the solar neighbourhood, then we know where they are in the Galaxy: in the
plane of the Galaxy (z = 0) at R = 8.5 kiloparsecs from its centre, just like the
Sun. So we have a system of four first order differential equations with initial
conditions:
Figure 100: The spiral Galaxy NGC 4414 (Credit: W. Freedman (Carnigie
Obs.) , L. Frattare (STScI) et al., & the Hubble Heritage Team (AURA/ STScI/
NASA) ). Our own Galaxy would look a bit like this if seen nearly face-on.
230
R0
z0
U (8.5, 0)
W (8.5, 0)
V (8.5, 0)
Figure 101: Orbit of a star in the R z plane with initial velocities U = 130
km/sec, V = 180 km/sec and W = 95 km/sec.
231
232
233
Figure 105: The interacting Antennae galaxies NGC4038 and NGC4039 (credit:
B. Whitmore (STScI), F. Schweizer (DTM), NASA)
Figure 106: Two Merging Galaxies NGC 4676. These galaxies are located 300
million light-years away in the constellation Coma Berenices. The galaxies have
been given the nickname The Mice because of the two long tails made up of
stars and gas originating from each galaxy (Credit: NASA and the ACS Science
Team).
234