skf2133-chapter2n

28
Page 2 - 1 Chemical Engineering Numerical Method © copyright PSE- FKKKSA, UTM Numerical Methods for Numerical Methods for Chemical Engineers Chemical Engineers Chapter 2: Approximations and Errors Chapter 2: Approximations and Errors Saharudin Saharudin Haron Haron

Upload: jossm04

Post on 27-Oct-2014

62 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: skf2133-chapter2n

Page 2 - 1

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Numerical Methods for Numerical Methods for Chemical EngineersChemical EngineersChapter 2: Approximations and ErrorsChapter 2: Approximations and Errors

Saharudin Saharudin HaronHaron

Page 2: skf2133-chapter2n

Page 2 - 2

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Dimensional HomogeneityValid equation must be dimensionally homogenousBoth 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) + 4What is the dimension and unit for constants 3 and 4?

Constant 3 length/time Constant 4 length

ft/sft

Page 3: skf2133-chapter2n

Page 2 - 3

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Scientific NotationLarge and very small number often encountered in process calculationsConvenient way to represent such number is to use scientific notationExpressed 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 4: skf2133-chapter2n

Page 2 - 4

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Significant FigureThe 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 pointthe last nonzero digit of the number if there is no decimal point

2300 or 2.3 x 103 has two significant figures2300. or 2.300 x 103 has four significant figures2300.0 or 2.3000 x 103 has five significant figures23040 or 2.304 x 104 has four significant figures0.035 or 3.5 x 10-2 has two significant figures0.03500 or 3.500 x 10-2 has four significant figures

Page 5: skf2133-chapter2n

Page 2 - 5

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Rule of thumb on significant figureMultiplication and division

The answer should be equal to the lowest significant figure of any multiplicands or divisors

(3) (4) (7) (3)(3.57)(4.286) = 15.30102 15.3

(2) (4) (3) (9) (2) (2)(5.2 x 10-4)(0.1635 x 107)/(2.67) = 318.426966 3.2 x102 = 320

rounding the last digit 5 to even number1.35 => 1.41.25 => 1.2

Page 6: skf2133-chapter2n

Page 2 - 6

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Calculate the following and give your answer according to the rule of significant figure:

a) (3.4)(2.75)b) (1.76)(0.00120)/(78.2)c) (5.400 x 103)/27d) (9.83 x 107)(0.2 x 10-5)

Significant Figure(assignment in class)

Page 7: skf2133-chapter2n

Page 2 - 7

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Accuracy and PrecisionAccuracy - How closely a computed or measured value agrees with the true valuePrecision - How closely individual computed or measured values agree with each other

the number of significant figures representing a quantitythe spread in repeated computations or measurements of a particular value

Page 8: skf2133-chapter2n

Page 2 - 8

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Accuracy and PrecisionIncreasing accuracy

Incr

easi

ng P

rec i

sion

Page 9: skf2133-chapter2n

Page 2 - 9

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

ErrorsNumerical error arise from the use of approximation to represent exact mathematical operations and quantities

Truncation Error - approximation of mathematical proceduresRound-off error - approximation of exact numbers

The relation between exact, or true and the approximateTrue value = Approximation + errorEt = true value - approximation

Short comings - no magnitude how big the error isTo rectify the problem - Fractional Relative Error = Error/True valuePercent relative error is given by ε t =

true errortrue value

100%

Page 10: skf2133-chapter2n

Page 2 - 10

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

ErrorsExample: 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 cmand 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 11: skf2133-chapter2n

Page 2 - 11

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Approximation of errorIn actual situation the true value is rarely availableTypically the case when we investigate the theoretical behavior of technique of simple system

The challenge of numerical method is to find the approximation errorSolving this by using iterative approach by using the previous value as basis

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)%

εa =approximate error

approximation100%

εa =present approximation − previous approximation

present approximation100%

Page 12: skf2133-chapter2n

Page 2 - 12

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Error EstimatesExponential function can be estimated by

(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 iteratione 0.5 = 1 + 0.5 = 1.5

ex = 1+ x +

x2

2!+

x 3

3!+L+

x n

n!

ε t =1.648721271 −1.5

1.648721271100% = 9.02 εa =

1.5 −11.5

100% = 33.3%

Page 13: skf2133-chapter2n

Page 2 - 13

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Error using iterative method

Terms Result et ,% ea ,%

1 1 39.32 1.5 9.02 33.33 1.625 1.44 7.694 1.645833333 0.175 1.275 1.648437500 0.0172 0.1586 1.648697917 0.00142 0.0158

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

Page 14: skf2133-chapter2n

Page 2 - 14

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Evaluate e-8.3 using two approches :

and

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

...-4!

3!

-2

1432 xxxxe x ++−=−

...4!

3!2

1

11432

+++++==−

xxxxee x

x

Error using iterative method(assignment in class)

Page 15: skf2133-chapter2n

Page 2 - 15

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Round-off ErrorsRelated to the manner in which numbers are stored in computerDue to the problems of word, string of binary digits and bits

In every day life we are using the base-10 system0,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-211 in computer (base -2) is equivalent to 3 in the base-10 system

Decimal -173 on a 16 bit computer using signed method

1 0 0 0 0 0 0 0 1 0 1 0 1 1 0 1

e,722,,7 π

Page 16: skf2133-chapter2n

Page 2 - 16

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Range of IntegersProblem 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 17: skf2133-chapter2n

Page 2 - 17

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Truncation ErrorOccur because an exact mathematical procedure is estimatedExample

first order equation in falling parachute problem using finite different method

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

dvdt

≈∆v∆t

=v ti+1( )− v t( )[ ]

ti+1 − ti( )

Page 18: skf2133-chapter2n

Page 2 - 18

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Taylor Series ExpansionUse to predict a function value at one point in terms of the function value and its derivatives at another point.

zero order estimationNormally use to estimate parameter or constant

first order estimationUse to predict linear equation

second order

To capture some of the curvature that the function might exhibit

f (xi+1) ≈ f (xi )

f (xi+1) ≈ f (xi ) + ′ f (xi )(xi+1 − xi )

f (xi+1) ≈ f (xi ) + ′ f (xi )(xi+1 − xi ) +

′ ′ f 2

(xi)( xi+1 − xi)2

Page 19: skf2133-chapter2n

Page 2 - 19

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Higher Order Taylor Series Expansion

( )

1)1(

321

)!1()(

!)(

!3)(

!2)()()(

++

+

++

++′′′

+′′

+′+=

nn

nin

iiiii

hn

f

hn

xfhxfhxfhxfxfxf

ξ

L

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

)( 1+= nn h0R

Page 20: skf2133-chapter2n

Page 2 - 20

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Remainder of Taylor Expansion

If we truncated the Taylor Series expansion after the zero term

The remainder or error of this zero order prediction will be

Ro ≈ ′ f (xi)h +

′ ′ f (xi )2!

h2 +′ ′ ′ f (xi )3!

h3 +L

f (xi+1) ≈ f (xi )

Page 21: skf2133-chapter2n

Page 2 - 21

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Zero Order Prediction & Remainder

Zero order prediction

Exact prediction

f(x)

x i+1

Ro

f(xi )

xi x

h

Page 22: skf2133-chapter2n

Page 2 - 22

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Taylor Series Approximation of PolynomialUse 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 function’s 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 23: skf2133-chapter2n

Page 2 - 23

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

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

Taylor Series Approximation of Polynomial

Page 24: skf2133-chapter2n

Page 2 - 24

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Taylor Series Approximation of PolynomialTaylor series with n = 2 (second-order)

f (xi+1) ≅ f (xi) + f’(xi ) ( xi+1 – xi ) + f’’ ( xi+1 – xi )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

2!)i(x

Page 25: skf2133-chapter2n

Page 2 - 25

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Taylor Series Approximation of PolynomialAdditional 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 26: skf2133-chapter2n

Page 2 - 26

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Approximation of f(x)

0.5

1.0

f(x)

xi = 0 xi+1 = 1

zero order

first order

second order

True

0x

h

Page 27: skf2133-chapter2n

Page 2 - 27

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 28: skf2133-chapter2n

Page 2 - 28

Chemical Engineering Numerical Method© copyright PSE- FKKKSA, UTM

Trade-off between Round-off and Truncation error

Round-off error

Truncation error

Total errorPoints of diminishingreturn

log

erro

r

log step size