You are on page 1of 6

MTH510 Numerical Analysis

LF/S12 1
II Non-Linear Equations
Text: Ch 5 & 6
1
2.1 Introduction
Common problem in Applied Mathematics
f(x)=0
Algebraic equations
Transcendental functions
Including Trig., log, exp to function
x of polynomial order th i f
f x f y f y f
i
n
n
n
n

= + + +

0
0 1
1
1
L
0 10 ) ln(
0 5 ) cos(
2
= + +
= + +
x x
x x
2
Solution Methods
Using formula- for simple cases
(quadratic eqn.)
Graphical method-gives rough estimate
Trial & Error Tedious and Inadequate
Numerical Method
3
2.2 Graphical method
Simple method for
one variable eqn.
Limited practical value
Plot the function and
observe the crossing
points @ x= x
r ,
f(x
r
)=0
f(x)
Root
x
4
y
x
r
Ways Roots may Occur
x
l
x
l
x
u
1-root 0-root
2-root
3-root
x
u
(a)
(c)
(b)
(d)
5
(a) (b)
(c)
(d)
x x
x
x
f(x)
f(x)
f(x)
f(x)
2.3 Bracketing Method
Two methods: Bisection & False Position
Need initial guess for the bracket
Globally convergent
Parallel usage of Graph- reduces
computation
Cannot identify multiple roots
6
MTH510 Numerical Analysis
LF/S12 2
2.3.1 Bisection Method
Incremental search method/Graphical - to identify
the root location interval ;
Interval always divided in half
Method systematically move the end points closer
until we obtain a small bracket
x
u
x
l
x
r1
L. Interval U. Interval
x
r 2
x x
l r
=
1
x x
u r
=
2
f(x)
x
7
Algorithm
1 Choose lower & upper guesses (x
l
, x
u
) such that the
function changes signs in the interval
2 Determine an estimate of the root x
r
by
3 Make evaluations
a) If f(x
l
). f(x
r
)<0, x
u
=x
r
and return to step 2
b) If f(x
l
). f(x
r
)>0, x
l
=x
r
and return to step 2
c) If f(x
l
). f(x
r
)=0, root equals x
r
, terminate the
computation
2
u l
r
x x
x
+
=
8
Error control
Relative Error
a
Termination criteria
Number of Iteration for specified error (E
ad
)
new
r
old
r
new
r
a
x
x x
=
s a

9


=
) 2 ln(
) ln( ) ln(
ad l u
E x x
Integer n
Example 2.1: Bisection method
10
7 . 4 2 . 2 4 . 0 ) (
2
+ + = x x x f
2.3.2 False Position Method
Method replaces a curve by a straight line
More efficient method than Bisection (converges faster)
There are cases where Bisection converges faster
x
l x
u
x
r
11
A
B
C
D
E
f(x
u
)-f(x
l
)
x
u
- x
l
Algorithm
1 Choose lower & upper guesses such that the function
changes signs in the interval
2 Determine an estimate of the root x
r
by
3 Compute the error
4 Set x
l
or x
u
= x
r
, which ever yields a function value with
the same sign as f(x
r
) & repeat step 2
a) If f(x
l
). f(x
r
)<0, x
u
=x
r
b) If f(x
l
). f(x
r
)>0, x
l
=x
r
and return to step 2
) ( ) (
) )( (
u l
u l u
u r
x f x f
x x x f
x x

=
s new
r
old
r
new
r
a
x
x x

=
12
MTH510 Numerical Analysis
LF/S12 3
Example 2.2 False Position method
13
7 . 4 2 . 2 4 . 0 ) (
2
+ + = x x x f
Comparison: Bisection & False Position
Bisection
False
Position
Iteration

a
14
Example 2.3: Bisection & False Position
methods
15
x x x f + = 5 ) ln( ) (
2.3 Open Method
Formula based & require 1or 2 starting values
Diverges sometimes
Converge faster than bracketing methods
Methods
Newton-Raphson method
Secant method
Simple fixed Point method
Two curve method
16
2.3.1 Newtons Method
Most widely used,
Needs one starting
guess x
0
value
Iteration formula
Convergence depends
on the function
) ( '
) (
1
i
i
i i
x f
x f
x x =
+
x
r
x
i
x
i +1
x f x
i i
, ( )
f x ( )
17 18
Method Pitfalls
x
0
x
1
x
2
f x ( )
x
0 x
1 x
2
(a) (b)
x
0
x
1
x
2
x
3
x
0 x
1
(c) (d)
MTH510 Numerical Analysis
LF/S12 4
Algorithm
1 Guess a value (x
i
) for the root & compute
f(x
i
), f(x
i
)
2 For f(x
i
)0, f(x
i
)0, compute the next
estimate from formula
3 Alert possibility of f(x
i
)=0 during comp.
4 Terminate Iteration
Criteria:
a
<
s
& | f(x
i
)|<Tol
19
Example 2.4: Newton Method
20
x x x f + = 5 ) ln( ) (
Example 2.5: Determine the lowest and highest
real roots
21
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0 0.5 1 1.5 2 2.5 3 3.5
f(x)=-6.1+11x-6x
2
+x
3
f(x)
Modified Newtons Method
Formula
Suitable to determine (M) multiple roots
Condition: f(x), f (x), f (x),f
M
(x) exits
f(x
r
)=0, f (x
r
)=0,f
M
(x)0
M=1- simple root, M=2- double roots at x
r
Less efficient & requires more computational effort
( ) [ ] ) ( ' ' ) ( ) ( '
) ( ' ) (
2 1
i i i
i i
i i
x f x f x f
x f x f
x x

=
+
22
Example 2.6: Find the roots of the polynomial
23
-3
-2
-1
0
1
2
3
4
0 0.5 1 1.5 2 2.5 3 3.5 4
f(x) = x
3
-5x
2
+7x-3
f(x) = 3x
2
-10x+7
f(x) = 6x-10, f(x=1)0
24
Example 2.7
-4
-2
0
2
4
6
8
10
0 1 2 3 4
f(x)=x
4
-6x
3
+12x
2
-10x+3
-5
0
5
10
15
20
25
0 1 2 3 4
f(x)=x
5
-7x
4
+6x
3
-22x
2
+13x-3
f(x)=fx)=f(x)=f(x)=0@x=1
f
IV
0 @x=1
f(x) = 4x
3
-18x
2
+24x-10
f(x) = 12x
2
-36x +24
f(x) = 24x-36, f(x=1) 0
MTH510 Numerical Analysis
LF/S12 5
2.3.2 Secant Method
Requires 2 initial estimates
(NOT required to change
sign)
Eliminates the evaluation of
f(x)
Formula
( )
[ ] ) ( ) (
) (
1
1
1
i i
i i
i i i
x f x f
x x
x f x x

+
x
i
x
i 1
f x ( )
f x
i
( )
1
f x
i
( )
25
Algorithm
1 Choose initial estimates x
i-1
& x
i
near to one
another
2 Determine the next possible root from
formula
3 Until |f(x
i
)|<Tol & | x
i+1
- x
i
|/| x
i+1
| <
s
26
Example 2.7: Solve Example 2.4 using Secant method
27
Modified Secant Formula
Formula
Problem:
Too small can result round off error
Big , the technique can be inefficient
[ ] ) ( ) (
) (
1
i i i
i i
i i
x f x x f
x x f
x x
+
=
+

28
2.3.3 Fixed Point Method
Function itself used to formulate the iteration formula
Formulation:
Rearrange f(x)=0, so that x (independent variable) is on the
LHS
X=g(x)
G(x)- the iteration function of the original f(x),
if function can be separated
Algebraic manipulation
Add independent variable on both sides of the equation
X=f(x)+x=g(x)
Iteration formula x
i+1
=g(x
i
)
Check for convergence of g(x): Condition |g(x)|<1
29
Algorithm
1. Guess initial value for the solution
2. Evaluate the new estimate
x
i+1
=g(x
i
)
1. Evaluate the error
a
If
a<

s
Terminate iteration
Else repeat step 2
30
MTH510 Numerical Analysis
LF/S12 6
Using Matlab function
General NL function f(x)
>> [x,feval]=fzero(function, X0)
fzero- matlab function (uses a combination of the methods)
X0- interval [xl xf] / nearest to the point x0
Polynomial (p=[ an a0])
>>roots(p)
31 32
Example 2.8 Find the roots of function in
Example 2.2, 2.4
Polynomial f= a
n
x^n +...a
0
P=[a
n
...a
0
]