Anda di halaman 1dari 104

Polinomial Interpolasi orde-n

 Aturan Trapezoid Polinomial Interpolasi Newton orde-1


(Trapezoidal Rule)

 Aturan 1/3 dan 3/8 Simpson Polinomial Interpolasi


(Simpson’s 1/3 and 3/8 Rules) Lagrange orde-2 dan orde-3

 Finite-divided-difference formula Forward, backward, centered


finite-divided-difference
formulas
b
Metode Integrasi
I   f  x dx
a

f(x)

a b x
b
Metode Integrasi
I   f  x dx
a

f(x)

a b x
Metode Differensiasi

f(x)

f  xi  x

y
f  xi 

xi xi + x
x x

y f  xi  x   f  xi 

x x
Specific Study Objectives

 Understand the derivation of the Newton-Cotes


formulas

 Recognize that the trapezoidal and Simpson’s 1/3


and 3/8 rules represent the areas of 1st, 2nd, and
3rd order polynomials

 Be able to choose the “best” among these formulas


for any particular problem
Specific Study Objectives

 Recognize the difference between open and closed


integration formulas

 Understand the theoretical basis of Richardson


extrapolation and how it is applied in the Romberg
integration algorithm and for numerical
differentiation
Specific Study Objectives

 Recognize why both Romberg integration and Gauss


quadrature have utility when integrating equations
(as opposed to tabular or discrete data).

 Understand basic finite difference approximations

 Understand the application of high-accuracy


numerical-differentiation.

 Recognize data error on the processes of integration


and differentiation.
Numerical Differentiation and
Integration

 Calculus is the mathematics of change.

 Engineers must continuously deal with systems and


processes that change, making calculus an essential
tool of our profession.

 At the heart of calculus are the related mathematical


concepts of differentiation and integration.
Differentiation

y f  xi  x   f  xi 

x x
 Dictionary definition of differentiate - “to mark off
by differences, distinguish; ..to perceive the
difference in or between”

 Mathematical definition of derivative - rate of


change of a dependent variable with respect to an
independent variable
f(x)

f  xi  x

y
f  xi 

x x

y f  xi  x   f  xi 

x x
Integration

 The inverse process of differentiation

 Dictionary definition of integrate - “to bring


together, as parts, into a whole; to unite; to indicate
the total amount”

 Mathematically, it is the total value or summation of


f(x)dx over a range of x. In fact the integration
symbol is actually a stylized capital S intended to
signify the connection between integration and
summation.
f(x)

x
b

I   f  x dx
a
Mathematical Background

d d x
sin x  ? e ?
dx dx
d d x
cos x  ? a ?
dx dx
d d n
tan x  ? x ?
dx dx
d
ln x  ?
dx
if u and v are functions of x
d n d
u ? (uv )  ?
dx dx
Mathematical Background

 udv  ?
 u du  ?
n

 a dx  ?
bx

dx
 x ?
 dx  ?
ax
e
Overview

 Newton-Cotes Integration Formulas


 Trapezoidal rule  Newton-Cotes Integration
Formulas
 Simpson’s Rules  Trapezoidal rule

 Unequal Segments  Simpson’s Rules

 Open Integration  equal Segments

 Single & multiple Segments

 Integration of Equations
 Romberg Integration

 Gauss Quadrature

 Improper Integrals
Overview

 Numerical Differentiation
 High accuracy formulas

 Richardson’s extrapolation

 Unequal spaced data

 Uncertain data

 Applied problems
Newton-Cotes Integration

 Common numerical integration scheme

 Based on the strategy of replacing a complicated

function or tabulated data with some approximating

function that is easy to integrate

b b

I   f  x dx   f  x dx
a a
n

f n  x   a0  a1 x .... an x n
Newton-Cotes Integration

 Common numerical integration scheme

 Based on the strategy of replacing a complicated


function or tabulated data with some approximating
function that is easy to integrate

b b

I   f  x dx   f n  x dx
a a

f n  x   a0  a1 x .... an x n fn(x) is an nth order


polynomial
The approximation of an integral by the area under
- a first order polynomial
- a second order polynomial

5 5

4 4

3 3
f(x)

f(x)
2 2

1 1

0 0
0 5 10 0 5 10
x x
The approximation of an integral by the area under
- a first order polynomial
- a second order polynomial

5 5

4 4

3 3
f(x)

f(x)
2 2

1 1

0 0
0 5 10 0 5 10
x x

We can also approximated the integral by using a


series of polynomials applied piece wise.
5

3
f(x)

0
0 1 2 3 4 5 6 7 8 9 10
x

An approximation of an integral by the area under


straight line segments.
5

3
f(x)

0
0 1 2 3 4 5 6 7 8 9 10
x

An approximation of an integral by the area under


straight line segments.
Newton-Cotes Formulas

 Closed form - data is at the beginning and end of the


limits of integration

 Open form - integration limits extend beyond the


range of data.

5 5

4 4

3 3
f(x)

2 f(x) 2

1 1

0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
x x
Trapezoidal Rule

 First of the Newton-Cotes closed


integration formulas

 Corresponds to the case where the


polynomial is a first order

b b

I   f  x dx   f  x dx
a a
1

f n  x   a0  a1 x
Trapezoidal Rule

b b

I   f  x dx   f 1  x dx
a a

f n  x   a0  a1 x

a b

A straight line can be represented as:

f  b  f  a 
f 1  x  f  a    x  a
ba
Trapezoidal Rule
b b

I   f  x dx   f 1  x dx
a a
b
f b  f  a 
 f a    x  a dx
a
ba

Integrate this equation. Results in the


trapezoidal rule :

f  a   f b
I  b  a 
2
f a   f b 
Trapezoidal Rule I  b  a 
2

Recall the formula for computing the area of a


trapezoid:

height x (average of the bases)

base
height

base
f a   f b 
Trapezoidal Rule I  b  a 
2

The concept is the same but the trapezoid is on its


side.

base

height
height

height width

base
Error of the Trapezoidal Rule

1
Et   f ' '  b  a 
3

12
where a    b

This indicates that is the function being integrated is linear, the


trapezoidal rule will be exact.

Otherwise, for section with second and higher order derivatives


(that is with curvature) error can occur.

A reasonable estimate of x is the average value of b and a


Multiple Application of the
Trapezoidal Rule

 Improve the accuracy by dividing the integration


interval into a number of smaller segments

 Apply the method to each segment

 Resulting equations are called multiple-application


or composite integration formulas
Multiple Application of the
Trapezoidal Rule

x1 x2 xn

I  f (x )dx   f (x )dx  f (x )dx


x0 x1 xn 1

f  x0   f  x1  f  x1   f  x2  f  xn  1   f  xn 
Ih h  h
2 2 2

where there are n+1 equally spaced base points.


Multiple Application of the
Trapezoidal Rule

We can group terms to express a general form


x1 x2 xn

I  f ( x)dx   f ( x)dx   f ( x)dx


x0 x1 xn 1

f  x0   f  x1  f  x1   f  x2  f  xn  1   f  xn 
I h h  h
2 2 2
n 1
f  x0   2 f  xi   f  xn 
I  b  a  i 1

2n

width average height


Multiple Application of the
Trapezoidal Rule
n 1
f  x0   2 f  xi   f  xn 
I  b  a  i 1

2n
}

width }
average height

The average height represents a weighted average


of the function values

Note that the interior points are given twice the weight
of the two end points 3
b  a 
Ea   2
f ''
12 n
Example

Evaluate the following integral using the trapezoidal rule


and h = 0.1

1.6

e
30
I x2
dx 25
1 20

f(x)
15
ba
h 10

n 5

0
0 0.3 0.6 0.9 1 .2 1 .5 1 .8
x

n 1
f  x0   2 f  xi   f  xn 
I  b  a  i 1

2n
Simpson’s 1/3 Rule

 Corresponds to the case


where the function is a
second order polynomial

b b

I   f  x dx  
a a
f 2  x dx

f n  x   a0  a1 x  a 2 x 2
Simpson’s 1/3 Rule

 Designate a and b as x0
and x2, and estimate f2(x)
as a second order
Lagrange polynomial

b b

I   f  x dx   f  x dx
a a
2

  x  x1  x  x2  
x2

  f  x0  .......dx
x 0  0
x  x1  x0  x2  
Simpson’s 1/3 Rule

 After integration and algebraic manipulation, we get


the following equations

h
I   f  x0   4 f  x1   f  x2 
3
f  x0   4 f  x1   f  x2 
 b  a 
6
}

}
width average height
Error

Single application of Trapezoidal Rule.


1
Et   f ' '  b  a 
3

12
where a    b

Single application of Simpson’s 1/3 Rule


1
Et   f (4)
 b  a 5
2880
Multiple Application of Simpson’s 1/3
Rule

x1 x2 xn

I  f ( x)dx   f ( x )dx   f ( x)dx


x0 x1 xn 1
n 1 n2
f  x0   4  f x   2  f x   f x 
i j n

I  b  a  i 1, 3,5.. j  2 , 4 , 6..

3n

Ea 
b  a
5

f 4
180n 4
n 1 n2
f  x0   4  f x   2  f x   f x 
i j n

I  b  a  i 1, 3,5.. j  2 , 4 , 6..

3n

The odd points represent the middle term for each application.
Hence carry the weight 4.
The even points are common to adjacent applications and are
counted twice.

i=1 (odd) i=2 (even)


weight of 4 weight of 2
f(x)

x
Simpson’s 3/8 Rule

 Corresponds to the case


where the function is a
third order polynomial

b b
I  f x dx   f x dx
a a
3

f n x   a 0  a1x  a 2 x 2  a 3 x 3
3h
I f x 0   3f x1   3f x 2   f x 3 
8
Integration of Unequal Segments

 Experimental and field study data is often unevenly spaced

 In previous equations we grouped the term (i.e. hi) which


represented segment width.

n 1
f  x0   2 f  xi   f  xn 
I  b  a  i 1

2n
f  x0   f  x1  f  x1   f  x2  f  xn  1   f  xn 
I h h  h
2 2 2
Integration of Unequal Segments

 We should also consider alternately using higher order equations if


we can find data in consecutively even segments

trapezoidal
rule
Integration of Unequal Segments

 We should also consider alternately using higher order


equations if we can find data in consecutively even
segments

1/3
trapezoidal rule
rule
Integration of Unequal Segments

 We should also consider alternately using higher order


equations if we can find data in consecutively even
segments

1/3
trapezoidal rule
rule 3/8
rule
Integration of Unequal Segments

 We should also consider alternately using higher order


equations if we can find data in consecutively even
segments

trapezoidal
1/3 rule
trapezoidal rule
rule 3/8
rule
Example

Integrate the following using the trapezoidal rule, Simpson’s 1/3


Rule, a multiple application of the trapezoidal rule with n=2 and
Simpson’s 3/8 Rule. Compare results with the analytical solution.

1 4000

1 2000
4 1 0000

 dx
2x
xe f(x) 8000

6000

4000
0
2000

0
0 1 2 3 4
x
f(x) b

I   f  x dx
a

a b x
Trapezoidal Rule
Single segment

f a   f b 
I  b  a 
2
n segment
x1 x2 xn

I  f ( x)dx   f ( x)dx   f ( x)dx


x0 x1 xn 1

f  x0   f  x1  f  x1   f  x2  f  xn  1   f  xn 
I h h  h
2 2 2
n 1
f  x0   2 f  xi   f  xn 
I  b  a  i 1

2n

width average height


Simpson’s 1/3 Rule
Single segment

h
I   f  x0   4 f  x1   f  x2 
3
f  x0   4 f  x1   f  x2 
 b  a 
6
}

width
}
average height

n segment
n 1 n2
f  x0   4  f x   2  f x   f x 
i j n

I  b  a  i 1, 3,5.. j  2 , 4 , 6..

3n
Simpson’s 3/8 Rule
Single segment

b b
I  f x dx   f x dx
a a
3

f n x   a 0  a1x  a 2 x 2  a 3 x 3
3h
I f x 0   3f x1   3f x 2   f x 3 
8

n segment ?
Bentuk data akan mempengaruhi hasil aproksimasi nilai integrasi.
 Bila data berbentuk tabel : terbatas oleh data yg diberikan

 Bila data berbentuk fungsi : data bisa di-generate sebanyak yg

diperlukan utk melakukan perhitungan sehingga diperoleh tingkat

akurasi tertentu.

 Richardson’n Extrapolation
 Gauss Quadrature
Integration of Equations

 Integration of analytical as opposed to tabular functions

 Romberg Integration

 Richardson’s Extrapolation

 Romberg Integration Algorithm

 Gauss Quadrature

 Improper Integrals
Richardson’s Extrapolation

 Use two estimates of an integral to compute a third more


accurate approximation

 The estimate and error associated with a multiple application


trapezoidal rule can be represented generally as:

 I = I(h) + E(h)

 where I is the exact value of the integral

 I(h) is the approximation from an n-segment application

 E(h) is the truncation error

 h is the step size (b-a)/n


Make two separate estimates using step sizes of h1 and h2 .

I(h1) + E(h1) = I(h2) + E(h2)

Recall the error of the multiple-application of the trapezoidal


rule

ba 2
E h f ''
12

Assume that f '' is constant regardless of the step size

E  h1  h12
 2
E  h2  h2
E  h1  h12
 2
E  h2  h2
2
 h1 
E  h1   E  h2  
 h2 

Substitute into previous equation:

I(h1) + E(h1) = I(h2) + E(h2)

I  h1   I  h2 
E  h2   2
 h1 
1  
 h2 
I  h1   I  h2 
E  h2   2
 h1 
1  
 h2 

Thus we have developed an estimate of the truncation


error in terms of the integral estimates and their step
sizes. This estimate can then be substituted into:

I = I(h2) + E(h2)

to yield an improved estimate of the integral:

 
 
 I  h2   I  h1 
1
I  I  h2    2
  h1   1
  h2  
Richardson’s Extrapolation

 
 
 I  h2   I  h1 
1
I  I  h2    2
  h1   1
  h2  

What is the equation for the special case where the interval
is halved?

i.e. h2 = h1 / 2
 h1    2h2   2
 h2   h2 
 1 
I  I h2    2  I  h   I  h1 
 2  1
2

collecting terms
4 1
I  I h2   I h1 
3 3
Example

Use Richardson’s extrapolation to evaluate:

4 1 4000

 dx
2x
xe 1 2000

0 1 0000

8000
f(x)

6000

4000

2000

0
0 1 2 3 4
x
Romberg Integration

We can continue to improve the estimate by successive


halving of the step size to yield a general formula:

4 1
I  I  h2   I  h1  k = 2; j = 1
3 3
16 1
I  I  hm   I  hl 
15 15
Note:
64 1
I  I  hm   I  hl  the subscripts
63 63 m and l refer to
more and less
4 k 1 I j 1,k 1  I j ,k 1
I j ,k  accurate estimates
4 k 1  1
Gauss Quadrature

Extend the area under the


f(x) straight line

f(x)

x
Method of Undetermined Coefficients

Recall the trapezoidal rule

f a   f b
I  b  a 
2 Before analyzing
this method, answer
this question.
This can also be expressed as
What are two
functions that
where the c’s are constant should be evaluated
Exactly by the
trapezoidal rule?
I  c0 f a   c1 f b
The two cases that should be evaluated exactly
by the trapezoidal rule: 1) y = constant
2) a straight line

f(x)

y=1

f(x)
-(b-a)/2 (b-a)/2 x y=x

-(b-a)/2

(b-a)/2 x
Thus, the following equalities should hold.

I  c0 f a   c1 f b

b  a 
c0  c1   2
1dx FOR y=1

ba
2 since f(a) = f(b) =1

b  a 
 b  a   b  a 
 c0    c1      b  a  xdx
2
FOR y =x
 2   2  2 since f(a) = x =-(b-a)/2
and
f(b) = x =(b-a)/2
Evaluating both integrals

c0  c1  b  a For y = 1

ba b 1
c0  c1 0 For y = x
2 2

Now we have two equations and two unknowns, c0 and c1.

Solving simultaneously, we get :

c0 = c1 = (b-a)/2

Substitute this back into:


I  c0 f  a   c1 f b
We get the equivalent of the trapezoidal rule.

f a   f b
I  b  a 
2

DERIVATION OF THE TWO-POINT


GAUSS-LEGENDRE FORMULA

I  c0 f  x0   c1 f  x1 

Lets raise the level of sophistication by:


- considering two points between -1 and 1
- i.e. “open integration”
f(x)

-1 x0 x1 1 x

Previously ,we assumed that the equation


fit the integrals of a constant and linear function.

Extend the reasoning by assuming that it also fits the integral


of a parabolic and a cubic function.
1

c0 f  x0   c1 f  x1    1dx  2 We now have four


1 equations and four
1 unknowns
c0 f  x0   c1 f  x1    xdx  0
1 c0 c1 x0 and x1
1

c0 f  x0   c1 f  x1    x 2 dx  2 / 3
1
What equations are
1

c0 f  x0   c1 f  x1    x 3dx  0 you solving?


1
f(xi) is either 1, xi, xi2 or xi3

c0 f  x0   c1 f  x1    1dx  2 c0 1  c1 1  2


1
1

c0 f  x0   c1 f  x1    xdx  0 c0 x0  c1 x1`  0
1
1

c0 f  x0   c1 f  x1    x 2 dx  2 / 3 c0 x02  c1 x12  2 / 3
1
1

c0 f  x0   c1 f  x1    x 3dx  0 c0 x03  c1 x13  0


1

Solve these equations simultaneously


This results in the following

c0  c1  1
1
x0 
3
1
x1 
3
 1   1
I  f  f 
 3  3

The interesting result is that the integral can be estimated by


the simple addition of the function values at

1 1
and
3 3
What if we aren’t integrating from –1 to 1?

A simple change in variables can be use to translate other


limits.

Assume that the new variable xd is related to the


original variable x in a linear fashion.

x = a0 + a1xd

Let the lower limit x = a correspond to xd = -1 and the upper


limit x=b correspond to x d=1

a = a0 + a1(-1) b = a0 + a1(1)
a = a0 + a1(-1) b = a0 + a1(1)

SOLVE THESE EQUATIONS


SIMULTANEOUSLY

ba ba
a0  a1 
2 2
substitute

x  a0  a1xd 
b  a   b  a  xd
2
x  a0  a1xd 
b  a   b  a  xd
2
ba
dx  dxd
2

These equations are substituted for x and dx respectively.

Let’s do an example to appreciate the theory


behind this numerical method.
Example

Estimate the following using two-point Gauss Legendre:

1 4000
4 1 2000

 dx
2x
xe 1 0000
0 8000
f(x)

6000

4000

2000

0
0 1 2 3 4
x
Higher-Point Formulas

I  c0 f  x0   c1 f  x1  cn1 f  xn1 

For two point, we determined that c0 = c1= 1

For three point:

c0 = 0.556 x0=-0.775
c1= 0.889 x1=0.0
c2= 0.556 x2=0.775
Numerical Differentiation

 Forward finite divided difference

 Backward finite divided difference

 Center finite divided difference

 All based on the Taylor Series

f ' '  xi  2
f  xi 1   f  xi   f '  xi h  h  .........
2!
Forward Finite Difference

f ' '  xi  2
f  xi 1   f  xi   f '  xi h  h  .........
2!

f  xi 1   f  xi 
f '  xi    O h 
h

f  xi 1   f  xi  f ' '  xi 
f '  xi    h  O h 2 
h 2
Forward Divided Difference

f  xi  1   f  xi  f i
f '  xi    O xi  1  xi    O h
xi  1  xi h

f(x)

What is derivative at this


(xi, yi) point?

x
Forward Divided Difference

f  xi  1   f  xi  f i
f '  xi    O xi  1  xi    O h
xi  1  xi h

f(x)
(x i+1,y i+1)

(xi, yi) Determine a second point


base on x (h)

x
Forward Divided Difference

f  xi  1   f  xi  f i
f '  xi    O xi  1  xi    O h
xi  1  xi h

f(x)
How does
(x i+1,y i+1)
this compare
to the actual
first derivative (xi, yi)
at xi?

x
Forward Divided Difference

f  xi  1   f  xi  f i
f '  xi    O xi  1  xi    O h
xi  1  xi h

f(x)
(x i+1,y i+1)

(xi, yi)

x
Forward Divided Difference

f i
f '  xi    O h Error is proportional to
h the step size

first forward divided difference

O(h2) error is proportional to the square of the step size

O(h3) error is proportional to the cube of the step size


Backward Difference Approximation of the
First Derivative

Expand the Taylor series backwards

f ' '  xi  2
f  xi 1   f  xi   f '  xi  h  h ......
2!
f ' '  xi  2
f  xi 1   f  xi   f '  xi  h  h .....
2!

f  xi   f  xi 1  f i
f '  xi   
h h

The error is still O(h)


f(x)

(xi,yi)

(xi-1,yi-1)

x
Centered Difference Approximation of the
First Derivative

Subtract backward difference approximation


from forward Taylor series expansion

f ' '  xi  2
f  xi 1   f  xi   f '  xi h  h  ....
2!
f  xi 1   f  xi 
f '  xi  
xi 1  xi
f ' ' '  xi  2
f  xi 1   f  xi 1   2 f '  xi h  h 
6
f  xi 1   f  xi 1 
f '  xi  
2h
 
 O h2
f  xi 1   f  xi 1 
f '  xi    Oh 2 
2h
f(x)

(xi+1,yi+1)
(xi,yi)

(xi-1,yi-1)

x
f(x) f(x)

forward
true derivative
finite divided
difference approx.

x x
f(x) f(x)

backward centered
finite divided finite divided
difference approx. difference approx.

x x
Derivatives of Unequally Spaced Data

 Common in data from experiments or field studies

 Fit a second order Lagrange interpolating polynomial to each set of


three adjacent points, since this polynomial does not require that
the points be equi-spaced

 Differentiate analytically

2 x  xi  xi 1 2 x  xi 1  xi 1
f '  x  f  xi 1   f  xi 
 xi 1  xi  xi 1  xi 1   xi  xi 1  xi  xi 1 
2 x  xi  xi 1
 f  xi 1 
 xi 1  xi  xi 1  xi 1 
Derivative and Integral Estimates for Data with
Errors

 In addition to unequal spacing, the other problem related to


differentiating empirical data is measurement error

 Differentiation amplifies error

 Integration tends to be more forgiving

 Primary approach for determining derivatives of imprecise


data is to use least squares regression to fit a smooth,
differentiable function to the data

 In absence of other information, a lower order polynomial


regression is a good first choice
250 30
2 00
150 20

dy/dt
y
1 00 10
50
0 0
0 5 10 15 0 10
t t

250 40
2 00 30

dy/dt
150
20
y

1 00
10
50
0 0
0 5 10 15 0 10

t t

Anda mungkin juga menyukai