Assignment 2 MATH4Q3 21 January 2000
This assignment is due in the locker in the basement of
the Burke Science Building by 15:00 on 4 February 2000.
- 1.
- Use
Taylor's series to derive the following second-order central difference
formula,
along with its error term.
- 2.
- (a)
- Use
the Matlab program 6.2 (from the text) to use Richardson
extrapolation to find
with an absolute error of
1.0e-4 for
.
Compare the estimated absolute and
relative errors with the actual errors. Why should the number of
steps (rows in the matrix D of program 6.2) be limited?
- (b)
- What
is the advantage of Richardson's extrapolation method? How might it
be used in practise?
- 3.
- Use
the composite Trapezoid rule with N=4 to approximate the
following integral,
[Hint: first remove the singularity.]
- 4.
- (a)
- Write
Matlab functions that perform numerical integration of a
user-defined function f(x) over an interval
using the Composite Trapezoid Rule (CTR)
with N panels and Composite Simpson Rule (CSR) with 2N panels.
Your function should be able to read the function name f, the limits
a, b and the number of panels N and return the numerical
integration result. For example, if ctr is the name of a
function that performs numerical integration by CTR, then it should
look like this: function y = ctr('f',a,b,N).
- (b)
- Use
both Matlab functions you wrote in (a) to evaluate the
following integrals:
with
N=10, 100, 1000. Compare the numerical results with their exact
values
and
by computing the
(absolute) errors. How does this compare with the theoretical
analysis that the global error for CTR and CSR are O(h2) and
O(h4) respectively?
- 5.
- When
confronted with an integral, in practice we usually do not know
at the beginning how many panels (intervals we should use. It is
possible to make this decision automatically by comparing the relative
error of the most recent two successive approximates and terminating
the process when the relative error is within a given tolerance. The
routine looks something like
clear; format long
oldval=0; kmax=100;
initialize a, b;
specify the tolerance tol;
for k=1:kmax
val=trapezoid('f',a,b,oldval,k);
if abs(val-oldval)< tol*abs(oldval); break; end
oldval=val;
end
where the function trapezoid('f',a,b,oldval,k) is defined by
function val=trapezoid('f',a,b,oldval,N)
if N==1,
val=0.5*(b-a)*(feval('f',a)+feval('f',b));
else
i=2^(N-2);
h=(b-a)/i;
x=(a+0.5*h):h:b;
val=0.5*(oldval+h*sum(feval('f',x)));
end
Implement such a routine in Matlab to perform the automatic
refinement and use it to evaluate the integral
with tol = 1.0e-6 and tol = 1.0e-8. How
many panels are used by the routine to achieve these accuracies?
- 6.
- (a)
- The
two-point Gaussian quadrature formula evaluates integrals of the
form
exactly if f(x) is a polynomial of degree 3. Use this fact to show
that the integration points xi and weights wi for the
integration formula
are
and
.
By symmetry you may assume in your derivation that w1=w2 and
x1=-x2. [Hint:
,
.]
- (b)
- Use
this formula to estimate
.
This document was generated using the
LaTeX2HTML translator Version 98.1p1 release (March 2nd, 1998)
Copyright © 1993, 1994, 1995, 1996, 1997,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
The command line arguments were:
latex2html -split 0 -no_navigation 4q3-2-00.
The translation was initiated by Nicholas Kevlahan on 2000-01-18
Nicholas Kevlahan
2000-01-18