0% found this document useful (0 votes)
11 views10 pages

MATH3511 Assignment 5

The document details an assignment on scientific computing, focusing on deriving the fourth-order Adams-Moulton formula and analyzing its stability through numerical methods. It includes the derivation of coefficients using the method of undetermined coefficients, the exploration of amplification factors for a one-step method, and the application of the fourth-order Runge-Kutta method to various ordinary differential equations. Additionally, it discusses the stability of numerical solutions and the effects of different step sizes on convergence and divergence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views10 pages

MATH3511 Assignment 5

The document details an assignment on scientific computing, focusing on deriving the fourth-order Adams-Moulton formula and analyzing its stability through numerical methods. It includes the derivation of coefficients using the method of undetermined coefficients, the exploration of amplification factors for a one-step method, and the application of the fourth-order Runge-Kutta method to various ordinary differential equations. Additionally, it discusses the stability of numerical solutions and the effects of different step sizes on convergence and divergence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MATH3511 - Scientific Computing

Assignment 5
Phoebe Grosser, u7294693
May 22, 2023

Question 1: Adams-Moulton Formula


We would like to derive the following fourth-order Adams-Moulton formula using the method of undetermined coefficients:
h
xk+1 = xk + (9fk+1 + 19fk − 5fk−1 + fk−2 ) (1)
24
where we are approximating the solution to the first-order ODE x′ (t) = f (t, x). To do this, we will consider the fourth-
order Adams-Moulton formula in its most general form:

xk+1 = xk + h(β0 fk+1 + β1 fk + β2 fk−1 + β3 fk−2 ) (2)

The method of undetermined coefficients requires our method to be exact for polynomials up to a specified degree, and
subsequently allows the coefficients to be determined through the restrictions that exactness imposes. As we have four
degrees of freedom (βi ), we will require our method to be exact for polynomials up to and including degree 3:

x(t) = p0 (t) = 1, x(t) = p1 (t) = t, x(t) = p2 (t) = t2 , x(t) = p3 (t) = t3

Exactness for x(t) = p0 (t) = 1


We let x(tk ) = xk = 1, and hence x′ (tk ) = fk = 0. Substituting this into Equation 2 produces:

1 = 1 + h(β0 · 0 + β1 · 0 + β2 · 0 + β3 · 0)
=⇒ 1 = 1

Clearly this equation is redundant, so we will need to require exactness for a fourth-degree polynomial, p4 (t) = t4 , to
solve for all four coefficients βi .
Exactness for x(t) = p1 (t) = t
We let x(tk ) = xk = tk , and hence x′ (tk ) = fk = 1. Substituting this into Equation 2 produces:

tk+1 = tk + h(β0 · 1 + β1 · 1 + β2 · 1 + β3 · 1)

This equation must hold for all ti and any h, so, without loss of generality, we can let tk+1 = 1, tk = 0, tk−1 = −1 and
tk−2 = −2, as well as h = 1. Substituting this into the above, we attain:

1 = β0 + β1 + β2 + β3 (3)

Exactness for x(t) = p2 (t) = t2


We let x(tk ) = xk = t2k , and hence x′ (tk ) = fk = 2tk . Substituting this into Equation 2 produces:

t2k+1 = t2k + h(2β0 tk+1 + 2β1 tk + 2β2 tk−1 + 2β3 tk−2 )

Again, without loss of generality we can assign tk+1 = 1, tk = 0, tk−1 = −1, tk−2 = −2 and h = 1. This produces:

1 = 2(β0 − β2 − 2β3 ) (4)

Exactness for x(t) = p3 (t) = t3


We let x(tk ) = xk = t3k , and hence x′ (tk ) = fk = 3t2k . Substituting this into Equation 2 produces:

t3k+1 = t3k + h(3β0 t2k+1 + 3β1 t2k + 3β2 t2k−1 + 3β3 t2k−2 )

Page 1
Let tk+1 = 1, tk = 0, tk−1 = −1, tk−2 = −2 and h = 1. This produces:

1 = 3(β0 + β2 + 4β3 ) (5)

As stated previously, we must require exactness for an additional polynomial of degree 4, p4 (t) = t4 , in order to uniquely
solve for the coefficients βi .
Exactness for x(t) = p4 (t) = t4
We let x(tk ) = xk = t4k , and hence x′ (tk ) = fk = 4t3k . Substituting this into Equation 2 produces:

t4k+1 = t4k + h(4β0 t3k+1 + 4β1 t3k + 4β2 t3k−1 + 4β3 t3k−2 )

Let tk+1 = 1, tk = 0, tk−1 = −1, tk−2 = −2 and h = 1. This produces:

1 = 4(β0 − β2 − 8β3 ) (6)

Hence, our coefficients can be found by solving the four simultaneous equations for β0 , β1 , β2 and β3 :

1 = β0 + β1 + β2 + β3 (7)
1 = 2(β0 − β2 − 2β3 ) (8)
1 = 3(β0 + β2 + 4β3 ) (9)
1 = 4(β0 − β2 − 8β3 ) (10)

Firstly, we will perform the manipulation 2× Equation 8 − Equation 10. This leaves us with:
1
1 = 24β3 =⇒ β3 =
24
1
Substituting β3 = 24 into Equation 8 and 9 produces:

1
1 = 2β0 − 2β2 −
6
1
1 = 3β0 + 3β2 +
2
Rearranging the second equation for β0 gives us β0 = 16 − β2 . Substituting this into the previous equation allows β2 to be
solved as:
 
1 1 5
1=2 − β2 − 2β2 − =⇒ β2 = −
6 6 24
1 1 5 9 9 5 1
β0 is accordingly equal to β0 = 6 − β2 = 6 + 24 = 24 . Substituting β0 = 24 , β2 = − 24 and β3 = 24 into Equation 7 gives
the final coefficient, β1 , as:
9 5 1 19
1= + β1 − + =⇒ β1 =
24 24 24 24
Thus, substituting these coefficients into Equation 2, we have derived the following for the fourth-order Adams-Moulton
method:
h
xk+1 = xk + (9fk+1 + 19fk − 5fk−1 + fk−2 ) (11)
24

Page 2
Question 2: Stability
We would like to find the amplification factor for the following one-step method:
 
1 1
xk+1 = xk + hf tk + h, xk + hf (tk , xk ) (12)
2 2

To find the amplification factor, we consider the simple ODE given by:
dx
= λx (13)
dt
Hence, f (t, x) = λx =⇒ f (tk , xk ) = λxk . If we apply the numerical scheme in Equation 12 to the above ODE, then we
can see that our iterations will obey:
 
1
xk+1 = xk + hλ xk + hf (tk , xk ) (14)
2
 
1
= xk + hλ xk + h(λxk ) (15)
2
1
= xk + hλxk + h2 λ2 xk (16)
 2 
1
= 1 + hλ + h2 λ2 xk (17)
2

Our amplification factor ρ(hλ), is defined as:

xk+1 = ρ(hλ)xk

Thus, we can clearly identify the amplification factor for the modified Euler scheme as:
1
ρ(hλ) = 1 + hλ + h2 λ2 (18)
2
If λ = −2, then the amplification factor is:

ρ(h) = 1 − 2h + 2h2

We require ρ(h) < 1 for stability. This is because the analytical solution to the ODE presented in Equation 13 is a
decaying exponential when λ = −2 (that is, ∝ exp (−2t)). So, we require |x| → 0 as t → ∞ (or, in discrete terms,
|xk | → 0 as k → ∞) to reproduce the expected behaviour. Noting this, we have that:

1 − 2h + 2h2 < 1
2h(h − 1) < 0
=⇒ 0 < h < 1

So the amplification factor, ρ(h), must lie between 0 and 1 for A-stability. We can see this specifically by using the
modified Euler scheme to approximate the solution to the ODE:
dx
= −2x (19)
dt
ie. λ = −2, as given, with initial conditions x(0) = 10. The modified Euler scheme was applied to the above ODE for
different step sizes h and subsequently plotted in the below Figures 1 - 6. The approximation was plotted against the
true solution, x(t) = 10 exp (−2t).
As can be seen, the approximation is A-stable for h = 0.10, h = 0.25, h = 0.50 and h = 0.75, all of which produce an
amplification factor between 0 and 1 (so the approximation convergences towards the true solution in all these cases for
t → ∞, albeit the rate at which this occurs differs). The solution is static for h = 1.0, which is expected because h = 1
implies that the amplification factor is ρ(1) = 1 − 2(1) + 2(1)2 = 1. That is, xk+1 = xk - subsequent approximations
will not change at all as the scheme is iterated. Importantly, a step size of h = 1.10 in Figure 6 produces divergence
from the true solution (ie. is not A-stable), which is expected as h = 1.10 does not sit within the A-stability range of
0 < h < 1. Rather, it implies that xk+1 > xk for subsequent iterations, which does not produce the expected behaviour
of the decaying exponential solution.

Page 3
Figure 1: Approximation of Equation 19 using step size h = 0.10

Figure 2: Approximation of Equation 19 using step size h = 0.25

Page 4
Figure 3: Approximation of Equation 19 using step size h = 0.50

Figure 4: Approximation of Equation 19 using step size h = 0.75

Page 5
Figure 5: Approximation of Equation 19 using step size h = 1.00

Figure 6: Approximation of Equation 19 using step size h = 1.10

Page 6
Question 3: Unstable ODE
a.
We have used the fourth-order Runge-Kutta method (RK4) to approximate the solution to the following ODE:

dx
= (2 − t)x (20)
dt
with initial condition x(2) = 1, which has the analytical solution x(t) = exp − 12 (t − 2)2 . The RK4 numerical scheme


was applied to the ODE to generate an approximate solution, and subsequently plotted against the analytical solution.
An example using step size h = 0.32 is shown in Figure 7.

Figure 7: RK4 approximation of Equation 20 using step size h = 0.32

What can be observed is that the RK4 numerical scheme appears to be a good approximation for small tk , but diverges
as tk increases. We can produce further insight on this by determining whether the scheme produces the expected O(h4 )
convergence for the global truncation error, which can be achieved by plotting the accumulated global error against step
size h for varying h. The global error is defined as the accumulated error between the approximate solution and true
solution at the final timestep tn , assuming exact knowledge of the true solution at the initial timestep.
The plot of the global truncation error against step size h is shown below in Figure 8.
What can be observed is that, in general, the global error of the RK4 numerical method applied to Equation 20 is fourth-
order accurate, as the gradient matches the O(h4 ) indication line. For very small h (approximately h < 10−4 ), the floating
point error becomes too dominant to accurately determine the global truncation error. At the start (approximately h > 1),
the gradient of Figure 8 does not precisely follow the O(h4 ) indication line because h here is too large to deem truncated
terms in the Taylor series derivation of the RK4 error accuracy negligible. For the majority of the h range considered,
the method is clearly fourth-order accurate.
We do expect the RK4 to give us convergent results for this particular ODE, as the mathematical problem is stable within
itself. We already know that the analytical solution to Equation 20 is:
 
1 2
x(t) = exp − (t − 2) (21)
2

when the initial condition x(2) = 1 is applied. If our initial value is slightly perturbed by some small error ϵ such that

Page 7
x(2) = (1 + ϵ), then the solution becomes:
 
1 2
x(t) = (1 + ϵ) exp − (t − 2)
2
   
1 2 1 2
= exp − (t − 2) + ϵ exp − (t − 2)
2 2

Thus, the solution is only perturbed by ϵ exp − 21 (t − 2)2 , which diminishes as t increases (ie. as the numerical scheme


is iterated through). We therefore wouldn’t expect any minor error perturbations that may arise to grow unbounded
and subsequently produce significant divergence from the exact solution. The ODE is hence stable, and we expect the
fourth-order Runge-Kutta method to give us convergent results.

Figure 8: Global truncation error for the RK4 numerical scheme applied to Equation 20

b.
We now consider the differential equation given by:
dx
= 100(sin (t) − x) (22)
dt
with initial value x(0) = 0. The fourth-order Runge-Kutta numerical method was used to approximate the solution to
this ODE with step sizes h = 0.015, h = 0.020, h = 0.025 and h = 0.030. The plot of the results is shown in Figure 9.
As can be seen, there is no numerical instability for the h = 0.015, h = 0.020 and h = 0.025 step sizes. The solution
remains bounded as the scheme is iterated through. There is a clear numerical instability for the h = 0.030 step size, as
the solution diverges significantly after a few iterations and grows unbounded with time.

Page 8
Figure 9: RK4 method applied to Equation 22 with various step sizes

Page 9
Question 4: Multistep ODE Solvers
The fourth-order Adams-Bashforth and fourth-order Adams-Moulton methods were implemented in Matlab and applied
to the following system of ODEs:

x′ (t) = x(t) − y(t) − exp (t) (23)



y (t) = x(t) + y(t) + 2 exp (t) (24)

We expect these methods to be of order O(h4 ) for the global truncation error (that is, the accumulated error between the
approximate and true solution at the final time step). Plotting the global error against h for different step sizes produces
the graph in Figure 10.

Figure 10: Adams-Moulton and Adams-Bashforth methods applied to Equations 23 - 24 with various step sizes

The global error of both the Adams-Moulton and Adams-Bashforth schemes can be seen to be fourth-order accurate in
general, as the gradient follows the O(h4 ) indication line. Floating point errors dominate the scheme for very small h
(hence the random global errors), and assumptions necessary to derive the fourth-order accuracy of the schemes are not
valid at very large h (so we wouldn’t expect O(h4 ) convergence to hold). For the large majority of the h region considered,
the scheme is O(h4 ) convergent.

Page 10

You might also like