Numerical Differentiation & Integration Numerical - - PowerPoint PPT Presentation

numerical differentiation integration numerical
SMART_READER_LITE
LIVE PREVIEW

Numerical Differentiation & Integration Numerical - - PowerPoint PPT Presentation

Numerical Differentiation & Integration Numerical Differentiation I Numerical Analysis (9th Edition) R L Burden & J D Faires Beamer Presentation Slides prepared by John Carroll Dublin City University c 2011 Brooks/Cole, Cengage


slide-1
SLIDE 1

Numerical Differentiation & Integration Numerical Differentiation I

Numerical Analysis (9th Edition) R L Burden & J D Faires

Beamer Presentation Slides prepared by John Carroll Dublin City University

c 2011 Brooks/Cole, Cengage Learning

slide-2
SLIDE 2

Introduction General Formulas 3-pt Formulas

Outline

1

Introduction to Numerical Differentiation

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 2 / 33

slide-3
SLIDE 3

Introduction General Formulas 3-pt Formulas

Outline

1

Introduction to Numerical Differentiation

2

General Derivative Approximation Formulas

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 2 / 33

slide-4
SLIDE 4

Introduction General Formulas 3-pt Formulas

Outline

1

Introduction to Numerical Differentiation

2

General Derivative Approximation Formulas

3

Some useful three-point formulas

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 2 / 33

slide-5
SLIDE 5

Introduction General Formulas 3-pt Formulas

Outline

1

Introduction to Numerical Differentiation

2

General Derivative Approximation Formulas

3

Some useful three-point formulas

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 3 / 33

slide-6
SLIDE 6

Introduction General Formulas 3-pt Formulas

Introduction to Numerical Differentiation

Approximating a Derivative

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 4 / 33

slide-7
SLIDE 7

Introduction General Formulas 3-pt Formulas

Introduction to Numerical Differentiation

Approximating a Derivative

The derivative of the function f at x0 is f ′(x0) = lim

h→0

f(x0 + h) − f(x0) h .

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 4 / 33

slide-8
SLIDE 8

Introduction General Formulas 3-pt Formulas

Introduction to Numerical Differentiation

Approximating a Derivative

The derivative of the function f at x0 is f ′(x0) = lim

h→0

f(x0 + h) − f(x0) h . This formula gives an obvious way to generate an approximation to f ′(x0); simply compute f(x0 + h) − f(x0) h for small values of h. Although this may be obvious, it is not very successful, due to our old nemesis round-off error.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 4 / 33

slide-9
SLIDE 9

Introduction General Formulas 3-pt Formulas

Introduction to Numerical Differentiation

Approximating a Derivative

The derivative of the function f at x0 is f ′(x0) = lim

h→0

f(x0 + h) − f(x0) h . This formula gives an obvious way to generate an approximation to f ′(x0); simply compute f(x0 + h) − f(x0) h for small values of h. Although this may be obvious, it is not very successful, due to our old nemesis round-off error. But it is certainly a place to start.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 4 / 33

slide-10
SLIDE 10

Introduction General Formulas 3-pt Formulas

Introduction to Numerical Differentiation

Approximating a Derivative (Cont’d)

To approximate f ′(x0), suppose first that x0 ∈ (a, b), where f ∈ C2[a, b], and that x1 = x0 + h for some h = 0 that is sufficiently small to ensure that x1 ∈ [a, b].

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 5 / 33

slide-11
SLIDE 11

Introduction General Formulas 3-pt Formulas

Introduction to Numerical Differentiation

Approximating a Derivative (Cont’d)

To approximate f ′(x0), suppose first that x0 ∈ (a, b), where f ∈ C2[a, b], and that x1 = x0 + h for some h = 0 that is sufficiently small to ensure that x1 ∈ [a, b]. We construct the first Lagrange polynomial P0,1(x) for f determined by x0 and x1, with its error term:

f(x) = P0,1(x) + (x − x0)(x − x1) 2! f ′′(ξ(x)) = f(x0)(x − x0 − h) −h + f(x0 + h)(x − x0) h + (x − x0)(x − x0 − h) 2 f ′′(ξ(x))

for some ξ(x) between x0 and x1.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 5 / 33

slide-12
SLIDE 12

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

f(x) = f(x0)(x − x0 − h) −h + f(x0 + h)(x − x0) h + (x − x0)(x − x0 − h) 2 f ′′(ξ(x))

Differentiating gives f ′(x) = f(x0 + h) − f(x0) h + Dx (x − x0)(x − x0 − h) 2 f ′′(ξ(x))

  • Numerical Analysis (Chapter 4)

Numerical Differentiation I R L Burden & J D Faires 6 / 33

slide-13
SLIDE 13

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

f(x) = f(x0)(x − x0 − h) −h + f(x0 + h)(x − x0) h + (x − x0)(x − x0 − h) 2 f ′′(ξ(x))

Differentiating gives f ′(x) = f(x0 + h) − f(x0) h + Dx (x − x0)(x − x0 − h) 2 f ′′(ξ(x))

  • =

f(x0 + h) − f(x0) h + 2(x − x0) − h 2 f ′′(ξ(x)) + (x − x0)(x − x0 − h) 2 Dx(f ′′(ξ(x)))

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 6 / 33

slide-14
SLIDE 14

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

f(x) = f(x0)(x − x0 − h) −h + f(x0 + h)(x − x0) h + (x − x0)(x − x0 − h) 2 f ′′(ξ(x))

Differentiating gives f ′(x) = f(x0 + h) − f(x0) h + Dx (x − x0)(x − x0 − h) 2 f ′′(ξ(x))

  • =

f(x0 + h) − f(x0) h + 2(x − x0) − h 2 f ′′(ξ(x)) + (x − x0)(x − x0 − h) 2 Dx(f ′′(ξ(x))) Deleting the terms involving ξ(x) gives f ′(x) ≈ f(x0 + h) − f(x0) h

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 6 / 33

slide-15
SLIDE 15

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

f ′(x) ≈ f(x0 + h) − f(x0) h

Approximating a Derivative (Cont’d)

One difficulty with this formula is that we have no information about Dxf ′′(ξ(x)), so the truncation error cannot be estimated.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 7 / 33

slide-16
SLIDE 16

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

f ′(x) ≈ f(x0 + h) − f(x0) h

Approximating a Derivative (Cont’d)

One difficulty with this formula is that we have no information about Dxf ′′(ξ(x)), so the truncation error cannot be estimated. When x is x0, however, the coefficient of Dxf ′′(ξ(x)) is 0, and the formula simplifies to f ′(x0) = f(x0 + h) − f(x0) h − h 2f ′′(ξ)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 7 / 33

slide-17
SLIDE 17

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

f ′(x0) = f(x0 + h) − f(x0) h − h 2f ′′(ξ)

Forward-Difference and Backward-Difference Formulae

For small values of h, the difference quotient f(x0 + h) − f(x0) h can be used to approximate f ′(x0) with an error bounded by M|h|/2, where M is a bound on |f ′′(x)| for x between x0 and x0 + h.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 8 / 33

slide-18
SLIDE 18

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

f ′(x0) = f(x0 + h) − f(x0) h − h 2f ′′(ξ)

Forward-Difference and Backward-Difference Formulae

For small values of h, the difference quotient f(x0 + h) − f(x0) h can be used to approximate f ′(x0) with an error bounded by M|h|/2, where M is a bound on |f ′′(x)| for x between x0 and x0 + h. This formula is known as the forward-difference formula if h > 0 and the backward-difference formula if h < 0.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 8 / 33

slide-19
SLIDE 19

Introduction General Formulas 3-pt Formulas

Forward-Difference Formula to Approximate f ′(x0)

y x x0 Slope f9(x0) Slope h f(x0 1 h) 2 f(x0) x0 1 h

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 9 / 33

slide-20
SLIDE 20

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

Example 1: f(x) = ln x

Use the forward-difference formula to approximate the derivative of f(x) = ln x at x0 = 1.8 using h = 0.1, h = 0.05, and h = 0.01, and determine bounds for the approximation errors.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 10 / 33

slide-21
SLIDE 21

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

Example 1: f(x) = ln x

Use the forward-difference formula to approximate the derivative of f(x) = ln x at x0 = 1.8 using h = 0.1, h = 0.05, and h = 0.01, and determine bounds for the approximation errors.

Solution (1/3)

The forward-difference formula f(1.8 + h) − f(1.8) h with h = 0.1

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 10 / 33

slide-22
SLIDE 22

Introduction General Formulas 3-pt Formulas

Numerical Differentiation

Example 1: f(x) = ln x

Use the forward-difference formula to approximate the derivative of f(x) = ln x at x0 = 1.8 using h = 0.1, h = 0.05, and h = 0.01, and determine bounds for the approximation errors.

Solution (1/3)

The forward-difference formula f(1.8 + h) − f(1.8) h with h = 0.1 gives ln 1.9 − ln 1.8 0.1 = 0.64185389 − 0.58778667 0.1 = 0.5406722

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 10 / 33

slide-23
SLIDE 23

Introduction General Formulas 3-pt Formulas

Numerical Differentiation: Example 1

Solution (2/3)

Because f ′′(x) = −1/x2 and 1.8 < ξ < 1.9, a bound for this approximation error is |hf ′′(ξ)| 2 = |h| 2ξ2 < 0.1 2(1.8)2 = 0.0154321

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 11 / 33

slide-24
SLIDE 24

Introduction General Formulas 3-pt Formulas

Numerical Differentiation: Example 1

Solution (2/3)

Because f ′′(x) = −1/x2 and 1.8 < ξ < 1.9, a bound for this approximation error is |hf ′′(ξ)| 2 = |h| 2ξ2 < 0.1 2(1.8)2 = 0.0154321 The approximation and error bounds when h = 0.05 and h = 0.01 are found in a similar manner and the results are shown in the following table.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 11 / 33

slide-25
SLIDE 25

Introduction General Formulas 3-pt Formulas

Numerical Differentiation: Example 1

Solution (3/3): Tabulated Results

h f(1.8 + h) f(1.8 + h) − f(1.8) h |h| 2(1.8)2 0.1 0.64185389 0.5406722 0.0154321 0.05 0.61518564 0.5479795 0.0077160 0.01 0.59332685 0.5540180 0.0015432 Since f ′(x) = 1/x The exact value of f ′(1.8) is 0.555, and in this case the error bounds are quite close to the true approximation error.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 12 / 33

slide-26
SLIDE 26

Introduction General Formulas 3-pt Formulas

Outline

1

Introduction to Numerical Differentiation

2

General Derivative Approximation Formulas

3

Some useful three-point formulas

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 13 / 33

slide-27
SLIDE 27

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

Method of Construction

To obtain general derivative approximation formulas, suppose that {x0, x1, . . . , xn} are (n + 1) distinct numbers in some interval I and that f ∈ Cn+1(I). From the interpolation error theorem

Theorem we have

f(x) =

n

  • k=0

f(xk)Lk(x) + (x − x0) · · · (x − xn) (n + 1)! f (n+1)(ξ(x)) for some ξ(x) in I, where Lk(x) denotes the kth Lagrange coefficient polynomial for f at x0, x1, . . . , xn.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 14 / 33

slide-28
SLIDE 28

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

f(x) =

n

  • k=0

f(xk)Lk(x) + (x − x0) · · · (x − xn) (n + 1)! f (n+1)(ξ(x))

Method of Construction (Cont’d)

Differentiating this expression gives f ′(x) =

n

  • k=0

f(xk)L′

k(x) + Dx

(x − x0) · · · (x − xn) (n + 1!)

  • f (n+1)(ξ(x))

+ (x − x0) · · · (x − xn) (n + 1)! Dx[f (n+1)(ξ(x))]

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 15 / 33

slide-29
SLIDE 29

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

f ′(x) =

n

  • k=0

f(xk)L′

k(x) + Dx

(x − x0) · · · (x − xn) (n + 1!)

  • f (n+1)(ξ(x))

+ (x − x0) · · · (x − xn) (n + 1)! Dx[f (n+1)(ξ(x))]

Method of Construction (Cont’d)

We again have a problem estimating the truncation error unless x is

  • ne of the numbers xj.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 16 / 33

slide-30
SLIDE 30

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

f ′(x) =

n

  • k=0

f(xk)L′

k(x) + Dx

(x − x0) · · · (x − xn) (n + 1!)

  • f (n+1)(ξ(x))

+ (x − x0) · · · (x − xn) (n + 1)! Dx[f (n+1)(ξ(x))]

Method of Construction (Cont’d)

We again have a problem estimating the truncation error unless x is

  • ne of the numbers xj. In this case, the term multiplying

Dx[f (n+1)(ξ(x))] is 0, and the formula becomes f ′(xj) =

n

  • k=0

f(xk)L′

k(xj) + f (n+1)(ξ(xj))

(n + 1)!

n

  • k=0

k=j

(xj − xk)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 16 / 33

slide-31
SLIDE 31

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

f ′(x) =

n

  • k=0

f(xk)L′

k(x) + Dx

(x − x0) · · · (x − xn) (n + 1!)

  • f (n+1)(ξ(x))

+ (x − x0) · · · (x − xn) (n + 1)! Dx[f (n+1)(ξ(x))]

Method of Construction (Cont’d)

We again have a problem estimating the truncation error unless x is

  • ne of the numbers xj. In this case, the term multiplying

Dx[f (n+1)(ξ(x))] is 0, and the formula becomes f ′(xj) =

n

  • k=0

f(xk)L′

k(xj) + f (n+1)(ξ(xj))

(n + 1)!

n

  • k=0

k=j

(xj − xk) which is called an (n + 1)-point formula to approximate f ′(xj).

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 16 / 33

slide-32
SLIDE 32

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

f ′(xj) =

n

  • k=0

f(xk)L′

k(xj) + f (n+1)(ξ(xj))

(n + 1)!

n

  • k=0

k=j

(xj − xk)

Comment on the (n + 1)-point formula

In general, using more evaluation points produces greater accuracy, although the number of functional evaluations and growth of round-off error discourages this somewhat.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 17 / 33

slide-33
SLIDE 33

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

f ′(xj) =

n

  • k=0

f(xk)L′

k(xj) + f (n+1)(ξ(xj))

(n + 1)!

n

  • k=0

k=j

(xj − xk)

Comment on the (n + 1)-point formula

In general, using more evaluation points produces greater accuracy, although the number of functional evaluations and growth of round-off error discourages this somewhat. The most common formulas are those involving three and five evaluation points.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 17 / 33

slide-34
SLIDE 34

Introduction General Formulas 3-pt Formulas

General Derivative Approximation Formulas

f ′(xj) =

n

  • k=0

f(xk)L′

k(xj) + f (n+1)(ξ(xj))

(n + 1)!

n

  • k=0

k=j

(xj − xk)

Comment on the (n + 1)-point formula

In general, using more evaluation points produces greater accuracy, although the number of functional evaluations and growth of round-off error discourages this somewhat. The most common formulas are those involving three and five evaluation points. We first derive some useful three-point formulas and consider aspects

  • f their errors.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 17 / 33

slide-35
SLIDE 35

Introduction General Formulas 3-pt Formulas

Outline

1

Introduction to Numerical Differentiation

2

General Derivative Approximation Formulas

3

Some useful three-point formulas

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 18 / 33

slide-36
SLIDE 36

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Important Building Blocks

Since L0(x) = (x − x1)(x − x2) (x0 − x1)(x0 − x2)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 19 / 33

slide-37
SLIDE 37

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Important Building Blocks

Since L0(x) = (x − x1)(x − x2) (x0 − x1)(x0 − x2) we obtain L′

0(x) =

2x − x1 − x2 (x0 − x1)(x0 − x2)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 19 / 33

slide-38
SLIDE 38

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Important Building Blocks

Since L0(x) = (x − x1)(x − x2) (x0 − x1)(x0 − x2) we obtain L′

0(x) =

2x − x1 − x2 (x0 − x1)(x0 − x2) In a similar way, we find that L′

1(x)

= 2x − x0 − x2 (x1 − x0)(x1 − x2) L′

2(x)

= 2x − x0 − x1 (x2 − x0)(x2 − x1)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 19 / 33

slide-39
SLIDE 39

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Important Building Blocks (Cont’d)

Using these expressions for L′

j(x), 1 ≤ j ≤ 2, the n + 1-point formula

f ′(xj) =

n

  • k=0

f(xk)L′

k(xj) + f (n+1)(ξ(xj))

(n + 1)!

n

  • k=0

k=j

(xj − xk)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 20 / 33

slide-40
SLIDE 40

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Important Building Blocks (Cont’d)

Using these expressions for L′

j(x), 1 ≤ j ≤ 2, the n + 1-point formula

f ′(xj) =

n

  • k=0

f(xk)L′

k(xj) + f (n+1)(ξ(xj))

(n + 1)!

n

  • k=0

k=j

(xj − xk) becomes for n = 2: f ′(xj) = f(x0)

  • 2xj − x1 − x2

(x0 − x1)(x0 − x2)

  • + f(x1)
  • 2xj − x0 − x2

(x1 − x0)(x1 − x2)

  • + f(x2)
  • 2xj − x0 − x1

(x2 − x0)(x2 − x1)

  • + 1

6f (3)(ξj)

2

  • k=0

k=j

(xj − xk) for each j = 0, 1, 2, where ξj = ξj(x).

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 20 / 33

slide-41
SLIDE 41

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

f ′(xj) = f(x0)

  • 2xj − x1 − x2

(x0 − x1)(x0 − x2)

  • + f(x1)
  • 2xj − x0 − x2

(x1 − x0)(x1 − x2)

  • + f(x2)
  • 2xj − x0 − x1

(x2 − x0)(x2 − x1)

  • + 1

6f (3)(ξj)

2

  • k=0

k=j

(xj − xk)

Assumption

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 21 / 33

slide-42
SLIDE 42

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

f ′(xj) = f(x0)

  • 2xj − x1 − x2

(x0 − x1)(x0 − x2)

  • + f(x1)
  • 2xj − x0 − x2

(x1 − x0)(x1 − x2)

  • + f(x2)
  • 2xj − x0 − x1

(x2 − x0)(x2 − x1)

  • + 1

6f (3)(ξj)

2

  • k=0

k=j

(xj − xk)

Assumption

The 3-point formulas become especially useful if the nodes are equally spaced, that is, when x1 = x0 + h and x2 = x0 + 2h, for some h = 0

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 21 / 33

slide-43
SLIDE 43

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

f ′(xj) = f(x0)

  • 2xj − x1 − x2

(x0 − x1)(x0 − x2)

  • + f(x1)
  • 2xj − x0 − x2

(x1 − x0)(x1 − x2)

  • + f(x2)
  • 2xj − x0 − x1

(x2 − x0)(x2 − x1)

  • + 1

6f (3)(ξj)

2

  • k=0

k=j

(xj − xk)

Assumption

The 3-point formulas become especially useful if the nodes are equally spaced, that is, when x1 = x0 + h and x2 = x0 + 2h, for some h = 0 We will assume equally-spaced nodes throughout the remainder of this section.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 21 / 33

slide-44
SLIDE 44

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

f ′(xj) = f(x0)

  • 2xj − x1 − x2

(x0 − x1)(x0 − x2)

  • + f(x1)
  • 2xj − x0 − x2

(x1 − x0)(x1 − x2)

  • + f(x2)
  • 2xj − x0 − x1

(x2 − x0)(x2 − x1)

  • + 1

6f (3)(ξj)

2

  • k=0

k=j

(xj − xk)

Three-Point Formulas (1/3)

With xj = x0, x1 = x0 + h, and x2 = x0 + 2h, the general 3-point formula becomes f ′(x0) = 1 h

  • −3

2f(x0) + 2f(x1) − 1 2f(x2)

  • + h2

3 f (3)(ξ0)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 22 / 33

slide-45
SLIDE 45

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

f ′(xj) = f(x0)

  • 2xj − x1 − x2

(x0 − x1)(x0 − x2)

  • + f(x1)
  • 2xj − x0 − x2

(x1 − x0)(x1 − x2)

  • + f(x2)
  • 2xj − x0 − x1

(x2 − x0)(x2 − x1)

  • + 1

6f (3)(ξj)

2

  • k=0

k=j

(xj − xk)

Three-Point Formulas (2/3)

Doing the same for xj = x1 gives f ′(x1) = 1 h

  • −1

2f(x0) + 1 2f(x2)

  • − h2

6 f (3)(ξ1)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 23 / 33

slide-46
SLIDE 46

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

f ′(xj) = f(x0)

  • 2xj − x1 − x2

(x0 − x1)(x0 − x2)

  • + f(x1)
  • 2xj − x0 − x2

(x1 − x0)(x1 − x2)

  • + f(x2)
  • 2xj − x0 − x1

(x2 − x0)(x2 − x1)

  • + 1

6f (3)(ξj)

2

  • k=0

k=j

(xj − xk)

Three-Point Formulas (3/3)

. . . and for xj = x2, we obtain f ′(x2) = 1 h 1 2f(x0) − 2f(x1) + 3 2f(x2)

  • + h2

3 f (3)(ξ2)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 24 / 33

slide-47
SLIDE 47

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Formulas: Further Simplification

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 25 / 33

slide-48
SLIDE 48

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Formulas: Further Simplification

Since x1 = x0 + h and x2 = x0 + 2h, these formulas can also be expressed as f ′(x0) = 1 h

  • −3

2f(x0) + 2f(x0 + h) − 1 2f(x0 + 2h)

  • + h2

3 f (3)(ξ0) f ′(x0 + h) = 1 h

  • −1

2f(x0) + 1 2f(x0 + 2h)

  • − h2

6 f (3)(ξ1) f ′(x0 + 2h) = 1 h 1 2f(x0) − 2f(x0 + h) + 3 2f(x0 + 2h)

  • + h2

3 f (3)(ξ2)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 25 / 33

slide-49
SLIDE 49

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Formulas: Further Simplification

Since x1 = x0 + h and x2 = x0 + 2h, these formulas can also be expressed as f ′(x0) = 1 h

  • −3

2f(x0) + 2f(x0 + h) − 1 2f(x0 + 2h)

  • + h2

3 f (3)(ξ0) f ′(x0 + h) = 1 h

  • −1

2f(x0) + 1 2f(x0 + 2h)

  • − h2

6 f (3)(ξ1) f ′(x0 + 2h) = 1 h 1 2f(x0) − 2f(x0 + h) + 3 2f(x0 + 2h)

  • + h2

3 f (3)(ξ2) As a matter of convenience, the variable substitution x0 for x0 + h is used in the middle equation to change this formula to an approximation for f ′(x0). A similar change, x0 for x0 + 2h, is used in the last equation.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 25 / 33

slide-50
SLIDE 50

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Formulas: Further Simplification (Cont’d)

This gives three formulas for approximating f ′(x0):

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 26 / 33

slide-51
SLIDE 51

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Formulas: Further Simplification (Cont’d)

This gives three formulas for approximating f ′(x0): f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) f ′(x0) = 1 2h[−f(x0 − h) + f(x0 + h)] − h2 6 f (3)(ξ1), and f ′(x0) = 1 2h[f(x0 − 2h) − 4f(x0 − h) + 3f(x0)] + h2 3 f (3)(ξ2)

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 26 / 33

slide-52
SLIDE 52

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Formulas: Further Simplification (Cont’d)

This gives three formulas for approximating f ′(x0): f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) f ′(x0) = 1 2h[−f(x0 − h) + f(x0 + h)] − h2 6 f (3)(ξ1), and f ′(x0) = 1 2h[f(x0 − 2h) − 4f(x0 − h) + 3f(x0)] + h2 3 f (3)(ξ2) Finally, note that the last of these equations can be obtained from the first by simply replacing h with −h, so there are actually only two formulas.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 26 / 33

slide-53
SLIDE 53

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Endpoint Formula

f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) where ξ0 lies between x0 and x0 + 2h.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 27 / 33

slide-54
SLIDE 54

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

Three-Point Endpoint Formula

f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) where ξ0 lies between x0 and x0 + 2h.

Three-Point Midpoint Formula

f ′(x0) = 1 2h[f(x0 + h) − f(x0 − h)] − h2 6 f (3)(ξ1) where ξ1 lies between x0 − h and x0 + h.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 27 / 33

slide-55
SLIDE 55

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

(1) f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) (2) f ′(x0) = 1 2h[f(x0 + h) − f(x0 − h)] − h2 6 f (3)(ξ1)

Comments

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 28 / 33

slide-56
SLIDE 56

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

(1) f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) (2) f ′(x0) = 1 2h[f(x0 + h) − f(x0 − h)] − h2 6 f (3)(ξ1)

Comments

Although the errors in both Eq. (1) and Eq. (2) are O(h2), the error in Eq. (2) is approximately half the error in Eq. (1).

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 28 / 33

slide-57
SLIDE 57

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

(1) f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) (2) f ′(x0) = 1 2h[f(x0 + h) − f(x0 − h)] − h2 6 f (3)(ξ1)

Comments

Although the errors in both Eq. (1) and Eq. (2) are O(h2), the error in Eq. (2) is approximately half the error in Eq. (1). This is because Eq. (2) uses data on both sides of x0 and Eq. (1) uses data on only one side.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 28 / 33

slide-58
SLIDE 58

Introduction General Formulas 3-pt Formulas

Some useful three-point formulas

(1) f ′(x0) = 1 2h[−3f(x0) + 4f(x0 + h) − f(x0 + 2h)] + h2 3 f (3)(ξ0) (2) f ′(x0) = 1 2h[f(x0 + h) − f(x0 − h)] − h2 6 f (3)(ξ1)

Comments

Although the errors in both Eq. (1) and Eq. (2) are O(h2), the error in Eq. (2) is approximately half the error in Eq. (1). This is because Eq. (2) uses data on both sides of x0 and Eq. (1) uses data on only one side. Note also that f needs to be evaluated at only two points in

  • Eq. (2), whereas in Eq. (1) three evaluations are needed.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 28 / 33

slide-59
SLIDE 59

Introduction General Formulas 3-pt Formulas

Three-Point Midpoint Formula

f ′(x0) = 1 2h[f(x0 + h) − f(x0 − h)] − h2 6 f (3)(ξ1) where ξ1 lies between x0 − h and x0 + h.

y x Slope 2h [ f (x0 1 h) 2 f (x0 2 h)] 1 Slope f 9(x0) x0 2 h x0 1 h x0

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 29 / 33

slide-60
SLIDE 60

Introduction General Formulas 3-pt Formulas

Examples of five-point formulas

Five-Point Midpoint Formula

f ′(x0) = 1 12h[f(x0 − 2h) − 8f(x0 − h) + 8f(x0 + h) − f(x0 + 2h)] + h4 30f (5)(ξ) where ξ lies between x0 − 2h and x0 + 2h.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 30 / 33

slide-61
SLIDE 61

Introduction General Formulas 3-pt Formulas

Examples of five-point formulas

Five-Point Midpoint Formula

f ′(x0) = 1 12h[f(x0 − 2h) − 8f(x0 − h) + 8f(x0 + h) − f(x0 + 2h)] + h4 30f (5)(ξ) where ξ lies between x0 − 2h and x0 + 2h.

Five-Point Endpoint Formula

f ′(x0) = 1 12h[−25f(x0) + 48f(x0 + h) − 36f(x0 + 2h) + 16f(x0 + 3h) − 3f(x0 + 4h)] + h4 5 f (5)(ξ) where ξ lies between x0 and x0 + 4h.

Numerical Analysis (Chapter 4) Numerical Differentiation I R L Burden & J D Faires 30 / 33

slide-62
SLIDE 62

Questions?

slide-63
SLIDE 63

Reference Material

slide-64
SLIDE 64

The Lagrange Polynomial: Theoretical Error Bound

Suppose x0, x1, . . . , xn are distinct numbers in the interval [a, b] and f ∈ Cn+1[a, b]. Then, for each x in [a, b], a number ξ(x) (generally unknown) between x0, x1, . . . , xn, and hence in (a, b), exists with f(x) = P(x) + f (n+1)(ξ(x)) (n + 1)! (x − x0)(x − x1) · · · (x − xn) where P(x) is the interpolating polynomial given by P(x) = f(x0)Ln,0(x) + · · · + f(xn)Ln,n(x) =

n

  • k=0

f(xk)Ln,k(x)

Return to General Derivative Approximations1