KIL1005: Numerical Methods For Engineering
KIL1005: Numerical Methods For Engineering
•Known
b b 2 4ac
ax bx c 0
2
x
2a
•But
ax 5 bx 4 cx 3 dx 2 ex f 0 x ?
sin x x 0 x ?
2
Nonlinear Equation
Solvers
All Iterative
3
Bracketing Methods
6
Figure 5.4b
Figure 5.4a
Figure 5.4c
7
The Bisection Method
For the arbitrary equation of one variable, f(x)=0
1. Pick xl and xu such that they bound the root of interest,
check if f(xl).f(xu) <0.
8
• If f(xl). f[(xl+xu)/2]>0, root
lies in the upper interval, then
xl= [(xl+xu)/2, go to step 2.
xl xu
• xl
If f(xl). f[(xl+xu)/2]=0, then 2
100%
root is (xl+xu)/2 and xl xu
terminate. 2
or
4. Compare e s with ea xl xu
xu
2
100%
xl xu
5. If ea< es, stop. Otherwise 2
repeat the process.
9
Figure 5.6
10
Evaluation of Method
Pros
Cons
› Slow
Easy
› Know
Alwaysa find
and broot
that bound root
› Multiple roots
11
Termination Criteria
› Without a termination criteria, the iteration will continue infinitely.
› Stopping criterion, εs – decide when to terminate the iteration.
› Happen when
εs = approximate relative error , εa
(a) Graphically
(b) Using the bisection method. Employ initial guesses of xl=0 and xu=1. Iterate until the
approximate relative error after each iteration falls below a stopping criterion of 10%.
The False-Position Method
(Regula-Falsi)
› If a real root is bounded
by xl and xu of f(x)=0,
then we can
approximate the
solution by doing a
linear interpolation
between the points [xl,
f(xl)] and [xu, f(xu)] to
find the xr value such
that l(xr)=0, l(x) is the
linear approximation of
f(x).
15
Procedure
›1. Find a pair of values of x, xl and xu such that
fl=f(xl) <0 and fu=f(xu) >0 or fl=f(xl) >0 and
fu=f(xu) <0. E.g. f(xl). f(xu) < 0.
2. Estimate the value of the root from the
following formula (Refer to Box 5.1)
=
and evaluate f(xr).
16
3. Use the new point to replace one of the original points,
keeping the two points on opposite sides of the x axis.
17
4. See if the new xl and xu are close enough for
convergence to be declared. If they are not go back
to step 2.
18
Exercise 2
Solve the following problems using Regula-Falsi method.
- Example 2
- Exercise 3
Open Methods
Figure 6.1
› Open methods are
based on formulas that
require only a single
starting value of x or
two starting values
that do not necessarily
bracket the root.
20
Simple Fixed-point Iteration
•Rearrange the function so that x is on
the left side of the equation:
f ( x) 0 g ( x) x
xk g ( xk 1 ) xo given , k 1, 2, ...
•Bracketing methods are “convergent”.
•Fixed-point methods may sometime
“diverge”, depending on the stating point
(initial guess) and how the function
behaves. 21
Example 4
2
𝑥 − 2 𝑥+3=0
Can be manipulated to yield
2
𝑥= 𝑥 +3
2
22
Example 5
Use simple fixed point iteration to locate the root of
f(x) = e-x - x
Figure 6.2
Convergence
24
Example 6
Separate the equation in Example 5 into two parts and
determine its roots graphically.
Newton-Raphson Method
› Most widely used method.
› Based on Taylor series expansion:
x 2
f ( xi 1 ) f ( xi ) f ( xi )x f ( xi ) Ox 3
2!
The root is the value of x i 1 when f(x i 1 ) 0
Rearrangin g,
Solve for
i )( xi 1 xi )
0 f(x i ) f (x
f ( xi )
xi 1 xi Newton-Raphson
f ( xi )
formula
26
Fig. 6.5
27
Fig. 6.6
Pitfalls of the
Newton-Raphson
Method
28
Example 7
Use the Newton Raphson method to estimate the root of
Example 5. Employ an initial guess of x0 = 0. Calculate
until the fifth iteration.
The Secant Method
› slight variation of Newton’s method for functions
A
whose derivatives are difficult to evaluate. For these
cases the derivative can be approximated by a
backward finite divided difference.
30
Fig. 6.7
• Requires two initial
estimates of x , e.g, xo, x1.
However, because f(x) is
not required to change
signs between estimates,
it is not classified as a
“bracketing” method.
• The Secant method has
the same properties as
Newton’s method.
Convergence is not
guaranteed for all xo, f(x).
31
Fig. 6.8
32
Example 8
Use the Secant method to estimate the root of Example 5
with initial estimates of 0 and 1.
Multiple Roots
› None of the methods deal with multiple roots
efficiently, however, one way to deal with problems
is as follows:
f ( xi )
Set u ( xi ) This function has
f ( xi ) roots at all the
same locations as
u ( xi ) the original
Then find xi 1
u ( xi ) function
34
Fig. 6.13
35
› “Multiple root” corresponds to a point where a
function is tangent to the x axis.
› Difficulties
– Function does not change sign at the multiple root,
therefore, cannot use bracketing methods.
– Both f(x) and f′(x)=0, division by zero with Newton’s and
Secant methods.
36