AMTH247 Lecture 20
Differential Equations II
Reading: Heath §9.3.2-9.3.4
Consider a solution
of an initial value problem
 |
(1) |
This solution
is said to be stable if solutions with nearby
initial values remain close to
.
The solution
is unstable if solutions with nearby
initial values diverge away from
.
The initial value problem
has the solution
The general solution of the differential equation is
The solution of the initial value problem has
, but
solutions with other initial values will have
and these will diverge away from the solution
.
Here is a graph of some solutions:
-->a = [-0.0001 -0.001 -0.01 -0.1 0 0.1 0.01 0.001 0.0001];
-->x = 0:0.01:10;
-->for i = 1:9
--> plot2d(x,1+a(i)*exp(x),1,"011",rect=[0 -5 10 5])
-->end
Figure 1:
An unstable solution.
|
|
It is extremely difficult to obtain accurate numerical solutions to
unstable initial value problems.
As soon as even the smallest numerical error occurs, the computed
solution will move to a neighbouring solution curve and thus
diverge from the true solution.
Instability of numerical solutions can be caused by
the numerical method itself even when the solutions to
the differential equation are stable.
Consider the initial value problem
The solution of this initial value problem is
These solutions will be stable when
, since
then all solutions are exponentially decaying to
.
Euler's method for the differential equation
is
Writing
for the computed solution at
,
that is after
steps of size
, we can write Euler's method
Applying Euler's method to the differential equation
gives
This is a difference equation which can be easily be seen to
have the solution
If
then the computed solution will decay
to zero.
On the other hand, if
then
computed solution will grow without bounds.
For
, the differential equation itself is stable.
For Euler's method to be stable we require, in addition, that
That is
We will use as our example from the previous lecture
which has the solution
We saw above that Euler method for
is unstable for
By analogy we might expect that Euler's method for
will be unstable for
Another way to think of this is that for fixed step size
,
Euler's method for
should become unstable at
Let us see what happens in practice.
We will use the function euler from the previous lecture.
The following example shows what happens:
-->function y = func(t, y)
--> y = - 2*t*y
-->endfunction
-->[t,y] = euler(func, 0, 1, 0.1, 251);
-->plot2d(t, y)
Zooming in on the end of the graph shows clearly the onset
of instability
This shows the instability apparently starting at
,
whereas according to the argument above it should start at
.
Closer examination of the output shows that the instability
does start at
. The smallest value of
the computed solution
-->[y1,k]=mini(abs(y))
k =
102.
y1 =
2.576E-57
occurs at k = 102, that is at
.
Plotting the solution near
clearly shows the
switch from stability to instability:
-->plot2d(y(90:115))
It turns out that rounding errors are much less
important than truncation errors in solving differential
equations.
There is still the problem that rounding error increases as the
step size decreases, however the step sizes used in practice
are usually such that truncation error is still the main
source of error.
There are two ways to look at the truncation error in a
numerical method for solving differential equations.
The global error is the difference between the
exact and computed solutions.
The local error is the error in one step
of the method.
The global error is not simply the sum of the local errors.
The way the local errors compound together to form the
global error is rather complicated.
This is because the local error measures the error in one step
assuming the starting point of the step is accurate.
However the starting point of the step is itself subject to error
compounded from errors at previous steps.
There are no general reliable methods for estimating
the global error, in general it is assumed that it is about the size
the sum of the local errors.
A numerical method for differential equations is said
to be of order
if the local truncation error is proportional
to
. When the global error is the sum of the local
errors, we then expect the global error to be proportional
to
since the number of steps taken to reach any particular
value of
is proportional to
.
Euler's method is of order 1 since it is based on a Taylor
series approximation and the first neglected term is
proportional to
.
We will see how the error depends the step size in our example.
We will take step sizes
and
for each
compute the error in the computed solution
at
. The exact value is
.
-->err = zeros(1,10);
-->for k = 1:10
--> n = 2^k;
--> [t,y] = euler(func, 0, 1, 1/n, n);
--> err(k) = abs(y(n+1) - exp(-1));
-->err
err =
column 1 to 5
! 0.1321206 0.0422768 0.0178353 0.0082540 0.0039755 !
column 6 to 10
! 0.0019514 0.0009668 0.0004812 0.0002401 0.0001199 !
-->plot2d(log10(err))
It looks like the error is decreasing by a factor of about
two when the step size halves. This is consistent with the
Euler's method being of order 1.
Euler's method is
The backward Euler method is
Given
, we need to solve the equation
to compute
. Because
is determined only
implicitly by
, methods such as this are
called implicit methods.
Methods like Euler's method where
can be determined
directly from
are called explicit methods.
Each step of an implicit method requires the solution of a
nonlinear equation.
Applying the backward Euler method to the differential
equation
gives
Rearranging gives
So for the backward Euler method to be stable
we require
which, when
, holds for all step sizes
.
Like Euler's method, the backward Euler method is a
first order method.
The big disadvantage of implicit methods is that we need to
solve a nonlinear equation at each step.
However implicit methods, like the backward
Euler method, have the property of being stable
for all step sizes.
Explicit methods, like Euler's method,
are may require extremely small step sizes to maintain
stability.
Stiff differential equations may be loosely
defined as those for which explicit numerical methods
require very small step sizes to maintain stability.
Stiff differential equations are common in applications.
They typically arise where there is a slowly varying
equilibrium solution with rapidly decaying transients.
Stiff differential equations are very stable mathematically,
but cause stability problems for explicit methods.
Implicit methods are the most practical method for
solving stiff systems; the disadvantage of having to
solve a nonlinear system at each step is outweighed
by the advantage of being able to take reasonably sized steps.
AMTH247 Lecture 20
Differential Equations II
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 amth247 on 2003-06-02
amth247
2003-06-02