Você está na página 1de 10

ALGORITHM 502

Dependence of Solution of Nonlinear


Systems on a Parameter [C5]
MILAN KUBiCEK
Prague Institute of Chemical Technology, Czechoslovakia

Key Words and Phrases. solution of nonlinear equation, differentiation with respect to a
parameter, one-parameter imbedding, dependence on parameter
CR Categories. 5.15
Language- Fortran

DESCRIPTION

The Fortran algorithm D E R P A R is a subroutine suitable for evaluation of the


dependence of the solution x ~ , . . . , xn of a system of equations
f~(xl, . . . , x., ~) = 0
: (1)
f,(xl, ..., x., ~ ) = 0
on the parameter a. The modified method of David~nko [-1, 2, 33, which applies
the implicit function theorem, is used in combination with the Newton method and
Adams integration formulas. A similar procedure was used by Deist and Sefor ['43,
who made use of an introduced parameter.
To establish the dependence x (a), the following set of differential equations can
be derived:

dx = _ r _ i ( x ' a) of__ x(ao) = Xo. (2)


da Oa'
Here
T

' 0a ''" '0al'

If r (x (a), ~) is a regular matrix for (~0, al), then x (a) obtained b y integration of
(2) satisfies
f(x(a),~) = O, a E (ao, a,). (3)

Received 27 December 1972 and 29 October 1973.


Copyright © 1976, Association for Computing Machinery, Inc. General permission to republish,
but not for profit,all or part of this material is granted provided that A C M ' s copyright notice is
given and that reference is made to the publication, to its date of issue, and to the fact that
reprinting privilegeswere granted by permission of the Association for Computing Machinery.
Author's address: Department of Chemical Engineering, Prague Institute of Chemical Tech-
nology, 166 28 Prague 6, Czechoslovakia.
ACM Transactionson Mathematical Software, Vol.2. No 1. March 19760Pages98-107.
Algorithms 99

However, at a branching point the matrix F is singular and the integration pro-
cedure mentioned above fails.
Therefore, the method must be adapted to be able to handle branching points,
i.e. to evaluate the whole dependence x (a), which is a continuously smooth curve
in the (n + 1)-th dimensional space (x - a). A parameterization with respect to
the arc length of the solution locus seems to be a powerful technique which over-
comes the difficulties [-5].
Differentiation of eq. (1) with respect to t gives
df, ~_, Of, dxj Of, da
d-~ = ~_, Ox-~ d--t -t- Oa dt - O, i -- 1, 2, . . . , n. (4)

An additional equation
2 2 2

+ ... +\ + = i (5)

determines the parameter t as the arc length of the curve x (a) in the space (x - a).
The initial conditions for eqs. (4) and (5) are in the form
t = 0 : x = x0, a = a0. (6)
Equation (4) forms a system of n linear equations for n - k l unknowns dx,/dt,
i = 1 , . . . , n, da/dt, for each t. Suppose that the matrix

"Ofz Of, Ofx of~


OXl ~ " " " ~ OZk_l ~ OZk÷l t " " ° ~ OZn+I

oI~
-- ,°. (7)
rk : o,:

of. of. Of,, of,,

OXl ~ "" " ~ OXk-1 ~ OZk+l' " " " ~ OXn-J.l

is regular (for certain values of t and k, 1 _ k < n d- 1). For clarity here, we have
denoted
x . + l = ~. (S)

Equation (4) can then be presolved with respect to the unknowns dx~/dt, . . . ,
dxk_~/dt, d x k + l / d t , . . . , dxn+~/dt, depending on dxk/dt in the form
dx, dxk
d--/ = #' -~-' i = 1, 2 . . . . , k - - l , k-t-l, . . . , n + l . (9)

In the program the unknowns with a subscript k (dx~/dt and xk) are called the
independent variables. The value of the subscript k is determined in the Gaussian
elimination procedure using controlled pivoting. The result depends on the values
of P R E F ( I ) .
On substituting (9) into (5) we obtain
2 --1

\-~-] 1 A- ~ #2 . (10)
s=l, ~k
ACM Transactions on Mathematical S o f t w a r e , V o l . 2, N o . I , M a r c h 1976.
I no
At most ITIN Newton iterations. If IIAxll < E P S is not
fulfilled, -i ÷ ITIN and if INITAL = i then RETURN.
If INITAL = 2 then always RETUILN after inltial Newton.
Output x1 .... ,Xn, a , ~ i after each Newton iteration.

L
f
I I Nc J
Q
Evaluation of f and ,'
Solutlon of llnear system for evaluation of Newton
increment Ax, k and coefflclents S in (9)
i

JIAxl] < EPS) yes

no

<NC _> N C O R R ~ yes if (NCORR # 0) warnln~

tx- Ax+xl
NC + 1 ÷ NC

t 1 ÷ NC ~
t
~ NCRAD = O) yes
no
x - Ax ÷ x
~
additional Newton correction

if (NCRAD = 0) output (x I ..... X n , ~ , V z f ~


I
i 1 )

if (NCRAD # O) output (x I ..... X n , e , - V Z g )


dx k dx k
Evaluation of and according to (i0) and (9).
dt dt
Integratlon over one step by Adams Bashforth method of
highest ( ~ 4) possible order.

If "closed curve" then -1 ÷ NAXOUT anG RETURN.


If values are out of bounds then -2 ÷ NAXOUT a n d RETURN.

Fig. 1. Schematic flowchart of m e t h o d

A C M Transactions on Mathematical Software, Vol 2, No. 1, M a r c h 1976


O7

>¢2

0.6

60

0.5

50

04

O.3
" , . . V15

137
135
02

0"I
d×z l de~= t 2

10

f i i
~ol 002 o.~3 0'04 0'o5 ,, ob~
Fig. 2. The dependence x2(a)
"~ = 1 0 0 0 , B = 22,/~1 = /~ = 2, 0cx = 0o~ = 0; x0 = (0;0;0;0), d0 = 0,
PREY(I) = (1,0.1, 1,1,0.02), H H = 0.02, E P S = 10 -~, M X A D M S = 4,
NCORR = 4, N C R A D = O, N D I R ( I ) = (1,1,1,1,1).
Calculated points on the curve x2(a) are numbered. For the points 1-12, 61-70, 114-140, 155--...,
a was independent (k = 5); otherwise x2 (k = 2) plays the role of an independent variable.
Altogether 332 evaluations of the subroutine F C T N for calculation of 162 points was necessary.
However, by choosing N C O R R = 0 and N C R A D = 1, the number of evaluations of F C T N w a s
lowered to 163, and in fact the same curve was obtained.
ACM Transactions on Mathematical S o f t w a r e , V o l . 2, N o 1, M a r c h 1976
102 Algorithms

The sign of dx~/dt is given by the orientation of the parameter t along the curve.
All derivatives dx~/dt are then determined by (9).
The Adams-Bashforth explicit multistep method with an automatic change in
the order of approximation is used for the integration of differential equations (9)
and (10). It is possible to use some other technique, e.g. the Runge-Kutta method.
However, it seems that our technique is more suitable when considering the time-
consuming evaluation of the Jacobian matrix and the matrix inversion procedure
in each step.
In the course of integration the truncation error causes a deviation between the
calculated solution x(t) and the correct profiles x(l). The Newton method for
variables x' = (xl, Xs, • . . , Xk_l, xk+l, . . . , X~+l)z is therefore used to improve the
calculated profiles:
XPnew- - XPold ~--. --r~-lf.
The higher accuracy of numerical integration lowers the computer time expenditure
only because of the low number of Newton iterations.
The algorithm is described by means of the schematic flow diagram given in
Figure 1. The specification of the individual d u m m y (formal) parameters of the
subroutine D E R P A R is given in the subroutine heading.
The particular form of eq. (1) has to be programmed by the user as a subroutine
FCTN. To illustrate the construction of the subroutine FCTN, an example is pre-
sented for a set of four nonlinear equations:
f~ = a(1 -- xs) exp (10x~/(1 -{- 10Xl//~f)) - - X3 = 0
f~ = aB(1 -- x3) exp (10xl/(1 ~- 10xl/~)) ~c ~10cl -- 10(1 ~- ~1)Xl = 0
fs = x3 -- x4 -{- a (1 -- x4) exp (10x2/(1 -t- 10x2/7)) = 0
f4 = 10Xl -- 10(1 -{- /3s)x2 + aB(1 -- x4) exp (10x2/(1 -t- 10x2/~,)) ~- ~20c2 = 0.
Here v, B, ~1, ~2, 0o~, 0c~, and a are physical parameters. The dependence xs (~) is
shown in Figure 2. Generally speaking, it is always convenient to transform the
unknowns x~, x ~ , . . . , x~, a so that their values are of similar magnitude.
Applicability. This program can be used in the computation of the dependence
of a solution on a parameter for sets of nonline£r equations, for nonlinear boundary
value problems for ordinary differential equations [6, 77, for difference equations
[8], etc.

ACKNOWLEDGMENTS

The author would like to thank the referee for his very valuable comments.

REFERENCES

[1] DAVID~NDO,D.F. On a new method of numerical solution of systems of nonlinear equations.


Dokl. Akad. Naulc S S S R 88(1953), 601-602.
[2] FICKEN, F.A. The continuation method for functional equations. Comm. Pure Appl. Math.
~(1951), 435-456.
[3] HASELGROVE,C.B. The solution of nonlinear equations with two-point boundary conditions.
Computer J. ~(1961), 255-259.
[4] DEIST, F.H., and SEFOR, L. Solutions of systems of nonlinear equations by parameter varia-
tion. Computer J. 10(1967), 78-82.
ACM Transactlons on Mathematlcal Software, Yol. 2, No. I, March 1976.
Algorithms 103

[5] KLOPFENSTEIN, R.W. Zeros of nonlinear functions. Y. ACM 8(1961), 366-373.


[6] KI~Bi6EK,M., and HLAV2~EK,V. Solution of nonlinear boundary value problems: Va. A novel
method, general parameter mapping (GPM); Vb. Predictor-corrector GPM method. Chem.
Eng. Sci. 27(1972), 743-750 and 2095-2098.
[7] KUBI6EK, M., and HL~,VX6EK, V. General parameter mapping technique--a procedure for
solution of non-linear boundary value problems depending on an actual parameter. J. Inst.
Math. Appl. 12(1973), 287-293.
[8] KUBI6EK, M., HLAV~.6EK, V., and JELINEK, J. Solution of counter-current separation pro-
cesses: IV. Application of the GPM method to solution of distillation problems. Chem. Eng.
Sc/. 29(1974), 435-441.

ALGORITHM
SUBROUTINE D E R P A R ( N , X, XLOW, XUPP, EPS, W, I N I T A L , ITIN, HH, DER 10
* HMAX, PREF, NDIR, E, M X A D M S , N C O R R , N C R A D , NOUT, OUT, DER 20
* M A X O U T , NPRNT) DER 30
DIMENSION X(II), XLOW(II), XUPP(II), W(II), HMAX(II), DER 40
* PREF(II), NDIR(II), OUT(100,12), F(II), G ( 1 0 , 1 1 ) , B E T A ( I I ) , DER 50
* MARK(If), DXDT(II) DER 60
C O B T A I N I N G OF D E P E N D E N C E OF S O L U T I O N X ( A L F A ) OF E Q U A T I O N DER 70
C F ( X , ALFA ) = 0 DER 80
C O N P A R A M E T E R A L F A BY M O D I F I E D M E T H O D O F D I F F E R E N T I A T I O N DER 90
C W I T H R E S P E C T TO P A R A M E T E R DER 100
C N - N U M B E R O F U N K N O W N S X(I) DER 110
C X(1), .... X(N) - I N I T I A L V A L U E S O F X ( I ) , A F T E R R E T U R N F I N A L V A L U E S DER 120
C OF X(I) DER 130
C X(N+I) - I N I T I A L V A L U E O F P A R A M E T E R ALFA, A F T E R R E T U R N F I N A L V A L U E DER 140
C OF A L F A DER 150
C XLOW(1),...,XLOW(N) - L O W E R B O U N D S F O R X(I) DER 160
C X U P P ( 1 ) .... ,XUPP(N) - U P P E R B O U N D S F O R X(I) DER 170
C XLOW(N+I),XUPP(N+I) - LOWER AND UPPER BOUNDS FOR ALFA DER 180
C IF X L O W O R X U P P IS E X C E E D E D , T H E N E N D O F D E R P A R DER 190
C AND MAXOUT=-2 AFTER RETURN DER 200
C EPS - A C C U R A C Y D E S I R E D IN N E W T O N I T E R A T I O N F O R DER 210
C S U M OF ( W ( I ) * A B S ( X N E W ( I ) - X O L D ( I ) ) ) , I=l, .... N + I DER 220
C W(1),...,W(N+I) - W E I G H T S U S E D IN T E R M I N A T I O N C R I T E R I O N OF N E W T O N DER 230
C PROCESS DER 240
C I N I T A L - IF ( I N I T A L . N E . 0 ) T H E N S E V E R A L S T E P S IN N E W T O N I T E R A T I O N DER 250
C ARE MADE BEFORE COMPUTATION IN O R D E R TO I N C R E A S E DER 260
C A C C U R A C Y OF I N I T I A L P O I N T - DER 270
C IF ( I N I T A L . E Q . I . A N D . E P S - A C C U R A C Y IS N O T F U L F I L L E D IN I T I N DER 280
C ITERATIONS) THEN RETURN. IF ( I N I T A L . E Q . 2 ) THEN ALWAYS RETURN DER 290
C A F T E R I N I T I A L N E W T O N I T E R A T I O N , R E S U L T S A R E IN X. DER 300
C IF ( I N I T A L . E Q . 3 ) T H E N C O N T I N U E IN D E R P A R A F T E R I N I T I A L N E W T O N . DER 310
C IF ( I N I T A L . E Q . 0 ) T H E N NO I N I T I A L N E W T O N I T E R A T I O N IS USED. DER 320
C ITIN - MAXIMAL N U M B E R OF I N I T I A L N E W T O N I T E R A T I O N S . IF DER 330
C EPS-ACCURACY IS N O T F U L F I L L E D IN ITIN I T E R A T I O N S T H E N DER 340
C ITIN=-I AFTER RETURN. DER 350
C HH - I N T E G R A T I O N S T E P A L O N G A R C L E N G T H O F S O L U T I O N L O C U S DER 360
C HMAX(1),...,HMAX(N+I) - U P P E R B O U N D S F O R I N C R E M E N T S OF X(I) IN DER 370
C O N E I N T E G R A T I O N S T E P ( A P P R O X I M A T I O N ONLY) DER 380
C PREF(1),...,PREP(N+I) - PREFERENCE NUMBERS ( E X P L A N A T I O N SEE IN DER 390
C SUBR.GAUSE) DER 400
C NDIR(1),...,NDIR(N+I) - I N I T I A L C H A N G E O F X(I) IS P O S I T I V E A L O N G DER 410
C S O L U T I O N L O C U S (CURVE) IF N D I R ( I ) = I A N D N E G A T I V E IF DER 420
C NDIR(I)=-I. DER 430
C E - C R I T E R I O N F O R T E S T ON C L O S E D C U R V E , IF DER 440
C (SUM OF ( W ( 1 ) * A B S ( X ( I ) - X I N I T I A L ( I ) ) ) , I = I ..... N + I ) . L E . E ) DER 450
C T H E N C L O S E D C U R V E M A Y BE E X P E C T E D . DER 460
C MXADMS - MAXIMAL O R D E R OF A D A M S - B A S H F O R T H FORMULA, DER 470
C I.LE.MXADMS.LE.4. DER 480
C NCORR - MAXIMAL N U M B E R OF N E W T O N C O R R E C T I O N S A F T E R P R E D I C T I O N DER 490
C BY A D A M S - B A S H F O R T H METHOD. DER 500
C N C R A D - IF ( N C R A D . N E . 0 ) THEN ADDITIONAL NEWTON CORRECTION DER 510
C W I T H O U T N E W C O M P U T A T I O N OF J A C O B I A N M A T R I X IS USED. DER 520
C N O U T - A F T E R R E T U R N N U M B E R OF C A L C U L A T E D P O I N T S ON T H E C U R V E DER 530
C X(ALFA), NOUT.LE.MAXOUT. DER 540
C OUT(J,I),OUT(J,2),...,OUT(J,N+I) - J - T H P O I N T X(1), .... X ( N ) , A L F A DER 550
C ON CURVE X(ALFA) DER 560
C OUT(J,N+2) - V A L U E OF S Q R T ( S U M OF S Q U A R E S OF F). DER 570

ACM Transactions on Mathematwal So£tware, Vol 2, No. 1, March 1976


104 Algorithms

C IF ( O U T ( J , N + 2 ) . L T . 0 . 0 ) T H E N A B S ( O U T ( J , N + 2 ) ) C O R R E S P O N D S TO X DER 580
C AND ALFA NOT EXACTLY, BECAUSE ADDITIONAL NBWTON CORRECTION WAS DER 590
C U S E D ( N C R A D . N E . 0) . DER 600
C V A L U E S F(I) A R E N O T C O M P U T E D F O R X A N D A L F A P R I N T E D A N D / O R DER 610
C S T O R E D A N D T H E R E F O R E L A S T T I M E C O M P U T E D V A L U E OF S Q R T ( S U M OF DER 620
C S Q U A R E S OF F) IS ON O U R D I S P O S A L ONLY. DER 630
C M A X O U T - M A X I M A L N U M B E R OF C A L C U L A T E D P O I N T S ON C U R V E X ( A L F A ) . DER 640
C IF M A X O U T A F T E R R E T U R N E Q U A L S T O - DER 650
C -I - T H E N C L O S E D C U R V E X ( A L F A ) M A Y BE E X P E C T E D DER 660
C -2 - T H E N B O U N D X L O W O R X U P P W A S E X C E E D E D DER 670
C -3 - T H E N S I N G U L A R J A C O B I A N M A T R I X O C C U R R E D , ITS R A N K IS DER 680
C .LT. N. DER 690
C N P R N T - IF ( N P R N T . E Q . 3 ) T H E N R E S U L T I N G P O I N T S ON C U R V E X ( A L F A ) DER 700
C ARE IN A R R A y OUT( , ) A F T E R R E T U R N . IF ( N P R N T . E Q . I ) T H E N T H E S E DER 710
C P O I N T S ARE P R I N T E D O N L Y . IF ( N P R N T . E Q . 2 ) T H E N T H E S E P O I N T S A R E DER 720
C B O T H P R I N T E D A N D IN A R R A Y OUT. DER 730
C S U B R O U T I N E F C T N M U S T BE P R O G R A M M E D IN F O L L O W I N G F O R M - DER 740
C S U B R O U T I N E F C T N (N,X, F,G) DER 750
C DIMENSION X(II),F(10),G(10,11) DER 760
C F ( I ) = FI ( X ( 1 ) , X ( 2 ) , .... X ( N ) , A L F A ) F O R I=i ..... N DER 770
C G ( I , J ) = D FI (X(1) ..... X ( N ) , A L F A ) / D X(J) F O R I,J=l, .... N DER 780
C G ( I , N + I ) = D FI (X(1) ..... X ( N ) , A L F A ) / D A L F A F O R I=l, .... N DER 790
C RETURN DER 800
C END DER 810
D A T A INDIC, I N D S P / I H * , I H / DER 820
C LW IS P R I N T E R D E V I C E N U M B E R DER 030
N1 = N + 1 DER 840
LW = 3 DER 850
IF (INITAL) 10, 60, 10 DER 860
C INITIAL NEWTON ITERATIONS DER 870
10 DO 40 L = I , I T I N DER 880
C A L L F C T N ( N , X, F, G) DER 890
S Q U A R = 0.0 DER 900
DO 20 I = I , N DER 910
SQUAR = SQUAR + F(I)**2 DER 920
20 CONTINUE DER 938
LL = L- 1 DER 940
SQUAR = SQRT(SQUAR) DER 950
IF ( N P R N T . N E . 3 ) W R I T E ( L W , 9 9 9 9 9 ) LL, ( X ( I ) , I = I , N I ) , S Q U A R DER 960
C A L L G A U S E ( N , G, F, M, 10, II, PREF, BETA, K) DER 970
IF (M.EQ.0) G O TO 310 DER 980
P = 0.0 DER 990
DO 30 J = I , N I DER 1000
X(J) = X(J) -'F(J) DER 1010
P = P + ABS(F(J))*W(J) DER 1020
30 CONTINUE DER 1030
IF ( P . L E . E P S ) G O TO 50 DER 1040
48 C O N T I N U E DER 1050
W R I T E (LW,99998) ITIN DER 1060
I T I N = -i DER 1078
IF ( I N I T A L . E Q . I ) R E T U R N DER 1080
50 IF ( N P R N T . N E . 3 ) W R I T E (LW,99997) ( X ( I ) , I = I , N I ) DER 1090
IF ( I N I T A L . E Q . 2 ) R E T U R N DER 1180
C AFTER INITIAL NEWTON ITERATIONS DER 1110
60 IF ( N P R N T . N E . 3 ) W R I T E ( L W , 9 9 9 9 6 ) DER 1120
KOUT = 0 DER 1130
NOUT = 0 DER 1140
MADMS = 0 DER 1150
NC = 1 DER 1160
K1 = 0 DER 1170
70 C A L L F C T N ( N , X, F, G) DER 1180
S Q U A R = 0. @ DER 1190
DO 80 I = I , N DER 1200
SQUAR = SQUAR + F(I)**2 DER 1210
80 C O N T I N U E DER 1220
C A L L G A U S E ( N , G, F, M, 10, ii, PREF, BETA, K) DER 1230
IF (M.EQ.0) G O T O 310 DER 1240
IF (KI.EQ.K) G O T O 9@ DER 1250
C C H A N G E OF I N D E P E N D E N T V A R I A B L E (ITS I N D E X = K NOW) DER 1260
MADMS = 0 DER 1270
K1 = K DER 1280
90 S Q U A R = S Q R T ( S Q D A R ) DER 1290
IF ( N C R A D . E Q . I ) S Q U A R = - S Q U A R DER 1300
P = 0.0 DER 1310
DO 1 0 0 I = I , N I DER 1320
P = P + W(I)*ABS(F(I)) DER 1330

A C M Transact,ons on M a t h e m a t i c a l Software, Vol 2, No. 1, March 1976


Algorithms 105
108 C O N T I N U E DER 1340
IF (P.LE.EPS) G O TO 130 DER 1350
IF ( N C . G E . N C O R R ) GO TO 120 DER 1360
DO i10 I = I , N I DER 1378
X(I) = X(I) - F(I) DER 1380
i10 C O N T I N U E DER 1390
C ONE I T E R A T I O N IN N E W T O N M E T H O D DER 1400
NC = NC + 1 DER 1410
GO TO 70 DER 1420
120 IF ( N C O R R . E Q . 0 ) GO TO 130 DER 1430
W R I T E (LW,99995) N C O R R , P DER 1440
130 NC = 1 DER 1450
IF ( N C R A D . E Q . 0 ) GO TO 150 DER 1460
C ADDITIONAL NEWTON CORRECTION DER 1470
DO 140 I = I , N I DER 1480
X(I) = X(I) - F(I) DER 1498
140 C O N T I N U E DER 1500
158 N O U T = N O U T + 1 DER 1518
DO 160 I = I , N I DER 1520
MARK(I) = I N D S P DER 1530
160 C O N T I N U E DER 1548
MARK(K) = INDIC DER 1550
IF ( N P R N T . E Q . 3 ) GO TO 170 DER 1560
W R I T E (LW, 99994) DER 1570
W R I T E (LW,99993) (X(I) ,MARK(I) ,I=I,NI) , S Q U A R DER 1580
178 IF ( N P R N T . E Q . I ) GO TO 200 DER 1590
IF ( N O U T . L E . 1 0 0 ) GO TO 180 DER 1600
W R I T E (LW, 99992) DER 1610
RETURN DER 1620
188 DO 190 I = I , N I DER 1638
O U T ( N O U T , I ) = X(I) DER 1640
190 C O N T I N U E DER 1650
OUT(NOUT,N+2) = SQUAR DER 1660
GO TO 210 DER 1670
200 IF ( N O U T . E Q . I ) GO TO 180 DER 1680
210 IF ( N O U T . G E . M A X O U T ) R E T U R N DER 1690
DO 220 I = I , N I DER 1780
IF ( X ( I ) . L T . X L O W ( I ) .OR. X ( I ) . G T . X U P P ( I ) ) GO TO 300 DER 1718
220 C O N T I N U E DER 1720
IF ( N O U T . L E . 3 ) G O TO 240 DER 1730
P = 0.0 DER 1740
DO 230 I = I , N I DER 1750
P = P + W(I)*ABS(X(I)-OUT(I,I)) DER 1760
230 C O N T I N U E DER 1770
IF (P.LE.E) G O TO 290 DER 1780
C C L O S E D C U R V E M A Y BE E X P E C T E D DER 1790
240 D X K 2 = 1.0 DER 1800
DO 250 I = I , N I DER 1810
DXK2 = DXK2 + BETA(I)**2 DER 1820
250 C O N T I N U E DER 1838
D X D T (K) = 1 . 0 / S Q R T (DXK2) * F L O A T (NDIR (K)) DER 1840
C D E R I V A T I V E OF I N D E P E N D E N T V A R I A B L E X(K) W I T H R E S P E C T TO A R C L E N G T H DER 1858
C OF S O L U T I O N L O C U S IS C O M P U T E D H E R E DER 1868
H = HH DER 1870
DO 270 I = I , N I DER 1880
NDIR(I) = 1 DER 1890
IF (I.EQ.K) GO TO 260 DER 1900
DXDT(I) = B E T A ( I ) * D X D T ( K ) DER 1910
260 IF ( D X D T ( I ) . L T . 0 . 0 ) N D I R ( I ) = - i DER 1920
IF ( H * A B S ( D X D T ( I ) ) . L E . H M A X ( I ) ) GO TO 270 DER 1930
MADMS = 0 DER 1940
H = HMAX(I)/ABS(DXDT(I) ) DER 1950
270 C O N T I N U E DER 1960
IF ( N O U T . L E . K O U T + 3 ) GO TO 288 DER 1970
IF ( H * A B S ( D X D T ( K ) ) . L E . @ . 8 * A B S ( X ( K ) - O U T ( I , K ) ) ) GO TO 280 DER 1980
IF ( ( O U T ( I , K ) - X ( K ) ) * F L O A T ( N D I R ( K ) ) . L E . 0 . 0 ) GO TO 280 DER 1990
MADMS = 0 DER 2000
IF ( H * A B S ( D X D T ( K ) ) . L E . A B S ( X ( K ) - O U T ( I , K ) ) ) GO TO 280 DER 2810
H = ABS(X(K)-OUT(I,K))/ABS(DXDT(K)) DER 2820
KOUT = NOUT DER 2030
280 C A L L A D A M S ( N , DXDT, M A D M S , H, X, M X A D M S ) DER 2840
GO TO 70 DER 2850
290 W R I T E (LN,99991) DER 2060
M A X O U T = -i DER 2070
RETURN DER 2880

A C M Transactions on M a t h e m a t i c a l Software, Vol, 2, No 1, March 1976


106 Algorithms
300 M A X O U T = -2 DER 2090
RETURN DER 2100
310 W R I T E (LW,99990) (X(I),I=I,NI) DER 2110
MAXOUT = -3 DER 2120
RETURN DER 2130
99999 F O R M A T (3X, 7H DERPAR, I3, 2 5 H . I N I T I A L N E W T O N I T E R A T I O N / 2 2 X , DER 2140
* I I H X , A L F A , S Q F = , 5FI5.7/(33X, 5F15.7)) DER 2150
99998 F O R M A T (/16H D E R P A R OVERFLOW, I5, 2X, 1 8 H I N I T I A L ITERATIONS/) DER 2160
99997 F O R M A T (3X, 39H D E R P A R A F T E R I N I T I A L N E W T O N I T E R A T I O N S / 2 2 X , DER 2170
* 7BX,ALFA=, 4X, 5FI5.~/(33X, 5F15.7)) DER 2180
99996 F O R M A T (/6X, 45H D E R P A R R E S U L T S (VARIABLE C H O S E N AS INDEPENDE, DER 2190
* 18HNT IS M A R K E D BY *)/) DER 2200
99995 F O R M A T (/37H D E R P A R N U M B E R OF N E W T O N C O R R E C T I O N S = , I5, DER 2210
* 31H IS NOT S U F F I C I E N T , E R R O R OF X=, F15.7/) DER 2220
99994 F O R M A T (6X, 27H D E R P A R R E S U L T S X,ALFA,SQF=) DER 2230
99993 F O R M A T (33X, 5(F15.7, AI)) DER 2240
99992 F O R M A T (/28H D E R P A R O U T P U T A R R A Y IS FULL//) DER 2250
99991 F O R M A T (/36H D E R P A R C L O S E D CURVE MAY BE EXPECTED/) DER 2260
99990 F O R M A T (/48H D E R P A R S I N G U L A R J A C O B I A N M A T R I X FOR X AND ALFA=, DER 2270
* 5FI2.6/(48X, 5F12.6)) DER 2280
END DER 2290

S U B R O U T I N E GAUSE(N, A, B, M, NN, MM, PREF, BETA, K) GAU 10


D I M E N S I O N A ( N N , M M ) , B(MM), PREF(MM), BETA(MM), Y(II), x(ll), GAU 20
* IRR(II), IRK(II) GAU 30
C S O L U T I O N OF N L I N E A R E Q U A T I O N S FOR N+I U N K N O W N S GAU 40
C BASED ON G A U S S I A N E L I M I N A T I O N WITH PIVOTING. GAU 50
C N - N U M B E R OF E Q U A T I O N S GAU 60
C A - N X (N+I) M A T R I X OF S Y S T E M GAU 70
C B - R I G H T - H A N D SIDES GAU 80
C M - IF (M.EQ.0) A F T E R R E T U R N THEN R A N K ( A ) . L T . N GAU 90
C PREF(I) - P R E F E R E N C E N U M B E R FOR X(I) TO BE I N D E P E N D E N T V A R I A B L E , GAU 100
C 0 . 0 . L E . P R E F ( I ) . L E . I . 0 , THE L O W E R IS PREF(I) THE H I G H E R IS GAU 110
C P R E F E R E N C E OF X(I). GAU 120
C BETA(I) - C O E F F I C I E N T S IN E X P L I C I T D E P E N D E N C E S O B T A I N E D IN FORM - GAU 130
C X ( I ) = B ( I ) + B E T A ( I ) * X ( K ) , I.NE.K. GAU 140
C K - R E S U L T I N G INDEX OF I N D E P E N D E N T V A R I A B L E GAU 150
NI=N+I GAU 160
ID = 1 GAU 170
M=I GAU 180
DO 10 I=I,NI GAU 190
IRK(I) = 0 GAU 200
IRR(I) = 0 GAU 210
10 C O N T I N U E GAU 220
20 IR = 1 GAU 230
IS = 1 GAU 240
A M A X = 0.0 GAU 250
DO 60 I=I,N GAU 260
IF (IRR(I)) 60, 30, 60 GAU 270
30 DO 50 J = I , N I GAU 280
P = PREF(J)*ABS(A(I,J)) GAD 290
IF (P-AMAX) 50, 50, 40 GAU 300
4@ IR = I GAU 310
IS = J GAU 320
AMAX = P GAU 330
50 CONTINUE GAU 340
60 C O N T I N U E GAU 350
IF (AMAX.NE.0.0) GO TO 70 GAU 360
C THIS C O N D I T I O N FOR S I N G U L A R I T Y OF M A T R I X M U S T BE S P E C I F I E D GAU 370
C MORE E X A C T L Y WITH R E S P E C T TO C O M P U T E R A C T U A L L Y USED GAU 380
M=0 GAU 390
GO TO 150 GAU 400
70 IRR(IR) = IS GAU 410
DO 90 I=I,N GAU 420
IF (I.EQ.IR .OR. A ( I , I S ) . E Q . @ . 0 ) GO TO 90 GAU 430
P = A(I,IS)/A(IR,IS) GAU 440
DO 80 J = I , N I GAU 450
A(I,J) = A(I,J) - P*A(IR,J) GAU 460
80 CONTINUE GAU 470
A(I,IS) = 0.0 GAU 480
B(I) = B(I) - P*B(IR) GAU 490
90 C O N T I N U E GAU 500
ID = ID + I GAU 510

ACM Transactmns on Mathemat*cal Software, VoL 2, No 1, March 1976


Algorithms • 107

IF (ID.LE.N) GO TO 20 GAU 520


DO 100 I - I , N GAU 530
IR - IRR(I) GAU 540
X(IR) ~ B ( I ) / A ( I , I R ) GAU 550
IRK(IR) i 1 GAU 560
100 CONTINUE GAU 570
DO 110 K = I , N I GAU 580
IF ( I R K ( K ) . E Q . 0 ) GO TO 120 GAU 590
110 CONTINUE GAU 600
120 DO 130 I = I , N GAU 610
IR = IRR(I) GAU 620
Y(IR) = - A ( I , K ) / A ( I , I R ) GAU 630
138 CONTINUE GAU 640
DO 140 I = I , N I GAU 650
B(I) = X(I). GAU 660
BETA(I) = Y(I) GAU 670
140 CONTINUE GAU 680
B(K) = 8.8 GAU 690
BETA(K) = 0.0 GAU 700
158 RETURN GAU 710
END GAU 720

S U B R O U T I N E A D A M S ( N , D, M A D M S , H, X, MXADMS) ADA 10
D I M E N S I O N D E R ( 4 , 1 1 ) , X ( I I ) , D(II) ADA 20
C ADAMS-BASHFORTH METHODS ADA 30
N1 = N + 1 ADA 40
DO 20 I=1,3 ADA 50
DO 10 J = I , N I ADA 60
DER(I+I,J) = DER(I,J) ADA 70
10 CONTINUE ADA 80
20 C O N T I N U E ADA 90
MADMS = MADMS + 1 ADA 100
IF ( M A D M S . G T . M X A D M S ) M A D M S = M X A D M S ADA 110
IF ( M A D M S . G T . 4 ) M A D M S = 4 ADA 120
DO 70 I = I , N I ADA 130
D E R ( I , I ) = D(I) ADA 140
GO TO (30, 40, 50, 60), M A D M S ADA 150
30 X(I) = X(I) + H * D E R ( I , I ) ADA 160
GO TO 70 ADA 170
40 X(I) = X(I) + 0 . 5 * H * ( 3 . 0 * D E R ( I , I ) - D E R ( 2 , I ) ) ADA 180
GO TO 70 ADA 190
50 X(I) = X(I) + H * ( 2 3 . 0 * D E R ( I , I ) - I 6 . 0 * D E R ( 2 , I ) + 5 . 8 * D E R ( 3 , I ) ) / ADA 200
* 12.0 ADA 210
GO TO 70 ADA 220
60 X(I) = X(I) + H * ( 5 5 . 0 * D E R ( I , I ) - 5 9 . 0 * D E R ( 2 , I ) + 3 7 . 0 * D E R ( 3 , I ) ADA 230
* -9.0*DER(4,I))/24.0 ADA 240
70 C O N T I N U E ADA 250
RE~URN ADA 260
END ADA 270

A C M Transactions on M a t h e m a t i c a l Software, ¥ol. 2, No 1, M a r c h 1976.

Você também pode gostar