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,

\begin{displaymath}f^{(3)}(x) \approx \frac{f(x+2h)-2f(x+h)+2f(x-h)-f(x-2h)}{2h^3}
\end{displaymath}

along with its error term.
2.
(a)
Use the Matlab program 6.2 (from the text) to use Richardson extrapolation to find $f'(1/\sqrt{2})$ with an absolute error of 1.0e-4 for $f(x)=\sin(\cos(1/x))$. 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,

\begin{displaymath}\int_{0}^{1} \frac{e^{-x}}{x^{3/4}} \,{\rm d}{x}.
\end{displaymath}

[Hint: first remove the singularity.]
4.
(a)
Write Matlab functions that perform numerical integration of a user-defined function f(x) over an interval $[a,b] : I =
\int_{a}^{b} f(x) \,{\rm d}{x}$ 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:

\begin{displaymath}I_1 = \int_0^1 \sin 7x \,{\rm d}{x} \mbox{\hspace{1em}}I_2 = \int_0^3 x\exp(-x^2) \,{\rm d}{x}
\end{displaymath}

with N=10, 100, 1000. Compare the numerical results with their exact values $I_1=(1-\cos 7)/7$ and $I_2=(1-\exp(-9))/2$ 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 $\int_0^1
x^{1/3}\,{\rm d}{x}$ 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

\begin{displaymath}\int_{-\infty}^\infty f(x) e^{-x^2}\,{\rm d}{x}
\end{displaymath}

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

\begin{displaymath}\int_{-\infty}^\infty f(x) e^{-x^2} \,{\rm d}{x} \approx w_1 f(x_1) + w_2
f(x_2)
\end{displaymath}

are $x_1=-1/\sqrt{2}, x_2=1/\sqrt{2}$ and $w_1 = w_2 = \sqrt{\pi}/2$. By symmetry you may assume in your derivation that w1=w2 and x1=-x2. [Hint: $\int_{-\infty}^\infty e^{-x^2} \,{\rm d}{x} =
\sqrt{\pi}$, $\int_{-\infty}^\infty x^2 e^{-x^2} \,{\rm d}{x} =
\sqrt{\pi}/2$.]
(b)
Use this formula to estimate $\int_{-\infty}^\infty e^{-x^2}\cos x
\,{\rm d}{x}$.

About this document ...

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