29.06.2014 Views

Numerical Differentiation First Derivative Second Derivative Error ...

Numerical Differentiation First Derivative Second Derivative Error ...

Numerical Differentiation First Derivative Second Derivative Error ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Exercise: differentiation II<br />

Central Difference<br />

1 xls/Lect13.xls<br />

2 Best precision at k = 8. When h k is too small, f(1) and f(1 + h k ) are very close<br />

together. The difference f(1 + h k ) − f(1) can exhibit the problem of loss of<br />

significance due to the substraction of quantities that are nearly equal.<br />

we have looked at approximating f ′ (x) with the backward D − (h) and forward<br />

difference D + (h).<br />

Now we just check out the approximation with the central difference:<br />

f ′ (x) ≃ D 0 (h) =<br />

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

2h<br />

Richardson extrapolation<br />

<strong>Error</strong> analysis of Central Difference I<br />

<strong>Error</strong> analysis of Central Difference II<br />

We consider the error in the Central Difference estimate (D 0 (h)) of f ′ (x):<br />

We apply Taylor’s Theorem,<br />

D 0 (h) =<br />

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

2!<br />

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

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

2h<br />

2!<br />

+ f ′′′ (x)h 3<br />

3!<br />

− f ′′′ (x)h 3<br />

3!<br />

(A) − (B) = 2f ′ (x)h + 2 f ′′′ (x)h 3<br />

3!<br />

(A) − (B)<br />

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

2h<br />

3!<br />

+ f (4) (x)h 4<br />

4!<br />

+ f (4) (x)h 4<br />

4!<br />

+ 2 f (5) (x)h 5<br />

5!<br />

+ f (5) (x)h 4<br />

5!<br />

+ · · · (A)<br />

+ · · · (B)<br />

+ · · ·<br />

+ · · ·<br />

We see that the difference can be written as<br />

or alternatively, as<br />

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

6<br />

where be know how to compute b 1 , b 2 , etc.<br />

h 2 + f (4) (x)<br />

+ · · ·<br />

24<br />

D 0 (h) = f ′ (x) + b 1 h 2 + b 2 h 4 + · · ·<br />

We see that the error R T = D 0 (h) − f ′ (x) is O(h 2 ).<br />

Remark. Remember: for D − and D + , the error is O(h).<br />

<strong>Error</strong> analysis of Central Difference III<br />

Rounding <strong>Error</strong> in Difference Equations I<br />

Example.<br />

Let try again the example:<br />

f(x) = e x<br />

We evaluate f ′ (1) = e 1 ≈ 2.71828... with<br />

for h = 10 −k , k ≥ 1.<br />

D 0 (h) =<br />

<strong>Numerical</strong> values: xls/Lect13.xls<br />

f ′ (x) = e x<br />

f(1 + h) − f(1 − h)<br />

2h<br />

When presenting the iterative techniques for root-finding, we ignored rounding<br />

errors, and paid no attention to the potential error problems with performing<br />

subtraction. This did not matter for such techniques because:<br />

1 the techniques are self-correcting, and tend to cancel out the accumulation of rounding<br />

errors<br />

2 the iterative equation x n+1 = x n − c n where c n is some form of correction factor has a<br />

subtraction which is safe because we are subtracting a small quantity (c n) from a large<br />

one (e.g. for Newton-Raphson, c n = f(x)<br />

f ′ (x) ).

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

Saved successfully!

Ooh no, something went wrong!