First Semester in Numerical Analysis with Julia, 2020a
First Semester in Numerical Analysis with Julia, 2020a
First Semester in Numerical Analysis with Julia, 2020a
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 169<br />
This formula gives an obvious way to estimate the derivative by<br />
f ′ (x 0 ) ≈ f(x 0 + h) − f(x 0 )<br />
h<br />
for small h. What this formula lacks, however, is it does not give any <strong>in</strong>formation about the<br />
error of the approximation.<br />
We will try another approach. Similar to Newton-Cotes quadrature, we will construct<br />
the <strong>in</strong>terpolat<strong>in</strong>g polynomial for f, and then use the derivative of the polynomial as an<br />
approximation for the derivative of f.<br />
Let’s assume f ∈ C 2 (a, b),x 0 ∈ (a, b), and x 0 + h ∈ (a, b). Construct the l<strong>in</strong>ear Lagrange<br />
<strong>in</strong>terpolat<strong>in</strong>g polynomial p 1 (x) for the data (x 0 ,f(x 0 )), (x 1 ,f(x 1 )) = (x 0 + h, f(x 0 + h)).<br />
From Theorem 51, wehave<br />
f(x) = x − x 1<br />
f(x 0 )+ x − x 0<br />
f(x 1 ) + f ′′ (ξ(x))<br />
(x − x 0 )(x − x 1 )<br />
x 0 − x 1 x 1 − x<br />
} {{ 0 2!<br />
} } {{ }<br />
p 1 (x)<br />
<strong>in</strong>terpolation error<br />
= x − (x 0 + h)<br />
x 0 − (x 0 + h) f(x 0)+ x − x 0<br />
f(x 0 + h)+ f ′′ (ξ(x))<br />
(x − x 0 )(x − x 0 − h)<br />
x 0 + h − x 0 2!<br />
= x − x 0 − h<br />
f(x 0 )+ x − x 0<br />
f(x 0 + h)+ f ′′ (ξ(x))<br />
(x − x 0 )(x − x 0 − h).<br />
−h<br />
h<br />
2!<br />
Now let’s differentiate f(x) :<br />
f ′ (x) =− f(x 0)<br />
h<br />
= f(x 0 + h) − f(x 0 )<br />
h<br />
+ f(x 0 + h)<br />
h<br />
+ f ′′ (ξ(x)) d<br />
dx<br />
+ (x − x 0)(x − x 0 − h)<br />
2<br />
+ 2x − 2x 0 − h<br />
2<br />
[ ]<br />
(x − x0 )(x − x 0 − h)<br />
2<br />
d<br />
dx [f ′′ (ξ(x))]<br />
f ′′ (ξ(x)) + (x − x 0)(x − x 0 − h)<br />
f ′′′ (ξ(x))ξ ′ (x).<br />
2<br />
In the above equation, we know ξ is between x 0 and x 0 + h, however, we have no knowledge<br />
about ξ ′ (x), which appears <strong>in</strong> the last term. Fortunately, if we set x = x 0 , the term <strong>with</strong><br />
ξ ′ (x) vanishes and we get:<br />
f ′ (x 0 )= f(x 0 + h) − f(x 0 )<br />
h<br />
− h 2 f ′′ (ξ(x 0 )).<br />
This formula is called the forward-difference formula if h>0 and backward-difference