Assigned: Thursday Nov. 14, 2013 Due Date: Thursday Nov. 21, 2013 MATH 373: Homework 8 “Integration I” Fall 2013 NOTE: For each homework assignment observe the following guidelines: • Include a cover page. • Always clearly label all plots (title, x-label, y-label, and legend). • Use the subplot command from MATLAB when comparing 2 or more plots to make comparisons easier and to save paper. 1. Consider the following 4 equally spaced points on the interval [x0 , x3 ]: xj = x0 + jh [j = 0, 1, 2, 3] , where h = (x3 − x0 )/3. (a) Construct all the Lagrange polynomials L3 j (x) that correspond to the points x0 , x1 , x2 , and x3 . (b) Use these Lagrange polynomials to construct the interpolating polynomial p3 (x) that interpolates the function f (x) at the points x0 , x1 , x2 , and x3 . (c) Integrate the interpolating polynomial p3 (x) to derive the following NewtonCotes formula often referred to as Simpson’s three-eigths rule: Z x3 i 3h h f (x) dx ≈ f (x0 ) + 3f (x1 ) + 3f (x2 ) + f (x3 ) . 8 x0 2. Consider the following n + 1 equally spaced points on the interval [x0 , xn ]: xj = x0 + jh [j = 0, 1, 2, . . . , n] , where h = (xn − x0 )/n. We write the integral of f (x) from x = x0 to x = xn as follows: Z xn n/3 Z x 3i X f (x) dx = f (x) dx. x0 i=1 x3i−3 NOTE: On each subinterval [x3i−3 , x3i ] there are 4 equally spaced data points. (a) On the subinterval [x3i−3 , x3i ] apply Simpson’s three-eigths rule to obtain an approximation to Z x3i f (x) dx . x3i−3 (b) Use this result to derive the Composite Simpson’s three-eigths rule: Z xn f (x) dx ≈ x0 n/3 n n/3−1 o X X 3h f (x0 )+3 f (x3i−2 )+f (x3i−1 ) +2 f (x3i )+f (xn ) . 8 i=1 i=1 1 Assigned: Thursday Nov. 14, 2013 Due Date: Thursday Nov. 21, 2013 3. SOURCE CODE: Write the following functions: • I = CompositeTrapezoidal(f,a,b,n): Composite Trapezoidal rule for approximating spaced points. Rb a f (x) dx using n + 1 equally • I = CompositeSimpsons(f,a,b,n): Composite Simpson’s rule for approximating spaced points. Rb a f (x) dx using n + 1 equally • I = CompositeSimpsons38(f,a,b,n): Composite Simpson’s three-eigths rule for approximating equally spaced points. Rb a f (x) dx using n + 1 4. Consider the following integral: Z 1 4 I= e−20x dx = 0.85722253700516515104. −1 (a) Using the composite Trapezoidal rule compute approximations to I using several grid resolutions: n = 2k+1 with k = 1, 2, 3, . . . , 11. Create a table showing the approximations, the absolute errors, and the error ratios for the various n. (b) Using the composite Simpsons rule compute approximations to I using several grid resolutions: n = 2k+1 with k = 1, 2, 3, . . . , 11. Create a table showing the approximations, the absolute errors, and the error ratios for the various n. (c) Comment on your results from Parts (a) and (b) and explain the relationship between the errors calculated and the theoretical error analysis from class. 5. Again, consider the following integral: Z 1 4 I= e−20x dx = 0.85722253700516515104. −1 (a) Using the composite Simpson’s three-eigths rule compute approximations to I using several grid resolutions: n = 3 × 2k with k = 1, 2, 3, . . . , 11. Create a table showing the approximations, the absolute errors, and the error ratios for the various n. (b) From this table determine the experimental order of convergence. 6. Consider the following integral: Z 1 cos π 2 + 7 2 I= sin π x dx = . π2 0 (a) Using the composite Trapezoidal rule compute approximations to I using several grid resolutions: n = 2k+1 with k = 1, 2, 3, . . . , 11. Create a table showing the approximations, the absolute errors, and the error ratios for the various n. 2 Assigned: Thursday Nov. 14, 2013 Due Date: Thursday Nov. 21, 2013 (b) Using the composite Simpsons rule compute approximations to I using several grid resolutions: n = 2k+1 with k = 1, 2, 3, . . . , 11. Create a table showing the approximations, the absolute errors, and the error ratios for the various n. (c) Comment on your results from Parts (a) and (b) and explain the relationship between the errors calculated and the theoretical error analysis from class. 3