Anda di halaman 1dari 51

Numerical Methods for Chemical Engineers

CHAPTER 6: NUMERICAL INTEGRATION & DIFFERENTIATION


6.1 Introduction Calculus is the mathematics of change which consists of concepts of differentiation and integration. Thus, it is very useful and essential for engineers to deal with systems and processes that change. Mathematically, the derivative is the fundamental vehicle for differentiation, represents the rate of change of a dependent variable with respect to an independent variable. Mathematical definition of derivative begins with a difference approximation :

!y f ( xi + !x) " f ( xi ) = !x !x
where; y and f(x) = dependent variable x = independent variable

------ (6.1)

Numerical Methods for Chemical Engineers If x approach zero (shown in Fig 1 a - c) the difference becomes derivative;

f ( xi + !x) " f ( xi ) dy = lim dx !x #0 !x


where; dy/dx or y or f(x) = 1st derivative of y with respect to x evaluated at xi. From Fig.1(c) 1st derivative is the slope of tangent to the curve at xi.

Numerical Methods for Chemical Engineers Inverse of differentiation is integration. Integrate means (dictionary): to bring together, to unite or to indicate the total amount. Mathematically, integration is represented by:
b

I = ! f ( x) dx
a

-------- (6.2)

where, I = integral the function f(x) with respect to independent variable x evaluated between limits x = a to x = b. Fig. 2 represent a graphical concept of integral, where integral of f(x) between limit x = a to x = b, represents to the area under the curve.

Numerical Methods for Chemical Engineers Function to be differentiated or integrated will be in one of three forms: 1. Simple continuous function such as polynomial, an exponential or trigonometric. 2. Complicated continuous function - difficult to differentiate or integrate directly 3. Tabulated function values x and f(x) are given as discrete points i.e experimental data or field data. Quick Example: Find the integral below.
0.8

I = ! (0.2 + 25 x " 200 x 2 + 675 x 3 " 900 x 4 + 400 x 5 )dx


0

Answer:

25 2 200 3 675 4 900 5 400 6 # & I = $0.2 x + x ' x + x ' x + x ! 2 3 4 5 6 % "0


As x = 0 to 0.8, thus I = 1.6405333

0.8

Numerical Methods for Chemical Engineers 6.2 Newton-Cotes Integration Formulas The most common numerical integration schemes. Based on strategy of replacing a complicated function or tabulated data with an approximating function that is easy to integrate.
b b

I = ! f ( x)dx " ! f n ( x)dx


a a

where; fn(x) = polynomial in the form of fn(x) = ao + a1x + a2x2 + . . . .an-1 x n-1 + anxn n = order of polynomial

Numerical Methods for Chemical Engineers Fig.3a ; first order polynomial is used as approximation (as straight line) Fig.3b ; parabola is employed

Numerical Methods for Chemical Engineers Integral can also be computed using a series of polynomial or data over segments of constant length. Fig.4 ; Three straight line segments are used to approximate the integral (also called as strip method)

Fig. 4 Newton-Cotes formulas can be divided into 2 forms; a. Closed forms - data points at beginning and end of the limits of integration are known (shown in Fig.5a) b. Open forms - integration limits extended beyond the range of the data (shown in Fig.5b) Chapter 6 is only emphasizes the closed forms.
7

Numerical Methods for Chemical Engineers

Fig. 5 (a) and (b) Open Newton-Cotes, generally are not used for definite integration, they are utilized for evaluating improper integrals and for solution of Ordinary Differential equations (ODE) - as discussed later in Chapter 7.

Numerical Methods for Chemical Engineers 6.2.1 Trapezoidal Rule The first of Newton-Cotes closed integration formula. For 1st order polynomial integration:

I = ! f ( x)dx " ! f1 ( x)dx


a a

In the form of straight line;

f (b) ! f (a ) f1 ( x) = f (a ) + ( x ! a) b!a
Integral forms (area under straight line between the limits a and b)

f (b) ( f (a ) ' $ I = ! % f (a) + ( x ( a )"dx a b(a & #


b

After integration; (called as Trapezoidal Rule Formula)

f (a ) + f (b) I = (b ! a ) 2

Numerical Methods for Chemical Engineers Geometrically, trapezoidal rule is equivalent to approximating the area of the trapezoidal under the straight line connecting f(a) and f(b) as shown in Fig.6. Integral estimate can be represented as; I = width x height or (b a) x Average height where; Average height = average of the function values at end points = [f(a) + f(b)]/2

Fig.6

10

Numerical Methods for Chemical Engineers 6.2.2 Error of Trapezoidal Rule An estimate for truncation error of a single application of the trapezoidal rule is;

1 " Ea = ! f (" )(b ! a ) 3 12 " = Lies somewhere in the interval from a to b


f() = mean 2nd derivative = ab f(x) dx/(b-a) Example 1: Use trapezoidal rule to numerically integrate the function below; f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 From a = 0 to b = 0.8 The exact value of the integral, analytically determined is 1.640533 Solution: Function values; f(0) = 0.2 and f(0.8) = 0.232 Substituted into trapezoidal rule formula:

I = (b ! a )

f (a ) + f (b) 2
11

= 0.8 (0.2 + 0.232) / 2 = 0.1728

Numerical Methods for Chemical Engineers Example 1: Use trapezoidal rule to numerically integrate the function below; f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 from a = 0 to b = 0.8 The exact value of the integral, analytically determined is 1.640533

Solution: Function values; f(0) = 0.2 and f(0.8) = 0.232 Substituted into trapezoidal rule formula:

f (a ) + f (b) I = (b ' a ) 2 & 0.2 + 0.232 # I = (0.8 ' 0) $ ! = 0.1728 2 % "


12

Numerical Methods for Chemical Engineers Et = 1.640533 0.1728 = 1.467733 t = 1.467733/1.640533 x 100% = 89.5% A large error (Fig.7) because neglects significant portion above the straight line.

Fig.7
13

Numerical Methods for Chemical Engineers In actual situations, we have no knowledge of the true value, therefore an approximate error estimate is required. To obtain approximate error, the functions 2nd derivative over the interval can be computed by differentiating the original function twice; For example: f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 f(x) = 25 400x + 2025x2 3600x3 + 2000x4 f(x) = -400 + 4050x 10800x2 + 8000x3 Average/Mean value of 2nd derivative:

f "( x) = !

0.8

("400 + 4050 x " 10800 x 2 + 8000 x 3 )dx 0.8 " 0

= - 60 Substituted into:

1 " Ea = ! f (" )(b ! a ) 3 12


= -(1/12) (-60)(0.8) = 2.56
14

Numerical Methods for Chemical Engineers 6.2.3 The Multiple Application Trapezoidal Rule To improve the accuracy of Trapezoidal Rule - by divide the integration interval from a to b into a number of segments. Results equation is called Multiple Application or composite integration formulas.

15

Numerical Methods for Chemical Engineers Fig.8: General format for Multiple Application Integrals

From Fig. 8, where;

h = (b-a)/n, -------- (1)

n = no. of segments equal width a = xo and b = xn Total integral represented as;

I = ! f ( x)dx + ! f ( x)dx + ..... + !


xo x1

x1

x2

xn

xn"1

f ( x)dx
16

Numerical Methods for Chemical Engineers Substituting the Trapezoidal rule;


I =h f ( xo ) + f ( x1 ) f ( xn !1 ) + f ( xn ) f ( x1 ) + f ( x2 ) +h + ..... + h 2 2 2

---(2)

In grouping terms of equation (2)


n (1 h& # I = $ f ( xo ) + 2' f ( xi ) + f ( xn )! 2% i =1 "

------ (3)

By using equation (1) where by substituting; h = (b-a)/n


n '1 & # f ( xo ) + 2( f ( xi ) + f ( xn ) ! $ i =1 ! I = (b ' a ) $ 2n ( width ) $ ! $ ! % " Averageheight

------ (4) Called as Multiple App. Trapezoidal Rule

An error can be obtained by summing individual error for each segment;

(b " a ) 3 n Et = " f " (# i ) 3 ! 12n i =1

------- (5)

where; f() = 2nd derivative at point i located in segment i.

17

Numerical Methods for Chemical Engineers Simplified equation (5)


_

f""
where;

! f " (# )
i i =1

----- (6)

! f " (# ) " nf "


i i =1

--------- (7)

Or equation (5) can be rewritten as;

(b ! a ) 3 _ Ea = ! f " ------ (8) 2 12n


where equation (8) is called as Approximate Error for Multiple Application Trapezoidal Rule If the number of segments is double, the truncation error will be quartered.

18

Numerical Methods for Chemical Engineers Example 2: Use the two-segment trapezoidal rule to estimate the integral of: f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 From a = 0 and b = 0.8. Then employ equation (8) to estimate the approximation error. The true value for the integral is 1.640533 Solution: n = 2, thus, h = (b-a)/n = (0.8-0)/2 = 0.4 Function values; f(0) = 0.2 f(0.4) = 2.456 f(0.8) = 0.232 Thus; from equation (4)
n & # f ( xo ) + 2( f ( xi ) + f ( xn ) ! $ i =1 ! I = (b ' a ) $ 2n $ ! $ ! % "

& 0.2 + 2(2.456) + 0.232 # I = (0.8) $ ! 4 % "


=1.0688
19

Numerical Methods for Chemical Engineers To calculate true error; Et = 1.640533 1.0688 = 0.57173 where = 34.9%

To calculate approximate error for multiple application trapezoidal rule: from equation (8);

(b ! a ) 3 _ Ea = ! f" 2 12n
(0.8) 3 Ea = ! (!60) = 0.64 2 12(2 )
Where (60) is the average 2nd derivative determined previously in Example. Fig.9: significant reduce in error by increasing segment

20

Numerical Methods for Chemical Engineers 6.3 Simpson Rules Another way to obtain a more accurate estimate of an integral, by using high-order polynomials to connect the data points. If there is an extra point midway between f(a) and f(b), the three points can be connected with a parabola, as shown in Fig. 10(a).

Fig.10a: The formula that result from the intervals under these polynomials are called Simpsons Rules.
21

Numerical Methods for Chemical Engineers 6.3.1 The Simpsons 1/3 Rule Simpsons 1/3 rule, results when a 2nd order interpolating polynomial is substituted into equation;

I = ! f ( x)dx " ! f 2 ( x)dx


a a

If a = xo and b = x2, and f2(x) = 2nd order Lagrange polynomial; the integral above becomes;
x2 ' ( x ( x )( x ( x ) $ ( x ( x0 )( x ( x2 ) ( x ( x0 )( x ( x1 ) 1 2 I =! % f ( x0 ) + f ( x1 ) + f ( x2 )" dx x1 ( x1 ( x0 )( x1 ( x2 ) ( x2 ( x0 )( x2 ( x1 ) & ( x0 ( x1 )( x0 ( x2 ) #

After integration and algebraic manipulation;

h I ! [ f ( x0 ) + 4 f ( x1 ) + f ( x2 )] 3
where; h = (b-a)/2 Same as the 2nd Newton-Cotes Closed integration formula. 1/3 label because h is divided by 3
22

Numerical Methods for Chemical Engineers Simpsons 1/3 Rule can also be expressed as;

& f ( x0 ) + 4 f ( x1 ) + f ( x2 ) # I ( (b ' a ) $ ! 6 width % "


average.height

where; a = xo , b = x2 , and x1 = point midway between a and b = (b + a) /2

6.3.2 Truncation Error for Simpsons 1/3 Rule For a single-segment application;

Et = "

1 5 ( 4) h f (! ) 90

Because, h = (b-a)/2, thus equation above becomes;

(b " a ) 5 ( 4 ) Et = " f (! ) 2880


where; = lies somewhere in interval from a to b. Simpsons 1/3 rule is more accurate than Trapezoidal Rule.

23

Numerical Methods for Chemical Engineers Example 3: Single application of Simpsons 1/3 Rule. Use equation below to integrate from a = 0 to b = 0.8. Also calculate the true error and approximation error. The true value for the integral is 1.640533 f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 Solution: Function values; f(0) = 0.2 f(0.4) = 2.456 f(0.8) = 0.232 Therefore from Simpsons 1/3 rule equation;

& f ( x0 ) + 4 f ( x1 ) + f ( x2 ) # I ( (b ' a ) $ ! 6 % " & 0.2 + 4(2.456) + 0.232 # I = (0.8) $ ! = 1.367467 6 % "
where; Et = 1.640533 1.367467 = 0.2730667 and; t = 0.2730667/1.640533 x 100% = 16.8% (5 time more accurate than trapezoidal rule; t = 89.5%)
24

Numerical Methods for Chemical Engineers To calculate approximation error;

(b " a ) 5 ( 4 ) Ea = " f (! ) 2880


= [-(0.8)5 / (2880)] x (-2400) = 0.2730667 Where, (-2400) is the average 4th derivative [f 4 ] for the interval.

25

Numerical Methods for Chemical Engineers 6.3.3 The Multiple Application Simpsons 1/3 Rule Simpsons rule can be improved by dividing the integration interval into a number of segments of equal width, h = (b-a)/n.

Fig.11: Segments divided into an even number (2,4,6..)

26

Numerical Methods for Chemical Engineers Total integral represents as;

I = ! f ( x)dx + ! f ( x)dx + ...... + !


x0 x2

x2

x4

xn

xn"2

f ( x)dx

Substituting Simpsons 1/3 rule for the individual integral;

& f ( x ) + 4 f ( x3 ) + f ( x4 ) # & f ( x) + 4 f ( x1 ) + f ( x2 ) # I = 2h ( $ + 2h $ 2 !+ ! x0 6 6 % " % " & f ( xn'2 ) + 4 f ( xn'1 ) + f ( xn ) # ....... + 2h $ ! 6 % "


x2

27

Numerical Methods for Chemical Engineers Combining terms and change, h = (b-a)/n
n '1 n'2 & # f ( x0 ) + 4 ) f ( xi ) + 2 ) f ( x j ) + f ( xn ) ! $ i =1, 3, 5... j = 2 , 4 , 6... ! I ( (b ' a) $ 3n ! width $ $ ! % " Average. Height

The equation above is called as the Multiple Application Simpsons 1/3 Rule.

6.3.4 Error Estimate of Multiple Application Simpson 1/3 Rule. Same fashion as for Trapezoidal Rule;

(b ! a ) 5 !4 ) Ea = ! f( 180n 4
where, f 4 = the average 4th derivative for the interval.
28

Numerical Methods for Chemical Engineers Example 4 : Multiple Application Simpsons 1/3 Rule By using the multiple application Simpsons rule, with n = 4 estimate the integral of; f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 From a = 0 and b = 0.8. Exact integral is 1.640533 Solution: n = 4; thus h = (b-a)/n = 0.8/4 = 0.2

Calculate for functions value; f(0) = 0.2 f(0.2) = 1.288 f(0.4) = 2.456 f(0.6) = 3.464

f(0.8) = 0.232

From the Multiple application Simpsons 1/3 Rule; n '1 n'2 & # f ( x0 ) + 4 ) f ( xi ) + 2 ) f ( x j ) + f ( xn ) ! $ i =1, 3, 5... j = 2 , 4 , 6... ! I ( (b ' a ) $ 3n $ ! width $ ! % "
Average. Height

& 0.2 + 4(1.288 + 3.464) + 2( 2.456) + 0.232 # = 0.8$ ! 12 % " = 1.623467


29

Numerical Methods for Chemical Engineers Thus; Et = 1.640533 1.623467 = 0.017067 t = 0.017067 / 1.640533 x 100% = 1.04%

Approximation error;

(b ! a ) 5 !4 ) Ea = ! f( 180n 4 (0.8) 5 =! (!2400) 4 180(4) = 0.017067


From the answers, multiple application version of Simpsons 1/3 Rule yields very accurate results. However, it is in limited cases where the intervals are in equi-spaced, limited situation where an even number of segments and an odd number of points.

30

Numerical Methods for Chemical Engineers 6.3.5 The Simpsons 3/8 Rule Permit evaluation of odd numbers of segments, and even number of points Derivative of Trapezoidal and Simpsons 1/3 rule, 3rd order Lagrange Polynomial can be fit to four points and integrated.

I = ! f ( x)dx " ! f 3 ( x)dx


a a

To yield;

3h I " [f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 )] 8 where b!a h= 3


We call the equation as 3/8 Rule because h is multiply by 3/8 (or called as Newton-Cotes closed integration 31 formula)

Numerical Methods for Chemical Engineers Simpsons 3/8 Rule expressed in trapezoidal forms;

& # f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 ) ! I ( (b ' a ) $ ! 8 Width $ Average. Height % "


6.3.6 Approximation Error of Simpson 3/8 Rule

3 5 ( 4) Et = " h f (! ) 80
Because, h = (b-a)/3, thus;

(b " a ) 5 ( 4 ) Et = " f (! ) 6480


Because denominator is larger than Simpsons 1/3 Rule; thus Simpsons 3/8 Rule is more accurate than Simpsons 1/3 Rule.
32

Numerical Methods for Chemical Engineers Example 5: The Simpsons 3/8 Rule a. Use Simpsons 3/8 Rule to integrate; f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 from a = 0 to b = 0.8. b. Use it in conjunction with Simpsons 1/3 Rule to integrate the same function for 5 segments.

Solution: a. A single application of Simpsons 3/8 Rule requires 4 points (3 intervals) Thus; f(0) = 0.2 f(0.2667) = 1.432724 f(0.5333) = 3.487177 f(0.8) = 0.232 For Simpsons 3/8 Rule;

' $ f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 ) " I ! (b ( a ) % " 8 Width % Average. Height & # ' 0.2 + 3(1.432724) + 3(3.487177) + 0.232 $ ! 0.8% " 8 & # ! 1.519170 33

Numerical Methods for Chemical Engineers Et = 1.640533 1.519170 = 0.1213630 t = 0.1213630/1.640533 x 100% = 7.4% For Approximation error;

(b ! a ) 5 ( 4 ) Ea = ! f (" ) 6480 (0.8) 5 =! ( !2400) 6480 = 0.1213630

34

Numerical Methods for Chemical Engineers b. The data needed for a 5-segment application (h = 0.16) is; f(0) = 0.2 f(0.32) = 1.743393 f(0.64) = 3.181929 f(0.16) = 1.296919 f(0.48) = 3.186015 f(0.80) = 0.232

Integral for the first two segments is obtained using Simpsons 1/3 Rule;

& f ( x0 ) + 4 f ( x1 ) + f ( x2 ) # I ( (b ' a ) $ ! 6 width % "


average.height

& 0.2 + 4(1.296919) + 1.743393) # = (0.32) $ ! 6 % " = 0.3803237

35

Numerical Methods for Chemical Engineers For the last three segments, Simpsons 3/8 Rule can be used to obtain;

' $ f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 ) " I ! (b ( a ) % " 8 Width % Average. Height & # '1.743393 + 3(3.186015) + 3(3.181929) + 0.232 $ ! 0.48% " 8 & # ! 1.264754
Total integral; I = 0.3803237 + 1.264753 = 1.645077 where; Et = 1.640533 1.645077 = -0.00454383 t = -0.28%

36

Numerical Methods for Chemical Engineers 6.4 Integration with Unequal Segments From previous section, all formulas for numerical integration have been based on equally spaced data points [h = (b-a)/n]. In many situation, this assumption does not happen and we must deal with unequal sized segments. One method is to apply the trapezoidal rule to each segment and sum the results;

& f ( x ) + f ( x1 ) # & f ( x1 ) + f ( x2 ) # & f ( x ) + f ( xn ) # I = h1 $ 0 + h2 $ + ..... + hn $ n'1 ! ! ! 2 2 2 " % " % % "


where; hi = width of segment i. This was the same approach used for the multiple application trapezoidal rule, but h does not same for each segment in this case.

37

Numerical Methods for Chemical Engineers Example 6: Trapezoidal Rule with unequal segments The information in Table below was generated using the same polynomial employed in Example 1. Use Trapezoidal Rule for Unequal Segments to determine the integral for this data. True value for polynomial is 1.640533. f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 x 0.0 0.12 0.22 0.32 0.36 0.40 f(x) 0.2 1.309729 1.305241 1.743393 2.074903 2.456000 x 0.44 0.54 0.64 0.70 0.80 f(x) 2.842985 3.507297 3.181929 2.363000 0.232000

38

Numerical Methods for Chemical Engineers Solution: From Trapezoidal Rule for Unequal Segments;

& f ( x0 ) + f ( x1 ) # & f ( x1 ) + f ( x2 ) # & f ( xn'1 ) + f ( xn ) # I = h1 $ ! + h2 $ ! ! + ..... + hn $ 2 2 2 " % " % % "


& f ( x0 ) + f ( x1 ) # & f ( x1 ) + f ( x2 ) # I = h1 $ + h2 $ ! !+ 2 2 % " % " & f ( xn '1 ) + f ( xn ) # ..... + hn $ ! 2 % " &1.309727 + 0.2 # &1.305241 + 1.309729 # = 0.12 $ + 0.10 $ ! !+ 2 2 % " % " & 0.232 + 2.363 # ..... + 0.10 $ ! 2 % " = 0.090584 + 0.130749 + ........ + 0.12975 = 1.594801

where; t= 2.8%
39

Numerical Methods for Chemical Engineers Example 7: Inclusion of Simpsons Rules in the Evaluation of Uneven Data Recompute the integral for the data but use Simpsons rules for those segments where they are appropriate. f(x) = 0.2 + 25x 200x2 + 675 x3 900x4 + 400x5 x 0.0 0.12 0.22 0.32 0.36 0.40 f(x) 0.2 1.309729 1.305241 1.743393 2.074903 2.456000 x 0.44 0.54 0.64 0.70 0.80 f(x) 2.842985 3.507297 3.181929 2.363000 0.232000

40

Numerical Methods for Chemical Engineers Solution: The first segment is evaluated with trapezoidal rule: 1. x = 0 to 0.12 (use trapezoidal)

&1.309729 + 0.2 # I = 0.12 $ ! = 0.09058376 2 % "


2. x = 0.12 to 0.32 (use Simpsons 1/3):

1.743393 + 4(1.30524) + 1.309729 I = 0.2 = 0.2758029 6


3. x = 0.32 to 0.44 (use Simpsons 3/8)

I = 0.2726863
4. x = 0.44 to 0.64 (use Simpsons 1/3)

I = 0.6684701
5. 6. x = 0.64 to 0.80 (use trapezoidal) Total integral = 1.603641

41

Numerical Methods for Chemical Engineers 6.5 NUMERICAL DIFFERENTIATION In previous chapter we discussed, finite-divideddifference, and also we developed forward, backward and centered difference approximations of 1st and higher derivatives. Now we will develop more accurate formula by retaining more terms, by applying Taylor Series. 6.5.1 High Accuracy differentiation Formulas Taylor series expansion;

f " ( xi )h 2 f ( xi +1 ) = f ( xi ) + f ' ( xi )h + + ...... 2


which can be solved; thus,

f (x i+1 ) " f (x i ) f '' (x i ) f '(x i ) = " h + O(h 2 ) h 2


Truncated the 2nd and higher derivative terms;

f ( xi +1 ) ! f ( xi ) f ' ( xi ) = + O ( h) h
42

Numerical Methods for Chemical Engineers In this chapter we retain 2nd derivative term by substituting the following approximation of 2nd derivative;

Thus;
'

f ( xi + 2 ) ! 2 f ( xi +1 ) + f ( xi ) f ( xi ) = + O ( h) 2 h
''

f ( xi +1 ) ! f ( xi ) f ( xi + 2 ) ! 2 f ( xi +1 ) + f ( xi ) f ( xi ) = ! h + O(h 2 ) h 2h 2
Simplify the equation above;

! f ( xi + 2 ) + 4 f ( xi +1 ) ! 3 f ( xi ) f ( xi ) = + O(h 2 ) 2h
'

Inclusion of 2nd derivative term has improved the accuracy of 0(h2) Similar improved versions for : backward and centered formulas as shown in Fig. 23.1, 23.2, and 23.3

43

Numerical Methods for Chemical Engineers Forward Finite-divided-difference Formulas:

44

Numerical Methods for Chemical Engineers Backward Finite-divided-difference Formulas:

45

Numerical Methods for Chemical Engineers Centered Finite-divided-difference Formulas:

46

Numerical Methods for Chemical Engineers Example 7: High Accuracy Differentiation Formulas Estimate the derivative of the following function using high accuracy formulas:

f ( x) = !0.1x 4 ! 0.15 x 3 ! 0.5 x 2 ! 0.25 x + 1.2


Solution: The derivative of the function at x = 0.5 using finitedivided-differences and a step size of h = 0.25 (Ch4). Forward O(h) Estimate True error (%) -1.155 -26.5 Backward O(h) -0.714 21.7 Centered O(h) -0.934 -2.4

47

Numerical Methods for Chemical Engineers Using high accuracy formulas, data needed:

xi ! 2 = 0

f ( xi ! 2 ) = 1.2

xi !1 = 0.25 xi = 0.5 xi +1 = 0.75 xi + 2 = 1


f ' (0.5) =

f ( xi !1 ) = 1.103516 f ( xi ) = 0.925 f ( xi +1 ) = 0.6363281 f ( xi + 2 ) = 0.2

The forward difference of accuracy O(h2):

! 0.2 + 4(0.6363281) ! 3(0.925) = !0.859375 2(0.25) " t = 5.82%


The backward difference of accuracy O(h2):

3(0.925) ! 4(1.035156) + 1.2 = !0.878125 2(0.25) " t = 3.77% f ' (0.5) =


The centered difference of accuracy O(h4):

f ' (0.5) =

! 0.2 + 8(0.6363281) ! 8(1.035156) + 1.2 = !0.9125 12(0.25)


48

" t = 0%

Numerical Methods for Chemical Engineers 6.5.2 Derivatives of Unequally Spaced Data For the finite-divided difference approximations, the data had to be evenly spaced. One way to handle non-equispaced data is to fit a second-order Lagrange interpolating polynomial.

f ' ( x) = f ( xi !1 )

2 x ! xi ! xi +1 + ( xi !1 ! xi )( xi !1 ! xi +1 )

2 x ! xi !1 ! xi +1 f ( xi ) + ( xi ! xi !1 )( xi ! xi +1 ) 2 x ! xi !1 ! xi f ( xi +1 ) ( xi +1 ! xi !1 )( xi +1 ! xi )
Three main advantages: 1. It can be used to estimate the derivative within any range by three points. 2. The points do not have to be equally spaced. 3. The accuracy is the same as centered difference.

49

Numerical Methods for Chemical Engineers Example: Differentiating Unequally Spaced Data

50

Numerical Methods for Chemical Engineers Solution:

51

Anda mungkin juga menyukai