Starting from:
$30

$27

Scientific Computing Assignment 2

Introduction to Scientific Computing
Assignment 2
Note: Please do your programming in Matlab, document thoroughly! The code must
compile on one of the lab machines with your instructions.
Instructions
During lecture we discussed a number of integral quadrature methods. Each method calculates a
set of weight/position pairs {𝑤𝑤𝑖𝑖, 𝑥𝑥𝑖𝑖}, for integrating a curve.
� 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑 ≈ �𝑤𝑤𝑖𝑖𝑓𝑓(𝑥𝑥𝑖𝑖)
𝑁𝑁
𝑖𝑖=1
𝑏𝑏
𝑎𝑎
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
3
0 8/9
±�3/5 5/9
4
±�(3 − 2�6/5)/7 (18 + √30)/36
±�(3 + 2�6/5)/7 (18 − √30)/36
5
0 128/225
±
1
3
�5 − 2�10/7 (322 + 13√70)/900
±
1
3
�5 + 2�10/7 (322 − 13√70)/900
3. Calculate the integral for the function below using all of the methods above.
2
� 1 + sin(𝑥𝑥) ∙ cos �
2𝑥𝑥
3 � ∙ sin(4𝑥𝑥) 𝑑𝑑𝑑𝑑
2𝜋𝜋
0
• 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?
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.

More products