# Numerical Differentiation

2/22/2012

1

First Order Derivative 

First Order Taylor Series for x closed to x0

P

x } f ( x0 )  f ' ( x0 ).

x  x0 1 P .

x  f ( x0 ) 1 f ' ( x0 ) } .

x  x0 by Adam Pamudji R 2/22/2012 2 .

graphical explanation f ' ( x0 ) backward difference forward difference f ( x0 ) f ( x ) } P1 .

x f ( x ) } P1 .

x x<x0 P .

x } f ( x0 )  f ' ( x0 ).

x  x0 1 f ' ( x0 ) } 2/22/2012 x0 x>x0 P .

x  f ( x0 ) 1 .

x  x0 f .

x  f ( x0 ) f ' ( x0 ) } .

x  x0 by Adam Pamudji R 3 .

If x = x0 + h. then for forward difference we have f .

x0  h  f ( x0 ) f ' ( x0 ) } h If x = x0 . then for backward difference we have f ' ( x0 ) } f .h.

x0  h  f ( x0 ) f ( x0 )  f .

x0  h ! h h 2/22/2012 by Adam Pamudji R 4 .

First Order Derivative  Second Order Taylor Series for x closed to x0 f ' ' ( x0 ).

x  x0 P2 .

x } f ( x0 )  f ' ( x0 ).

x  x0  2! f ' ' ( x0 )h 2 f .

x0  h } f ( x0 )  f ' ( x0 )h  2 f ' ' ( x0 )h 2 f .

x0  h } f ( x0 )  f ' ( x0 )h  2 f .

x0  h  f .

x0  h } 0  2h f ' ( x0 )  0 f .

x0  h  f .

x0  h f ' ( x0 ) } 2h 2 2/22/2012 by Adam Pamudji R 5 .

graphical explanation f ' ( x0 ) central difference f ( x0 ) f ( x0  h ) f ( x0  h ) x0-h x0 x0+h f .

x0  h  f ( x0  h) f ' ( x0 ) } 2h 2/22/2012 by Adam Pamudji R 6 .

Reading Assignment Please read page 146 to 150 section 4.1 for another approach Find about:     The three point formulas The five point formulas 2/22/2012 by Adam Pamudji R 7 .

Second Order Derivative  Second Order Taylor Series for x closed to x0 f ' ' ( x0 )h 2 f .

x0  h } f ( x0 )  f ' ( x0 )h  2 f ' ' ( x0 )h 2 f .

x0  h } f ( x0 )  f ' ( x0 )h  2 f .

x0  h  f .

x0  h } 2 f ( x0 )  0  f ' ' ( x0 )h 2 f .

x0  h  2 f ( x0 )  f .

x0  h f ' ' ( x0 ) } h2 2/22/2012 by Adam Pamudji R 8 .

Read page 145 and 146 2/22/2012 by Adam Pamudji R 9 .Differentiation from interpolation function   The use of polynomials in approximation problems allow us to find the derivative and integral from that functions.

Differentiation and Integration Pn .

x } f .

x Pn ' .

x } f ' .

x Pn .

x dx } ´ f .

x dx ´ 2/22/2012 by Adam Pamudji R 10 .

Differentiation d ¨ ¸ Pn ' .

x ! © § f .

xi Ln .i .

x ¹ dx ª i !0 º n !§ i !0 2/22/2012 n d f .

xi .

Ln .i .

x dx by Adam Pamudji R 11 .

i .Differentiation Ln.

x  x .

x !  .

x  x n j j !0 j {i i j ¸ ¨ ¹ n © n d 1 © .

x  x ¹ .

i .Ln.

x ! n §© l ¹ dx j !0 l !0 ¹  .

xi  x j j {i © ll {ij º ª { j !0 j {i 2/22/2012 by Adam Pamudji R 12 .

Numerical Integration  We can use the interpolation function to approximate an integral x !b b f .

x } Pn .

x ´ f .

x dx } ´ P .

x dx n ¨ n ¸ ´aPn .

x dx ! ´ © § f .

i .xi Ln.

x ¹dx º x! a ª i !0 dx ! § f .

xi ´ .

Ln .i .

x i !0 a 13 2/22/2012 by Adam Pamudji R n b .

Numerical Integration  For the first and second Lagrange polynomials with equally spaced nodes   Trapezoidal rule Simpson s rule   Read page 163 to 165 Learn about closed and open NewtonNewtonCotes formulas (p 168 to p 173) by Adam Pamudji R 14 2/22/2012 .

Trapezoidal rule   For function f(x) between x0=a and x1=b h = x1 x0 y ´ b a h h3 f ( x)dx ! ?f ( x0 )  f ( x1 )A f ' ' (\ ) 2 12 f P1 a=x0 2/22/2012 b=x1 by Adam Pamudji R x 15 .

Simpson rule  For function f(x) between x0=a and x2=b y f ´ b a f ( x) dx ! h ?f ( x0 )  4 f ( x1 )  f ( x2 )A 3 h5 ( 4) f (\ )  90 P1 a=x0 2/22/2012 x1 b=x2 x 16 by Adam Pamudji R .

Closed and Open Newton-Cotes Newton Closed N-C N   Trapezoidal rule Simpson s rule Simpson s three-eight rule threey f P1  Open N-C N   Midpoint rules: n=0 n=1 n=2 by Adam Pamudji R 2/22/2012 a=x-1 x0 b=x1 x 17 .

Examples  See the excel file 2/22/2012 by Adam Pamudji R 18 .

1] [- 2/22/2012 by Adam Pamudji R 19 . it is necessary to transform linearly the function to an interval [-1. By using a standard tabulated coeff and node positions.Numerical Integration  Gaussian Quadrature    For a given known function Optimizing accuracy by selecting best position of nodes.

Gauss Quadrature   Read page 198 to 204 Example file 2/22/2012 by Adam Pamudji R 20 .