Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. Given a smooth function f on an interval a, b, let 1(f; a, b) = J:f(z) dz. We

ID: 3600402 • Letter: 3

Question

3. Given a smooth function f on an interval a, b, let 1(f; a, b) = J:f(z) dz. We want to ap- proximate I(f; a, b) using the composite trapezoidal rule, which for N intervals is constructed as follows: Let h = (b-a)/N and zi = a + ih, for i = 0,1, , N. Then we define ar o) +f(xv) We expect that I(f; a, b) T(f;a, b, h). Write a program to implement this approach; the program should accept any integrand and should allow the user to specify the number of subdivision points desired. Consider f(x)-e on [1, 2 and use your code to show that the approximation is second order accurate, that is, e(A) = 11(f; a, b) _ TU; a, b, h)| = 0(h2).

Explanation / Answer

: We want the formula Z 1 0 f(x) dx = w1f(0) + w2f(x1) to hold for polynomials 1, x, x2,.... Plugging these into the formula, we obtain: f(x) = x0 Z 1 0 1 dx = x| 1 0 =1 = w1 · 1 + w2 · 1, f(x) = x1 Z 1 0 x dx = x2 2 1 0 = 1 2 = w1 · 0 + w2 · x1, f(x) = x2 Z 1 0 x2 dx = x3 3 1 0 = 1 3 = w1 · 0 + w2 · x2 1. We have 3 equations in 3 unknowns: w1 + w2 = 1, w2x1 = 1 2 , w2x2 1 = 1 3 , or w2 = 1 w1, x1(1 w1) = 1 2 , x2 1(1 w1) = 1 3 . Multiplying the second equation by x1 and subtracting the third equation, we obtain x1 = 2 3 . Then, w2 = 3 4 and w1 = 1 4 . Thus, the quadrature formula is Z 1 0 f(x) dx = 1 4 f(0) + 3 4 f 2 3 . XThe accuracy of this quadrature formula is n = 2, since this formula holds for polynomials 1, x, x2. We can check how well this formula approximates R 1 0 x3 dx: Z 1 0 x3 dx = 1 4 · 0 + 3 4 · 8 27 = 2 9 = 0.2222. X The exact value of this integral is Z 1 0 x3 dx = x4 4 1 0 = 1 4 = 0.2500.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote