1-Root Finding-Open Methods
1-Root Finding-Open Methods
Nasser A. Al-Azri
Definition
Find the volume of 100 moles of water vapor at 100 kPa and 150 oC. For water vapor, a=0.547 Pa.m6/mol2 and
b=0.00003052 m3/mol.
1 𝜖𝜖 2.51
Colebrook Equation for Fining Friction Factor = −2 log +
𝑓𝑓 3.7𝐷𝐷 𝑅𝑅𝑅𝑅 𝑓𝑓
Find the friction coefficient for a 5 cm-diameter pipe with roughness of 0.004mm and flow with Re=80,500.
Error Definition
Exact decimal places are rarely used due to either measurement limitations or infinite
calculation procedure.
𝑥𝑥 3 𝑥𝑥 5 𝑥𝑥 7 𝑥𝑥 9
sin 𝑥𝑥 = 𝑥𝑥 − + − + − ⋯ + ⋯
3! 5! 7! 9!
Expressing Error
The error of a number is the difference between the true value and the approximate
one.
𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣 = 𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴 𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣 + 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒
The relative error is the percentage of the absolute error from the true value.
𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 − 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎.
𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 = ∗ 100%
𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇
Expressing Error
The relative error is the percentage of the absolute error from the true value.
𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 − 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎.
𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 = ∗ 100%
𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇
Finding the
Square-root of a
number
About 2000 years ago, Babylonians developed an iterative square root finding
method, which for until late centuries was a mystery.
In order to find the square root of M i.e. 𝑥𝑥 = 𝑀𝑀, then one should start with an
initial guess 𝑥𝑥0 and then the procedure will follow in an iterative manner using the
iterative equation:
1 𝑀𝑀
𝑥𝑥𝑖𝑖+1 = 𝑥𝑥𝑖𝑖 +
2 𝑥𝑥𝑖𝑖
Initially, 𝑥𝑥0 can be taken any number, preferably as close as possible to the exact
solution in order to speed up the convergence to the desired solution.
Finding the Square-root of a number
Using the Babylonian method, find the square root of 326 using hand calculations.
Use a reasonable initial guess, x0, and stop iterating when the relative error is less
than or equal to 0.001%.
Advantage: Fast convergence even when the first guess is far different from the exact solution.
Disadvantage: They may diverge or miss the targeted solution in case of multiple solutions exist.
Example of a closed/bracketing method
Step (1): make sure that 𝑓𝑓(𝑥𝑥) values at both bounds, xL and xU , have different signs.
𝑥𝑥𝑙𝑙 +𝑥𝑥𝑢𝑢
Step (2): evaluate 𝑥𝑥𝑟𝑟 = and 𝑓𝑓(𝑥𝑥𝑟𝑟 )
2
Step (3): select the new interval so as to maintain the same criterion in step (1)
Step (4): check the new relative error:
𝑥𝑥𝑟𝑟,𝑛𝑛𝑛𝑛𝑛𝑛 − 𝑥𝑥𝑟𝑟,𝑜𝑜𝑜𝑜𝑜𝑜
𝐸𝐸𝑟𝑟 = × 100%
𝑥𝑥𝑟𝑟,𝑛𝑛𝑛𝑛𝑛𝑛
Step (5): if 𝐸𝐸𝑟𝑟 < 𝐸𝐸𝑟𝑟,𝑀𝑀𝑀𝑀𝑀𝑀 , stop, otherwise go to step (3).
Bisection Method: Algorithm
Example: Solve
∆0 = 10 − −10 = 20
0.001 0.001
∆𝑛𝑛 = 0.5𝑛𝑛 × 20 = 0.001 → 0.5𝑛𝑛 = → 𝑛𝑛 𝑙𝑙𝑙𝑙 0.5 = ln
20 20
0.001
ln
𝑛𝑛 = 20 = 14.29
ln 0.5
Hence, 15 iterations are needed to reach a final solution within the targeted accuracy.
Programming Task …
Open methods involve searching for the solution within an open domain by starting
with initial search point or points. In this course, three open methods are covered:
• Simple Fixed-Point Iteration
• Newton’s (aka Newton-Raphson) Method
• Secant Method
Simple Fixed-Point Iteration
The simple fixed point iteration method is based
on the concept of using a fixed point in an
iterative manner in order to get the solution of
the given equation.
• The equation is solved or manipulated so as to
put the variable on one side and the equation
is then solved iteratively.
• For a given function 𝑓𝑓(𝑥𝑥) = 0, a fixed point is a
point in the domain of a function, 𝑔𝑔, such that
𝑔𝑔 𝑥𝑥 = 𝑥𝑥.
• After solving for the independent variable, the
expression is used to guess the next iteration.
Simple Fixed-Point Iteration
Example (1): Solve
𝑓𝑓 𝑥𝑥 = 𝑥𝑥 2 − 2𝑥𝑥 + 3
Solving for x :
𝑥𝑥 2 + 3 𝑥𝑥𝑖𝑖2 + 3
𝑥𝑥 = → 𝑥𝑥𝑖𝑖+1 = 𝑔𝑔(𝑥𝑥𝑖𝑖 ) =
2 2
Example (2): Solve
𝑓𝑓 𝑥𝑥 = 𝑠𝑠𝑠𝑠𝑠𝑠 𝑥𝑥 = 0
𝑓𝑓 𝑥𝑥 = 𝑥𝑥 2 − 𝑥𝑥 + 3
𝑥𝑥 2 + 3
𝑥𝑥 = → 𝑔𝑔^′(𝑥𝑥) = 2𝑥𝑥 𝑓𝑓𝑓𝑓𝑓𝑓 0 ≤ 𝑥𝑥 ≤ 0.4
2
0 ≤ 𝑔𝑔′ 𝑥𝑥 ≤ 0.4 ≤ 1 𝑠𝑠𝑠𝑠 |𝑔𝑔′ 𝑥𝑥 | < 1
Simple Fixed-Point Iteration
Example: Find the root of 𝑓𝑓(𝑥𝑥) = 𝑒𝑒 −𝑥𝑥 − 𝑥𝑥 = 0
𝑬𝑬𝑬𝑬, % 𝑬𝑬𝑬𝑬, %
Solving for 𝑥𝑥 𝒊𝒊 𝒙𝒙𝒊𝒊 𝒙𝒙𝒊𝒊+𝟏𝟏 = 𝒈𝒈(𝒙𝒙𝒊𝒊 ) 𝒊𝒊 𝒙𝒙𝒊𝒊 𝒙𝒙𝒊𝒊+𝟏𝟏 = 𝒈𝒈(𝒙𝒙𝒊𝒊 )
Further proceeding with the method 7 0.579612 0.560115 3.480867 21 0.567148 0.567141 0.001222
∆𝑓𝑓(𝑥𝑥) 𝑑𝑑𝑓𝑓(𝑥𝑥)
lim =
∆𝑥𝑥 → ∞ ∆𝑥𝑥 𝑑𝑑𝑥𝑥
Try this:
𝑓𝑓 𝑥𝑥 = 3𝑥𝑥 3.5 + 5𝑥𝑥 + 1
𝑓𝑓 ′ 𝑥𝑥 = 10.5𝑥𝑥 2.5 + 5
Compare:
𝑓𝑓 ′ 5 = 930.9071 with:
𝑓𝑓(6.01) − 𝑓𝑓(5.99)
= 930.90873 when ∆𝑥𝑥 = 0.01
0.02
𝑓𝑓 6.5 − 𝑓𝑓 5.5
= 934.92 when ∆𝑥𝑥 = 0.5
1
Line Segment Approximation
𝑓𝑓 𝑥𝑥 + ∆𝑥𝑥 − 𝑓𝑓 𝑥𝑥
𝑓𝑓 ′ 𝑥𝑥 = lim
∆𝑥𝑥→0 ∆𝑥𝑥
Or
′
𝑓𝑓 𝑥𝑥 + ℎ − 𝑓𝑓 𝑥𝑥 − ℎ
𝑓𝑓 𝑥𝑥 = lim
ℎ→0 2ℎ
Hence, a better approximation of the derivative at point 𝑥𝑥 can be obtained by evaluating the rate
of change of the function between (𝑥𝑥 + ℎ) and (𝑥𝑥 − ℎ) whereas the value of ℎ approaches zero.
Let ε=0.001
𝑓𝑓 𝑥𝑥 + 𝜀𝜀 − 𝑓𝑓 𝑥𝑥 − 𝜀𝜀
𝑓𝑓′ 𝑥𝑥 ≅
2𝜀𝜀
Secant Method
Example: Find the analytical and approximate solution of f(5) in the function:
𝑓𝑓 𝑥𝑥 = 3𝑥𝑥 1.5 + ln 𝑥𝑥 − 𝑒𝑒 𝑥𝑥
File menu click Options click Add-ins click Solver Add-in click Go… check solver Add-in click OK
Soft Once loaded, the solve appears in Data menu under “Analyze” group.
Skills
Set Objective: the cell you want to have the value zero