John H. Matthews, Numerical Methods for Mathematics, Science,
and Engineering, 2nd edition, Prentice Hall, 1992.
Covers material from Chapter 9, Sections 9.5-9.8.
1. Extend Problem 5 of the last homework to solve the initial value problem
y'(t) = 2ty(t) for t in [0,1]
y(0)=1
using (a) Euler's method, (b) Heun's method, (c) the Runge-Kutta method of
order N=4, and (d) the Adams-Bashforth-Moulton Predictor-Corrector
method.
Either have the program prompt the user for the number of steps N, or else
have N as a command-line argument. Use h=1/N as the step size. Make a
table with, for each of N=10, N=100, N=1000, and N=10000 and for all four
methods, the computed value of y(1) and the absolute value of the
difference between y(1) and the true value e = 2.71828182845904523536.
(Hint: If you include the header file math.h in a C program,
then the constant M_E should evaluate to the constant e to
around 20 decimal places.)
2. Use the Runge-Kutta method of order 4 to solve the Initial Value
Problem
y'' - 2y' + y = 0, y(0)=1, y'(0)=4, x in (0,3) (1)
by rewriting (1) as a system of two first-order equations. Compare your
solution at x=3 with the exact solution y(x)=(1+3x)e^x for both of the
step sizes h=0.1 (n=30 steps) and h=0.01 (n=300 steps).
3. Use the shooting method to solve the boundary-value problem
y'' = 1 + xy^2 + 3y' on (0,1), y(0)=1, y(1)=4
Use the Runge-Kutta method of order 4 with M=1000 steps (h=0.001)
starting from x=0 to do the shooting. Use the Newton-Raphson method to
find the value of y'(0)=c (with y(0)=1) that solves y(1)=4. Display
the solution values at x=k/10 for k=0,1,2,...,10.
(HINT: Let y(x,c) be the solution with initial values y(0)=1
and y'(0)=c. The ``shooting method'' here is to find c that solves
y(1,c)=4. Use the Newton-Raphson method with a central-difference
approximation for (d/dc)y(1,c) with step size h. Note that the solution of
(1) may only be defined on some interval (0,la_c) for la_c less than 1 for
large values of y'(0)=c. It may be necessary to add the condition c_{n+1}
less than (c_n+M_c)/2 to the Newton-Raphson iterations for some
appropriate upper bound M_c.)
Last modified April 23, 1998
Top of this page