The goal of this laboratory is to implement the trapezoidal rule, Simpson's rule and Romberg integration algorithms. A second goal is to analyze the errors of Trapezoidal rule and Simpson's rule. Two programs will be required. The first involves computing the integral of exp(-x^2) between x=-1 and x=1 using both Trapezoidal rule and Simpson's rule for a variety of step sizes. The second program implements the Romberg algorithm on an integral describing the arclength of a sin curve.
Instructions for the First Program: Compute the integral of exp(-x^2) between x=-1 and x=1 using both Trapezoidal and Simpson's rules for step sizes h=1, 1/2, 1/4, 1/8, 1/16 and 1/32. For ease of understanding your program, you should utilize two subroutines - one for Trapezoidal rule and one for Simpson's rule. The inputs for the subroutines should be the left and right endpoints together with the step size (or equivalently, the number of nodes). The outputs for each should be the approximate values of the integral.
Turn in your code, your answers and a summary write-up. In your summary write-up, state the errors between your computed values and Maple's computed value for the integral. Compare these computed errors with the theoretical errors given in the book for Trapezoid and Simpson's. Also give an upper bound estimate on the round-off error for your algorithms (if using Maple, assume 10 digits of accuracy or an error of 5*10^(-11) for each computation; if using C or Fortran with single precision, assume 7 digits of accuracy or an error of 5*10^(-8) for each computation). Estimate the smallest step size that can be used by either algorithm so that the round-off error is smaller than the algorithm error.
Instructions for the Second Program: This program should compute 10 iterations of the Romberg algorithm for computing the integral given on page 156 of your book which gives the amount (length) of aluminum required to make a 48 foot sheet of corrugated siding. Use your program to compute the entire integral (from x=0 to x=48). Then use your program to compute the integral from x=0 to x=2*Pi. Use the fact that cos(x) is periodic to help compute the rest of the integral. Note that this latter method is more accurate (fewer iterations of Romberg are required for the same degree of accuracy). Turn in your code, your answers and a summary write-up that briefly explains the Romberg algorithm and why, for a very smooth function, it is more accurate than either Trapezoid or Simpson's.
Monday - Thursday: 7pm - 12 midnight
Friday: 9 am - 5 pm
Saturday 12 noon - 6 pm
Sunday 12 noon - 12 midnight