AMTH142 Lecture 21
Differential Equations -- Systems and Higher Order Equations
A system of first order differential equations has the form
that is, we have a system of
first order differential equations for
functions
.
An initial value problem specifies the initial values of all
functions
at the same point
:
As in the case of a single equation, an initial value problem for
a first order system has a unique solution.
It is often convenient to write the equations in vector form;
if
then the system of differential equations
can be written
where
is the vector of functions
.
The initial values can also be written in vector form
As an example we will look at the Lotka-Volterra equations which
are used to model the dynamics of predator-prey interactions.
The prey population is denoted by
and the predator population
by
. The differential equations are
The parameters
and
are the natural growth rates
of the populations, and the parameters
and
determine
the interaction between the two populations.
Recall that Euler's method for a single equation takes the form
Simply replacing the scalars
and
by vectors gives a formula
which makes sense for systems of equations
In terms of the individual equations this reads
We will adapt our procedure euler from the previous
lecture to deal with systems of equations.
Again it will take the form
[t, y] = euler(f, t0, y0, dt, n)
and perform n steps of Euler's method with step size dt.
The difference now is that since we have a system of equations
we need to careful about the sizes of the variables. If we
have a system of k equations then we specify:
t: |
a column vector of size n+1. |
y: |
a matrix of size n+1 k, |
| |
the rows of y are the components at a given value
of , |
f(t,y): |
the second argument is a row vector of size k, |
| |
it returns a row vector of size k. |
y0: |
a row vector of size k. |
Our function euler is essentially the same as for a single equation,
except for the dimensions of the variables involved:
function [t, y] = euler(f, t0, y0, dt, n)
k = length(y0) // this determines the number of equations
t = zeros(n+1, 1)
y = zeros(n+1, k)
t(1) = t0
y(1,:) = y0
for i = 1:n
t(i+1) = t(i) + dt
y(i+1,:) = y(i,:) + f(t(i), y(i,:))*dt
end
endfunction
As our example we will use the Lotka-Volterra equations
with parameter values:
and initial conditions
Here is the function for the right hand side of our
system of equations:
-->a1 = 1;
-->a2 = 0.5;
-->b1 = 0.1;
-->b2 = 0.02;
-->function ydot = lv(t, y)
--> ydot = zeros(y)
--> ydot(1) = y(1)*(a1 - b1*y(2))
--> ydot(2) = y(2)*(-a2 + b2*y(1))
-->endfunction
By setting the values of the parameters outside the function
we could easily change them if we wanted to experiment with
different parameter values.
By setting ydot = zeros(y) we insure that ydot
has the same shape as y, (i.e. if y is a row vector
then so is ydot).
We will solve the differential equations over the interval
using steps of
.
-->[t, y] = euler(lv, 0, [100 10], 0.01, 2500);
-->plot2d(t, y)
Note that the plot works because plot2d plots each of the
columns of y and we have set things up so that the
columns correspond to the two populations
and
.
The curve with larger values is
the prey population.
Both populations show noticeable oscillations but they do
not oscillate in phase.
This has a biological interpretation.
First the prey numbers are decreasing as the predators are increasing -
the predators are eating the prey and increasing in number
because of the plentiful supply of food.
Then the predator numbers decrease as the supply of food continues
to decreases.
When the predator numbers decrease enough the prey numbers start to
increase and the cycle repeats itself.
These sorts of oscillations has been observed in
natural predator/prey populations.
Another useful graph in examples like this is a
phase-plane plot when one component of the solution,
, is plotted against the other,
, rather than plotting
each against
.
-->plot2d(y(:,1), y(:,2))
The main thing to be gained from a graph like this is
how the two populations vary with one another.
There is a clear cyclic pattern to the populations over time.
Also apparent is the fact that the maxima and minima
of the two populations do not coincide.
The function ode works the same way for systems of
equations as for a single equation
y = ode(y0, t0, t, f)
Here y0 is assumed to be a column vector and the result,
y, contains the components of the solution as rows.
This is the opposite of our function euler and we need
to take transposes when plotting.
Here is our example using ode:
-->t = 0:0.01:25;
-->y = ode([100 10]', 0, t, lv);
-->plot2d(t', y')
-->plot2d(y(1,:), y(2,:))
The results are very similar to those obtained with euler,
although the phase plane plot shows an almost exactly closed
curve indicating exact periodic behaviour in the solutions.
(We would expect the more sophisticated method
ode to give more accurate solutions than euler.)
The differential equations we have studied so far contain only
first derivatives.
Higher order differential equations involve the second
and possibly higher derivatives.
An
-order differential equation has the
form
An initial value problem specifies the initial values of
all the derivatives up to order
:
Again, such an initial value has a unique solution.
An initial value problems for a higher order equation can be
reduced to an equivalent initial problem for a system of
first order equations.
This is convenient since we understand how to deal
with the latter numerically.
Given an
-th order equation
 |
(1) |
introduce
new variables
There are
relationships between the new variables:
which together with equation (1), which can be rewritten as,
gives a system of
first order equations for the
unknown
functions
.
The initial values for the
-th order equation
are equivalent to the following initial values for our new variables
Thus any initial value problem for an
-th order differential
equation can be converted to an initial value problem for
a system of
first order equations. Similarly, initial value
problems for systems of higher order equations can be converted
to equivalent problems for 1st order systems using the same
techniques. The method is obvious but tedious to write out.
According to Newton's laws the the position
in
the orbital plane of
a body orbiting a much larger body of mass
centered at the origin is
governed by the differential equations
where
is the gravitational constant and
.
Each of the differential equations is 2nd order
so the pair of equations is equivalent to a system of four
1st order equations.
Introducing variables
We have the relations
and
The original 2nd order equations can be written in terms
of the new variables as
and
giving our system of four 1st order equations.
To solve these equations numerically, we will let
y denote the vector
.
To simplify the computation we can choose units such that
, so the right hand side of system is given by the
Scilab function
-->function ydot = orbit(t, y)
--> ydot = zeros(y)
--> ydot(1) = y(2)
--> ydot(3) = y(4)
--> ydot(2) = - y(1)*(y(1)^2 + y(3)^2)^(-3/2)
--> ydot(4) = - y(3)*(y(1)^2 + y(3)^2)^(-3/2)
-->endfunction
With the initial conditions
and solving over the interval
:
-->y0 = [0.4 0 0 2]';
-->t = 0:0.01:50;
-->y = ode(y0, 0, t, orbit);
-->plot2d(y(1,:),y(3,:))
// position of central body
-->plot2d(0,0,-2)
Note that y(1,:) and y(3,:) are the data
corresponding to the variables
and
.
The graph shows that the orbit is an ellipse with the central body at
a focus, something well known to Newton.
AMTH142 Lecture 21
Differential Equations -- Systems and Higher Order Equations
This document was generated using the
LaTeX2HTML translator Version 2K.1beta (1.61)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split +0 lecture.tex
The translation was initiated by Applied Mathematics 142 on 2002-10-23
Applied Mathematics 142
2002-10-23