0% found this document useful (0 votes)
5 views32 pages

Ch2b-Solution of Nonlinear Equation

The document discusses various methods for solving nonlinear equations, including the Secant Method, Jacobi Iteration Method, and Newton's Method. It highlights the advantages and disadvantages of each method, provides examples, and explains the mathematical principles behind them. Additionally, it covers the concept of multiplicity of roots and includes a case study on intersecting circles.

Uploaded by

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

Ch2b-Solution of Nonlinear Equation

The document discusses various methods for solving nonlinear equations, including the Secant Method, Jacobi Iteration Method, and Newton's Method. It highlights the advantages and disadvantages of each method, provides examples, and explains the mathematical principles behind them. Additionally, it covers the concept of multiplicity of roots and includes a case study on intersecting circles.

Uploaded by

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

Solution of Nonlinear Equation

(b)

Dr. Asaf Varol


[email protected]

1
Secant Method

• Similar approach as the Newton-Raphson method

• Differs because the derivative does not need to be


calculated analytically, which can be a great advantage

F(xi) = [F(xi) - F(xi-1)]/(xi – xi-1)

• Disadvantage is that two initial guesses are needed


instead of one
F( x i )( x i  x i  1 )
x i 1 x i 
F( x i )  F( x i  1 )
2
Graphical Interpretation of Newton-Raphson and
Secant Method

3
Example: Secant Method

• Water flow from a tower


at a height h, through a
pipe of diameter D and
length L which is
connected to the tower
running vertically
downward and then laid
horizontally to the desired
point of delivery. For this
system the following
equation for the flow rate
Q is found. Find the roots
using the Secant Method.

4
Matlab Program

5
Result for Secant Method

6
Multiplicity of Roots and Newton-Based
Methods
• In some situations, one root can fulfill the role of being a root
more than one time. For example, the equation

F(x) = x3 - x2 - x + 1= (x + 1)(x - 1)2 = 0

has three roots, namely x = -1, and x = 1 with a multiplicity of two


• Using l’Hospital’s Rule, the Newton-Raphson method can be
modified

xi+1 = xi - F(xi)/F(xi)

Or, if the second derivative is also zero then l'Hospital's rule can
be applied once more to obtain

xi+1 = xi - F(xi)/F(xi)
7
Multiplicity of Roots and Newton-Based
Methods
F(x)

+ +
x
(a)

F(x)

+
x
(b) -

Figure 2.4.1 Roots with multiplicity higher than one: (a) even multiplicity; (b) odd 8
Example E2.4.1
Problem: Apply Newton-Raphson method to the polynomial equation

F(x) = x3 - 3x2 + 3x - 1 = (x - 1)3 = 0

Solution: First we apply Newton-Raphson method without any modification of


the given function. It can be shown that the method does not converge for any of
the starting values x0 = 0., 0.5, 0.9, and 1.5. In fact the iterations oscillate between
0.2504306 and 0.4258722. But if we make the following substitution

U(x) = F(x) and U(x) = F(x)

and apply the same method, i.e.

xi+1 = xi - U(xi)/U(xi)

then the method converges in 24 iterations to the root x=.9999999 with an error
bound of 1.0E-07, and starting value of x=0.0

9
Systems of Nonlinear Equations

• Extension of the previous methods to systems of N equations with N


variables
• Our discussion will be limited to solutions to the following system of
nonlinear equations:

F(x,y) = 0

G(x,y) = 0

• For example,

x2 + y 2 - 2 = 0

-exp(-x) + y2 - 1 = 0

10
Jacobi Iteration Method

• Jacobi method is an extension of the fixed-point iteration method to


systems of equations

• The equations F(x,y) = 0 G(x,y) = 0


need to be transformed into

x = f(x,y)
y = g(x,y)

• Actual iteration is similar to the case of one equation with one variable

xi+1 = f(xi,yi)
yi+1 = g(xi,yi)

11
Jacobi Iteration Method

• Convergence criteria - in the vicinity of the root (xr, yr),

f f
 1
x y

g g
 1
x y

12
Example E2.5.1a

Problem: Solve the following systems of equations using Jacobi iteration method

x - 5 + exp(-xy) = 0

y - 1 + exp(-0.5x)cos(xy) = 0

Solution: First rewrite the equations in the form x = f(x, y), y = g(x,y)

x = 5 - exp(-xy)

y = 1 - exp(-0.5x)cos(xy)

We start with the initial guess x0 = 0, y0 = 0, and apply the Jacobi method with an error bound of 1.e-07.
The result is shown in Table 2.5.1 which shows that the Jacobi iteration converges to the root x=4.9926,
y=0.98372 in about 20 iteration. Note here the norm of the absolute error in x and in y is used as stopping
criteria, i.e. ERROR = (errorx2 + errory2)1/2 < errbound.

13
Matlab for Jacobi Method

• %Jacobi Iteration Method


• x0=0.0;
• y0=0.0
• E=1.0E-4;
• %
• %---writing out headers to the file 'jacobimethod.dat'
• %
• fid=fopen('jacobi.dat','w');
• fprintf(fid,'Roots of Equations x-5+exp(-xy)=0 \n\n')
• fprintf(fid,'Roots of Equations y-1+exp(-0.5x)cos(xy)=0 \n\n')
• fprintf(fid,'Using Jacobi Method \n')
• fprintf(fid,'iter x y ErrorX ErrorY \n');
• fprintf(fid,'------------------------------------------\n');
• %
• %---entering the loop to determine the root
• %

14
Matlab for Jacobi Method (Cont’d)

• for i=1:100
• x1=5-exp(-x0*y0);
• y1=1-exp(-0.5*x0)*cos(x0*y0);
• errorx=abs(x1-x0);
• errory=abs(y1-y0);
• %---writing out results to the file 'jacobi method.dat'
• %
• fprintf(fid,'%4.1f %7.4f %7.4f %7.4f %7.4f \n',i,x1,y1,errorx,errory);
• %

• if abs(x1-x0)<E&abs(y1-y0)<E
• break;
• end

• x0=x1;
• y0=y1;

• end
• fclose(fid)
• disp('Roots approximation=')
• x1,y1

15
Results for Jacobi Method

16
Gauss-Seidel Iteration Method

• Similar to the Jacobi iteration method


• Differs by using updated x or y values (i.e. the approximate
roots) for calculations

x
*
i+ 1 = f( x i , y i )

y i+ 1 = g ( x * i+ 1 , y i )

o r in t h e r e v e r s e o r d e r

*
y i+ 1
= g( xi , yi)

*
x i+ 1 = f ( x i , y i+ 1 )

17
Newton’s Method (I)

• Consider the two nonlinear equations

F(x,y) = 0
G(x,y) = 0

• The Taylor series expansion for a function F(x, y) is

F(x, y) = F( x o , yo) + Fx ( x o , yo)(x - x o) +


Fy ( x o , yo)(y - yo) + Fxy ( x o , yo)(x - x o)(y - yo)/2 +
2 2
Fxx ( x o , yo)(x - x o ) /2 + Fyy ( x o , yo)(y - yo ) /2 + ...

where ( )x and ( )xx denote the first and second partial derivatives with
respect to x, and similarly for ( )y , ( )yy and ( )xy

18
Newton’s Method (II)

• Keeping the first three terms on the right-hand side yields

• Solving these equations for x and y after letting


yields

 (F G y - G Fy ) 
x i+1 x i -  
 J  x=xi , y= yi

 (G Fx - F G x ) 
yi+1 yi -  
 J x=xi , y= yi
where J is the Jacobian defined by J = (FxGy - GxFy)
19
Newton’s Method (III)

• Retaining only two terms and thus simplifying the equations,


x i 1 x i   F 
F 
 x  x i ,yi
G 
y i 1 y i   
 G y  x i ,yi

F G
where Fx  and G y 
x y

20
Technique of Underrelaxation and
Overrelaxation
• Expresses ‘confidence’ in the new estimate of the root
• Underrelaxation 0 < < 1

• Overrelaxation - 1 < < 2


x i 1  x i 1  1   x i
y i 1  y i 1  1   x i

• Can be applied to Newton’s method as

x i 1 x i    F 
 Fx  x i ,yi
G 
y i 1  yi    
 G y  x ,y
i i
21
Case Study C2.2: Two Intersecting Circles

I n v a r i o u s e n g i n e e r i n g a p p l i c a t i o n s , m e a s u r e m e n t s o f fl u i d v e l o c i t y u s i n g la se r D o p p le r
a n e m o m e te r ( L D A ) it is n e c e s s a r y to d e te r m in e if a n d w h e r e tw o c ir c le s in te r s e c t e a c h
o th e r w h e n th e r a d ii a n d th e lo c a tio n o f th e c o o r d in a te s o f th e c e n te r s a r e g iv e n . I n th is
c a s e , w ith o u t lo s s o f g e n e r a lity , o n e c a n p u t th e o r ig in o f th e c o o r d in a te s y s te m a t th e
c e n te r o f o n e o f th e c ir c le s , h e n c e th e e q u a tio n s a r e

x 2  y 2  r 12
( x  x c ) 2  ( y  y c ) 2  r 22

w h e r e ( x c, y c) is th e c o o r d in a te s o f th e c e n te r o f th e s e c o n d c ir c le . G iv e n f o r e x a m p le ,
x c = 1 , y c = 1 , r 1 = 1 , r 2 = 1 , fi n d t h e p o i n t s o f i n t e r s e c t i o n o f t h e s e t w o c i r c l e s .

22
Case Study C2.2: Two Intersecting Circles
(Cont’d)
S o lu tio n : T h e N e w to n -R a p h s o n ite r a tio n m e th o d d e r iv e d fo r tw o e q u a tio n s c a n b e
u s e d w i t h r e l a t i v e e a s e t o fi n d t h e r o o t s o f t h e a b o v e g i v e n e q u a t i o n s . L e t
2 2
F (x ,y )  x  y  1  0

2 2
G (x ,y )  (x  1)  (y  1)  1  0

T h e p a r tia l d e r iv a tiv e s a r e

F x = 2 x ; F y = 2 y ; G x = 2 (x -1 ) ; G y = 2 (y -1 )

a n d th e J o c o b ia n is g iv e n b y

J = (F xG y - G xF y)

w h ere ( )x d e n o te s th e p a r tia l d e r iv a tiv e w ith r e s p e c t to x , a n d s im ila r ly fo r y .T h e e x a c t


r o o ts o f th e a b o v e e q u a tio n s c a n b e fo u n d b y in s p e c tio n o f th e e q u a tio n to b e (1 ,0 ) a n d
(0 ,1 ). W ith a n in itia l g u e s s o f x = 0 .5 , y = 0 . 1 f o r t h e fi r s t r o o t , a n d x = 0 . 1 , y = 0 . 5 f o r
th e s e c o n d r o o t, th e r o o ts a r e fo u n d to b e:

(i) x r = 1 .0 0 0 0 1 3 , y r = -1 .3 1 0 1 9 0 e-0 5 ;
(ii) x r = -1 .3 1 0 1 9 0 e-0 5 , y r = 1 .0 0 0 0 1 3

23
Case Study C2.3: Damped Oscillation of an Object

T h e d a m p e d o s c illa tio n o f a n o b je c t a s s e e n in th e F ig u r e b e lo w is g o v e r n e d b y N e w to n ’ s s e c o n d la w .

F ig u r e C .2 .3 a M a s s - s p r in g s y s t e m w it h d a m p e r .

k s p r in g
m o b je c t

c
flu id

(m a s s )( a c c e le r a tio n ) = (n e t f o r c e a c tin g o n th e o b je c t)

F o r th is p r o b le m th is e q u a tio n c a n b e w r itte n a s

m a = - cv - kx

w h e r e m i s t h e m a s s ( i n k g ) , a i s t h e a c c e l e r a t i o n , c i s t h e d a m p i n g c o e ffi c i e n t ( i n k g / s ) , k ( i n k g / s ) i s
th e s p r in g c o n s ta n t, a n d x is th e d is p la c e m e n t d is ta n c e f r o m a n e q u ilib r iu m p o s itio n . T h e a b o v e
e q u a tio n c a n a ls o b e w r itte n a s

d 2x d x
m + c + k x = 0 . x = x0 ; v = 0. at t = 0.
d t2 d t

24
Case Study C2.3: Damped Oscillation of an Object
(continued)
The analytical solution to this problem can be found knowing the fact that this is an oscillatory motion, and
it is damped by a viscous fluid, so the displacement should go to zero for large time, i.e. as t goes to
infinity. A solution of the form

x =x0 exp(-bt) [ ACos(t) + BSin(t) ]

is first assmed. In order to satisfy the initial conditions we must have A = 1 ; B = b/

Substituting the proposed solution in to the differential equation and equating the coefficients of Cos(t) and
Sin(t) to zero( note that the r.h.s. of the differential equation must be zero for arbitrary time) yields the
following relation for two unknowns

b = c/(2m) ;  = [ (k/m) - (c2/4m2)]1/2


For a meaningful solution it is necessary to have
c2 < 4mk
Given that c= 100 kg/s, k = 10,000 kg/s2, and m=50 kg
(i) Determine the time after which the oscillations of the object would be less than 10% of its initial
displacement.
(ii) Determine the first time at which the object will pass through the equilibrium point, i.e. x=0.
(iii) Given the above values of c and k, determine m such that the object passes the zero pint at t=0.20
seconds for the first time.
25
Case Study C2.3: Damped Oscillation of an Object
(continued)
Solution (i): First we calculate the parameters b and  which are:
b =1. sec-1 ;  =14.11 sec-1

To solve problem (i) it is not necessary to use any numerical method. But we first plot
this function as a function of time to observe the general behavior of it. Figure C2.3b
shows how the objects oscillates in a periodic manner with decaying amplitude. To find
out when the amplitude will be less than 0.1, we first find where the function will have
local maxima or minima by setting the first derivative of the function w.r.t. to time
equal to zero. This yields the information that

Sin(t) = 0. or Cos(t) = 1

where the function will have a local maximum or a minimum. Thus we have

0.1 = exp(-bt) [1.0 +0.0]

to find the answer to the first part, which is t = 2.3 seconds.

26
Case Study C2.3: Damped Oscillation of an Object
(continued)
Solution (ii): Part (ii) requires the solution of

0 = exp(-bt) [ Cos(t) + c/(2m)Sin(t) ]

Since exp(-bt) is never zero we divide both sides by this to get

F(t) =Cos(t) + c/(2m)Sin(t) ] = 0.

Using the bisection method with the given values of the parameters and the lower and
upper bounds tlower = 0., tupper=0.2, we find the answer to Part (ii) to be

t = 0.11636 seconds

Note that this problem can also be solved using the Newton-Raphson method, the
differentiation w.r.t. time is not so difficult.

27
Case Study C2.3: Damped Oscillation of an Object
(continued)

1.0

0.5
x/x0

0.0

-0.5

-1.0
0 1 2 3
time (seconds)
Figure C2.3b Variation of X/X0 with time: m = 50 kg ;
2
k = 1.0E+04 kg/s ; c =1.0E+02 kg/s 28
Case Study C2.3: Damped Oscillation of an Object
(continued)
Solution to part (iii): In this case the dependent variable is the mass, m, not the time. So we first plot the
function making m the independent variable as seen in the figures. The first figure is generated by scanning the
function at 0.5 kg intervals. As mentioned before without using some analytical analysis and without using
engineering judgment it is difficult to guess where approximately the roots of the equation would be. This
problem is a good example in that for a fixed time, in this case t=0.2 s, it seems as if there should be only one
(unique) mass, m. It is seen from the graphs that this is not the case. Inspection of the graph carefully reveals that
there are roots in the following intervals:

(0.5, 1.0) ; (1.5, 2.0) ; (2.5, 3.0) ; (5.5, 6.0) ; (16.5, 17.0) ; (153.5, 154)

and so on. However, it is difficult to locate all of these points from the first figure. For this, the portion of the
graph is enlarged and replotted in the second figure where it is possible to see the roots in the interval (0.5, 7.0).
Inspection of the table of values for this function for m < 0.5 reveals that the function becomes almost chaotic in
this region with many more roots. Therefore, a proper statement of part (iii) should specify the interval for which
a solution is being sought. For example it could be as follows:
“Determine the possible values of m in the interval (10,20) such that the object crosses the equilibrium point
(x=0.) at time t=0.2 seconds for the first time.” To solve this problem we apply the bisection method with
the lower and upper bounds 10 and 20, respectively with the following function subprogram. It is seen the
root in the interval is

m = 16.861 kg

with an error bound of 1.E-04

Now, to make sure that with this value of mass, the displacement is zero at time
t = 0.2 seconds for the first time, the function should be plotted again where x/x0 versus time is displayed.
29
Case Study C2.3: Damped Oscillation of an Object
(continued)

1.0
0.10

0.5 0.05
x/x0

x/x0
0.0 0.00

-0.5 -0.05

-0.10
-1.0 0 1 2 3 4 5 6 7
0 20 40 60 80 100 120 140 160 180 200
mass (kg)
mass (kg)
Figure C2.3d Variation of X/X0 with mass: t = 0.2 kg ;
Figure C2.3c Variation of X/X0 with mass: t = 0.2 kg ;
k = 1.0E+04 kg/s2; c =1.0E+02 kg/s
k = 1.0E+04 kg/s2; c =1.0E+02 kg/s 30
• End of Chapter 2b

31
References
• Celik, Ismail, B., “Introductory Numerical Methods for Engineering Applications”,
Ararat Books & Publishing, LCC., Morgantown, 2001
• Fausett, Laurene, V. “Numerical Methods, Algorithms and Applications”, Prentice
Hall, 2003 by Pearson Education, Inc., Upper Saddle River, NJ 07458

• Rao, Singiresu, S., “Applied Numerical Methods for Engineers and Scientists, 2002
Prentice Hall, Upper Saddle River, NJ 07458
• Mathews, John, H.; Fink, Kurtis, D., “Numerical Methods Using MATLAB” Fourth
Edition, 2004 Prentice Hall, Upper Saddle River, NJ 07458
• Varol, A., “Sayisal Analiz (Numerical Analysis), in Turkish, Course notes, Firat
University, 2001

32

You might also like