You are on page 1of 28

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Numerical Methods for Chemical Engineers


Chapter 3: Roots of Equations

Saharudin Haron
Page 3 - 1

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Roots of Equations
Definitions: Root of an equation can be defined as the value of x that makes f(x) = 0 or can be called as the zeros of the equation. The quadratic formula normally used to calculate the roots of equation f(x) = ax2 + bx +c = 0,

b b 2 4ac x= 2a
cannot solve the root for many other equations, such as, f(x) = e-x x ,

f (c) =

gm 1 e ( c / m ) t v c
Page 3 - 2

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Bracketing Method
Called bracketing method because two initial guesses for the root are required The name implies that the guesses bracketing the root There are two types of bracketing method Bisection Method False Position Algorithm The difference of both method lies through their strategies to systematically reduce the width of the bracket
Page 3 - 3

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Illustrations of places of roots


f(x)
No roots

f(x)
One root

x f(x)
Even # of roots

x f(x)
Odd # of root

x xu xl f(xl ) and f(xu ) having same sign xl xu

f(xl ) and f(xu ) having different sign


Page 3 - 4

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Exception of general case


f(x)
Discontinues function when end point having opposite signs - having even # of roots

x f(x)
Multiple roots occur when the function tangential to the x axis - having even # of roots

x xl xu

f(xl ) and f(xu ) having different sign


Page 3 - 5

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Requirements: f(x) is real and continuos in the interval of xl and xu f(xl ) and f(xu ) having opposite sign that is f(xl ) f(xu ) < 0 This method is also known as Binary chopping Interval halving Bolzanos method Characteristic incremental search method in which the interval is divided in half if a function changes sign over an interval, the function value at midpoint is evaluated
Page 3 - 6

Bisection Method

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Procedure of Bisection Method


1. Choose the lower xl and upper xu guesses for the root. The function changes sign over the interval Checked by ensuring that f(xl ) f(xu ) < 0 2. An estimate of the roots xr is determined

xl + xu xr = 2 3. Make the following evaluations z If f(xl ) f(xr ) < 0, the roots lies in the lower subinterval. Set xu = xr Return to step 2 z If f(xl ) f(xr ) > 0, the roots lies in the upper subinterval. Set xl = xr Return to step 2 z If f(xl ) f(xr ) = 0, the roots equals xr : Terminate the computations
Page 3 - 7

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Termination Criteria & Error Estimates for Bisection


The approximate relative error a can be calculated as

x rnew x old r a = 100% new xr


The true relative error t can be calculated as

x rtrue x estimate r t = 100% true xr


When |a | become less than prespecified stopping criterion s the computation is terminated
Page 3 - 8

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Shortcoming of Bisection Method


Its brute-force technique is inefficient In dividing the interval from xl to xu into equal halves, no account is taken of the magnitude of f(xl ) and f(xu ) For example if f(xl ) is much closer to zero than f(xu ); it is likely that the root is closer to xl than xu By dividing the interval into halves all the time, normally this algorithm will slow to converge.

Page 3 - 9

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

False-Position Method
Exploits graphical insight to join the points by a straight line The intersection of this line with the x axis represents an improved estimate of the root. The replacement of the curve with f(x) f(xu) straight line give a false position for the roots xr The intersection of the straight line with the x axis can be estimated as xl f ( xl ) f ( xu ) = x r xl x r xu x xu f ( xu )( xl xu ) f(xl) xr = xu f ( xl ) f ( xu )
Page 3 - 10

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Procedure of False-Position Method


1. Choose the lower xl and upper xu guesses for the root. The function changes sign over the interval Checked by ensuring that f(xl ) f(xu ) < 0 2. An estimate of the roots xr is determined f ( xu )( xl xu ) xr = xu f ( xl ) f ( xu ) 3. Make the following evaluations z If f(xl ) f(xr ) < 0, the roots lies in the lower subinterval. Set xu = xr Return to step 2 z If f(xl ) f(xr ) > 0, the roots lies in the upper subinterval. Set xl = xr Return to step 2 z If f(xl ) f(xr ) = 0, the roots equals xr : Terminate the computations
Page 3 - 11

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Parachute Problem
Use the bisection method and the false position method to determine the drag coefficient c needed for a parachutist of mass m = 68.1 kg to have a velocity of 40 m/s after free falling for time t = 10 s. Note the acceleration due to gravity is 9.8 m/s2. This problem can be solved by using cl = 12 and cu = 16 and s = 0.5%. True value = 14.78024. Equation needed to solve the problem

f ( c) =

9.8(68.1) (1 e (c / 68.1)10 ) 40 c 667.38 (1 e 0.147 c ) 40 c

f (c) =

Page 3 - 12

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Results
Bisection Algorithm Results Example 5.4 with s = 0.5%
Iter cl cu cr

False Position Algorithm Results Example 5.6 with s = 0.5%


t(%)
Iter cl cu cr

a(%)

a(%)

t(%)

1 2 3 4 5 6

12.00 14.00 14.00 14.50 14.75 14.75

16.000 16.000 15.000 15.000 15.000 14.875

14.0000 15.0000 14.5000 14.7500 14.8750 14.8125

6.667 3.448 1.695 0.840 0.422

5.279 1.487 1.896 0.205 0.641 0.218

1 12.00 16.000 14.9113 2 12.00 14.911 14.7942 3 12.00 14.794 14.7817

0.792 0.085

0.887 0.094 0.010

Page 3 - 13

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Bisection is preferable to False Position for a certain case


Use bisection and false position to locate the root of f(x) = x10 - 1 between x = 0 and 1.3 and s = 2 %

Solution
After ten iteration, the true error only reduced to about 31 %. Note that | a | < | t | thus the approximate is misleading Insight to this problem can be examined by plotting the function

Page 3 - 14

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Results
Bisection Algorithm Results
Example 5.7 with Iter xl xu

False Position Algorithm Results


Example 5.7 with

= 2%
s

= 2%
s

xr

a(%)

t(%)

Iter

xl

xu

xr

a(%)

t(%)

1 0.00 2 0.65 3 0.98 4 0.98 5 0.98 6 0.98 7 1.00

1.300 1.300 1.300 1.138 1.056 1.016 1.016

0.6500 0.9750 1.1375 1.0563 1.0156 0.9953 1.0055

33.333 14.286 7.692 4.000 2.041 1.010

35.000 2.500 13.750 5.625 1.562 0.469 0.547

1 2 3 4 5 6 7 8 9 10

0.00 0.09 0.18 0.26 0.34 0.41 0.47 0.53 0.59 0.64

1.300 1.300 1.300 1.300 1.300 1.300 1.300 1.300 1.300 1.300

0.0943 0.1818 0.2629 0.3381 0.4079 0.4726 0.5326 0.5881 0.6395 0.6869

48.118 30.857 22.251 17.106 13.692 11.264 9.449 8.037 6.900

90.570 81.824 73.713 66.189 59.212 52.742 46.743 41.186 36.046 31.306

Page 3 - 15

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Pitfalls of False Algorithm


Although this method is the preferred bracketing method, there are cases where f(x) it performs poorly. This happen when it violates the premise 10 upon which false position was based : that is if f(xl) is much closer to zero than f(xu), it suggest that the root is closer to xl than to xu. But the opposite is true for the current 0 example To avoid problem check the root estimate into original equation and determine whether the result is close to zero.

1.0

Page 3 - 16

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Bracketing Method
(assignment in class)
The velocity v of falling parachutist is given by,

v(t ) =

gm 1 e ( c / m ) t c

where

g = 9.8 m/s2 c = 14 kg/s

Compute the mass m so that the velocity is v = 35 m/s at t = 7 s. Use the bisection method with s = 1.0 and false-position method with s = 0.1.

Page 3 - 17

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Open Method
Bracketing method requires root to be located between the upper and lower bound. Repeated application always result in closer estimates of the true value of the root Such method are normally called convergent, because they move closer to the real roots In contrast Open Method requires one to have a formula Requires one or two starting value but not necessarily bracket the root Sometimes diverge or move away after several computations However when it converges it will be faster than bracketing method

Page 3 - 18

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Illustration of Open Method


(A)
f(x) f(x)

(B)

xi xi+1 x

xi xi+1 x

The method failed diverge

The method converge rapidly

Page 3 - 19

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Simple Point Iteration


Need a formula to solve the root problem Rearranging the function f(x) = 0 so that x is on the left hand side x = g(x) Example x2 - 2x +3 = 0

transform into

x2 + 3 x= 2

sin x = 0 transform into x = sin x + x e-x - x = 0 transform into x = e-x Given an initial guess at the root xi the above equation can be used to estimate x i+1
The iterative formula will be

x i+1 = g (xi )
Page 3 - 20

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Convergence of Simple Point Iteration

f(x) f(x) = ex - x

Characteristic of one point iteration is having linear convergence

x
Since we have two equal equations as f1(x) = g(x) The two function can be drawn separately and the intersection of these function represent the roots of f(x) = 0

f(x)

f1(x) =x

g(x) = ex x
Page 3 - 21

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Procedure of Simple Point Iteration


1) State the initial guess, xi and stopping criterion, s 2) Rearranging the function f(x) = 0 so that x is on the left hand side x = g(x) 3) Determine xi+1 from : 4) Calculate a from : xi+1 = g(xi)

a =

xi +1 xi 100 % xi +1

5) If a > s, repeat step (3).


Page 3 - 22

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Simple Point Iteration


(assignment in class)

Determine the root of the following equation using simple point iteration method, f(x) = sin (x) x Use initial guess, xo = 0.5 and s = 0.1%. (Give answer in 7 significant figures)

Page 3 - 23

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Newton Raphson Method


The most widely used of all root-locating formula If the initial guess at the root is xi , a tangent can be extended from the point [xi , f(xi ) ]

f(x) f(xi )

Slope = f( xi ) f(xi ) - 0

Newton Raphson method can be derived by using the figure as a guide: f ( x i ) = f (xi ) 0 xi xi +1 f ( xi ) f ( x i )

xi+1

xi

xi +1 = x i

xi - xi+1
Page 3 - 24

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Procedure of Newton Raphson Method


1) State the initial guess, xi and stopping criterion, s 2) Perform first derivative on function f(x) to get f(x) f ( xi ) f ( x i )

3) Determine xi+1 from : 4) Calculate a from :

xi +1 = x i

a =

xi +1 xi 100 % xi +1

5) If a > s, repeat step (3).


Page 3 - 25

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Secant Method
Potential problem with Newton Raphson is to evaluate the derivative For this case the derivative can be estimated by using backward finite divided difference f ( xi 1 ) f ( xi ) f(x) f ( x i ) x i 1 x i f(xi )

f ( xi ) xi +1 = x i f ( x i ) f(xi-1 ) 0 xi +1 = x i xi+1 xi-1 xi x f ( xi )( x i 1 x i ) f ( xi 1 ) f ( xi )

The method requires two initial guesses


Page 3 - 26

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Procedure of Secant Method


1) State the initial guesses, xi-1 and xi , and stopping criterion, s

2) Determine xi+1 from : xi +1 = x i 3) Calculate a from : f ( xi )( x i 1 x i ) f ( xi 1 ) f ( xi )

a =

xi +1 xi 100 % xi +1

4) If a > s, repeat step (2).


Page 3 - 27

Chemical Engineering Numerical Method copyright PSE- FKKKSA, UTM

Open Method
(assignment in class)
The concentration rate of a toxic agent discharged into a river can be approximated by the following mathematical model, dc V dt = W-Qc-kV c where V = 1 x 106 m3 Q = 1 x 105 m3/yr W = 1 x 106 g/yr k = 0.2 g0.5/m1.5yr

If the concentration of the toxic agent, c is constant, determine its value using Newton Raphson and Secant method with initial guesses, ci = 4 g/m3 and ci-1 = 3.8 g/m3 , and s = 0.1 %.
Page 3 - 28

You might also like