Você está na página 1de 111

Major: Chemical

Engineering CHAPTER 6
Subject: Chemical
Engineering
Mathematics 2 NUMERICAL
DIFFERENTIATION
Author:
Andrew KUMORO
AND
INTEGRATION
Dept. of FOR CHEMICAL
Chemical
Engineering ENGINEERS
Diponegoro
University
2013
Specific Study Objectives

Understand the derivation of the Newton-


Cotes formulas

Recognize that the trapezoidal and Simpsons


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

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.
NUMERICAL
DIFFERENTIATION
Mathematical definition of derivative :
rate of change of a dependent variable with
respect to an independent variable

y y xi x y xi

x xi 1 xi
Y =f(x)
f xi x

y
f xi
x
x x + x x

dy y f xi x f xi

dx x x
The derivative of f (x) at x0 is:

Limit f x0 x f ( x0 )
f x0
x 0 x
An approximation to this is:

f x0 x f ( x0 )
f x0 for small
x values of h.
Forward Difference
Formula
The methods of derivation of f (x) at x0
Forward finite divided
are to be difference
made using the followings:
Backward finite divided
difference
Center finite divided
difference

All based on the Taylor Series


f ' ' xi 2
f xi 1 f xi f ' xi x .........
2!
Forward Finite Difference

f ' ' xi 2
f xi 1 f xi f ' xi x x .........
2!

f xi 1 f xi
f ' xi O x most
x used

f xi 1 f xi f ' ' xi
f ' xi
x

2

x O x 2
rarely
used
Forward Finite Difference

f xi 1 f xi f i
f ' xi O xi 1 xi O x
xi 1 xi x

f(x)

What is
(xi, yi) derivative at
this point?
x
Forward Finite 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 or (h)

x
Forward Finite Difference

f xi 1 f xi f i
f ' xi O xi 1 xi O x
xi 1 xi x

f(x)
How does this (x i+1,y i+1)
i mat e
compare to est
the actual first (xi, yi)
derivative at
xi?
x
Forward Divided Difference

f xi 1 f xi f i
f ' xi O xi 1 xi O x
xi 1 xi x

f(x)

t ual (x i+1,y i+1)


ac a te
sti m
e
(xi, yi)

x
Forward Divided Difference

f i
f ' xi O x Error is proportional to
x
the step size

First
first forward divided
forward divided difference
difference formula
O(x2) error is proportional to the square of the step size

O(x3) 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 x x ......
2!
f ' ' xi 2
f xi 1 f xi f ' xi x x .....
2!

f xi f xi 1 f
f ' xi i
x x

The error is still O()


f(x)

c tu al
a

(xi,yi)
e
at
stim
e
(xi-1,yi-1)

x
Centered Difference Approximation of
the
First Derivative

Subtract backward difference approximation from


forward Taylor series expansion f ' ' ' xi
f xi 1 f xi 1 2 f ' xi x
2
x
6
f xi 1 f xi
f ' xi
xi 1 xi
f xi f xi 1
f ' xi
xi xi 1
f xi 1 f xi 1
f ' xi
2 x

O x 2
f xi 1 f xi 1
f(x)
f ' xi
2x

O x 2

al
actu
(xi+1,yi+1)
(xi,yi)

t im ate
es

(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
Example
1.Given the following function to determine
the derivative at x = 0.5 by taking x =
0.25.
f(x) = -0.1x4 -00.15x - 0.5x2 - 0.25x +1.2
0.5 31.0
Note:
0.25 0.75
f(0) = 1.2
f(0.25) =1.1035
Compare the actual value
f(0.75) = 0.636
(analytical difference) with
f(1) = 0.2 the forward, backward and
2. Try also findcentered differences.of f(x) =
the derivatives
1/3x3+1/4x2+1 at x = 0.2. Take x = 0.01
Compare the actual value (analytical
difference) with the forward, backward and
centered differences.
Case: interpretation of experimental data
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
150

dy /dt
20
y

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

t t
Let f ( x ) ln x and x0 1.8
Find an approximate f 1.8
value for
x f (1.8 x) f (1.8 x) f (1.8)
f (1.8)
0.1 0.58778 0.6418 0.5406720
x
67 539
0.01 0.58778 0.5933 0.5540100
67 268
0.00 0.58778 0.5883 0.5554000
1 67 421
The exact valuef 1.8 0.55 5
of
Assume that a function goes through three
points:
x0 , f x0 , x1 , f x1 and x2 , f x2 .
f ( x) P( x)

P x L0 x f x0 L1 x f x1 L2 x f x2

Lagrange Interpolating
Polynomial
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
P x L0 x f x0 L1 x f x1 L2 x f x 2

( x x1 )( x x2 )
P x f x0
( x0 x1 )( x0 x2 )
( x x0 )( x x2 )
f x1
( x1 x0 )( x1 x2 )
( x x0 )( x x1 )
f x2
( x2 x0 )( x2 x1 )
f ( x ) P ( x )
2 x x1 x2
P x f x0
( x0 x1 )( x0 x2 )
2 x x0 x2
f x1
( x1 x0 )( x1 x2 )
2 x x0 x1
f x2
( x2 x0 )( x2 x1 )
If the points are equally spaced, i.e.,

x1 x0 h and x2 x0 2h
2 x0 ( x0 h) ( x0 2h)
P x0 f x0
x0 ( x0 h) x0 ( x0 2h)
2 x0 x0 ( x0 2h)
f x1
( x0 h) x0 ( x0 h) ( x0 2h)
2 x0 x0 ( x0 h)
f x2
( x0 2h) x0 ( x0 2h) ( x0 h)
3h 2h h
P x0 f x0 f x1 2 f x 2
2h 2
h 2
2h
1
P x0 3 f x0 4 f x1 f x2
2h

Three-point formula:
1
f x0 3 f x0 4 f x0 h f x0 2h
2h
If the points are equally spaced with x0
in the middle:
x1 x0 h and x 2 x0 h
2 x0 ( x0 h) ( x0 h)
P x0 f x0
x0 ( x0 h) ( x0 ( x0 h)
2 x0 x0 ( x0 h)
f x1
( x0 h) x0 ( x0 h) ( x0 h)
2 x0 x0 ( x0 h)
f x2
( x0 h) x0 ( x0 h) ( x0 h)
0 h h
P x0 f x0 2 f x1 2 f x 2
h 2
2h 2h

Another Three-point formula:

1
f x0 f x0 h f x0 h
2h
Alternate approach (Error estimate)

Take Taylor series expansion of f(x+h)


about x: 2 3
h 2 h 3
f x h f x hf x f x f x
2 3!
h2 2 h3 3
f x h f x hf x f x f x
2 3!

f x h f x h 2 h2 3
f x f x f x
h 2 3!
..............
(1)
f x h f x
f x O h
h
f x h f x
f x O h
h

f x h f x Forward
f x
h Difference
Formula
h 2 h2 3
O h f x f x
2 3!
4h 2 2 8h 3 3
f x 2h f x 2hf x f x f x
2 3!
4h 2 2 8h 3 3
f x 2h f x 2hf x f x f x
2 3!

f x 2h f x 2h 2 4h 2 3
f x f x f x
2h 2 3!
................
. (2)
f x h f x h 2 2
h 3
f x f x f x
h 2 3!
..............
(1)
f x 2h f x 2h 2 4h 2 3
f x f x f x
2h 2 3!
................
. (2)
2 Eqn. (1) Eqn. (2)
f x h f x f x 2 h f x
2
h 2h
2 h2 3 6 h3 4
f x f x f x
3! 4!
f x 2 h 4 f x h 3 f x
2h
2 h2 3 6 h3 4
f x f x f x
3! 4!

f x O h2
f x 2h 4 f x h 3 f x
2h

f x O h 2

f x 2h 4 f x h 3 f x
f x
2h

O h2

f x 2h 4 f x h 3 f x
f x
2h
Three-point
Formula
O h2
2 3
2 h 6 h
f 3 x f 4 x
3! 4!
THE SECOND THREE-POINT
FORMULA
Take Taylor series expansion of f(x+h)
about x: 2 3
h 2 h 3
f x h f x hf x f x f x
2 3!
Take Taylor series expansion of f(x-h)
about x: 2 3
h 2 h 3
f x h f x hf x f x f x
2 3!
Subtract one expression from another
2h 3 3 2h 6 6
f x h f x h 2hf x f x f x
3! 6!
2h 3 3 2h 6 6
f x h f x h 2hf x f x f x
3! 6!

f x h f x h h2 3 h5 6
f x f x f x
2h 3! 6!

f x h f x h h 2 3 h5 6
f x f x f x
2h 3! 6!
f x h f x h
f x
2h
O h2

2 5
h h
O h2 f 3 x f 6 x
3! 6!

f x h f x h
f x
2h
Second Three-point
Formula
Summary of Errors

f x h f x Forward
f x
h Difference
Formula
h 2 h2 3
Error O h f x f x
term 2 3!
Summary of Errors continued

First Three-point
Formula f x 2h 4 f x h 3 f x
f x
2h


2 3
2 h 6 h
Error O h2 f 3 x f 4 x
term 3! 4!
Summary of Errors continued

Second Three-point
Formulaf x h f x h
f x
2h


2 5
h h
Error O h2 f 3 x f 6 x
3! 6!
term
Example:
f x xe x
Find the approximate f 2 with h 0.1
value of

x f x
1.9
12.70319
9
2.0
14.77811
2
2.1
Using the Forward Difference
formula:
1
f x0 f x0 h f x0
h

1
f 2
0.1
f 2.1 f 2

1
17.148957 14.778112
0.1
23.708450
Using the 1st Three-point formula:
1
f x0 3 f x0 4 f x0 h f x0 2h
2h
1
f 2 3 f ( 2) 4 f ( 2.1) f ( 2.2)
2 0.1
1
3 14.778112 4 17.148957
0.2
19.855030
22.032310
Using the 2nd Three-point
formula:
1
f x0 f x0 h f x0 h
2h
1
f 2 f ( 2.1) f (1.9)
2 0.1
1
17.148957 12.703199
0.2
22.228790
The exact value f 2 is : 22.167168
of
Comparison of the results with
h = 0.1
The exact f 2 is
value of 22.167168
Formula f 2 Error
Forward 23.70845 1.541282
Difference 0
1st Three- 22.03231 0.134858
point 0
2nd Three- 22.22879 0.061622
point 0
Second-order Derivative
h2 2 h3 3
f x h f x hf x f x f x
2 3!
h2 2 h3 3
f x h f x hf x f x f x
2 3!
Add these two equations.
2h 2 2 2h4 4
f x h f x h 2 f x f x f x
2 4!
2h2 2 2 h4 4
f x h 2 f x f x h f x f x
2 4!
f x h 2 f x f x h 2 h 2

2
f 2
x f 4
x
h 4!

f 2 x
f x h 2 f x f x h
2 h 2
f 4
x
2
h 4!

f x h 2 f x f x h
f 2
x
h2
NUMERICAL INTEGRATION

The inverse process of differentiation

Mathematically, INTEGRATION 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.
In many cases a mathematical expression for
f(x) is unknown and in some cases even if f(x)
is known its complex form makes it difficult to
perform the integration.
b

I f x dx
f(x)
a

a b x
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
Newton-Cotes Integration
Formulas

Riemann Rule
Trapezoidal rule
Simpsons Rules
Rarely used in
Unequal Segments chem eng
Open Integration
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
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 )
2

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

f(x ) 3

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 )

f(x )
2 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 1 x dx
a a

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 straight line can be represented as:

f b f a
f 1 x f a x a
ba
Area= (b-a) f(a) + (b-a) (f(b) f(a))
= (b-a) (f(a)- f(a)+ f(b))

y
(b-a) (f(b) f(a))f(b)

f(x)

(b-a) f(a) f(a)

x 0 =a x 0 =b x
AREA OF THE
TRAPEZOID
The length of the two parallel sides of the
trapezoid are: f(a) and f(b)
The height is b-a

Area= (b-a) f(a) + (b-a) (f(b) f(a))


= (b-a) (f(a)- f(a)+ f(b))
= (b-a) ( f(a)+ f(b))
= (b-a) ( ( f(a)+ f(b))
b
ba
f ( x )dx f ( a ) f ( b )
a
2
h
f ( a ) f ( b )
2
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
ba

Integrate this equation will results in


the trapezoidal rule.
f a f b
I b a
2
Error of the Trapezoidal Rule

1
Et f ' ' b a
3

12
where a b

This indicates that if 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


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

x n 1

Area . f x0 2 f xi f xn
2 i 1
where there are n+1 equally spaced base points.
Multiple Application of the Trapezoidal
Rule

x1 x2 xn

I f ( x)dx f ( x)dx f ( x)dx


x0 x1 xn1

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 xn1

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


b a 3
the weight of the two end points
Ea 2
f ''
12 n
Example

Evaluate the following integral using the


trapezoidal rule and h = 0.1
1.6 30

e
x2
I dx 25

1 20

f(x)
15
ba
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
Simpsons 1/3 Rule

Corresponds to the case where the function is


a second order polynomial
b b

I f x dx f 2 x dx
a a

f n x a0 a1 x a2 x 2
Simpsons 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 2 x dx
a a
x2
x x1 x x2

f x0 ....... dx
x 0
0
x x1 x0 x2
Simpsons 1/3 Rule
I1
I3
Simpsons 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 Simpsons 1/3 Rule


1
Et f (4)
b a 5

2880
Multiple Application of Simpsons 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
Simpsons 3/8 Rule

Corresponds to the case where the function is


a third order polynomial
b b
I f x dx f3 x dx
a a

f n x a 0 a1 x a 2 x a 3 x
2 3

3h
I f x 0 3f x1 3f x 2 f x 3
8
Composite Numerical
Integration
Riemann Sum (Rectangular
Subdivided Area)
The area under the curve is
subdivided into n subintervals. Each
subinterval is treated as a rectangle.
The area of all subintervals are
added to determine the area under
the curve.
There are several variations of
Riemann sum as applied to
composite integration.
Left
xIn b a / n
x1 Riemann
a
sum, the
x2 a x
left-side
sample of
x3 the
a function
2 x
M
is used as
the height

xi ofathe
i 1 x
individual
rectangle.
n

f x dx f x x
b

a i
i 1
x
In Right
b a / n
x1 a xsum,
Riemann
the right-side
x2 a of
sample 2the
x
function is
x3 aas
used
3the
x
M of the
height
individual
xi a i x
rectangle.

f x dx f x x
b

a i
i 1
x In bthe
a / n
Midpoint Rule,
a 2sample
x1 the 1 1 xat/ 2
a 2middle
x2 the 2 1 ofx / 2
the
a 2 3 1 xis/ 2
x3 subinterval
Mused as the
xi height
a 2 i of
1 the
x / 2
individual
rectangle.
n
f x dx f xi x
b
a
i 1
Composite Trapezoidal Rule:
Divide the interval into n
subintervals and apply Trapezoidal
Rule in each subinterval.
b
h n 1

f ( x )dx f a 2 f ( x k ) f (b )
a
2 k 1
whe
re
ba
h and x k a kh for k 0, 1, 2, ... , n
n

Fin sin (x)dx


d 0

by dividing the interval into 20


subintervals.
n 20
ba
h
n 20
k
x k a kh , k 0, 1, 2, ....., 20
20

h n 1

0 sin( x )dx 2 f a 2
k 1
f ( x k ) f ( b )

19
k
sin 0 2 sin sin
40 k 1 20
1.995886
Composite Simpsons Rule:
Divide the interval into n subintervals
and apply Simpsons Rule on each
consecutive pair of subinterval. Note
that n must be even.

h
b ( n / 2 ) 1

f ( x )dx f a 2 f (x 2k )
a
3 k 1

n/ 2

4 f ( x 2 k 1 ) f (b )
k 1

9
2k
0 sin( x )dx 60 sin 0 2
k 1
sin
20

10
( 2k 1)
4 sin sin( )
k 1 20
2.000006
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
Trapezoidal rule integration
with Excel

Riemann
Sum rule
integration
with Excel
n

f x dx f x x
b

a i
i 1

x n 1
I f x0 2 f xi f xn Trapezoidal
2 i 1 Sum rule
integration
The endpoints (initial and terminal) of the interval,
and the number of divisions are entered in the cells
A2, B2, C2, respectively. The value of h is calculated
in the cell D2 by entering the formula = (B2-A2)/C2.

To generate the xs i we take the following steps:


1. In cell E2 enter the formula =A2. This copies the
value of 0 a = x into E2.

2. The next values are generated with the formula


= IF(E2>=$B$2,$B$2,E2+$D$2) in E3.
This formula adds h to the previous value until
we reach the value of b .
Afterwards it keeps entering the value of b . This
mechanism is used to enable changing the value
of n to get more control on the accuracy of the
solution as explained in Step 5.
3. Copy this formula to the next 100 cells or so
below E4. The below figure shows a part of the
sheet further down, where you can see the value
of b being repeated.
4. The function f is entered in the column labeled ( )
i f x by entering the formula =7+14*E2^6 in the
cell F2 and copying it along the corresponding
cells for the ixs.
5. We then form the elements of the summation in
the trapezoidal rule by entering the formula =
(E3-E2)/2*(F2+F3) in cell G3 and copying it along
the corresponding cells for the ixs.
6. The last step is to add the terms in column G to
get the approximation of the integral. Select the
range of cells that contains the summation terms
and then click the sum button ( ) on the toolbar.
Observe that, instead of using the value of h
generated in cell D2, we used the equivalent
difference E3-E2. This has two advantages:
a) The formula produces zeros when we go past the
right endpoint b . In this way,the final sum of
these numbers is not affected by the repetition
of b .
b) It allows the use of the trapezoidal rule with non-
uniform divisions of the interval [a, b].
Note:
(a) If you now change the number of divisions n to
100, the new, more accurate approximation will
appear in the same cell (G103).
(b) To change the interval of integration all you need
to do is to change the values a, b in cells A2, B2.
(c) To change the integrated function enter the new
formula in cell F2 and copy it to cell F103.
Simpson rule integration with
Excel

Where the interval [a, b] is divided into n intervals,


each of length

The Excel implementation of Simpsons rule is very


much similar to that of the trapezoidal rule, except
for some details.
h
I f x0 4 f x1 f x2
3
f x0 4 f x1 f x2
b a
6
Simpson rule integration with
Excel

As you can see from


this figure the table is
exactly the same as
that for the
trapezoidal rule
except for the last
column. The last
column is generated
as follows. In the cell
G3 enter the formula
=(E4-
E2)/6*(F2+4*F3+F4).
Group Task
1. Using Riemann, Trapezoidal and Simpson rule,
find the value of
a.
exact value =
If it is taken as x = 0.5

1

x2
b. x .e dx
0

If it is taken as x = 0.25
Compare their calculation results with the
exact value and make a remark.
2. Do problem No. 17 Chapter 3 Chemical
Reaction Engineering by Levenspiel on
catalytic reaction of sucrose.
THE END
1.5


x2
Example: I ce 1.00000
dx (if c = 1.517858)
0.2
n Trap. Simp. 1/3 Simp. 3/8
1 1.05191
2 1.00499* 0.98935
3 1.00187* 0.99561
4 1.00099 0.99965*
6 1.00042 0.99994* 0.99985
8 1.00023 0.99998*
9 1.00019 0.99998*
12 1.00011 1.00000* 1.00000*
15 1.00008 1.00000*
16 1.00006 1.00000*
32 1.00001
64 1.00000
Asterisk (*) denotes the more accurate answer for each n.