mm245/ma260 lab4


http://www.maths.nuigalway.ie/~gettrick/teach/mm245/labs/l4.html




You should study (and run) the code in trap1.m at http://www.maths.nuigalway.ie/~gettrick/teach/mm245/labs/matlab/ which is commented to explain its operation.

For this lab, consider the integral of x*sin(x) between the limits of 0 and 3*PI/4 (i.e. 135 degrees).

  1. Find the estimate given by using the trapezoidal rule in MATLAB with 8 (eight) intervals. By calculating the exact integral (on a sheet of paper), calculate (in MATLAB) the relative error. You should submit all the MATLAB code you use to do your calculations.
  2. Determine the number of iterations necessary to ensure a relative error of less than 0.3%. You should submit all the MATLAB code you use to do your calculations. [Hint: it is a good idea to use a WHILE loop here: iterate the trapezoid calculations, using progressively more points xi, until the relative error is below 0.003.]


© NUI, Galway