You are on page 1of 14

~ Numerical Differentiation and Integration ~

Newton-Cotes Integration Formulas

Chapter 21

1
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
• Calculus is the mathematics of change. Since engineers continuously deal with
systems and processes that change, calculus is an essential tool of engineering.
• Standing at the heart of calculus are the concepts of:

Differentiation
and Integration
y f ( xi  x)  f ( xi ) b
 I   f ( x)dx
x x a
dy f ( xi  x)  f ( xi )
 lim
dx x0 x

2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Newton-Cotes Integration Formulas

b b
• Based on the strategy of replacing a
I   f ( x)dx   f n ( x)dx
complicated function or tabulated data
a a
with an approximating function that is
easy to integrate: f n ( x)  a0  a1 x    an x n

Zero order approximation First-order Second-order

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Trapezoidal Rule

b b
I  
a
f ( x ) dx   f1 ( x ) dx
a

f (a)  f (b) The area under this first order polynomial is


I  (b  a) an estimate of the integral of f(x) between a
2 and b:

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Error Estimate of the Trapezoidal Rule

Error:
1
Et   f (x )(b  a)3
12
where x lies somewhere in the
interval from a to b

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Example 21.1 Single Application of the Trapezoidal Rule
f(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5

Integrate f(x) from a=0 to b=0.8


b  0.8
True integral value : I   f ( x )dx  1.64053
a 0

Solution: f(a)=f(0) = 0.2 and f(b)=f(0.8) = 0.232

f (a )  f (b)
Trapezoida l Rule : I  (b  a )
2
0.2  0.232
 0.8  0.1728
2
which represents an error of :

E t  1.64053  0.1728  1.46773  t  89.5%


Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Multiple-Application Trapezoidal Rule
• The accuracy can be improved by dividing the
interval from a to b into a number of segments
and applying the method to each segment.

• The areas of individual segments are added to


yield the integral for the entire interval.
ba
h n  # of seg. a  x0 b  xn
n
x1 x2 xn

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


x0 x1 xn1

Using the trapezoidal rule, we get:

f ( x0 )  f ( x1 ) f ( x1 )  f ( x2 ) f ( x )  f ( xn )
I h h    h n1
2 2 2
ba  n 1

I
2n 
f ( x 0 )  f ( x n )  2 i 1 i 
f ( x )
Width Average height 7
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Error Estimate for
The Multiple-Application Trapezoidal Rule

• Error estimate for one segment is given as:


(b  a)3
Et   f (x )
12
• An error for multiple-application trapezoidal rule can be obtained by
summing the individual errors for each segment:

h3 n "
Ea    f (x i ) since f "
(x i )  nf "
12 i 1
h3 "
Ea   nf where f " is the mean of the second derivative over the interval
12
(b  a ) (b  a) 3 " (b  a) 2 "
Since h  Ea   2
f   h f  O( h 2
)
n 12n 12
Thus, if the number of segments is doubled,
the truncation error will be quartered.
8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Simpson’s Rules
• More accurate estimate of an integral is obtained if
a high-order polynomial is used to connect the
points. These formulas are called Simpson’s rules.

Simpson’s 1/3 Rule: results when a 2nd order


Lagrange interpolating polynomial is used for f(x)
a=x0 x1 b=x2
b b
I   f ( x)dx   f 2 ( x)dx where f 2 ( x ) is a second - order polynomial.
a a

Using a  x0 b  x2

 ( x  x1 )( x  x2 ) ( x  x0 )( x  x2 ) ( x  x0 )( x  x1 ) 
x2

I   f ( x0 )  f ( x1 )  f ( x2 )dx
x0 
( x0  x1 )( x0  x 2 ) ( x1  x0 )( x1  x 2 ) ( x 2  x0 )( x 2  x1 ) 
after integration and algebraic manipulation, the following formula results :
ba
I
h
 f ( x0 )  4 f ( x1 )  f ( x2 ) h  SIMPSON' S 1/3 RULE
3 2
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The Multiple-Application Simpson’s 1/3 Rule

• Just as the trapezoidal rule, Simpson’s rule can be improved by dividing the
integration interval into a number of segments of equal width.

• However, it is limited to cases where values are equispaced, there are an even
number of segments and odd number of points.
ba
h n  # of seg. a  x0 b  xn
n
x2 x4 xn

I  f ( x)dx   f ( x)dx    f n  2 ( x) dx
0 2

x0 x2 xn2

h
I  f ( x0 )  4 f ( x1 )  f ( x2 ) 
3
h
  f ( x2 )  4 f ( x3 )  f ( x4 )  
3
h
  f ( xn  2 )  4 f ( xn 1 )  f ( xn ) 
3
h n 1 n2 
I   f ( x0 )  4  f ( xi )  2  f ( x j )  f ( xn ) 
3 i 1, 3, 5... j  2 , 4 , 6... 

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Simpson’s 3/8 Rule
Simpson’s 1/3 and 3/8 rules can be
Fit a 3rd order Lagrange interpolating applied in tandem to handle
polynomial to four points and integrate multiple applications with odd
number of intervals

b b
I   f ( x)dx   f 3 ( x)dx
a a

I   f ( x0 )  3 f ( x1 )  3 f ( x2 )  f ( x3 )
3h
8
(b  a )
h 
3

f ( x0 )  3 f ( x1 )  3 f ( x2 )  f ( x3 )
I  (b  a )
8 11

Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Newton-Cotes Closed Integration Formulas

Segments Points Name Formula Truncation


(n) Error

1 2 Trapezoidal (b-a) * (f(x0)+ f(x1))/2 -(1/12)(b-a)3f”(ξ)

2 3 Simpson’s (b-a) * (f(x0)+ 4f(x1)+f(x2))/6 -(1/2880)(b-a)5f(4)(ξ)


1/3
3 4 Simpson’s (b-a) * (f(x0)+ 3f(x1)+ 3f(x2)+ f(x3))/8 -(1/6480)(b-a)5f(4)(ξ)
3/8
4 5 Boole’s (b-a) * (7f(x0) + 32f(x1) + 12f(x2) + 32f(x3) proportional with (b-a)7
+ 7f(x4))/90

Same order,
but Simpson’s 3/8 is more accurate

In engineering practice, higher order (greater than 4-point) formulas are rarely used
12
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Integration with Unequal Segments
Using Trapezoidal Rule
f ( x0 )  f ( x1 ) f ( x1 )  f ( x2 ) f ( xn 1 )  f ( xn )
I  h1  h2    hn
2 2 2
Example 21.7
1.309  0.2 1.305  1.309 0.363  3.181 0.232  2.363
I  0.12  0.10    0.06  0.10
2 2 2 2
 0.0905  0.1307    0.12975  1.594
which represents a relative error of  = 2.8%
x f(x) x f(x)
0.0 0.2 0.44 2.842

0.12 1.309 0.54 3.507

Data for 0.22 1.305 0.64 3.181


f(x)= 0.2+25x-200x2+675x3-900x4+400x5 0.32 1.743 0.70 2.363

0.36 2.074 0.80 0.232

0.40 2.456
13
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Compute Integrals Using MATLAB
x f(x) x f(x) First, create a file called fx.m which contains f(x):
0.2
function y = fx(x)
0.0 0.44 2.842
y = 0.2+25*x-200*x.^2+675*x.^3-900*x.^4+400*x.^5 ;
0.12 1.309 0.54 3.507
0.22 1.305 0.64 3.181
Then, execute in the command window:
0.32 1.743 0.70 2.363 >> Q=quad('fx', 0, 0.8) % true integral
0.36 2.074 0.80 0.232
0.40 2.456 Q =1.6405  true value

>> x=[0 .12 .22 .32 .36 .4 .44 .54 .64 .7 .8]

>> y = fx(x)
y = 0.200 1.309 1.305 1.743 2.074 2.456
2.843 3.507 3.181 2.363 0.232

>> Integral = trapz(x,y) % or trapz(x, fx(x))

Integral =1.5948
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

You might also like