Professional Documents
Culture Documents
Bab-3 Nonlinear Equation
Bab-3 Nonlinear Equation
3.1 Introduction
In the previouschapterwe dealtwith'linear'equationswhich did not involve powersof
'nonlinear'
the unknowns. A common form of equations which frequently arises in
practice does contain such powers, for example
x 1 3* 2 x r x 2 * xr2:4
( 3l )
x1*4x1x2*3xr2:7
Y:s6):x3-x:1 (3.3)
and look for the intersectionof 9(x) with the line y: I as a solution of the equation, also
1; shown in the figure.
I Since we now knowthat x::1.324is a solution, we can factorise/(x) to yield
i (3.4)
f ( x ) = ( x - 1 . 3 2 4 ) ( x z+ 1 . 3 2 4 x + 0 . 7 5 5 ) : 6
Taking the roots of the quadratic equation in eq. 3.4, we arrive at solutions
- r.324t
x= (3.5)
1.0
t<- Rnnl
We shali also see that methods for solving nonlinear equations are intrinsically
iterative in character.Referringto Fig. 3.1, it should be clear that such an iterative
processmight depend strongly on the quality of an initial guessedsolution. For
example,a guessof x : I or x :2 in that casemight have much more chanceof success
t h a n a g u e s so f x : - 1 0 0o r x : * 1 0 0 .
F2Q) Fr ( x l
tr
r(x)
i -
N O N L I N E A RE O U A T I O N S
x: F(x) (3.6)
x:Fr(x):x3-l (a)
I
x:F:(x): . . (b) (3.7)
x-- I
The program expectsF(x) to be supplied by the user as a FoRTRAN FUNCTION. For example,
the function F3(x) is generated as shown at the end of the program in ruNcttoN F using the
identity
j6+1:exp[]log"(x+1)l (3.8)
The program merely reads a starting value xs, and calculatesa new value x1 : f(xo). If x1 is close
66 CHAPTER 3
PROGRAM P31
C
c PROGRAM3.I ITERATTVE SUBSTITUTION FOR SINGLE ROOT
h
t
Initial value
Tolerance
XO
1.2
TOL
1.8-5
Iteration limit ITS
100
Fig. 33(a) Input data for Program3.1
l
INITIAL VAIUE
.1200E+01
0 8
t.2 7
l.J 6
10.0 9
100.0 10
Example 3.1
Solution 3.1
We couldwrite(1) x:x3-l
Q)x:-J-
-x2-l
(3)x:ii;JT
In this case,arrangement(3) is the only one that converges,
hence
xo: 1.3
",:{/3+t :1.32006
*r:{lL32cr,6L: 1.3238
,r:{rnts+t :1.3245erc.
can be factorisedinto
x: F(x):i, l 2 x 2+ ( 3 .rr)
-3
Fig. 3.4 Functions of f(x) and F(x) in eqs 3.10 and 3.11
This function is also shown in Fig. 3.4 where it can be seenthat for x < 1.0,F(x) becomes
imaginary.For x just greaterthan 1.0,dFldx> l, although in the vicinity of the root at
x:3, dFldx<1.
When Program 3.1is usedto attempt to solvethis problem,a startingguessxo: 1.1
convergesto the root x:3 in 3ll iterations while starting guessesof xo:l.Q sn6
xo:4.0 converge to the root x:3 in close to 100 iterations. We can see that
convergenceis slow, and that it is impossible to converge on the root x: 1 at all. We
thereforeturn to other methods, beginning with those basedon interpolation between
two estimatesto find a root.
3.4 Interpolationmethods
This classof methods is basedon the assumption that the function changessign in the
vicinity of a root. In fact if, for the type of function shown in eq. 3.10,there had been
a double root rather than a triple one, no sign change would have occurred at the
double root, but this occurrence is relatively rare. Let us begin by assuming that the
vicinity of a root, involving a change in sign of the function, has beenlocated - perhaps
graphicaliy. The next two sections describe methods whereby the root can be
N O N L I N E A BE O U A T I O N S OY
To take a typical example, we know that the function given by eq.3.2, namely
Example3.2
Solution3-2
A tabular approachis useful,i.e.
x f (x)
1.3 -0.1030
t.4 0.3440
1.3s 0.1104
r.325 0.0012
r.312\ - 0.0515
1 . 31 8 7 5 -0.0253
1.32188 - 0.0r
2r
1.32344 -0.0055
r.32422 - 0.0021etc
70 C H A P T E R3
1.32422<x<1.325
PROGRAM P32
C
C PROGRAM 3.2 BTSECTION METHOD FOR A STNGLE ROOT
c
READ(5,*) XN,XNI,TOL,rTS
WRITE(6, *) ( I *a************* B I S E q f I O N M E T H O D* * * * * * * * * * * * * * * |\
WRITE(6, *)
wRrTE(6,*) ('INITIAL V A L U E S ')
wRrTE (6,100) xN,xN1
ITERS : O
ICoN : o
l-o XoLD = XN
1 rF (rcoN.EQ.0 .AND. ITERS.LE.ITS) THEN
XHID : q.5* (XN+XNl)
PRoD = F(xN)*F()a{ID)
IF (PROD.LT..0) THEN
XNl" = )OIID
t'
i';
ELSE
END IF
XN = XMID
C A L L C H E C K( X M T D , X O L D , T O L , I C O N )
fTERs:ITERS+1
G O T O l
END IF
WRITE(6,*)
WRITE(6,*) (ISOLUTION AND ITERATIONS TO CONVERGENCE')
wRrTE (6,200) )(I\{ID,ITERS
10o FoRMAT (2812.4)
200 FoRMAT (E12.4,r10)
STOP
END
FUNCTION F(X)
c
C THIS FTINCTION PROVIDES THE VALUE OF F(X)
c AND WILL VARY FROM ONE PROBLEM TO THE NEXT
c
c
F = X * * 3 _ X _ 1 . 0
RETI'RN
END
N O N L I N E A RE O U A T I O N S 71
********rr***** B I S E C I I I O N M E T H O D* * * * * * * * * * * * ***
INITTAL VALUES
.1000E+01 .2000E+01
As long as convergencehas not been achieved,or the iteration limit reached,the estimatesof
the root are bisected to give x*;6, and the lower or upper estimate are updated as required.
A library routine cnrcx checksif any convergencehas been obtained. (This is done in the same
way as cHEcoN usesfor arrays.)
When the tolerancehas been achieved.or the iterations exhausted.the current estimate of the
root is printed together with the number of iterations to achieve it.
As shown in Fig. 3.5(b),for the tolerance of I x l0- 5, the bisection method takes 17 iterations
to converge from lower and upper starting limits of 1.0 and 2.0.
Again this is based on finding roots of opposite sign and interpolating between them,
but by a method which is generally more efficient than bisection.
F i g u r e 3 . 6 s h o w s a p l o t o f / 1 ( x ) v e r s u s x w i t h a r o o t i n t h e r e g i o no f x : 2 . 5 . S u p p o s e
our interpolation guesseS8r€ xn:1.0 and xn+r:4.0. The false position method
interpolateslinearlybetweenfxn, f @^))and [x,* r, f (xn+t)], taking the intersectionof
the interpolating line with the x-axis as an improved guessat the root. Using the same
procedure as in bisection,the improved guessreplaceseither the lower bound or upper
bound previous guessas the case may be. The interpolation can be written
--l
l- -
xn"*:Xn-.ftr,ll=i!* | oszl
L.f(x,*r)-,f(x,U
Example3.3
f(x):x'-x- 1:o
in the range 1.3< x < 1.4.
C H A P T E R3
f, (x)
f2 ( x \
First ii t
estimate
/r/
of root //
Solutioni.3
_,,_/(,,)[ ^n+ t- Xn I
Xaa*
f( X n + ' )_(/_J-
)- ("fx")l
x ,f("x)
l.J
- 0.1030
1.4 0.3440
t.32304 -0.0071
r.32460 -0.0005
|
1.3247 -0.0000
Program3.3. Falsepositionmethod
This program illustratesthe processdescribedby eq.3.12. Comparisonwith the previous
p.og."* will showthat thedifference limitedto oneline,in whicheq.3.12replaces
is essentially
the bisectionstatement.For clarity x.16[XMID) in the bisectionProgramis replacedby
x."*[XNEW) in thefalsepositionprogram.Whenthe progtamis run with thedataof Fig. 3.7(a)'
theconverged result(Fig.3.7(b)will befoundto havebeenachievedin l3 iterationscomparedto
17.
bisection's
PROGRAM P33
c
C PROGRAH 3.3 FALSE POSITION METHOD FOR A SINGLE ROOT
c
R E A D( 5 , * ) X N , X N l , T O L , I T S
vrnrtrie, *1 ( t********** F A L S E P o s r r r o N M E T H o D* * * * * * * * * * * * * * * r )
wRITE(6,*)
I
W R I T E ( 6 ,* ) ( I I N I T I A L V A L U E S)
NONLINEAR EOUATIONS 73
FUNCTTONF(X)
c
'rr{IS
FUNCTfON PROVIDES THE VALUE OF F(X)
c AND WILL VARY FROM ONE PROBLEM TO THE NEXT
c
c
F = X**3 x - 1.o
RETURN
END
INITIAI, VATUES
.10008+01 .20008+01
Supposewe expand a Taylor seriesabout a single guessat a root, xn. For a small step
ft in the x direction the Taylor expansion is
"{t^)* . (3.I 3)
f (*^* r)L f (x^+h): f (x,)+ hf' (x^)*\ f
Consequently xa+r is a root, i.e. f(x,+h):O if, dropping terms in the expansion
',
higher than f
'(x"):O
f ( x ^ )+ h f
(3.14)
Xn+t:Xn-
f (x^) (3.r 5)
,-
Obviously this has a simple graphical interpretation as shown in Fig. 3.8. The
extrapolation isjust tangential to the function at the guessedpoint xn. The new feature
of the method is the needto calculatethe derivative of the function, and this can present
difliculties (seeChapter 5). However, for simple algebraic expressionslike eq. 3.2 the
differentiationis easily done, and the derivative returned as a FoRTRANFUNCTIoN.
Example 3.4
Use the Newton-Raphson method to find a rool close to x:2 of the function
.f(x):xt-x-1:0
Solution 3.4
N e w t o n - R a p h s o nf o r m u l a x n * , : * ^ - H
xn3-xn- l
h e n c ei n t h i s c a s e ,x n * t : x ^ - -
3X^_2 |
x. f (x)
z s.0000
1.5455 l.I 458
1 . 3 5 9 6 0.l 537
1.3258 0.0046
t.3247 0.0000
PROGRAM P34
FUNCUON F(X)
c
76 CHAPTER 3
c
F = X * * 3 - X - 1 . O
RETURN
END
c
FUNCTION FDASH(X)
C
THIS FUNSIION PROVTDES THE VALUE OF DF/DX
AND WILL VARY FROM ONE P R O B L E M T O T H E N E X T
c
FDASH:3.O*X**2-1.0
RETURN
END
Initial vaJue X0
r.2
Tolerance TOL
l.E-5
Iteration limit ITS
100
* * * * * * * * * * NEWITON-RAPHSON I'IETHOD * * * * * * * t * * * * * * *
INITIAL VAI,UE
- 12 0oE+O1
is now achievedin
When the programis run with the data from Fig. 3.9(a),convergence
4 iterations as shown in Fig. 3.9(b).
3.5.2 A modifiedNewton-Raphsonmethod
Example 3.5
Use the modified Newton-Raohson method to find a root closeto x:2 of the function
Solution 3.5
ModifiedNewton-Raphson
formula)cn*r:xn- f (x^)
f'(xo)
letxo:.2,hencein thiscase,,^*r:r^-#*
.
Xat l:Xr-
.f (x^)
ll
x .f (x)
2 5.0000
r.5455 1.1458
t.44t3 0.5528
r.3910 0.3006
1.3637 0.1724
1.3480 0.1016
1.3388 0.0609
1.3333 0.0368
r.3299 0.0223
1.3279 0.01 36
1.3267 0.0083etc
7B C H A P T E R3
The convergencein this caseis rather slow becausethe gradient at x:2, which remains
unchanged,is a poor approximation to the'correct'gradient at x=1.3247.
PROGRAM P35
C
C PROGRAM 3.5 MODIFIED NEWTON-RAPHSON FOR SINGLE ROOT
c
READ (5,*) X0,TOL,ITS
WRITE(6,*) ( r****** N E T H O D* * * * * * * * * * * r
M o D I F T E D N E W T O N - R A P H S OM )
WRITE(6, *)
WRITE(6, *) ( ' INITIAL VALUE')
wRrTE (6,10o) Xo
WRITE(6,*)
WRITE(6,*) ('VALUE OF X AT EACH ITERATIONI)
ITERS = O
ICON : O
FD = FDASH(Xo)
1 X1: xo - F(xo)/rD
C A L L C H E C K( X 1 , X 0 , T O L , I C O N )
ITERS=ITERS+1
WRITE(6,1O0) X1, ITERS
rF (ICON.EQ.O .AND. rTERS-LT.ITS) GO rO 1
WRITE(6,*)
VTRITE(6,*) ( rsol,tiltloN AND ITERATIONS TO CONVERGENCE')
wRrTE (6, l-00) xl-, rTERS
100 FoRMAT (EL2.4,rl.o)
h; STOP
END
U
FTINCTION F(X)
c
c THIS FUNCTION PROVTDES THE VALUE OF T(X)
c AND WILL VARY FROM ONE PROBLE}.I TO THE NEXT
c
c
F = X * * 3 - X - 1 . 0
RETURN
END
FUNCTION FDASH(X)
c
c T H I S F U N C T I O N P R O V I D E S THE VALUE OF DF/DX
c AND WILL VARY FROM ONE PROBLE}I TO THE NEXT
c
C
FDASH=3.0*X**2-1.O
RETURN
END
N O N L I N E A RE O U A T I O N S 79
Initial value XO
1.0(1.2)
Tolerance TOL
LE_5
Iterationlimit ITS
100
Fig. 3.ll(a) Input data for program 3.5
TNITIAL VALUE
.1000E+o1
: :
.1081E+O1 95
.14908+01 97
. r-o81E+O1 98
.1{90E+01 99
.108LE+O1 100
****** UoDIFIED N E W : I O N - R A P H S O NM E T H O D * * * * * * * * * * *
INTTTAL VALUE
.1200E+O1
XrXt + 2- X** t2
--ncw (3.16)
x1r',2-2x1*a1*xy
The processis far from universally successfulbut can lead to much improved con-
vergenc€rates.
2 x 1 2+ x r 2: 4 . J )
(3.17)
xr'-xrt--0
,, : r/zte - t, |: F(xr,xz)
(3.r8)
x,:a874 :G(x62)
and the iterative procedure followed as before. For example, a starting guessof xt :
xz:1.0 leadsto solutions
Iterationnumber 0 I 2 3 4 5 6
X1 1.0 r.29 1.29 1 . 1 6 t . r 6 r . 2 2 1 . 1 9
^2 1.0 1.0 1.29 t . 2 9 1 . 1 6 1 . 1 6 1 . 1 9
which are clearly converging to the correct result. In the manner of Gauss-Seidel
iteration, the convergencecould be improved by using updated values as soon as they
becomeavailable.
PARAMETERrestrictions
IN>N
PROGRAM P36
c
c PROGRAM 3.6 TTERATIVE SUBSTITI,ITION FOR UANY EQUATIONS
c
c ALTER NEXT LINE TO CHANGE PROBLEI,I SIZE
PARAMETER (IN=2o)
REAL X0(rN),x1(rN)
c
READ(5,*) N, (Xo(I),I=1,N)
READ (5,*) TOL,ITS
WRITE(6,T) (I** SIMPLE ITERATION FOR A SYSTEM OF EQUATIONS **')
wRrTE(6,*)
wRrTE(6,*) ( t T N I T I A L V A L U E S T)
CALL PRINTV(XO,N,6)
WRITE(6,*)
ITERS : O
ICON = O
1 CALL F(Xo,Xl)
CALL CHECON (X1, Xo. N, TOL, rCON)
ITERS=ITERS+1
rF (rcoN.EQ.O .AND. ITERS.LT.ITS) Go To 1
WRITE(6.*) ( ' S O L U T I O N S A N D I T E R A T I O N S T O CoNVERGENCE| )
CALL PRrNW(Xl,N,6)
WRITE(6, IOO) ITERS
1oo FoRMAT (r10)
STOP
END
S U B R O U T I N EF ( X O , X 1 )
Number of unknowns N
z
Initial values x O ( I ) , I : 1 ,N
1.0 1.0
Tolerance TOL
1.E-5
Iteration limit ITS
100
INITIAL VALUES
.1000E+01 .1000E+01
Input data and output resultsare shown in Figs 3.12(a)and (b) respectively.The program is really
just a copy of Program 3.1 with arrays in place of simple variables.The functions F and G in eqs
3.18 are user-suppliedin the form ofa subroutine called F. For theseequations and the starting
guess .xr:xz:1.0, convergenceis achieved in 31 iterations.
AF AF
^ ^ <l
oxr QXz
and (3.re)
lac AG
F'
!
l ^
Ioxr
^
oXz
<1
0/(a*'x,*)
f ( * , . r * r , r r r * r ) : f ( x , * , x r r )+ ( x , r * r - r , * , + ( x 2 r *, - r r r r j f ( * J " " r ) *...
0x, dx,
(3.2t)
Again neglectingderivatives higher than the first, eqs 3.21 gle an improved estimate
of a root in the form
0f (xrk,xrkl - rt
(x,r*r -x,k) J + ( x z k *' - * r * ) Y6 if i(ux ,:t -f(xrr,xzr) (3'221
or,
(xr** I - r, *; 9QLd4 (t
+ (xz,* t - x 2r)ag -' |) - - s(xJ, x 2k)
/xr:7r*+ t -tr*
and Q.23)
a
/x2-yrk+t-*rr
. a f a f -
l xr;-+ /xr - - :- : t
oXr oXz
G'24\
oq oa - g
lxr;:+/x2::
OXr OXz
'\
f af af 1( I r
lI +o x r "o x_z ll l l / * ' |l l| - f Il
I l{ ):( i e.2s)
l a o o ol l I I I
L*, ;)lo") l-n)
Thusfor a systemof N simultaneous nonlinearequations, wemustsolveN simultaneous
linearequationsto find the changes/x1 and/x2 in everyiteration.The matrix on the
left-handsideof eqs3.25is calledthe 'Jacobian'matrix J and its determinantsimply
'the Jacobian'.Clearly,if the Jacobianis zero, the process
fails, and if it is closeto
zero,slow convergence may be anticipated.
For a startingguessof x1: vr: 1.0,the iterationmatrix for the first iterationon eqs
3 . 1 7i s :
Il+
z]ft,,l r.rz'l
r ( ) -- (f
lz -zl [zx,J [o )r
which yieldsthe solution/xr:7*r:0.22 and hencean improvedsolutionx, :
xz:1.22.
C H A P T E R3
Examplej.6
Solution3.6
Arrangeequationas follows:
f(x,y):xy-l:Q
f (*,y):{'+y2 -4:0
l' 'l
':Lr' 2vl
r ^
/.y -xll
I I
J-': 'r'-z*'
[-" rJ
1st iteration
Initial guessx: 1.8,1l:0.5
f -o.rotz o.3orol
J-r:L
0.6020-0.08361
-o:en o.3orolr
Ir'l_l {o }_{o.r:es}
-0.08361
lzyj-L 0.6020 [o.stJ-[o.otzej
2nd iteration
x:1.8+0.1368:1.9368
/:0.5 +0.0176:0'5176
[ - o.r+se o.2z8ol
J-':L o.s56o -o.oi43-l
r+se 027801
{o,\ _[-o {-o.oozs}_{-o.oo+r}
lty|-L 0.5560-0.07431
[-o.otstJ [ 0.0000J
3rd iteration
-0.0049: 1.9319
x: 1.9368
v:0.5176 =0.5176 etc.
N O N L I N E A RE Q U A T I O N S 85
Simple oariables
N Number of equations
TOL Convergencetolerance
ITS Maximumnumberof iterationsallowed
ITERS Currentnumberof iterations
ICON Convergence
criterionin cHEcoN
P R O G R A MP 3 7
c
c PROGRAM 3.7 NEWTON-RAPHSON FOR HANY EQUATIONS
c
ALTER NEXT LINE TO CHANGE PROBLEM
SIZE
o
PARAMETER (IN=20)
c
REALX(IN),X1(IN),DELX(TN),F(IN),DF(IN,
IN)
READ (s, *) N, (x(I) , r=1,N)
READ (5,*) TOL,rTs
( r r*** NE!']ToN-RAPHSoN
FoRA svsrEMoF EeuArroNS**** '
ffiiIE[E;:i )
wRrTE(6,*) ( ' T N I T T A L V A L U E S .)
CALL PRINTV(X,N,6)
wRrTE(6,*)
ITERS = 0
ICON = 0
1 C A L L F A N D D F ( X . F , D F ,I N , N )
CALL MATINV(DF,TN,N)
CALL MWULT (DF, TN, F. N, N, DELX)
C A L L V E C S U B( X , D E L X , X 1 , N )
C A L L C H E C O N( X 1 , X , N , T O L , I C O N )
rTERS-ITERS+1
IF (TCON.EQ.O .AND. ITERS.LT.TTS) GO TO
wRrrE(6,*) ('soLUTroNSaro rrEnairoNs ToT coNvERcENcEr)
CALL PRINTV(X1,N,6)
wRrTE (6,100) rTERS
100 FORMAT (I10)
STOP
END
c
S U B R O U T T N E F A N D D F( X , F , D F , I N , N )
c
c THTS SUBROUIINE PROVIDES THE VALUES
OF THE FI'NCTTONS'
c OF X AND THEIR DERIVATIVES, AND WTLL VARY T'NOIT OHT
c PROBLE}I TO THE NEXT
c
c
REALX(*),F(*),DF(rN, *)
c
=
I t l l = 2 . 0 * x ( 1 ) * x ( 1 )+ x ( 2 ) * x ( 2 ) - 4 . 3 2
IDl F?(l1 , 1 ) x =( 1 ) * x ( 1 ) - x ( 2 ) * x ( 2 )
4.0*X(1)
DF(2,1) : 2.OrX(1)
DF(1,2) = 2.0*X(2)
DF(2,2) = -2.o*X(2)
RETI'RN
END
86 C H A P T E R3
PARAMETERTCSTTiCI|ON
IN>N
Number of unknowns N
2
INITIAL VALUES
. 10008+01 .1000E+01
F .12OOE+O1 .120OE+01
t
Fig. 3.13(b) Results from Program 3.7
The input data and output results are given in Figs 3.13(a) and (b) respectively. The number of
l
l equations, an initial guessof the solution vector, the iteration tolerance and the number of
f1 iterations allowed must be read in by the program. The actual functions and their derivations
are contained in the user-suppliedsubroutine FANDDF.
Library routines MATINv and t',tvt'luLt complete the equation solution required by eqs
3.25,resulting in the changesin X held in DELX. Vector X is then incrementedby DELX and the
cHECoN subroutine called. Note that for large systems,MATINv should be replaced by the
solution algorithms describedin Chapter 2. Figure 3.13(b)shows that convergencewas achieved
in this simple case in 4 iterations.
The presenceof subroutine MArrNv inside the iteration loop will mean substantial
calculations if N becomeslarge. We describedpreviously a modified method which, in
this case,would mean that the matrix on the left-hand side of eqs 3.25need be inverted
once only, at the first iteration. This method is programmed as Program 3.8.
L
N O N L I N E A RE O U A T I O N S
Example3.7
Solution3.7
Arrangeequatiorisas follows
f1(x,y):e' a y:Q
- f r ( r ,y ) : - x f c o s h y - 3 . 5 : o
a _
.r:l ex I I
sinhyJ
L-l
I -ll
J-,: f s l n r r r
l*e'sinhy[_ I .']
-
"r_,: [-o.ron r.oo92-l
L r.ooe2o.oer
sJ
In the modified Newton-Raphson method, J-r is not altered at each iteration.
Hence
lst iteration
x: -2.4, -0.1
/:
ir'l:[-o.rou -r.00e21
fo.oorl
_ f_o.oroal
lorJ I r.oorz00er5J
ioorsoj-i0.0r8rJ
2nd iteration
x : - 2.4- 0.0968 : - 2.4968
/ : - 0 . 1 + 0 . 0 1 8:1 - 0 . 0 8 1 9
-
[z']_[-o rorr 1.00e21
[-ooo*l f o.ooozl
lzv) [ r.oorz0oer5J
i-oooozj:i-o*j
C H A P T E R3
3rd iteration
PROGRAM P38
c
C P R O G R A M3 . 8 MODIFTED N E W T O N - R A P H S O NF O R H A N Y E Q U A T I O N S
c
C ALETR NEXT LINE TO CHANGE PROBLEM SIZE
c
no*ETER (IN=2o)
.
REALx(rN),X1(rN),DELX(rN),F(rN),DF(rN,IN)
c
gEAD (5,*) N, (X(r),1:1,N)
READ (5,*) ToL,ITS
WRITE(6,*) ( r************ M O D I F I E D N E W T O N - R A P H S O*N* * * * * * * * * * * * r )
l.lRITE(6,*) (r*********** F O R A S Y S T E M O F E Q U A T I O N S* * * * * * * * * * * * r )
I{RITE(6,*)
W R I T E ( 6 , * ) ( ' T N I T I A L V A L U E S I)
CALL PRINTV(X,N,6)
I{RITE(6, *)
ITERS : O
ICON = O
C A L L F A N D D F( X , F , D F , I N , N )
F
C A L L V E C S U B ( X ,D E L X , X 1 , N )
C A L L C H E C O N( X 1 , X , N , T O L . r C O N )
ITERS:ITERS+1
rF (rcoN.EQ.0 .AND. TTERS.LT-rrs) Go ro 1
l WRITE(6,*)
CALL PRINTV(X1,N,6)
WRITE (6,1o0)
('SOLUTTONS AND TTERATIONS TO COITVERGENCET)
rrERS
r,
b
c
10o FoRMAT (I1O)
STOP
END
S U B R O U T I N E F A N D D F ( X ,F , D F , I N , N )
Number of unknowns N
2
Initial values X0(I),I: l,N
1.0 1.0
Tolerance TOL
1.8-5
Ilerationlimit ITS
100
Fig. 3.14(a) Input data for Program3.8
* * * * * * * * * * * * I,IODf FI ED NEI{TON-RAPHSON * * * * r * * * * i t * *
*****r***** FoR A SySTEl,roF EQUATIONS ************
INITIAL VAIUES
.1OOOE+O1 .10OOE+o1
3.8 Exercises
I Find a root of the equationx4-8x3 +23x2+ l6x-50:0 in the vicinityof 1.0by simple
iteration.
Answer:1.4142
3 Find a root of the equationin ExerciseI in the range 1.0< x < 2.0 by bisection.
Answer:l.4l42in l7 iterationsfor a toleranceof I x l0-s.
90 3
CHAPTER
7 Find a root of the equationin ExerciseI in the vicinity of 1.0by the Newton-Raphson
process.
Answer:l.4l42in 3 iterations for a toleranceof 1x l0-s.
8 Find a root of the equationin Exercise2 in the vicinity of 1.0by the Newton-Raphson
process.
Answer:0.5 of 1x I0-5.
in 6 iterationsfor a tolerance
9 Find a root of the equation in ExerciseI in the vicinity of 1.0 by the modified
Newton-Raphsonprocess.
Answer:1.4142in 5 iterationsfor a toleranceof I x 10-5.
l0 Find a root of the equation in Exercise2 in the vicinity of 1.0 by the modified
Newton-Raphsonprocess.
Answer:0.5in 30 iterationsfor a tolerance
of 1x 10-5.
ll Solvethe equations
:
1 1* x 2 - 1 r r l 2 - 9 . 2 5 : g
I
8 x r 2 +1 6 x r - 8 x 1 x 2 - 5 : 0
xt:xz-l'
2 x 1 2_ 4 x 1 x 2 - x z 2: O
2 x 2 2+ l l x y - x 1 2- 4 x r x 2 - 5 : 0
xr:icz - l'
Answer: xl:0.58, xz:0.26 in (a) 1470 iterations and (b) 6 iterations for a tolerance of
1x 10-s.
N O N L I N E A RE O U A T I O N S 91