Lecture 3
interpolation -- need of spline -- quatradature -- Trapezoidal rule --
Simpson's rule -- Romberg integration
Homework Problems
Please return the solution of these problems by Thursday 15th of March midnight. The computer
programs should be checked-in in your directory at Google Drive that we share. The handwritten answers
should be in my mailbox by the morning of 16th of March or handed over to me in class on the same
day. The marks allocated to each problem is give inside parenthesis. The total marks of this homework
adds up to $100$.
- The following three problems are from Acton's book. You can use the code {\tt quad.f90}
that we wrote in class to do the numerical computation in this problem. In each of the
numerical computations below note their convergence with the number of points $N$ you
use to compute the integral.
- Evaluate
\begin{equation}
\int_0^{\pi/2} \sin x dx
\end{equation}
by the trapezoidal rule, by Simpson's rule.
(20 marks)
- Evaluate
\begin{equation}
\int_0^{1.553343} \tan x dx
\end{equation}
by the same technique as the previous problem. Compare with the analytic answer.
(20 marks)
- Evaluate the integral in the previous problem having first subtracted
$(\frac{\pi}{2} -x)^{-1}$ from $\tan x$ and then compensate by adding the analytic
integral of this function to your result. Use Simpson's rule.
(20 marks)
- Write a subroutine that uses the Romberg integration technique as discussed in class.
(Do not copy the routine in Numerical Recepies.) For this exercise, first copy {\tt quad.f90}
to your own directory (in the google code) and the romberg integration as a new
subroutine in this module which uses that already existing trapezoidal integrator.
Then to show that the Romberg integral works integrate:
\begin{equation}
\int_0^1 \exp(-x^2) dx
\end{equation}
You can get a accurate value of this integral by writing it in terms of the error function
(as discussed in class) and then finding out the value of the error function from
{\tt gsl}. Give a piece of code that calculates the value of the function from {\tt gsl}
library. (40 marks)