$24
Instructions
During lecture we discussed a number of integral quadrature methods. Each method calculates a set of weight/position pairs {wi , xi }, for integrating a curve.
B f(x)dx = N wif(xi)
a i=1
1. Implement the following Newton-Cotes methods for finding {ww ii , xx ii } pairs
a. Constant interpolant (composite midpoint rule) for NN = 17,33,65,129,257,513
b. Linear interpolant (composite trapezoid rule) for NN = 17,33,65,129,257,513
c. Quadratic interpolant (composite Simpson formula) for NN = 17,33,65,129,257,513
2. Implement the following Gaussian methods given by the following {xx ii , ww ii } pairs.
Note: the points are defined on [-1,1] and have to be mapped onto [a,b].
NN xi wi
TABLE MISSING sorry
Which of the Newton-Cotes formulas converges fastest? Is that in line with the theoretical error? Why?
o
Estimate the error for the Trapezoidal Rule and Simpson’s Rule by estimating the appropriate derivatives and using the explicit from of the error. Now estimate the errors by using Richardson Extrapolation . Which error estimates are more accurate?
Report the results for = 2, 3, 4, 5 for the Gaussian quadratures given above
o The Gaussian quadratures are high-order functions, yet they don’t do a good job approximating the integral, why?
o What could be done to make the Gaussian quadratures give better results?
What to turn in
For these assignments, we expect both SOURCE CODE and a written REPORT be uploaded as a zip or tarball file to Canvas.
Source code for all programs that you write, thoroughly documented.
o Include a README file describing how to compile and run your code.
Your report should be in PDF format and should stand on its own. o It should describe the methods used.
o It should explain your results and contain figures. o It should also answer any questions asked above.
o It should cite any sources used for information, including source code. o It should list all of your collaborators.
This homework is due on February 21 by 11:59 pm. If you don't understand these directions, please send questions to me or to the TAs or come see one of the TAs or the instructor during office hours well in advance of the due date.
2