

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Examples of computing derivatives using quotient rule, chain rule, centered difference approximation, and lagrange interpolation. The examples involve a complex function and demonstrate the advantages of using approximation methods over traditional differentiation rules.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Jim Lambers Math 105A Summer Session I 2003- Lecture 11 Examples
These examples correspond to Section 4.1 in the text.
Example Consider the function
f (x) =
sin^2
x^2 +x cos x−x
sin
( (^) √x− 1 √x (^2) +
Our goal is to compute f ′(0.25). Differentiating, using the Quotient Rule and the Chain Rule, we obtain
f ′(x) =
2 sin
x^2 +x cos x−x
cos
x^2 +x cos x−x
2 x+ 2 √x^2 +1(cos x−x) +
√x (^2) +1(sin x+1) (cos x−x)^2
sin
( (^) √x− 1 √x (^2) +
sin
x^2 +x cos x−x
cos
( (^) √x− 1 √x (^2) +
1 2 √x√x^2 +1 −^
x(√x−1) (x^2 +1)^3 /^2
sin^2
( (^) √x− 1 √x (^2) +
Evaluating this monstrous function at x = 0.25 yields f ′(0.25) = − 9. 066698770. An alternative approach is to use a centered difference approximation,
f ′(x) ≈ f^ (x^ +^ h)^ −^ f^ (x^ −^ h) 2 h
Using this formula with x = 0.25 and h = 0.005, we obtain the approximation
f ′(0.25) ≈
f (0.255) − f (0.245)
which has absolute error 7. 7 × 10 −^4. While this complicated function must be evaluated twice to obtain this approximation, that is still much less work than using differentiation rules to compute f ′(x), and then evaluating f ′(x), which is much more complicated than f (x). 2
Example We will construct a formula for approximating f ′(x) at a given point x 0 by interpolating f (x) at the points x 0 , x 0 + h, and x 0 + 2h using a second-degree polynomial p 2 (x), and then approximating f ′(x 0 ) by p′ 2 (x 0 ). Since p 2 (x) should be a good approximation of f (x) near x 0 , especially when h is small, its derivative should be a good approximation to f ′(x) near this point. Using Lagrange interpolation, we obtain
p 2 (x) = f (x 0 )L 2 , 0 (x) + f (x 0 + h)L 2 , 1 (x) + f (x 0 + 2h)L 2 , 2 (x),
1
where {L 2 ,j (x)}^2 j=0 are the Lagrange polynomials for the points x 0 , x 1 = x 0 + h and x 2 = x 0 + 2h. Recall that these polynomials satisfy
L 2 ,j (xk) = δjk =
1 if j = k 0 otherwise. Using the formula for the Lagrange polynomials,
L 2 ,j (x) =
i=0,i 6 =j
(x − xi) (xj − xi) ,
we obtain
L 2 , 0 (x) = (x^ −^ (x^0 +^ h))(x^ −^ (x^0 + 2h)) (x 0 − (x 0 + h))(x 0 − (x 0 + 2h))
= x
(^2) − (2x 0 + 3h)x + (x 0 + h)(x 0 + 2h) 2 h^2 , L 2 , 1 (x) = (^) (x (x^ −^ x^0 )(x^ −^ (x^0 + 2h)) 0 +^ h^ −^ x 0 )(x 0 +^ h^ −^ (x 0 + 2h)) =
x^2 − (2x 0 + 2h)x + x 0 (x 0 + 2h) −h^2 , L 2 , 2 (x) =
(x − x 0 )(x − (x 0 + h)) (x 0 + 2h − x 0 )(x 0 + 2h − (x 0 + h))
= x
(^2) − (2x 0 + h)x + x 0 (x 0 + h) 2 h^2
It follows that
L′ 2 , 0 (x) = 2 x^ −^ (2x^0 + 3h) 2 h^2 L′ 2 , 1 (x) = − 2 x^ −^ (2x^0 + 2h) h^2 L′ 2 , 2 (x) = 2 x^ −^ (2x^0 +^ h) 2 h^2 We conclude that f ′(x 0 ) ≈ p′ 2 (x 0 ), where p′ 2 (x 0 ) = f (x 0 )L′ 2 , 0 (x 0 ) + f (x 0 + h)L′ 2 , 0 (x 0 ) + f (x 0 + 2h)L′ 2 , 0 (x 0 )
≈ f (x 0 )
2 h +^ f^ (x^0 +^ h)
h +^ f^ (x^0 + 2h)^
2 h ≈
3 f (x 0 ) + 4f (x 0 + h) − f (x 0 + 2h) 2 h. Using Taylor’s Theorem to write f (x 0 + h) and f (x 0 + 2h) in terms of Taylor polynomials centered at x 0 , it can be shown that the error in this approximation is O(h^2 ), and that this formula is exact when f (x) is a polynomial of degree 2 or less. 2