4 An implicit method
Another approach that can be used to address the initial value problem
is to consider integrating the differential equation
from to . This leads to
that is,
and the problem now becomes one of approximating the integral on the right-hand side.
If we approximate the integral using the simple trapezium rule and replace the terms by their approximations we obtain the numerical method
The procedure for time stepping with this method is much the same as that used for Euler’s method, but with one difference. Let us imagine applying the method, we are given as the initial condition and now aim to find from
And here is the problem: the unknown appears on both sides of the equation. We cannot, in general, find an explicit expression for and for this reason the numerical method is called an implicit method.
In practice the particular form of may allow us to find fairly simply, but in general we have to approximate for example by using the bisection method, or Newton-Raphson. (Another approach that can be used involves what is called a predictor-corrector method, in other words, a “guess and improve" method, and we will discuss this again later in this Workbook.)
And then, of course, we encounter the problem again in the second time step, when calculating . And again for and so on. There is, in general, a genuine cost in implementing implicit methods, but they are popular because they have desirable properties, as we will see later in this Workbook.
Key Point 6
The trapezium method for approximating the solution of
is as follows. We choose a time step , then
In general, is approximated by
In Example 2 the implicit nature of the method is not a problem because does not appear on the right-hand side of the differential equation. In other words, .
Example 2
Suppose that is the solution to the initial value problem
Carry out two time steps of the trapezium method with a step size of so as to obtain approximations to and .
Solution
For the first time step we require and and therefore
For the second time step we also require and therefore
We conclude that
Example 3 has dependent on , so the implicit nature of the trapezium method could be a problem. However in this case the way in which depends on is simple enough for us to be able to rearrange for an explicit expression for .
Example 3
Suppose that is the solution to the initial value problem
Carry out two time steps of the trapezium method with a step size of so as to obtain approximations to and .
Solution
The trapezium method is and in this case will appear on both sides because depends on . We have
where which is the part of that depends on . On rearranging to get all terms on the left, we get
In this case .
For the first time step we require and and therefore
Hence , to six decimal places.
For the second time step we also require and therefore
Hence . We conclude that and to 6 d.p.
Task!
Suppose that is the solution to the initial value problem
Carry out two time steps of the trapezium method with a step size of so as to obtain approximations to and .
The trapezium method is and in this case will appear on both sides because depends on . However, we can rearrange for to give
where
is the part of
that depends on
.
For the first time step we require
and
and therefore
Hence
to 6 d.p.
For the second time step we also require
and therefore
Hence , to 6 d.p.
Example 4
The current in a simple circuit involving a resistor of resistance and an inductance loop of inductance with applied voltage satisfies the differential equation
Consider the case where , and . Given that use a value of in implementation of the trapezium method to approximate the current at times and .
Solution
The current satisfies
and the trapezium approximation to this is
Rearranging this for gives
It follows that
where these approximations are given to 6 decimal places.
4.1 Accuracy of the trapezium method
Let us now consider an example with a known solution and consider just how accurate the trapezium method is. Suppose that we look at the same test problem we considered when looking at Euler’s method
We know that the solution to this problem is , and we now compare exact values with the values given by the trapezium method. For the sake of argument, let us consider approximations to at . The exact value is to 6 decimal places. The following table shows results to 6 decimal places obtained on a spreadsheet program for a selection of choices of .
Notice that each time is reduced by a factor of , the error reduces by a factor of (approximately) . This observation verifies something we will see in Section 32.2, that is that the error in the trapezium approximation is (approximately) proportional to . This sort of behaviour is called second-order .
Key Point 7
The trapezium approximation is second order. In other words, the error it incurs is approximately proportional to .
Exercises
-
Suppose that
is the solution to the initial value problem
Carry out two time steps of Euler’s method with a step size of so as to obtain approximations to and .
-
Suppose that
is the solution to the initial value problem
Carry out two time steps of the trapezium method with a step size of so as to obtain approximations to and .
-
Suppose that
is the solution to the initial value problem
Carry out two time steps of the trapezium method with a step size of so as to obtain approximations to and .
-
The current
in a simple circuit involving a resistor of resistance
, an inductance loop of inductance
with applied voltage
satisfies the differential equation
Consider the case where , and . Given that use a value of in implementation of the trapezium method to approximate the current at times and .
-
For the first time step we require
and therefore
For the second time step we require and therefore
We conclude that -
For the first time step we require
and
and therefore
For the second time step we also require and therefore
We conclude thatto six decimal places.
-
The trapezium method is
and in this case
will appear on both sides because
depends on
. However, we can rearrange for
to give
where is the part of that depends on .
For the first time step we require and and thereforeHence .
For the second time step we also require and thereforeHence .
-
Dividing through by
we find that the current
satisfies
and the trapezium approximation to this is
Rearranging this for gives
It follows that