CS 3200: Introduction to Scientific Computing Assignment 2 solved


Category: You will receive a download link of the .ZIP file upon Payment


5/5 - (1 vote)

During lecture we discussed a number of integral quadrature methods. Each method calculates a
set of weight/position pairs {𝑀𝑀𝑖𝑖, π‘₯π‘₯𝑖𝑖}, for integrating a curve.
οΏ½ 𝑓𝑓(π‘₯π‘₯)𝑑𝑑𝑑𝑑 β‰ˆ �𝑀𝑀𝑖𝑖𝑓𝑓(π‘₯π‘₯𝑖𝑖)
1. Implement the following Newton-Cotes methods for finding {𝑀𝑀𝑖𝑖, π‘₯π‘₯𝑖𝑖} pairs
a. Constant interpolant (composite midpoint rule) for 𝑁𝑁 = 17,33,65,129,257,513
b. Linear interpolant (composite trapezoid rule) for 𝑁𝑁 = 17,33,65,129,257,513
c. Quadratic interpolant (composite Simpson formula) for 𝑁𝑁 = 17,33,65,129,257,513
2. Implement the following Gaussian methods given by the following {π‘₯π‘₯𝑖𝑖, 𝑀𝑀𝑖𝑖} pairs.
Note: the points are defined on [-1,1] and have to be mapped onto [a,b].
𝑡𝑡 π’™π’™π’Šπ’Š π’˜π’˜π’Šπ’Š
1 0 2
2 ±1/√3 1
0 8/9
Β±οΏ½3/5 5/9
Β±οΏ½(3 βˆ’ 2οΏ½6/5)/7 (18 + √30)/36
Β±οΏ½(3 + 2οΏ½6/5)/7 (18 βˆ’ √30)/36
0 128/225
οΏ½5 βˆ’ 2οΏ½10/7 (322 + 13√70)/900
οΏ½5 + 2οΏ½10/7 (322 βˆ’ 13√70)/900
3. Calculate the integral for the function below using all of the methods above.
οΏ½ 1 + sin(π‘₯π‘₯) βˆ™ cos οΏ½
3 οΏ½ βˆ™ sin(4π‘₯π‘₯) 𝑑𝑑𝑑𝑑
β€’ Report the results and create a convergence plot for the 3 Newton-Cotes formulas (a) (b)
and (c) above for 𝑁𝑁 = 217,33,65,129,257,513 that shows how quickly the methods go to a
common final value.
o Which of the Newton-Cotes formulas converges fastest? Is that in line with the theoretical
error? Why?
β€’ 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.