You are on page 1of 28

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Numerical Methods for Chemical Engineers


Chapter 2: Approximations and Errors

Saharudin Haron
Page 2 - 1

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Dimensional Homogeneity
Valid equation must be dimensionally homogenous Both sides of equation must have same dimensions V(m/s) = Vo(m/s) + g(m/s2)t(s) Example : Consider this equation D(ft) = 3t(s) + 4 What is the dimension and unit for constants 3 and 4? Constant 3 Constant 4 length/time length

ft/s ft
Page 2 - 2

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Scientific Notation
Large and very small number often encountered in process calculations Convenient way to represent such number is to use scientific notation Expressed between 0.1 and 10 and a power of 10 123 000 000 = 1.23 x 108 (or 0.123 x 109) 0.000028 = 2.8 x 10-5 (or 0.28 x 10-4)

Page 2 - 3

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Significant Figure
The significant of a number are the digits from the first nonzero on the left to either the last digit (zero or nonzero) on the right if there is decimal point the last nonzero digit of the number if there is no decimal point 2300 or 2.3 x 103 has two significant figures 2300. or 2.300 x 103 has four significant figures 2300.0 or 2.3000 x 103 has five significant figures 23040 or 2.304 x 104 has four significant figures 0.035 or 3.5 x 10-2 has two significant figures 0.03500 or 3.500 x 10-2 has four significant figures

Page 2 - 4

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Multiplication and division The answer should be equal to the lowest significant figure of any multiplicands or divisors (3) (4) (7) (3.57)(4.286) = 15.30102 (2) (4) (3) (9) (5.2 x 10-4)(0.1635 x 107)/(2.67) = 318.426966 rounding the last digit 5 to even number 1.35 => 1.4 1.25 => 1.2 (3) 15.3

Rule of thumb on significant figure

(2) (2) 3.2 x102 = 320

Page 2 - 5

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Significant Figure
(assignment in class)

Calculate the following and give your answer according to the rule of significant figure: a) b) c) d) (3.4)(2.75) (1.76)(0.00120)/(78.2) (5.400 x 103)/27 (9.83 x 107)(0.2 x 10-5)

Page 2 - 6

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Accuracy and Precision


Accuracy - How closely a computed or measured value agrees with the true value Precision - How closely individual computed or measured values agree with each other
the number of significant figures representing a quantity the spread in repeated computations or measurements of a particular value

Page 2 - 7

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Accuracy and Precision


Increasing accuracy
Increasing Precision

Page 2 - 8

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Errors
Numerical error arise from the use of approximation to represent exact mathematical operations and quantities Truncation Error - approximation of mathematical procedures Round-off error - approximation of exact numbers The relation between exact, or true and the approximate True value = Approximation + error Et = true value - approximation Short comings - no magnitude how big the error is To rectify the problem - Fractional Relative Error = Error/True value true error Percent relative error is given by t = 100% true value
Page 2 - 9

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Errors
Example: The measured lengths of a bridge and a pen are 9999 cm and 9 cm respectively. If the true values are 10,000 cm and 10 cm respectively, compute, (a) true error and (b) true percent relative error for each case. Solution: a) The error for measuring the bridge is: Et = 10,000 9999 = 1 cm and for the pen is: Et = 10 9 = 1 cm b) The percent Relative Error for the bridge is:
t = 1/10,000 * 100 = 0.01 % and for the pen is: t = 1/10 * 100% = 10 %
Page 2 - 10

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Approximation of error
In actual situation the true value is rarely available Typically the case when we investigate the theoretical behavior of technique of simple system approximate error a = 100% approximation The challenge of numerical method is to find the approximation error Solving this by using iterative approach by using the previous value as basis

a =

present approximation previous approximation 100% present approximation

The iteration is stop until |a| < s (the prespecified tolerance) Tolerance to at least n significant figures is given as s = (0.5 X 10 2-n)%
Page 2 - 11

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Error Estimates
Exponential function can be estimated by
2 3 n x x x ex = 1 + x + + + L + 2! 3! n!

(Maclaurin Series)

Find the estimate of e 0.5 with s to 3 significant figures. The true value for this function is 1.648721271. Results from iteration

e 0.5 = 1 + 0.5 = 1.5 1.648721271 1.5 t = 100% = 9.02 1.648721271 1.5 1 a = 100% = 33.3% 1.5
Page 2 - 12

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Error using iterative method


Terms Result et ,% ea ,%

1 2 3 4 5 6

1 1.5 1.625 1.645833333 1.648437500 1.648697917

39.3 9.02 1.44 0.175 0.0172 0.00142

33.3 7.69 1.27 0.158 0.0158

After six terms are included, the approximate error falls below ea = 0.05 %

Page 2 - 13

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Error using iterative method


(assignment in class) Evaluate e-8.3 using two approches :

and

x 2 x3 x 4 = 1 x + - + - ... 2 3! 4!

ex =

1 = x e

1 x 2 x3 x 4 1 + x + + + + ... 2 3! 4!

and calculate the errors. Compare the answers with the true value of 2.485168 x 10-4 after 6 iteration.

Page 2 - 14

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Round-off Errors
Related to the manner in which numbers are stored in computer Due to the problems of word, string of binary digits and bits 22 7 , , , e 7 In every day life we are using the base-10 system 0,1, 2, 3, 4, 5, 6, 7, 8, 9 For larger quantity combination of this digit is used. 86409 = (8 X 104) + (6 X 103) + (4 X 102) + (0 X 101) + (9 X 100) The computers are using the system of binary unit or base-2 11 in computer (base -2) is equivalent to 3 in the base-10 system 1 0 0 0 0 0 0 0 1 0 1 0 1 1 0 1

Decimal -173 on a 16 bit computer using signed method


Page 2 - 15

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Range of Integers
Problem Statement Determine the range of integers in base-10 that can be presented on a 16 - bit computer Solution

Of the 16 bits, the first bit holds the sign. The remaining 15 bits can hold binary numbers from 0 to 11111111111111. Converted to a decimal integer which equals to 32767. Thus the ranging of 16-bit computer will be :
-32,767 to 32767

Page 2 - 16

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Truncation Error
Occur because an exact mathematical procedure is estimated Example first order equation in falling parachute problem using finite different method

dv v [v(ti +1 ) v(t )] = dt t (ti+1 ti )


It occur due to the difference equation only approximates the true value of the derivative

Page 2 - 17

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Taylor Series Expansion


Use to predict a function value at one point in terms of the function value and its derivatives at another point. f ( xi +1) f ( xi ) zero order estimation Normally use to estimate parameter or constant

f ( xi +1) f ( xi ) + f ( xi )( xi +1 xi )
Use to predict linear equation

first order estimation

f ( xi +1) f ( xi ) + f ( xi )( xi +1 xi ) +

f ( xi )( xi +1 xi )2 2

second order

To capture some of the curvature that the function might exhibit

Page 2 - 18

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Higher Order Taylor Series Expansion


f ( xi ) 2 f ( xi ) 3 f n ( xi ) n f ( xi +1 ) = f ( xi ) + f ( xi )h + h + h +L+ h 2! 3! n! f ( n +1) ( ) n +1 + h ( n + 1)!
Where h = x i+1 - xi This function can evaluate any function with nth-order approximation The last term in the equation mean the truncation error with the order of

Rn = 0 ( h n +1 )
Page 2 - 19

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Remainder of Taylor Expansion


If we truncated the Taylor Series expansion after the zero term

f ( xi +1) f ( xi )
The remainder or error of this zero order prediction will be

Ro f ( xi ) h +

f ( xi ) 2 f ( xi ) 3 h + h +L 2! 3!

Page 2 - 20

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Zero Order Prediction & Remainder


f(x)
n o i t dic

a Ex

e r p ct

Ro

Zero order prediction

f(xi ) x i+1 x

xi h

Page 2 - 21

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Taylor Series Approximation of Polynomial


Use zero- through fourth-order Taylor series expansions to approximate the function: f(x) = -0.1x4 0.15x3 0.5x2 0.25x + 1.2

from xi = 0 with h = 1. That is, predict the functions value at xi+1 = 1. (f(1) = 0.2 - true value)
Taylor series with n = 0 (zero-order); f (xi+1) f (xi)

Thus, f(1) 1.2 Et = 0.2 1.2 = - 1.0


Page 2 - 22

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Taylor Series Approximation of Polynomial


Taylor series with n = 1 (first-order) f (xi+1) f (xi) + f(xi) (xi+1 xi)

The first derivative must be determined & evaluated at x = 0; f (0) = -0.4(0.0)3 0.45(0.0)2 1.0(0.0) 0.25 = -0.25 Therefore, the first-order approximation: f (xi+1) 1.2 0.25h f (1) 0.95 This results in a reduction of the Et to; Et = 0.2 0.95 = -0.75
Page 2 - 23

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Taylor Series Approximation of Polynomial


Taylor series with n = 2 (second-order) f (xi+1) f (xi) + f(xi ) ( xi+1 xi ) + f(xi )( xi+1 xi )2

2! The second derivative must be determined & evaluated at x = 0;

f = -1.2(0.0)2 0.9(0.0) 1.0 = -1.0 Therefore, the second-order approximation: f (xi+1) 1.2 0.25h 0.5 h2 f (1) 0.45 The Et is reduced further to = 0.2 0.45 = -0.25

Page 2 - 24

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Taylor Series Approximation of Polynomial


Additional terms would improve the approximation even more. Inclusion of 3rd and 4th derivatives results in exactly the same equation we started with:

f (x) = 1.2 0.25h 0.5h2 0.15h3 0.1h4 where the remainder term is; R4 = f (5) ( )/5! h5 = 0 R4 = 0 because the 5th derivative of a 4th-order polynomial is zero.
Consequently, the Taylor series expansion to the fourth derivative yields an exact estimate at xi+1 = 1:

f (1) = 1.2 - 0.25(1) - 0.5(1)2 - 0.15(1)3 - 0.1(1)4 = 0.2


Page 2 - 25

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Approximation of f(x)
f(x) zero order 1.0 first order 0.5
Tr u e

second order 0 xi = 0 h
Page 2 - 26

xi+1 = 1

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Taylor Series Approximation of Polynomial


(assignment in class)
Use zero- through third-order Taylor series expansions to predict f(2) for

f(x) = 25x3 6x2 + 7x - 88

from x = 1. Compute the true percent relative error t for each approximation.

Page 2 - 27

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Trade-off between Round-off and Truncation error


Points of diminishing return
log error
Tot ror r e al

Ro un

tio a c n Tru

rror e n

d-o ff

erro r

log step size

Page 2 - 28

You might also like