0% found this document useful (0 votes)
16 views41 pages

Lecture3 - Roots of Equations - 04march2024 - NK - v1

The document discusses root finding methods for polynomials including the Müller method, Bairstow's method, and a comparison of various root finding techniques. The Müller method uses three points to fit a parabola and projects the root. Bairstow's method divides the polynomial into factors of x-t and modifies guesses to drive the remainder to zero.

Uploaded by

yamanf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views41 pages

Lecture3 - Roots of Equations - 04march2024 - NK - v1

The document discusses root finding methods for polynomials including the Müller method, Bairstow's method, and a comparison of various root finding techniques. The Müller method uses three points to fit a parabola and projects the root. Bairstow's method divides the polynomial into factors of x-t and modifies guesses to drive the remainder to zero.

Uploaded by

yamanf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

CME302

COMPUTATIONAL METHODS IN
ENGINEERING
Part 2 – Roots of Equation

Dr.Namık KILIÇ e-mail: [email protected] 04th March2024


Part2 – Roots of Equation
Chap.7 – Roots of polynomials
Chap.8 – Case Studies
Roots of Polynomials
The roots of polynomials such as,

f n ( x ) = ao + a1 x + a2 x + 2
+ an x n

Follow these rules:


1. For an nth order equation, there are n real or complex roots. It
should be noted that these roots will not necessarily be distinct.
2. If n is odd, there is at least one real root.
3. If complex root exist in conjugate pairs (that is

 + i and  − i ), where i = −1.


Conventional Methods

▪ The efficacy of bracketing and open methods depends on


whether the problem being solved involves complex roots. If
only real roots exist, these methods could be used. However,
▪ Finding good initial guesses complicates both the open and
bracketing methods, also the open methods could be
susceptible to divergence.
▪ Special methods have been developed to find the real and
complex roots of polynomials – Müller and Bairstow methods.
Conventional Methods

a simple second-order system defined by the following linear ordinary


differential equation (or ODE):
Conventional Methods

If the discriminant is negative, the roots will be complex conjugate


numbers,
Müller Method
• Müller’s method obtains a root estimate by projecting a parabola
to the x axis through three function values.
Müller Method 2

The method consists of deriving the coefficients of


parabola that goes through the three points:

1. Write the equation in a convenient form:

f 2 ( x ) = a ( x − x2 ) + b ( x − x2 ) + c
2
Müller Method
2. The parabola should intersect the three points  xo , f ( xo )  ,  x1 , f ( x1 )  ,
 x2 , f ( x2 )  . ▪ The coefficients of the polynomial can be estimated by
▪ substituting three points to give.

f ( xo ) = a ( xo − x2 ) + b ( xo − x2 ) + c
2

f ( x2 ) = a ( x1 − x2 ) + b ( x1 − x2 ) + c
2

f ( x3 ) = a ( x2 − x2 ) + b ( x2 − x2 ) + c
2

3. Three equations can be solved for three unknowns, a, b, c. Since two of the
terms in the 3rd equation are zero, it can be immediately solved for c=f(x2).

f ( xo ) − f ( x2 ) = a ( xo − x2 ) + b ( xo − x2 )
2

f ( x1 ) − f ( x2 ) = a ( x1 − x2 ) + b ( x1 − x2 )
2
Müller Method
Algebraic manipulation can then be used to solve for the remaining coefficients,
a and b.
h0 = x1 − x0 h1 = x2 − x1

f ( x1 ) − f ( x0 ) f ( x2 ) − f ( x1 )
0 = 1 =
x1 − x0 x2 − x1

( 0 1)
+ − ( 0 1 ) a = h0 0 + h11  Solve for a and b
+
2
h h b h h

h1 b − h12
a = h11 

1 −  0
a = b = ah1 + 1 c = f ( x2 )
h1 + h0
Müller Method
• Roots can be found by applying an alternative form of quadratic
formula:

−2c
x3 = x2 +
b  b 2 − 4ac

• The error can be calculated as:

x3 − x2
a = 100%
x3

• ± term yields two roots, the sign is chosen to agree with b. This will
result in a largest denominator, and will give root estimate that is closest
to x2.
Müller Method
• Once x3 is determined, the process is repeated using the
following guidelines:
1. If only real roots are being located, choose the two
original points that are nearest the new root estimate, x3.
2. If both real and complex roots are estimated, employ a
sequential approach just like in secant method, x1, x2, and
x3 to replace x0, x1, and x2.
Müller Method
Müller Method
Müller Method
Bairstow’s Method
• Bairstow’s method is an iterative approach loosely related to both Müller
and Newton Raphson methods.
• It is based on dividing a polynomial by a factor x-t:

f n ( x ) = ao + a1 x + a2 x 2 + + an x n
f n −1 ( x ) = b1 + b2 x + b3 x 2 + + bn x n
▪ with a reminder R = b0, the coefficients are calculated by recurrence
relationship
bn = an bi = a i +bi +1t i = n − 1 to 2

determine whether there is a remainder. If not, the guess was perfect and
the root is equal to t. If there is a remainder, the guess can be systematically adjusted
and the procedure repeated until the remainder disappears and a root is located. After
this is accomplished, the entire procedure can be repeated for the quotient to locate
another root.
Bairstow’s Method
• To permit the evaluation of complex roots, Bairstow’s method divides
▪ the polynomial by a quadratic factor x 2 − rx − s :

f n − 2 ( x ) = b2 + b3 x + + bn −1 x n −3 + bn x n − 2
R = b1 ( x − r ) + b0

Using a simple recurrence relationship

bn = an
bn-1 = an-1 + rbn
bi = ai + rbi +1 + sbi + 2 i = n − 2 to 0
Bairstow’s Method
• For the remainder to be zero, b0 and b1 must be zero.
However, it is unlikely that our initial guesses at the
values of r and s will lead to this result, a systematic
approach can be used to modify our guesses so that b0
and b1 approach to zero.
• Using a similar approach to Newton Raphson method,
both b0 and b1 can be expanded as function of both r and
s in Taylor series.
Bairstow’s Method
b1 b
b1 ( r + r , s + s ) = b1 + r + 1 s
r s
b0 b
b0 ( r + r , s + s ) = b0 + r + 0 s
r s

Assuming that the initial guesses are adequately close to the values of r
and s at roots. The changes in s and r needed to improve our
guesses will be estimated as

b1 b
r + 1 s = −b1
r s
b0 b0
r + s = −b0
r s
Bairstow’s Method
If partial derivatives of the b’s can be determined, then the two equations can
be solved simultaneously for the two unknowns r and s .
Partial derivatives can be obtained by a synthetic division of the b’s in a similar
fashion to how the b’s themselves were derived:

cn = bn
cn −1 = bn −1 + rcn
ci = bi + rci +1 + sci + 2 i = n − 2 to 2

where

bo bo b1 b1


= c1 = = c2 = c3
r s r s
Bairstow’s Method
Then,

c2 r + c3 s = −b1 ▪ Solved r and s,


▪ for
in turn are employed to
c1r + c2 s = −bo improve the initial guesses.

At each step the error can be estimated as:

r
 a, r = 100%
r
r
 a, s = 100%
r
Bairstow’s Method
The values of the roots are determined by,

r  r 2 + 4s
x=
2
At this point three possibilities exist:
1. The quotient is a third-order polynomial or greater. The previous values of r
and s serve as initial guesses and Bairstow’s method is applied to the quotient
to evaluate new r and s values.
2. The quotient is quadratic. The remaining two roots are evaluated directly,
using the above eqn.
3. The quotient is a 1st order polynomial. The remaining single root can be

evaluated simply as x = −s r .
Comparison of Root Finding Methods
Comparison of the characteristics of alternative methods for finding roots of algebraic and
transcendental equations. The comparisons are based on general experience and do not
account for the behavior of specific functions.

Method Type Guesses Convergence Stability Programming Comments


Direct Analytical — — —

Graphical Visual — — — — Imprecise


Bisection Bracketing 2 Slow Always Easy

False- Bracketing 2 Slow/medium Always Easy


position
Modified FP Bracketing 2 Medium Always Easy

Fixed-point Open 1 Slow Possibly Easy


iteration divergent
Newton- Open 1 Fast Possibly Easy Requires evaluation
Raphson divergent of f’(x)
Comparison of Root Finding Methods

Method Type Guesses Convergence Stability Programming Comments


Modified Open 1 Fast (multiple), Possibly Easy Requires evaluation
Newton- medium divergent of f’(x) and f”(x)
Raphson (single)
Secant Open 2 Medium/fast Possibly Easy Initial guesses do not
divergent have to bracket the
root
Modified Open 1 Medium/fast Possibly Easy
secant divergent
Brent Hybrid 1 or 2 Medium Always (for Moderate Robust
2 guesses)
Müller Polynomials 2 Medium/fast Possibly Moderate
divergent
Bairstow Polynomials 2 Fast Possibly Moderate
divergent
MATLAB APPLICATIONS
Common functions in MATLAB related to root location and polynomial manipulation.
MATLAB APPLICATIONS- increment search

Let our function x3-20x2+5=0

Roughly root is between 0,6-0,8

>> x=linspace(0,1,100);
>> y=x.^3-10*x.^2+5;
>> axis([0 1 0 5]);
>> plot(x,y)
MATLAB APPLICATIONS- increment search
function [x1,x2] = rootsearch(f, a, b, dx) >> rootsearch(inline('x^3-10*x^2+5', 'x'), 0, 1, 0.1)
x1= a;
f1= f(x1);
x2= a + dx;
f2= f(x2); 0.1000 4.9010
while f1*f2>0.0 0.2000 4.6080
if x1 >= b 0.3000 4.1270
x1= NaN; 0.4000 3.4640
x2= NaN; 0.5000 2.6250
return 0.6000 1.6160
end 0.7000 0.4430
x1= x2;
f1= f2; ans =
x2= x1 + dx;
f2= f(x2); 0.7000
disp([x1 f1])
end
MATLAB APPLICATIONS - bisection
MATLAB APPLICATIONS - bisection
function root = mybisect(f, x1, x2, filter, tol) n=ceil(log(abs(x2-x1)/tol)/log(2.0));
if nargin <5; for i=1:n
tol= 1.0e4*eps; xr=0.5*(x1+x2);
end fr=f(xr);
if nargin <4; if(filter ==1) & (abs(fr)>abs(f1)) & (abs(fr)>abs(f2))
filter= 0; root=NaN;
end return
f1= f(x1); end
if f1==0.0; if fr==0.0
root=x1; root=xr;
return; return
end end
f2=f(x2); if f2*fr<0
if f2==0.0; x1=xr;
root=x2; f1=fr;
return else
end x2=xr;
if f1*f2>0; f2=fr;
error('root is not in given interval') end
end root=(x1+x2)/2; end
>> mybisect(inline('x^3-10*x^2+5','x'), 0, 1, 1, 0.01)

ans =

0.7383
MATLAB APPLICATIONS – Newton Raphson

f ( xi )
xi +1 = xi −
f  ( xi )
MATLAB APPLICATIONS – Newton Raphson
function [root, numIter] = mNewtonRaphson(f, df, x0, tol)
for i=1:30
dx=-f(x0)/df(x0);
x0=x0+dx;
if abs(dx)<tol
root=x0
numIter=i;
return
end

>> mNewtonRaphson(inline('x^3-10*x^2+5','x'),inline('3*x^2-20*x','x'), 1, 0.0001)

ans =

0.7346
MATLAB APPLICATIONS – Secant
xi − xi −1
xi +1 = xi − f ( xi ) i = 1, 2,3,
f ( xi ) − f ( xi −1 )
MATLAB APPLICATIONS – Secant

function [root, numIter] = secant(f, x0, x1, tol)


for i=1:100
xr=x1-f(x1)*(x1-x0)/(f(x1)-f(x0));
x1=xr;
if abs(xr-x1)<tol
root=x1;
numIter=i;
return

>> secant(inline('x^3-10*x^2+5','x'),0.8, 1, 0.000001)

ans =

0.7429
Summary of Important Info in Part 2
PIPE FRICTION (Mechanical/Aerospace Eng.)
The Colebrook equation provides a means to calculate the friction factor for a pipe,

   2.51 
0 = + 2.0 log  + 
 3.7 D Re f
f  
where  = the roughness ( m ) , D = diameter (m), and Re = the Reynolds number,

VD
Re =

where  = the fluid’s density ( kg m3 ) , V = its velocity ( m s ) , and  =


dynamic viscosity ( N  s m ).
2
PIPE FRICTION (Mechanical/Aerospace Eng.)
Determine f for air flow through a smooth, thin tube given
 = 1.23 kg m3 ,  = 1.79 10−5 N s m 2 , D = 0.005 m,
V = 40 m s , and  = 0.0015 mm.

An explicit formulation called the Swamee-Jain equation provides an


approximate estimate that can serve as a good initial guess.

1.325
f = 2
   5.74  
ln  3.7 D + Re0.9  
  
PIPE FRICTION (Mechanical/Aerospace Eng.)

Before determining the root, it is advisable to plot the function to


estimate initial guesses and to anticipate possible difficulties. This can
be done easily with tools such

>> rho=1.23;mu=1.79e-5;D=0.005;V=40;e=0.0015/1000;
>> Re=rho*V*D/mu;
>> g=@(f) 1/sqrt(f)+2*log10(e/(3.7*D)+2.51/(Re*sqrt(f)));
>> fplot(g,[0.008 0.08]),grid,xlabel('f'),ylabel('g(f)')
PIPE FRICTION (Mechanical/Aerospace Eng.)
▪ Graphical method:
PIPE FRICTION (Mechanical/Aerospace Eng.)

>> rho=1.23;mu=1.79e-5;D=0.005;V=40;e=0.0015/1000;
>> Re=rho*V*D/mu
>> g=@(f) 1/sqrt(f)+2*log10(e/(3.7*D)+2.51/(Re*sqrt(f)));
>> fzero(g,0.008)
PIPE FRICTION (Mechanical/Aerospace Eng.)
Method Iterations Result Comments
Graphical 0.03
Bisection 22 0.0289678
Newton-Raphson 6 0.0289678 Needs good initial guess
MATLAB fzero 0.0289678 Needs good initial guess

Even great, professionally-developed software like MATLAB is not


always foolproof. Further, there is usually no single method that
works best for all problems. Sophisticated users understand the
strengths and weaknesses of the available numerical techniques.
In addition, they understand enough of the underlying theory so that
they can effectively deal with situations where a method breaks
down.

You might also like