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 171<br />

x 0 +2h. Then, we obta<strong>in</strong><br />

f ′ (x 0 )= 1<br />

2h [−3f(x 0)+4f(x 0 + h) − f(x 0 +2h)] + h2<br />

3 f (3) (ξ 0 ) (4.11)<br />

f ′ (x 0 + h) = 1<br />

2h [−f(x 0)+f(x 0 +2h)] − h2<br />

6 f (3) (ξ 1 ) (4.12)<br />

f ′ (x 0 +2h) = 1<br />

2h [f(x 0) − 4f(x 0 + h)+3f(x 0 +2h)] + h2<br />

3 f (3) (ξ 2 ). (4.13)<br />

It turns out that the first and third equations ((4.11) and(4.13)) are equivalent. To see<br />

this, first substitute x 0 by x 0 − 2h <strong>in</strong> the third equation to get (ignor<strong>in</strong>g the error term)<br />

f ′ (x 0 )= 1<br />

2h [f(x 0 − 2h) − 4f(x 0 − h)+3f(x 0 )] ,<br />

and then set h to −h <strong>in</strong> the right-hand side to get 1 [−f(x 2h 0 +2h)+4f(x 0 + h) − 3f(x 0 )],<br />

which gives us the first equation.<br />

Therefore we have only two dist<strong>in</strong>ct equations, (4.11) and(4.12). We rewrite these<br />

equations below <strong>with</strong> one modification: <strong>in</strong> (4.12), we substitute x 0 by x 0 − h. We then<br />

obta<strong>in</strong> two different formulas for f ′ (x 0 ):<br />

f ′ (x 0 )= −3f(x 0)+4f(x 0 + h) − f(x 0 +2h)<br />

2h<br />

f ′ (x 0 )= f(x 0 + h) − f(x 0 − h)<br />

2h<br />

+ h2<br />

3 f (3) (ξ 0 ) → three-po<strong>in</strong>t endpo<strong>in</strong>t formula<br />

− h2<br />

6 f (3) (ξ 1 ) → three-po<strong>in</strong>t midpo<strong>in</strong>t formula<br />

The three-po<strong>in</strong>t midpo<strong>in</strong>t formula has some advantages: it has half the error of the endpo<strong>in</strong>t<br />

formula, and it has one less function evaluation. The endpo<strong>in</strong>t formula is useful if one does<br />

not know the value of f on one side; a situation that may happen if x 0 is close to an endpo<strong>in</strong>t.<br />

Example 84. The follow<strong>in</strong>g table gives the values of f(x) =s<strong>in</strong>x. Estimate f ′ (0.1),f ′ (0.3)<br />

us<strong>in</strong>g an appropriate three-po<strong>in</strong>t formula.<br />

x f(x)<br />

0.1 0.09983<br />

0.2 0.19867<br />

0.3 0.29552<br />

0.4 0.38942<br />

Solution. To estimate f ′ (0.1), we set x 0 =0.1, and h =0.1. Note that we can only use the<br />

three-po<strong>in</strong>t endpo<strong>in</strong>t formula.<br />

f ′ (0.1) ≈ 1 (−3(0.09983) + 4(0.19867) − 0.29552) = 0.99835.<br />

0.2

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

Saved successfully!

Ooh no, something went wrong!