You are on page 1of 27

ChE 374

Computational Methods in Engineering

Solution of Non-Linear Equations

1
Roots of Equations
• Many engineering problems require the
determination of the values of the variable x
which satisfies the non-linear equation

f ( x) = 0

2
Non-Linear Eqn.
• Bracketing methods
– Bisection
– Regula falsi (False position)

– Graphical methods to provide insight


– Error formulation

3
Non-Linear Eqn.
• Open methods
– Systematic trial and error
– Computationally efficient, but do not always
work
• Newton Raphson
• Secant
• One-point iteration
• Roots of Polynomials
– Muller’s
– Bairstow’s
4
Example
• Using the graphical approach to determine
the value of 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 time of 10s.
• NOTE g = 9.8 m/s2.

5
Drag coefficient to attain a given
velocity at a set time period

v=
gm
c
1− e (
− ( c / m )t
)

f (c ) =
gm
c
(
1− e )
− ( c / m )t
−v

6
f (c ) =
gm
c
1− e (
− ( c / m )t
−v) g= 9.8m/s2, m=68.1 kg,
t=10s, v = 40 m/s

f (c )
c f (c )
40
35 f (c )
4 34.115
30
25
8 17.653 20
15

10
12 6.067
5
0
16 -2.269 -5 0 5 10 15 20 25

-10

20 -8.401 -15

The curve crosses the x axis between 12 and 16. A rough estimate of
the root is 14.8. The graphical method is not very accurate, but provides
a good estimate. Also helps to understand the properties of the function. 7
Plot of tan (x) showing singularities
tanx

10
tanx
8

0
0 1 2 3 4 5 6 7
-2

-4

-6

-8

-10

8
Root search algorithm
%Incremental search for a root of f(x)
%USAGE: [x1,x2] = rootsearch(func, a,b, dx)
%INPUT:
% func = handle of function that returns f(x)
% a,b = limits of search
% dx = search increment
% OUTPUT
% x1, x2 = bounds of function that returns f(x)
% set to NaN if no root is found
%
function [x1,x2] = rootsearch(func, a,b, dx)

x1 = a;
f1 = feval(func,x1);
x2 = a + dx;
f2 = feval(func,x2);

while f1*f2 > 0.0


if x1 >= b
x1=NaN; x2 = NaN; return
end
x1 = x2;
f1 = f2;
x2 = x1+dx;
f2 = feval(func,x2);
end
9
Bisection Algorithm
Step 1 Choose lower xl and upper xu guesses for the root
such that the function changes sign over the interval.
This can be checked by ensuring that f(xl)f(xu) <0
Step 2 An estimate of the root xr is determined by
xr = (xl + xu)/2
Step 3 Make the following evaluations to determine in which
subinterval the root lies
(a) If f(xl)f(xr) <0, root lies in lower subinterval, set
xu=xl and go to step 2
(b) If f(xl)f(xr) >0, root lies in upper interval, set xl = xr
and return to step 2
(c) If f(xl)f(xr) =0, the root equals xr; end computation

10
Number of bisections
Bisection is repeated until the original interval
has been reduced to a small value, ε so that
xi − xi −1 ≤ ε
If Δx (0) is the original interval
the number of bisections required to attain
a prescribed absolute error is

⎛ Δx (0) ⎞
ln ⎜ ⎟
ε
n= ⎝ ⎠
ln 2

Slow but sure !!! 11


Termination criteria and error estimates
Define approximate percent error as
xrnew − xrold
εa = new
× 100%
xr

xrnew ≡ root for the present iteration


xrold ≡ root from the previous iteration
(using absolute values because we are concerned about the magnitude,
Not the sign)

When the error becomes less than specified stopping criterion, the
computation stopped.
12
13
Regula Falsi (False Position) Method
f (x1)
f ( x)

x x3 x4
2

x 1

f ( x2 )

f ( xi ) ( xi − xi −1 )
xi +1 = xi −
f ( xi ) − f ( xi −1 ) 14
Newton Raphson Method
f ( x) f ′( x1 )

f ′( x2 )

f ′( x3 )

x
x4 x3 x2 x1
f ( x)

f ( xi )
xi +1 = xi − i = 1, 2, 3....
f ′( xi ) 15
Newton Method: Properties
• Requires derivative of the function f’ = df/dx
• Very fast convergence in most cases
(Quadratic convergence) !!
• May not converge if the estimate is far off
• May not converge if the derivative (slope) at
an estimate is close to zero
• Can be used to find complex roots

16
Newton : Non-convergent

17
Convergence criteria for stopping iterative
procedure
xi − xi −1 ≤ ε

xi − xi −1
≤ε xi ≠ 0
xi

f ( xi ) ≤ε

ε a small number 10−3 or 10−6


18
Secant method
• Similar to Newton’s method but different in
that the derivative f’ is approximated using
two consecutive iterates

f ( xi ) − f ( xi −1 )
f ′( xi ) =
xi − xi −1

f ( xi ) ⎡ xi − xi −1 ⎤
f ( xi ) = xi − = xi − f ( xi ) ⎢ ⎥

f ( xi ) ⎣ f ( xi ) − f ( xi −1 ⎦
)

i = 2, 3, 4, …
• Needs two initial guesses
19
Convergence of the Secant Method

Convergence of Secant method


f ( x) f ( x1 )

f ( x2 )
Exact root

f ( x3 )

x
x4 x3 x2 x1
f ( x)

⎡ xi − xi−1 ⎤
xi+1 = xi − f (xi ) ⎢ ⎥ i = 2,3,4....
⎣ f (xi ) − f (xi−1) ⎦ 20
Secant : non-convergence

f ( x)

x
x2 x1

21
Fixed Point Iteration

22
Roots of Polynomials

23
Roots of Polynomials
f (x) =a0 +ax
1 +a2x + +anx 2 n

n = order of polynomial
a’s = constant coefficients

For real coefficients


• An nth order equation will have n real or complex roots
• If n is odd, at least one root is real
• If complex roots exist, they exist in conjugate pairs, i.e

24
Polynomial Deflation
• If a root of a polynomial has been found, it
is desirable to factor the polynomial

Pn (x) = ( x − r) Pn−1(x)
• Deflation or synthetic division

25
26
Roots of Polynomials
• Polynomials
• Polynomial deflation
• Muller’s Method
• Bairstow’s Method

27

You might also like