06.09.2021 Views

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

First Semester in Numerical Analysis with Julia, 2020a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 4. NUMERICAL QUADRATURE AND DIFFERENTIATION 142<br />

The first <strong>in</strong>tegral on the right-hand side gives the quadrature rule:<br />

⎛ ⎞<br />

∫ b<br />

∫ (<br />

b n∑<br />

)<br />

n∑<br />

∫ b<br />

P n (x)dx = f(x i )l i (x) dx = ⎜<br />

⎝ l i (x)dx⎟<br />

⎠ f(x i)=<br />

a<br />

a i=0<br />

i=0 a<br />

} {{ }<br />

w i<br />

n∑<br />

w i f(x i ),<br />

i=0<br />

and the second <strong>in</strong>tegral gives the error term.<br />

We obta<strong>in</strong> different quadrature rules by tak<strong>in</strong>g different nodes, or number of nodes. The<br />

follow<strong>in</strong>g result is useful <strong>in</strong> the theoretical analysis of Newton-Cotes formulas.<br />

Theorem 65 (Weighted mean value theorem for <strong>in</strong>tegrals). Suppose f ∈ C 0 [a, b], the Riemann<br />

<strong>in</strong>tegral of g(x) exists on [a, b], and g(x) does not change sign on [a, b]. Then there<br />

exists ξ ∈ (a, b) <strong>with</strong> ∫ b<br />

f(x)g(x)dx = f(ξ) ∫ b<br />

g(x)dx.<br />

a a<br />

Two well-known numerical quadrature rules, trapezoidal rule and Simpson’s rule, are<br />

examples of Newton-Cotes formulas:<br />

• Trapezoidal rule<br />

Let f ∈ C 2 [a, b]. Take two nodes, x 0 = a, x 1 = b, and use the l<strong>in</strong>ear Lagrange<br />

polynomial<br />

P 1 (x) = x − x 1<br />

f(x 0 )+ x − x 0<br />

f(x 1 )<br />

x 0 − x 1 x 1 − x 0<br />

to estimate f(x). Substitute n =1<strong>in</strong> Equation (4.1) toget<br />

∫ b<br />

a<br />

f(x)dx =<br />

∫ b<br />

a<br />

P 1 (x)dx + 1 2<br />

∫ b<br />

and then substitute for P 1 to obta<strong>in</strong><br />

∫ b ∫ b<br />

∫<br />

x − x b<br />

1<br />

x − x 0<br />

f(x)dx =<br />

f(x 0 )dx +<br />

f(x 1 )dx + 1<br />

a<br />

a x 0 − x 1 a x 1 − x 0 2<br />

a<br />

1∏<br />

(x − x i )f ′′ (ξ(x))dx,<br />

i=0<br />

∫ b<br />

a<br />

(x − x 0 )(x − x 1 )f ′′ (ξ(x))dx.<br />

The first two <strong>in</strong>tegrals on the right-hand side can be evaluated easily: the first <strong>in</strong>tegral<br />

is hf(x 2 0) and the second one is hf(x 2 1), where h = x 1 − x 0 = b − a. Let’s evaluate<br />

∫ b<br />

a<br />

(x − x 0 )(x − x 1 )f ′′ (ξ(x))dx.<br />

We will use Theorem 65 for this computation. Note that the function (x−x 0 )(x−x 1 )=<br />

(x − a)(x − b) does not change sign on the <strong>in</strong>terval [a, b] and it is <strong>in</strong>tegrable: so this<br />

function serves the role of g(x) <strong>in</strong> Theorem 65. The other term, f ′′ (ξ(x)), serves the

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!