You are on page 1of 14

ANALISIS NUMERIK

SEMESTER GENAP TAHUN AKADEMIK 2007/2008


JURUSAN TEKNIK KIMIA – FTI – UPN “VETERAN” YOGYAKARTA
MAIN TOPIC & OBJECTIVES (2)
2 - Open Methods for Finding the Root of
a Single Nonlinear Equation
PENENTUAN AKAR PERSAMAAN Objectives:
TAK LINIER TUNGGAL
• Recognizing the difference between bracketing and
open methods for root location
Materi Kuliah:
PENGANTAR • Understanding the fixed-point iteration method and how
BRACKETING METHODS you can evaluate its convergence characteristics
OPEN METHODS • Knowing how to solve a roots problem with the Newton-
Raphson method and appreciating the concept of
Oleh: Siti Diyar Kholisoh quadratic convergence
• Knowing how to implement both the secant and the
modified secant methods
februari 2008

MAIN TOPIC & OBJECTIVES (1)


INTRODUCTION
1 - Bracketing Methods for Finding the Root of
a Single Nonlinear Equation ► What is a nonlinear equation?
Specific objectives and topics:
► What are roots?
• Understanding what roots problems are and where they
Roots = zeros
occur in engineering and science
• Knowing how to determine a root graphically ► Method/approach for finding roots:
• Understanding the incremental search method and its 1. analytical method
shortcomings 2. graphical method
• Knowing how to solve a roots problem with the 3. trial and error
bisection method 4. numerical method Æ iterative
• Knowing how to estimate the error of bisection and why
it differs from error estimates for other types of root ► Function of f(x): (1) Explicit, (2) Implicit
location algorithm (based on the influence of independent variable on
• Understanding false position and how it differs from dependent variable)
bisection

1
GRAPHICAL METHODS Contoh Ilustratif:
Persamaan: f (x) = x2 – 5 x - 14 = 0
A simple method for obtaining an estimate of the root of the
equation f(x) = 0 is to:
Akar persamaannya: ….?
™ make a plot of the function, and Secara 15
™ observe where it crosses the x axis analitik: 10
(x value for which f(x) = 0)
ÆMudah…! 5
Advantages:
0
™ provides a rough approximation of the root → can be
Secara -3 -2 -1-5 0 1 2 3 4 5 6 7 8 9
employed as starting guesses for numerical methods grafik: -10
™ useful for understanding the properties of the functions
-15
™ useful for anticipating the pitfalls of the numerical methods
-20
Disadvantage:
-25
not precise

Secara Analitik:
Dengan menggunakan rumus abc untuk
(a)
menentukan akar-akar persamaan kuadrat,
diperoleh:
(d)
(e) −b± b −4 a c
2
x12 =
2a
Atau, dalam hal ini:
(b)
5 − (−5) 2 − 4 (1) (−14) 5 − 9
x1 = = = −2
2 (1) 2
(f) (g)
5 + ( −5) 2 − 4 (1) (−14) 5 + 9
Illustration of root location(s) x2 = = =7
(c)
2 (1) 2

2
Secara numerik: BRACKETING METHODS
f ( xi ) and INITIAL GUESSES
Misal, dipilih metode Newton-Raphson: xi +1 = xi −
f ' ( xi ) Two major classes of methods for finding the root of a
single nonlinear equation (distinguished by the type of
initial guess):
Nilai
tebakan 1. Bracketing methods
awal 2. Open methods

™ Based on two initial guesses that “bracket” the root


™ Always work, but converge slowly (i.e. they
typically take more iterations)

Hasil ™ Can involve one or more initial guesses, but there


is no need for them to bracket the root
™ Do not always work (i.e. they can diverge), but
when they do they usually converge quicker

Hasil yang diperoleh


dengan Polymath:

Bracketing Methods
(Incremental Search Methods)
1. Metode Bisection
2. Metode False Position

3
Consider: a function f(x) which is known to have
Incremental Search Method one and only one real root in the interval xl < x < xu
In general, if f(x) is real and continuous in the interval from xl f(x)
to xu and f(xl) and f(xu) have opposite signs, that is: f(xu)
f(xl).f(xu) < 0
then there is at least one real root between xl and xu.

Incremental search methods capitalize on this observation f(xM)


xl
by locating an interval where the function changes sign. A 0 x
xM xu
potential problem with an incremental search is the choice
of the increment length. If the length is too small, the search f(xl)
can be very time consuming. On the other hand, if the length midpoint value
is too great, there is a possibility that closely spaced roots
might be missed. The problem is compounded by the xl + xu
Bisection formula: xM =
possible existence of multiple roots. 2

Two initial guesses of x (xl and xu),


START
and tolerance (tol)
BISECTION METHOD xl + xu
xM =
2
= Binary Search Method
Evaluate: f(xl), f(xu), and f(xM)
A “brute force” technique for root solving which is too
inefficient for hand computation, but is ideally suited to Y Y
f(xM).f(xu) ≤ 0 ? f(xM).f(xu) = 0 ?
machine computation.
N N

An incremental search method in which the interval is xM → xu xM → xl

always divided in half. If a function changes sign over x l + xu


an interval, the function value at the midpoint is next xM =
iteration 2
evaluated. The location of the root is then determined as
lying within the subinterval where the sign change
N xM , present − xM , previous
occurs. The subinterval then becomes the interval for the ≤ tol ?
xM , present
next iteration. The process is repeated until the root is
known to the required precision. BISECTION METHOD Y
FLOWCHART x = xM END

4
FALSE POSITION METHOD Example #1:
= Linear Interpolation Method Use: (a) bisection method, and (b) false position
= Regula-Falsi Method method, to locate the root of: f(x) = e-x - x
It is very similar to bisection method, with the Use initial guesses of xl = 0 and xu = 0,8, and
exception that it uses a different strategy to come iterate until the approximate error falls below 1%
up with its new root estimate. 1,2
Graphically: 1

False-position formula: 0,8 x = 0,5671


0,6

f ( xu ) ( xl − xu ) 0,4
xM = xu −

f(x)
0,2
f ( xl ) − f ( xu ) xM 0
-0,2 0 0,2 0,4 0,6 0,8
-0,4
-0,6
x

Two initial guesses of x (xl and xu),


START
and tolerance (tol)

f ( xu ) (xl − xu )
Calculation Results:
xM = xu −
f ( xl ) − f ( xu )

Evaluate: f(xl), f(xu), and f(xM)

Y Y
f(xM).f(xu) ≤ 0 ? f(xM).f(xu) = 0 ?

N N
xM → xu xM → xl

f ( xu ) ( xl − xu )
next xM = xu −
iteration f ( xl ) − f ( xu )

N xM , present − xM , previous
≤ tol ?
xM , present
FALSE POSITION
Y
METHOD FLOWCHART
x = xM END

5
Example #2: Calculation Results (by using MS Excel):
Use bisection method and false position method to deter-
mine the mass of the bungee jumper with a drag coeffi-cient
of 0,25 kg/m to have a velocity of 36 m/s after 4 s of free fall.
Note: The acceleration of gravity is 9,81 m/s2
Free-fall velocity as a function of time:
gm ⎛ g cd ⎞
v(t ) = tanh ⎜⎜ t ⎟⎟
cd ⎝ m ⎠
An alternative way to make the equation as a function of
mass:
gm ⎛ g cd ⎞
f ( m) = tanh ⎜⎜ t ⎟⎟ − v(t ) = 0
cd ⎝ m ⎠
Use initial guesses of ml = 50 kg and mu = 200 kg, and
iterate until the approximate error falls below 5% (εs =
stopping criterion = 5%)

Graphical illustration Calculation Results (by using Polymath):


f(m) versus m

6
Thus, given an initial guess at root xi, the equation
above can be used to compute a new estimate xi+1 as
expressed by the iterative formula:
Open Methods xi+1 = g(xi)
The approximate error can be determined by:
xi + 1 − xi
1.Metode Iterasi Satu Titik εa = . 100 %
xi + 1
– Metode Dua Kurva
Example:
2. Metode Newton-Raphson Use the simple fixed-point iteration to locate the
3. Metode Secant root of f(x) = e-x - x
Solution:
The function can be separated directly and then
− xi
expressed as: x
i +1 =e

Starting with an initial guess of x0 = 0, this iterative


SIMPLE FIXED POINT ITERATION METHOD equation can be applied to compute:
It is also called: i xi e-xi ε a, % εt, %
á One point iteration method, or 0 0,0000 1,0000 - -
á Successive substitution method 1 1,0000 0,3679 100,000 76,322
Rearranging the function f(x) = 0 so that x is on the 2 0,3679 0,6922 171,828 35,135
left-hand side of the equation: 3 0,6922 0,5005 46,854 22,050
x = g(x)
4 0,5005 0,6062 38,309 11,755
a formula to predict a new value of x as 5 0,6062 0,5454 17,447 6,894
a function of an old value of x 6 0,5454 0,5796 11,157 3,835
7 0,5796 0,5601 5,903 2,199
This transformation can be accomplished either by: 8 0,5601 0,5711 3,481 1,239
á Algebraic manipulation, or 9 0,5711 0,5649 1,931 0,705
á Simply adding x to both sides of the original 10 0,5649 0,5684 1,109 0,399
equation Note: The true value of the root = 0,56714329

7
Two Curves CONVERGENC
Graphical Method E OF SIMPLE
FIXED-POINT
By graphical method, ITERATION
there are two alternatives
for determining root of: (a) & (b)
−x
f(x)=e −x Æconvergent
(c) & (d)
(a) Root at the point Ædivergent
where it crosses the
x axis
Note that
(b) Root at the
convergence
intersection of the
component functions occurs when
‫׀‬g’(x)‫ < ׀‬1

Two curves graphical method

START NEWTON-RAPHSON METHOD


An initial guess of x (xi = x0), tol The most widely used of all root-locating formula

xi + 1 = g ( xi ) Fixed-point iteration formula If the initial guess at the root


is xi, a tangent can be
xi = xi+1
xi − xi +1
extended from the point [xi,
εa = .100% Approximate error f(xi)]. The point where this
next xi +1
iteration tangent crosses the x axis
N usually represents an
εa < tol ?
improved estimate of the
Y root.
xi
FIXED-POINT
ITERATION The first derivative at xi is f ( xi ) − 0
END f ' ( xi ) =
METHOD flowchart equivalent to the slope: xi − xi +1

8
which can be rearranged to yield: START
f ( xi )
xi +1 = xi − An initial guess of x (xi = x0), tol
f ' ( xi )
Newton-Raphson formula xi + 1 = x i −
f ( xi )
Newton-Raphson formula
Example: f ' ( xi )

Use the Newton-Raphson method to estimate the root xi = xi+1


xi − xi + 1
of f(x) = e-x – x, employing an initial guess of x0 = 0 εa = .100 % Approximate error
next xi + 1
iteration
Solution:
N
The first derivative of the function can be evaluated εa < tol ?

as: f ’(x) = - e-x - 1 Y

Then, by the Newton-Raphson formula: xi

e − xi − xi NEWTON-RAPHSON
xi +1 = xi − METHOD flowchart
END

− e − xi − 1

Starting with an initial guess of x0 = 0, this iterative FOUR CASES OF POOR CONVERGENCE OF THIS
METHOD
equation can be applied to compute:

i xi εa, % ε t, %
0 0 - 100
1 0,5 100 11,83886
2 0,566311003 11,70929 0,146751
3 0,567143165 0,146729 2,2.10-5
4 0,567143290 2,21.10-5 7,23.10-8

Comment:
The approach rapidly converges on the true root.
There is no general convergence criterion for Newton-Raphson
Notice that the true percent relative error at each method. Its convergence depends on:
iteration decreases much faster than it does in simple á the nature of the function, and
fixed-point iteration (in previous example) á the accuracy of the initial guess

9
SECANT METHOD START

A potential problem in implementing the Newton- Two initial guesses of x (xi-1 & xi), tol
Raphson method is: the evaluation of the derivative
f ( xi ) ( xi −1 − xi )
There are certain functions whose derivatives may be xi +1 = xi − Secant formula
f ( xi −1 ) − f ( xi )
difficult or inconvenient to evaluate. For these cases,
the derivative can be approximated by a backward finite xi-1 = xi
divided difference: xi = xi+1 xi − xi +1
εa = .100% Approximate error
f ( xi − 1 ) − f ( xi ) xi +1
f ' ( xi ) ≅ next
xi − 1 − xi iteration
N
εa < tol ?
This approximation can be substituted into Newton-
Raphson formula to yield the following iterative Y
equation: xi
f ( xi ) ( xi −1 − xi ) Secant me- SECANT METHOD
xi +1 = xi − thod formula END
f ( xi −1 ) − f ( xi ) flowchart

Notice that this approach requires two initial estimates


of x. However, because f(x) is not required to change Hasil Penyelesaian Contoh Soal yang Sama
signs between the estimates, it is not classified as a dengan Sebelumnya (Metode Secant):
bracketing method.
Rather than using two arbitrary values to estimate the
derivative, an alternative approach involves a fractional
perturbation of the independent variable to estimate f’(x):
f ( x i + δ x i ) − f ( xi )
f ' ( xi ) ≅
δ xi
where δ = a small perturbation fraction
This approximation can be substituted into Newton-
Raphson formula to yield the following iterative
equation:
δ xi f ( xi ) Modified se-
xi +1 = xi −
f ( xi + δ xi ) − f ( xi ) cant method Konvergen!

10
START 10 −6 ( 50 )( −4 ,57938708 )
x1 = 50 − = 88 ,39931
An initial guess of x (xi = x0), δ, tol − 4 ,579381118 − ( −4 ,57938708 )

δ xi f ( xi )
‫׀‬εt‫ = ׀‬38,07%: ‫׀‬εa‫ = ׀‬43,44%
xi+1 = xi − Modified secant formula
f ( xi + δ xi ) − f ( xi )
Second iteration:
xi = xi+1 x −x
ε a = i i +1 .100% Approximate error x1 = 88,39931 f(x1) = -1,69220771
xi +1
next x1 + δ x1 = 88,39940 f(x1 + δ x1) = -1,692203516
iteration
N
εa < tol ?
10 −6 ( 88 ,39931 )( −1,69220771 )
x2 = 88 ,39931 − = 124 ,08970
Y − 1,692203516 − ( −1,69220771 )
xi
MODIFIED
SECANT
‫׀‬εt‫ = ׀‬13,06%: ‫׀‬εa‫ = ׀‬28,76%
END
METHOD
flowchart

The calculation can be continued to yield:


Example: i xi xi + δ xi f (xi) f (xi + δ xi) ‫׀‬εt‫׀‬ ‫׀‬εa‫׀‬
(%) (%)
Use the modified secant method to determine the
mass of the bungee jumper with a drag coefficient of 0 50 50,00005 -4,57938708 -4,579381118 64,97 -
0,25 kg/m to have a velocity of 36 m/s after 4 s of free 1 88,39931 88,39940 -1,692207707 -1,692203516 38,07 43,44
fall. Note: The acceleration of gravity is 9,81 m/s2. Use 2 124,08970 124,08982 -0,432369881 -0,43236662 13,06 28,76
an initial guess of 50 kg and a value of 10-6 for the
perturbation factor. 3 140,54172 140,54186 -0,045550483 -0,045547526 1,54 11,71
4 142,70719 142,70733 -0,000622927 -0,000620007 0,02 1,52
Solution:
5 142,73763 142,73777 -1,19176.10-7 2,80062.10-6 0,00 0,02
First iteration: 6 142,73763 142,73778 9,9476.10-14 2,9198.10-6 0,00 0,00

x0 = 50 f(x0) = -4,57938708 Comment:


x0 + δ x0 = 50,00005 f(x0 + δ x0) = -4,5793381118 The choice of a proper value for δ is not automatic.
If δ is too small : …………………
If δ is too big : ………………..

11
Problem #2:
Using x =1 as the starting point, find a root of the
following equation to three significant figures:

PROBLEMS f ( x) = x 2 e x − 1 = 0
using:
a. successive substitution
b. Newton’s method
c. the secant method (use x = 1,01 as
your second point)

Problem #1: Problem #3:


Using x = 4 as the starting point, find a root of
(a) f ( x) = sin ( x )− x x0 = 0,5 the following equation:

f ( x) = x e x + x − 5 e x − 5 = 0
(b) f ( x) = −11 − 22 x + 17 x 2 − 2,5 x 3 using:
a. Newton’s method
b. the secant method (use x = 4,1 as your
second point)
a. the regula falsi method

12
Problem #4: Problem #6:
In a chemical engineering process, water vapor (H2O) is
heated to sufficiently high temperatures that a significant
Consider the following nonlinear equation: portion of the water dissociates, or splits apart, to form
oxygen (O2) and hydrogen (H2):
f ( x) = x 2 − e x = 0 H2O Æ H2 + ½ O2
If it assumed that this is the only reaction involved, the mole
fraction x of H2O that dissociates can be represented by:
Show at least three cycles of search using a
starting point of x = 1 for: x 2 Pt
K=
a. Newton’s method 1− x 2+x
b. regula falsi method where K is the reaction’s equilibrium constant and Pt is the
total pressure of the mixture. If Pt = 3 atm and K = 0,05,
determine the value of x that satisfies the equation above.

Problem #5: Problem #7:


Water is flowing in a trapezoidal channel at a rate of Q = 20 The Redlich-Kwong RT a
p= −
m3/s. The critical depth y for such a channel must satisfy the
2
equation of state is given by: v − b v (v + b ) T
equation: 0 = 1 − Q B
g Ac3 where R = the universal gas constant [= 0,518 kJ/kg.K], T =
where g = 9,81 m/s2, Ac = the cross-sectional area (m2), and absolute temperature (K), p = absolute pressure (kPa), and v
B = the width of the channel at the surface (m). For this case, = the volume of a kg of gas (m3/kg). The parameter a and b
the width and the cross-sectional area can be related to depth are calculated by:
y by: B = 3 + y R 2 Tc2 ,5 Tc
and A = 3 y + y
2 a = 0 ,427 and b = 0 ,0866 R
c pc pc
2
Solve for the critical depth using: (a) the graphical method, (b) where pc = 4600 kPa and Tc = 191 K. As a chemical engineer,
bisection, and (c) false position. For (b) and (c), use initial you are asked to determine the amount of methane fuel that
guesses of xl = 0,5 and xu = 2,5, and iterate until the can be held in a 3-m3 tank at a temperature of -40oC with a
approximate error falls below 1% or the number of iterations pressure of 65000 kPa. Use a root locating method of your
exceeds 10. Discuss your results.
choice to calculate v and then determine the mass of methane
contained in the tank.

13
2
pCO PT
Problem #8: The equilibrium relationship is given by: K =
2
pCO
2

pO2
Determine the equilibrium conversion for:
where PT is the total pressure and remembering that the
2 CO + O2 Æ 2 CO2
standard state fugacities of CO2, CO, and O2 are unity.
if stoichiometric amounts of CO and air are reacted at Substituting yields:
2000 K and 1 atmosphere pressure. At 2000 K the x 2 (6,76 − 0,5 x)
equilibrium constant for this reaction is 62,4 x 106 atm-1. = 62,4 . 106
As a basis, consider 2 gmoles of CO. Then there would (1 − 0,5 x) (2 − x) 2

be 1 gmole of O2 and 3,76 gmole of N2. Performing a Rearranging into a normalized form:
mole balance on each species and defining x as the
amount of CO that reacts yields: x 2 (6,76 − 0,5 x)
−1 = 0
NCO = 2 – x 62,4 . 106 (1 − 0,5 x) (2 − x) 2
NO2 = 1 – 0,5 x a. Solve for the equilibrium composition using Newton’s
NCO2 = x method with a starting point of x0 = 1,0 gmole.
NN2 = 3,76 b. Solve this problem using the regula falsi method.

Then the partial pressures are given as:


Problem #9:
Van der Waals equation of state is given as:

pCO
N
= CO =
2− x ⎛ a ⎞
( )
⎜⎜ P + 2 ⎟⎟ V − b = R T
⎝ V ⎠
NT 6,76 − 0,5 x
where: P ≡ pressure (10 atm), T ≡ temperature (250 K)
R ≡ gas constant (0,082 liter.atm/gmole.K), V ≡ specific
N O2 1 − 0,5 x volume (liter/gmole)
pO2 = = Determine the specific volume for ammonia using:
NT 6,76 − 0,5 x a. successive substitution
b. Newton’s method
N CO2 x c. Secant method
pCO2 = = The Van der Waals constants for ammonia are:
NT 6,76 − 0,5 x a = 4,19 x 106 atm (cm3/gmole)2 and b = 37,2 cm3/gmole.
(Beware of the units!)

14

You might also like