Ch2b-Solution of Nonlinear Equation
Ch2b-Solution of Nonlinear Equation
(b)
1
Secant Method
3
Example: 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
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
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
F(x,y) = 0
G(x,y) = 0
• For example,
x2 + y 2 - 2 = 0
-exp(-x) + y2 - 1 = 0
10
Jacobi Iteration Method
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
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
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
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)
F(x,y) = 0
G(x,y) = 0
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)
(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)
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
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)
(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
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
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
26
Case Study C2.3: Damped Oscillation of an Object
(continued)
Solution (ii): Part (ii) requires the solution of
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
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