First Semester in Numerical Analysis with Julia, 2020a
First Semester in Numerical Analysis with Julia, 2020a
First Semester in Numerical Analysis with Julia, 2020a
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CHAPTER 4. NUMERICAL QUADRATURE AND DIFFERENTIATION 143<br />
role of f(x). Apply<strong>in</strong>g the theorem, we get<br />
∫ b<br />
(x − a)(x − b)f ′′ (ξ(x))dx = f ′′ (ξ)<br />
∫ b<br />
a<br />
a<br />
(x − a)(x − b)dx<br />
where we kept the same notation ξ, somewhat <strong>in</strong>appropriately, as we moved f ′′ (ξ(x))<br />
from <strong>in</strong>side to the outside of the <strong>in</strong>tegral. F<strong>in</strong>ally, observe that<br />
∫ b<br />
a<br />
(x − a)(x − b)dx =<br />
(a − b)3<br />
6<br />
= −h3<br />
6 ,<br />
where h = b − a. Putt<strong>in</strong>g all the pieces together, we have obta<strong>in</strong>ed<br />
∫ b<br />
a<br />
f(x)dx = h 2 [f(x 0)+f(x 1 )] − h3<br />
12 f ′′ (ξ).<br />
• Simpson’s rule<br />
Let f ∈ C 4 [a, b]. Take three equally-spaced nodes, x 0 = a, x 1 = a + h, x 2 = b, where<br />
h = b−a , and use the second degree Lagrange polynomial<br />
2<br />
P 2 (x) = (x − x 1)(x − x 2 )<br />
(x 0 − x 1 )(x 0 − x 2 ) f(x 0)+ (x − x 0)(x − x 2 )<br />
(x 1 − x 0 )(x 1 − x 2 ) f(x 1)+ (x − x 0)(x − x 1 )<br />
(x 2 − x 0 )(x 2 − x 1 ) f(x 2)<br />
to estimate f(x). Substitute n =2<strong>in</strong> Equation (4.1) toget<br />
∫ b<br />
a<br />
f(x)dx =<br />
∫ b<br />
and then substitute for P 2 to obta<strong>in</strong><br />
∫ b<br />
a<br />
f(x)dx =<br />
+<br />
∫ b<br />
a<br />
∫ b<br />
a<br />
a<br />
P 2 (x)dx + 1 3!<br />
∫ b<br />
∫<br />
(x − x 1 )(x − x 2 )<br />
b<br />
(x 0 − x 1 )(x 0 − x 2 ) f(x 0)dx +<br />
(x − x 0 )(x − x 1 )<br />
(x 2 − x 0 )(x 2 − x 1 ) f(x 2)dx + 1 6<br />
a<br />
2∏<br />
(x − x i )f (3) (ξ(x))dx,<br />
i=0<br />
a<br />
∫ b<br />
(x − x 0 )(x − x 2 )<br />
(x 1 − x 0 )(x 1 − x 2 ) f(x 1)dx+<br />
a<br />
(x − x 0 )(x − x 1 )(x − x 2 )f (3) (ξ(x))dx.<br />
The sum of the first three <strong>in</strong>tegrals on the right-hand side simplify as:<br />
h<br />
[f(x 3 0)+4f(x 1 )+f(x 2 )]. The last <strong>in</strong>tegral cannot be evaluated us<strong>in</strong>g Theorem 65<br />
directly, like <strong>in</strong> the trapezoidal rule, s<strong>in</strong>ce the function (x − x 0 )(x − x 1 )(x − x 2 ) changes<br />
sign on [a, b]. However, a clever application of <strong>in</strong>tegration by parts transforms the<br />
<strong>in</strong>tegral to an <strong>in</strong>tegral where Theorem 65 is applicable (see Atk<strong>in</strong>son [3] for details),