Skip to main content

Full text of "ibm :: ssp :: GH20-0205-4-SSP-programmers Aug70"

See other formats


*s 



■i>A 



= T = Application Program 



System/3B0 Scientific Subroutine Package 
Version III 
Programmer s Manual 

Program Number 3B0A-CM-03X 



The Scientific Subroutine Package (SSP) is a collection of 
over 250 FORTRAN subroutines divided, for the sake of 
presentation, into two groups: statistics and mathematics. 
Also, over 200 subroutines are presented in both single and 
double precision mode. SSP is a collection of input/output- 
free computational building blocks that can be combined with 
a user's input, output, or computational routines to meet 
his needs. The package can be applied to the solution of 
many problems in industry, science, and engineering. 

Version 3 of the Scientific Subroutine Package for 
System/360 incorporates and extends the capabilities of 
the original SSP/360. This version provides over 40 new 
mathematical and statistical subroutines 24 of which are in 
both single- and double-precision FORTRAN. Examples of 
the new capabilities are the use of the QR iteration for 
obtaining eigenvalues of a matrix, and the nonparametric 
test of KoLmogorov-Smirnov. 

This manual contains sufficient information to permit the 
reader to understand and use all of the subroutines of the 
Scientific Subroutine Package, 



GH20-0205-4 



S;.j; 



Fifth Edition (August 1970) 

TOs edition. GH2(W)205-4, is a reprint of GH20-O2O5-3 incorporating TNL GN20-1994. It does not 

obsolete GH20-O205-3 as updated by that TNL. 

This edition appUes to Version 3, Modification Level 1, of System/360 Scientific Subroutme Pactege 
(37oITm-03X) and to all subsequent versions and modfflcations until otherwise indicated m new 
editions or Technical Newsletters. 

Changes are continually made to the information herein. Therefore, before using this pubUcation, 
consult the latest System/360 SRL Newsletter (GN20-O360) for the editions that are appUj^lWe 
and current. 

Copies of this and other IBM pubUcations can be obtained through IBM branch offices. 

A form has been provided at the back of this publication for readers' comments. If this form has been 
removed, address comments to: IBM Corporation, Technical Publications Department, 112 East 
Post Road, White Plains, New York 10601. 

© Copyright International Business Machines Corporation 1966, 1967, 1968. 



CONTENTS 



Purpose and Objectives of the Package ... 1 

Areas of Application 1 

Statistics 1 

Mathematics 1 

Characteristics 1 

Overall Rules of Usage 3 

General Rules 3 

Matrix Operations 3 

Variable Dimensioning 3 

Storage Compression 4 

Matrix Element References 5 

Program Modification 7 

Advanced FORTRAN Features 7 

Optimization of Time 7 



Double Precision g 

Format of the Documentation 9 

Subroutine Descriptions 9 

Sample Program Descriptions 9 

Operating Notes 10 

Categorical Guide to Subroutines and 

Sample Programs 11 

Alphabetic Guide to Subroutines with 

Storage Requirements ........,, 19 

Subroutine Descriptions and Listings .... 27 

Statistics 27 

Mathematics 94 

Appendix A. Accuracy of Subroutines .... 386 

Appendix B. Sample Program Descriptions . 400 



This programming package has been developed with the cooperation and 
assistance of IBM Germany and IBM France. 



PURPOSE AND OBJECTIVES OF THE PACKAGE 



The Scientific Subroutine Package is a set of basic 
computational subroutines intended to aid the user in 
the development of his own FORTRAN subroutine 
library. While this package may provide many of 
the tools necessary to solve the more commonly 
encountered problems in engineering and science, 
there is no intent to imply that these subroutines 
represent the current state of the art in statistics 
or numerical analysis. As with all tools, the user 
should understand their capabilities and their appli- 
cation to his functional requirements before de- 
ciding to use them. 

AREAS OF APPLICATION 

Individual subroutines, or a combination of them, 
can be used to carry out the listed fimctions in the 
following areas: 

Statistics 



• Fourier analysis of given or tabulated 
functions 

• Bessel and modified Bessel function 
evaluation 

• Gamma function evaluation 

• Jacobian elliptic functions 

• Elliptic, exponential, sine cosine, Fresnel 
integrals 

• Finding real roots of a given function 

• Finding real and complex roots of a real 
polynomial 

• Polj^nomial arithmetic (addition, division, etc.) 

• Polynomial evaluation, integration, 
differentiation 

• Chebyshev, Hermite, Laguerre, Legendre 
polynomials 

• Minimum of a function 

• Approximation, interpolation, and table 
construction 



• Probit analysis 

• Analysis of variance (factorial design) 

• Correlation analysis 

• Multiple linear regression 

• Stepwise regression 

• Polynomial regression 

• Canonical correlation 

• Factor analysis (principal components, 
varimax) 

• Discriminant analysis (many groups) 

• Time series analysis 

• Data screening and analysis 

• Nonpar ametric tests 

• Random number generation (imiform, normal) 

• Distribution functions 

Mathematics 

• Inversion 

• Eigenvalues and eigenvectors 

• Simultaneous linear algebraic equations 

• Transpositions 

• Matrix arithmetic (addition, product, etc. ) 

• Matrix partitioning 

• Matrix tabulation and sorting of rows or 
columns 

• Elementary operations on rows or columns of 
matrices 

• Matrix factorization 

• Integration and differentiation of given or 
tabulated functions 

• Solution of systems of first-order differential 
equations 



CHARACTERISTICS 

Some of the characteristics of the Scientific Sub- 
routine Package are: 

• All subroutines are free of input/output 
statements . 

• Subroutines do not contain fixed maximum 
dimensions for the data arrays named in their 
calling sequences. 

• All subroutines are written in FORTRAN. 

• Many matrix manipulation subroutines handle 
S3mimetric and diagonal matrices (stored in 
economical, compressed formats) as well as 
general matrices. This can result in con- 
siderable saving in data storage for large 
arrays . 

• The use of the more complex subroutines (or 
groups of them) is illustrated in the program 
documentation by sample main programs with 
input /output. 

• All subroutines are documented uniformly. 
The subroutines in SSP have been programmed in 

the subset of the FORTRAN IV language, which is 
compatible with all of the FORTRAN processors 
announced for System/360. Many of the larger 

functions such as those in statistics have been pro- 
grammed as a series or sequence of subroutines. 

An example of the use of sequences of subroutines 
is the statistical function called factor analysis. 
Factor analysis is a method of analyzing the inter- 
correlations within a set of variables. It deter- 
mines whether the variance in the original set of 
variables can be accounted for adequately by a 



Purpose and Objectives of the Application 1 



smaller number of basic categories; namely, fac- 4. LOAD - to compute a factor matrix 

tors. In the Scientific Subroutine Package, factor 5. VARMX - to perform varimax rotation of the 

analysis is normally performed by calling the fol- factor matrix 

lowing five subroutines in sequence: ' The multiple use of subroutines is illustrated by 

1. CORRE - to find means, standard deviations, the fact that subroutine CORRE is also utilized in 
and correlation matrix the multiple linear regression and canonical corre- 

2. EIGEN - to compute eigenvalues and asso- lation. Subroutine EIGEN is used in canonical cor- 
ciated eigenvectors of the correlation matrix relation as a third-level subroutine. 

3. TRACE - to select the eigenvalues that are 
greater than or equal to the control value specified 
by the user 



2 Purpose and Objectives of the Application 



OVERALL RULES OF USAGE 



GENERAL RULES 

All subroutines in the Scientific Subroutine Package 
(SSP) are entered by means of the standard 
FORTRAN CALL statement. These subroutines are 
purely computational in nature and do not contain 
any references to input/output devices. The user 
must therefore furnish, as part of his program, what- 
ever input/output and other operations are necessary 
for the total solution of his problem. In addition, the 
user must define by DIMENSION statements all 
matrices to be operated on by SSP subroutines as 
well as those matrices utilized in his program. The 
subroutines contained in SSP are no different from 
any user-supplied subroutine. All of the normal 
rules of FORTRAN concerning subroutines must 
therefore be adhered to, with the exception that the 
dimensioned areas in the SSP subroutine are not 
required to be the same as those in the calling 
program. 

The CALL statement transfers control to the sub- 
routine and replaces the dummy variables in that 
subroutine with the value of the actual arguments that 
appear in the CALL statement if the argument is a 
constant or a variable. When the argument is an ar- 
ray or function subprogram name, the address of 
the array or subprogram is transmitted to the called 
subroutine. 

The arguments in a CALL statement must agree 
in order, number, and type with the corresponding 
arguments in the subroutine. A number may be 
passed to a subroutine either as a variable name in 
the argument list or as a constant in the argument 
list. For example, if the programmer wishes to add 
matrix ARl to matrix AR2 in order to form matrix 
AR3 using the SSP subroutine GMADD, and if ARl 
and AR2 are both matrices with ten rows and twenty 
columns, either of the two following methods can 
be used: 

Method 1 

CALL GMADD(AR1, AR2, AR3, 10, 20) 



Method 2 



N= 10 
M=20 
CALL GMADD(AR1,AR2,AR3,N, M) 



Many of the subroutines in SSP require the name 
of a user function subprogram or a FORTRAN- 
supplied function name as part of the argument list 



in the CALL statement. If the user's program con- 
tains such a CALL, the function name appearing in 
the argument list must also appear in an EXTERNAL 
statement at the beginning of that program. 

For example, the SSP subroutine RK2 integrates 
a function furnished by the user. The user must 
therefore program the function and give the name 
of the function to RK2 as a parameter in the CALL 
statement. If the user wishes to integrate the func- 
tion g^ = 3. X + 2. OY, his main program may 
appear as: 

EXTERNAL DERY 

CALL RK2(DERY, ) 

RETURN 

END 

His function subprogram can be: 

FUNCTION DERY (X, Y) 

DERY=3.0*X+2.0*Y 

RETURN 

END 

The user's main program gives the name of the 
programmed function to RK2 by including that name 
in the CALL statement and in an EXTERNAL state- 
ment. RK2, in turn, goes to the function DERY 
each time it requires a value for the derivative. The 
subroutine RK2 is not modified by the programmer. 
The dummy function name FUN in subroutine RK2 is, 
in effect, replaced by the name appearing in the user's 
CALL statement during execution of the subroutine. 

MATRIX OPERATIONS 

Special consideration must be given to the subroutines 
that perform matrix operations. These subroutines 
have two characteristics that affect the format of the 
data in storage — variable dimensioning and data 
storage compression. 

Variable Dimensioning 

Those subroutines that deal with matrices can oper- 
ate on any size array, limited in most cases only 
by the available core storage and numerical analysis 
considerations. The subroutines do not contain fixed 
maximum dimensions for data arrays named in their 
calling sequence. The variable dimension capability 



Overall Rules of Usage 3 



has been implemented in SSP by using a vector storage 
approach. Under this approach, each column of a 
matrix is immediately followed in storage by the next 
column. Vector storage and two-dimensional Storage 
result in the same layout of data in core, so long as 
the number of rows and columns in the matrix are 
the same as those in the user's dimension statement. 
If, however, the matrix is smaller than the dimen- 
sioned area, the two forms of storage are not 
compatible. 

Consider the layout of data storage when operat- 
ing on a 5 by 5 array of numbers in an area dimen- 
sioned as 10 by 10. If the programmer has been 
using double -sub scripted variables in the normal 
FORTRAN sense, the 25 elements of data will appear 
as shown in Figure 1. FORTRAN stores double- 
subscripted data by column based on the column 
length specified in the DIMENSION statement. Thus, 
In the example, sequential core locations will con- 
tain data elements 1 to 5, five blank locations, data 
elements 6 to 10, five blank locations, and so on. 
The matrix subroutines take a vector approach in 
storing arrays by column, which means that they 
assume the data is stored as shown in Figure 2. 



Colun 



10 



Row 



1 

2 
3 
4 
5 
6 
7 
8 
9 
10 



(1) 
(2) 
(3) 
(4) 



(6) 
(7) 
(8) 
(9) 



(11) (16) (21) 

(12) (17) (22) 

(13) (18) (23) 

(14) (19) (24) 



(5) (10) (15) (20) (25) 



Figure 1. Double-subscripted data storage 



(1) (11) 


(21) 


(2) (12) 


(22) 


(3) (13) 


(23) 


(4) (14) 


(24) 


(5) (15) 


(25) 


(6) (16) 




(7) (17) 




(8) (18) 




(9) (19) 




(10) (20) 





Figure 2. Vector storage 



As stated previously, if the dimensioned area is 
the same as the matrix size, the two approaches 
will have the same data storage layout, and the user 
can proceed in a regular double -subscripted fashion. 
If, however, he is operating in a mode where the 
dimensioned area is larger than the arrays, and if 
he wishes to use the SSP subroutines, he must be 
certain that his data is stored in the vector fashion 
illustrated by Figure 2. A subroutine called 
ARRAY is available in SSP to change from one form 
of storage to the other. In addition, a subroutine 
called LOG is available to assist in referencing ele- 
ments in an array stored in the vector fashion. 

Storage Compression 

Many subroutines in SSP can operate on compressed 
forms of matrices as well as on the normal form . 
By using this capability, which is called "storage 
mode", considerable savings in data storage can be 
obtained for special forms of large arrays. The 
three modes of storage are termed general, sym- 
metric, and diagonal. In this context, general mode 
is one in which all elements of the matrix are in 
storage. Symmetric mode is one in which only the 
upper triangular portion of the matrix is retained 
columnwise in sequential locations In storage. (The 
assumption is made that the corresponding elements 
in the lower triangle have the same value. ) Diagonal 
mode is one in which only the diagonal elements of 
the matrix are retained in sequential locations in 
storage. (The off-diagonal elements are assumed 
to be zero. ) This capability has been implemented 
using the vector storage approach. 

Figure 3 Illustrates the effect of the storage mode 
capability. A symmetric matrix is shown in Figure 
3A. If this array is to be manipulated using the SSP 
matrix subroutines with storage mode capability, 
the array may be stored as shown in Figure 3B. 
This is the upper triangular portion of the array and 
corresponds to a storage mode code of 1. Sym- 
metric matrices of order N may be stored in a vec- 
tor of only N*(N+l)/2 locations rather than N*N 
locations. For larger matrices, this will be a 
saving of almost one half. 

The effect of storage mode when dealing with 
diagonal matrices is even more pronounced. Diago- 
nal matrices of order N may be stored in a vector 

only N locations long. Figure 3C shows a 3 by 3 

diagonal matrix. If this array is to be manipulated 
using the SSP matrix subroutines with storage mode 
capability, only the diagonal elements of the array 
need be stored. This is shovm in Figure 3D and 
corresponds to a storage mode code of 2. 

General matrices of order N by M require a 
vector N*M long and use a storage mode code of 0. 



4 Overall Rules of Usage 




1 

2 
4 
3 
5 

6 
B 



> Column 1 
} Column 2 

Column 3 



1 










1 


? Column 1 





2 







2 
3 


I Column 2 
V Column 3 








3 









D 



Figures. Storage mode 



Thus, if the programmer wishes to use SSP sub- 
routines on matrix A, which is general, matrix B, 
which is symmetric, and matrix C, which is diagonal, 
and all matrices are 10 by 10 or smaller, the di- 
mension statement in his program can be: 

DIMENSION A(IOO), B(55), C(10) 
Matrix Element References 

Subroutine LOG in the Scientific Subroutine Package 
may be used to reference elements within a matrix 
stored in a vector fashion, and may involve storage 
mode compression. The calling sequence for LOG 
is: 

GALL LOG (I, J, IJ, N, M, MS) 

The capabilities of subroutine LOG are as follows. 
If reference is required to the element at row I and 
column J of matrix A whose dimensions are N by M, 
and if the storage mode code is MS, a CALL to the 
LOG subroutine as shown above will result in the 



computation of the subscript IJ such that A(IJ) is the 
desired element. The parameters represented by I, 
J, N, M, MS can be either integer variables or 
integer constants. The parameter represented bylJ 
is an integer variable. Note that the user must di- 
mension the array A as a single-subscripted variable 
to meet the restrictions of some FORTRAN systems. 
To illustrate the use of LOG, if reference is re- 
quired to the element at row 2, column 2 of the 3 by 
3 symmetric matrix illustrated in Figure 3A and 
stored as shown in Figure 3B (storage mode code 
1), the sequence may be: 

GALL LOG (2, 2, IJ, 3, 3, 1) 
The value of IJ computed by LOG will be 3, meaning 
that the proper element is the third element in the 
specially stored symmetric matrix (Figure 3B), If 
the storage mode code is for a symmetric matrix 
where only the upper triangular portion is retained 
in storage, and if I and J refer to an element in the 
lower triangular portion, IJ will contain the sub- 
script for the corresponding element in the retained 
upper triangle. Thus if the user wanted the element 
in row 3, column 1 of the matrix shown in Figure 
3A, and the array was stored as in Figure 3B, the 
statement : 

GALL LOG (3, 1, IJ, 3, 3, 1) 

would result in IJ having the value of 4; that is, the 
fourth element in Figure 3B. If a matrix is stored 
as shown in Figure 3D (storage mode 2), and LOG 
is used to compute the subscript for an off- 
diagonal element (I not equal to J), the result in IJ 
will be zero. This is due to the fact that the ele- 
ment does not exist in storage. In this situation, 
the user must not utilize IJ as a subscript. Fol- 
lowing is an illustration of how to take care of this 
condition and also handle the case where the current 
storage mode is unknown. 

If the user wishes to set a variable X equal to the 
element in the third row and fourth column of a 10 
by 10 array named A, for either a symmetric, 
diagonal, or general matrix, the required program 
can be implemented for any storage mode MS as 
follows: 

GALL LOG (3, 4, IJ, 10, 10, MS) 

X = 0.0 

IF(IJ)20, 30, 20 

20 X = A(IJ) 



30 



(MS is assumed to have been set at 0, 1, or 2 at 
some earlier point in the program. ) This sequence 
will then set the proper value for X, given any 
storage mode that may be encountered. The second 
and third statements take care of the off -diagonal 
condition for a matrix with a storage mode of 2. 



Overall Rules of Usage 5 



As a special case, LOG can be used to compute will result in IJ being set to 6. This is not only the 

the total length of an array in storage with a state- proper subscript to reference element 3, 3, but is 

ment such as: also the actual length of the vector in storage. 

CALL LOG (N, M, IJ, N, M, MS) ' '^^^ information contained in the fifth parameter 

(number of columns) in the calling sequence for 
For example, if the user has a 3 by 3 matrix whose LOG is not actually used in the calculations per- 

storage mode is 1 (Figure 3B), the statement: formed by LOG. It has been included in the calling 

sequence in case the user wishes to expand LOG to 
CALL LOG (3, 3, IJ, 3, 3, 1) cover other forms of data storage. 



6 Overall Rules of Usage 



PROGRAM MODIFICATION 



ADVANCED FORTRAN FEATURES 

The user may wish to take advantage of more ad- 
vanced FORTRAN compiler features. For example, 
the larger FORTRAN systems include a subroutine 
multiple entry point capability. Some of the sub- 
routines in SSP can be combined by using this feature. 
To illustrate this, GMADD and GMSUB (addition and 
subtraction of general matrices) can be combined as 
shown in Figure 4. This will in no way affect the 
programs using these subroutines but will reduce the 
total program storage requirements. 





SUBROUTINE GMADD (A,B,R,N,M) 




DIMENSION A(1),B(1),R(1) 




K=0 




GOTO 10 




ENTRY GMSUB (A,B,R,N,M) 




K=l 


10 


NM=N*M 




DO 40 1=1, MM 




IF(K) 20,20,30 


20 


R(1)=A(I)+B(I) 




GO TO 40 


30 


R(I)=A(I)-B(I) 


40 


CONTINUE 




RETURN 




END 



Figure 4. Multiple entry point 



OPTIMIZATION OF TIME 



The subroutines in SSP are designed to conserve 
storage for data. If the user wishes to exchange 
space for time, there are several ways in which SSP 
may be modified to effect this end. For example, 
many of the subroutines in SSP make use of the LOG 
subroutine to handle vector storage and storage mode 
referencing. The execution time of these sub- 
routines can be substantially reduced by implement- 
ing LOO in Assembler Language. (The distributed 
version of LOG is implemented in FORTRAN. ) 
Another approach is to incorporate the function of 



LOO within each subroutine and thus avoid the "set- 
up" costs of repeated calls to LOG. This has the 
effect of reducing execution time but at some cost 
in subroutine storage and in the ease with which other 
modes of storage, such as triangular matrix storage 
or storage by row rather than by column, can be 
implemented. Figure 5 shows how matrix addition 
and the LOG capabilities can be implemented within 
the same subroutine. 



CIl'E^SIO^ Adi.eill.PIll 

TEST fCR StKc SICBAGE fCCE 
IF(CSA-«S6) 3CtlC.3C 

COfPUTE VECTCP LE^GTH 

10 NC=N«H 

IF(»<SA-1) 2'>,22,}3 
22 ND=<ND«Nl/2 

GO TC 2'i 
2 3 KD=K 

ACD PATRICES CF SAfE STORAGE KCDE 

2'< CO 25 I = lfNC 

25 R<i>»A(n-teii I 

RETURN 

GET STCRAGt "CCE CF CUTPtT KATRIX 

30 KTESI^PSA^KSB 

HSR=0 

IF(KTEST1 35,35,22 
32 fSR=l 
35 CO 60 J'lif" 

CO 60 I'l.N 

LOCATE ELEKENI IS OUTPUT KATBIX 

KX--1 
fS=f SR 
GC TC 65 
40 iJR'IR 

tCCATE ELEfEM IN fATPIX A 

KX^Q 

CS-t'SA 

GC TC 65 
15 UA-IR 

AEL=O.C 

IFdJAl 44,48,46 
46 AEL=A{IJ«1 

tCCATE ELEHENT IN NATRIX 6 

4B KX=1 

CS-fSB 

GO TC 65 
5C IJE=la 

eEL=0.0 

IFdJBI 55,60,55 
55 bei=6(IJEI 

ACC f-AIAICES lF CIFFEPENT SICRAGE MCCES 

eC R(IJ«)=AEl»eEL 
BETURK 

IN lim; lcc 

65 IFICS-ll 7C,75,9C 
7C w-^•lJ-ll*I 

GC TC 95 

75 iF(I-J) CC,a5,fl5 

= II>=I*IJ»J-Jl/2 

GO TC 95 
85 IR=Jt(I«l-II/2 

GO TC 95 
■SC 1K = C 

IF(I-J) 95,92,95 
92 IR=I 
95 IFIKXI «0,45,50 

ENC 



Figure 5. Inline LOG 



Program Modification 7 



DOUBLE PRECISION 

The accuracy of the computations in many of the SSP 
subroutines is highly dependent upon the number of 
significant digits available for arithmetic operations. 
Matrix inversion, integration , and many of the statis- 
tical subroutines fall into this category. The user 
may, therefore, wish to use double-precision 
versions of these subroutines. 

Many of the subroutines in SSP have been provided 
in both single- and double -precis ion versions. In 
others, instructions for converting to double preci- 
sion are included as part of the subroutine descrip- 
tion. FORTRAN double-precision statements have 
been included in each of these subroutines in the form 
of a comments card. In most cases, the double- 
precision version of the subroutine can be obtained 
merely by removing the C from column 1 of the 
double-precision statement card(s) before compila- 
tion. In a few cases, additional instructions are 
given for changing references to FORTRAN-furnish- 
ed functions; for example, 9QRT to DSQRT and ABS 
to DABS; in other cases, new constants are given. 

The use of double-precision subroutines requires a 
detailed knowledge of the FORTRAN rules concerning 
double precision. A few of the more basic ones are 
as follows: 

1. Any real variable, vector, or array name 
contained in the argument list of a CALL to a double- 
precision subroutine must be declared as double 
precision in the calling program. For example, if 
the SSP matrix inversion subroutine MINV has been 
modified for double precision, and if the user's pro- 
gram contains the statement: 



CALL MINV (ARl, N, DET, MYl, MY2) 



where : 



ARl is the array name (real, double-precision 

array) 

N is the dimension (Integer variable) 



DET is the determinant (real, double-precision 

variable) 

MYl is a work vector (integer array) 

MY2 is a work vector (integer array) 

then the program must also have at its beginnii^ the 
specification statement: 

DOUBLE PRECISION ARl, DET 

The other variables are integer variables and should 
not be included in the specification statement. 

2. Any user-supplied function named in the CALL 
statement for a double-precision SSP subroutine must 
be programmed as a double-precision function. For 
example, the sample program for Runge-Kutta inte- 
gration performs the integration on a sample function 
called FUN using subroutine RK2. This function is 
programmed as: 

FUNCTION FUN (X, Y) 

FUN = 1. 1*X 

RETURN 

END 

If a double-precision version of RK2 is used, the 
fimction must also be double precision. The sample 
function will then be: 

DOUBLE PRECISION FUNCTION FUN (X, Y) 

DOUBLE PRECISION X, Y 

FUN = 1.1*X 

RETURN 

END 



8 Program Modification 



FORMAT OF THE DOCUMENTATION 



The major portion of this manual consists of the 
documentation for the individual subroutines and 
the sample programs. 

SUBROUTINE DESCRIPTIONS 

Subroutine and sample program guides, both categori- 
al and alphabetic, designed to aid in locating any 
particular subroutine are given in the pages that follow . 

Each of the subroutine descriptions consists of a 
program listing and, in some cases, a mathematical 
description. The first part of the program listing 
is a set of comment cards containing the subroutine 
name, its calling sequence, description of param- 
eters, remarks, names of other subroutines re- 
quired, and method. References to books and 
periodicals will be found under the method section of 
the description. The mathematical description 
pages do not, in most cases, indicate the derivation 
of the mathematics. They are intended to indicate 
what mathematical operations are actually being 
performed in the subroutines. Some of the major 
statistical functions are performed by a sequence of 
SSP subroutines. An explanation of this sequence 
wiU be found just before the description of the first 
subroutine that is specific to this function. 

SAMPLE PROGRAM DESCRIPTIONS 

The sample program listings are given in Appendix 
B. 

Each sample program consists of a detailed 
description including information on the problem, 
the program, input, output, program modification, 
operating instructions, error messages, timing and 
machine listings of the programs , input data and 
output results. The sample programs have been 



chosen to (1) illustrate a sequence of SSPeubroutines, 

(2) illustrate the use of a complex subroutine, or 

(3) show the way in which one member (such as 
matrix addition) of a large set of simple subroutines 
might be used. 

As part of the development of the sample programs , 
some special sample subroutines have been imple- 
mented that may prove useful to the programmer. 
These include: 

HIST - print a histogram of frequencies 

MATIN - read an input matrix into storage in 
vector form for use by SSP matrix 
subroutines 

PLOT - plot several variables versus a base 
variable 

MXOUT - print a matrix stored in the SSP 
vector format 

Listings of the above subroutines are included after the 
sample program documentation in this manual. The 
source decks are part of the sample program source 
decks on the distributed magnetic tape. 

The sample programs have been implemented for 
execution on a 32K byte (8K word) System/360 using 
Basic Programming Support FORTRAN (Tape). 
Instructions for modifying the sample programs for 
different data capacities are included in the docu- 
mentation. In addition, those sample programs that 
illustrate potentially double-precision subroutines 
include double-precision statements in the form of 
comment cards. These comment cards are con- 
tained in the sample program source decks. 



Format of the Documentation 



OPERATING NOTES 



ft is recommended that those SSP subroutines that 
will be frequently used in an installation be compiled 
and the relocatable decks placed on the FORTRAN 
system's residence device. In the case of Basic 
Programming Support FORTRAN (Tape), this will 
be the library portion of the system tape. Informa- 
tion on the method for updating the system to include 



user-supplied subroutines will be found in the 
appropriate FORTRAN programmer's guide. SSP 
subroutines are handled in the same manner as user- 
supplied subroutines. If the subroutines are not 
placed on the FORTRAN system's residence device, 
those required by a particular program will have to 
be included in that program each time it is run. 



10 Operating Notes 



CATEGORIAL GUIDE TO SUBROUTINES AND 
SAMPLE PROGRAMS 



(Subroutines added in Version III are marked with 
an asterisk) 

STATISTICS 

Data Screening 

TALLY — totals, means, standard 

deviations, minimums, and 
maximums 

BOUND — selection of observations within 
bounds 

SUBST — subset selection from observation 
matrix 

ABSNT — detection of missing data 

TABl- -tabulation of data (one variable) 

TAB2 — tabulation of data (two variables) 

SUBMX — building of subset matrix 

Correlation and Regression (See Smoothing, 
Factorization) 

CORRE— means, standard deviations, and 
correlations 

*MISR — means, standard deviations, third 
and fourth moments, correlations, 
sim^ple regression coefficients and 
their standard errors; considers 
that data may be missing 

ORDER — rearrangement of intercorrela- 
tions 

MULTR— multiple linear regression 

GDATA — data matrix generation for 
poljmomial regression 

*STPRG — stepwise multiple linear 
regression 

*PROBT— probit analysis 

CANOR — canonical correlation 



27 

27 

28 

28 
29 
30 
31 



32 



33 



36 

37 
39 

41 

44 
47 



Design Analysis (See Smoothing, Regression, 
Factorization) 

AVDAT — data storage allocation 49 

AVCAL — L and A operation 50 

MEANQ — mean square operation 57 

Discriminant Analysis 

DMA TX- -means and dispersion matrix 52 

DISCR- -discriminant functions 53 

Factor Analysis (See Elgenanalysis) 

TRACE — cumulative percentage of 55 

eigenvalues 

LOAD — factor loading 56 

VARMX — varimax rotation 56 

Time Series (See Smoothing) 

AUTO — autocovariances 59 

CROSS — cross covariances 60 

SMO--application of filter coefficients 61 

(weights) 

EXSMO — triple exponential smoothing 62 

Nonparametric Statistics 

*KOLMO — Kolmogorov-Sraimov one- 63 

sample test 

*KOLM2 — Kolraogorov-Smirnov two- 65 

sample test 

*SMIRN — Kolmogorov-Smlrnov limiting 66 

distribution values 

2 
CHISQ — X test for contingency tables 68 

KRANK — Kendall rank correlation 69 

*MPAIR~Wilcoxin's signed ranks test 70 



Categorial Guide to Subroutines 11 



QTEST— Cochran Q-test 

RANK — rank observations 

*SIGNT~sigii test 

SRANK — Spearman rank correlation 

TIE — calculation of ties in ranked obser- 
vations 

TWOAV — Friedman two-way analysis of 
variance statistic 

UTEST— Mann-Whitney U-test 

WTEST— Kendall coefficient of 
concordance 

Generation of Random Varlates - 
Distribution Functions 

RANDU — uniform random deviates 

GAUSS — normal deviates 

*NDTR — normal distribution function 

*BDTR — beta distribution function 

2 
*CDTR — X distribution function 

*NDTRI — inverse of normal distribution 
function 

Elementary Statistics and Miscellany 

MOMEN— first four moments 

TTEST — test on population means 

*BISER — biserial correlation coefficient 

*PHI — phi coefficient 

*POINT--point-biserial correlation 
coefficient 

*TETRA — tetrachoric correlation 
coefficient 

*SRATE— survival rates 

Matrices: Storage 

MCPY--matrix copy 



71 
71 
72 
73 

74 

74 

75 
76 



77 
77 
78 
78 
81 
83 



85 
86 
87 
88 
89 

90 

92 

94 



RCPY — copy row of matrix into vector 94 

CCPY — copy column of matrix into vector 95 

DCPY — copy diagonal of matrix into vector 95 

XCPY — copy submatrix from given matrix 96 

MSTR — storage conversion 96 

LOG— location in compressed-stored 97 
matrix 

CONVT — single-precision/double-precision 97 
conversion 

ARRAY — vector storage/double-dimensioned 98 
storage conversion 

Matrices: Operations 

GMADD — add two general matrices 98 

GMSUB — subtract two general matrices 99 

GMPRD — product of two general matrices 99 

GMTRA — transpose of a general matrix 100 

GTPRD — transpose product of two general 100 
matrices 

MADD — add two matrices 101 

MSUB — subtract two matrices 101 

MPRD — matrix product (row into column) 102 

MTRA — transpose a matrix 102 

TPRD — transpose product 103 

MATA — transpose product of matrix by 103 
itself 

SADD — add scalar to matrix 104 

SSUB — subtract scalar from a matrix 104 

SMPY — matrix multiplied by a scalar 105 

SDIV — matrix divided by a scalar 105 

SOLA — matrix clear and add scalar 106 

DCLA — replace diagonal with scalar 106 



12 Categorial Guide to Subroutines 



RADD — add row of one matrix to row of 
another matrix 



107 



• CADD — add column of one matrix to column 107 
of another matrix 

SRMA — scalar multiply row and add to 108 
another row 

SCMA — scalar multiply column and add to 108 
another column 

RINT — interchange two rows 109 

CINT — interchange two columns 109 

RSUM — sum the rows of a matrix no 

CSUM — sum the columns of a matrix no 

RTAB — tabulate the rows of a matrix m 

CTAB — tabulate the columns of a matrix 112 

RSRT — sort matrix rows 112 

CSRT — sort matrix columns 113 

RCUT — partition by row 113 

CCUT — partition by column 114 

RTIE — adjoin two matrices by row 114 

CTIE — adjoin two matrices by column 115 

*MPRC, DMPRC— permute rows or I15 
columns 

MFUN — matrix transformation by a 117 
function 

RECP — reciprocal function for MFUN 117 

Matrices: Inversion, Systems of Linear 
Equations and Related Topics 

MINV — matrix inversion 118 

*SINV, DSINV — invert a symmetric 119 
positive definite matrix 

SIMQ — solution of simultaneous linear, 120 
algebraic equations 

GELG, DGELG— system of general simul- 121 
taneous linear equations 
by Gauss elimination 



*RSLMC--solution of simultaneous linear 124 
equations with iterative refine- 
ment 

*FACTR — triangular factorization of a 126 

nonsingular matrix 

MFGR, DMFGR— matrix factorization and 127 
rank determination 

GELS, DGELS— system of general simul- 133 
taneous linear equations 
with symmetric coeffi- 
cients 

GELB, DGELB — system of general simul- 137 
taneous linear equations 
with band-structured 
coefficients 

*MTDS, DMTDS—divide a matrix by a 142 

triangular matrix 

*MLSS, DMLSS — solution of simultaneous 145 
linear equations with 
symmetric positive 
semidefinite matrix 

*MCHB, DMCHB— triangular factorization 148 
of a S5rmmetric positive 
definite band matrix 



*MFSS, DMFSS— triangular factorization 152 
and rank determination of 
a symmetric positive 
semidefinite matrix 

*MFSD, DMFSD— triangular factorization 158 
of a symmetric positive 
definite matrix 

LLSQ, DLLSQ— solution of linear least- 160 

squares problems 

Matrices: Eigenanalysis and Related Topics 

EIGEN — eigenvalues and eigenvectors of a 164 
real, symmetric matrix 

NROOT— eigenvalues and eigenvectors of a igg 
special nonsymmetric matrix 

*ATEIG — eigenvalues of a real almost 

triangular matrix 167 

*HSBG— reduction of a real matrix to 169 

almost triangular form 



Categorial Guide to Subroutines 13 



Pol3Tiomials: Operations 

PADD--add two polynomials 



171 



PSUB — subtract one polynomial from '■'^ 

another 



PMPY — multiply two polynomials 



172 



PDIV — divide one pol3Tiomial by another ^'^^ 

PCLA — replace one polynomial by another ^'^^ 

PADDM — multiply polynomial by constant ^"^3 
and add to another pol3momial 



PVAL — value of a polynomial 



PDER — derivative of a polymonial 
PINT — integral of a polynomial 



174 



PVSUB — substitute variable of polynomial 174 
by another pol3Tiomial 

PILD — evaluate pol3Tiomial and its first 175 

derivative 



175 
176 



PQSD — quadratic synthetic division of a ^"^^ 

pol5Tiomial 

PCLD — complete linear synthetic division 177 

PGCD — greatest common divisor of two 177 

polsmomials 

PNORM— normalize coefficient vector of 178 

polynomial 

PECN, DPECN— economization of a poly- 178 
nomial for symmetric 
range 

PECS, DPECS— economization of a poly- 180 
nomial for unsymmetric 
range 

Polynomials: Roots 

POLRT--real and complex roots of a real 181 
polynomial 

PRQD, DPRQD— roots of a real polynomial 183 
by QD algorithm with dis- 
placement 



*PRBM, DPRBM--roots of a real poly- 189 

nomial by Bairstow's 
algorithm 

*PQFB, DPQFB— determine a quadratic 193 

factor of a real poly- 
nomial 

Polynomials: Special T3rpes 

CNP, DCNP— value of N* Chebyshev 198 

polynomial 

CNPS, DCNPS — value of series expansion 199 
in Chebyshev polynomials 

TCNP, DTCNP — transform series expansion 200 
in Chebyshev polynomials 
to a polynomial 

CSP, DCSP—value of N*^*^ shifted Chebyshev 201 
polynomial 

CSPS, DCSPS — value of series expansion in 202 
shifted Chebyshev poly- 
nomials 

TCSP, DTCSP — transform series expansion 203 
in shifted Chebyshev poly- 
nomials to a polynomial 

HEP, DHEP — value of Hermite polynomial 205 

HEPS, DHEPS — value of series expansion in 206 
Hermite polynomials 

THEP, DTHEP — transform series expan- 207 
sion in Hermite polynomials 
to a polynomial 

LAP, DLAP — value of Laguerre polynomial 208 

LAPS, DLAPS — value of series expansion 209 
in Laguerre polynomials 

TLAP, DTLAP — transform series expan- 210 
sion in Laguerre poly- 
nomials to a polynomial 

LEP, DLEP — value of Legendre polynomial 212 

LEPS, DLEPS — value of series expansion 213 
in Legendre polynomials 



14 Categorial Guide to Subroutines 



TLEP, DTLEP — transform a series expan- 214 
sion in Legendre poly- 
nomials to a polynomieil 

Roots of Nonlinear Equations 

RTWI, DRTWI— refine estimate of root by 215 
Wegstein's iteration 

RTMI, DRTMI— determine root within a 217 

range by Mueller's iteration 

RTNI, DRTNI— refine estimate of root by 220 
Newton's iteration 

Extremum of Functions 

FMFP, DFMFP — unconstrained minimum 221 
of a function of several 
variables — Davidon 
method 

FMCG, DFMCG — unconstrained minimum 225 
of a function of several 
variables — conjugate 
gradiant method 

Permutations 

*PPRCN — composition of permutations 231 

*PERM — operations with permutations 232 

and transpositions 

Sequences: Sums and Limits 



ATSE, DATSE— table selection out of an 251 

equidistant table 



*SG13, DSG13— local least-squares 

smoothing of tabulated 
functions 



253 



*SE13, DSE13 
*SE15, DSE15 
*SE35, DSE35~local least-squares 255 

smoothing of equidistantly 

tabulated functions 

*APFS, DAPFS— solve normal equations 260 

for least-squares fit 

*APCH, DAPCH— least-squares polynomial 263 
approximation 

*ARAT, DARAT 

*FRAT. DFRAT— rational least-squares 265 

approximation 

*APLL, DAPLL — linear least-squares 271 

approximation 

FORIF — Fourier analysis of a given function 274 

FORIT — Fourier analysis of a tabulated 275 

function 

HARM, DHARM — complex three-dimensional 276 
Fourier analysis 

RHARM, DRHARM— real one-dimensional 281 
Fourier analysis 



TEAS, DTEAS—limit of a given sequence 234 

TEUL, DTEUL— sum of a given function 238 

sequence 

Interpolation, Approximation, and 
Smoothing 

ALT, DALI — Aitken-Lagrange interpolation 241 

AHI, DAHI — Aitken-Hermite interpolation 243 

ACFI, DACFI—continued fraction inter- 245 
polation 

ATSG, DATSG— table selection out of a 248 

general table 

ATSM, DATSM— table selection out of a 250 

monotonic table 



*APMM, DA PMM— linear Chebyshev 283 

approximation over a 
discrete range 

Numerical Quadrature 

QTFG, DQTFG — integration of monotonically 289 
tabulated function by 
trapezoidal rule 

QTFE, DQTFE- -integration of equidistantly 290 
tabulated function by 
trapezoidal rule 

QSF, DQSF- -integration of equidistantly 291 

tabulated function by Simpson's 
rule 

QHFG, DQHFG — integration of monotonically 293 
tabulated function with first 
derivative by Hermitian 
formula of first order 



Categorial Guide to Subroutines 15 



294 



295 



QHFE, DQHFE — integration of equidistantly 
tabulated function with first 
derivative by Hermitian 
formula of first order " 

QHSG, DQHSG—integration of monotonically 
tabulated function with first 
and second derivatives by 
Hermitian formula of first 
order 

QHSE, DQHSE—integration of equidistantly 
tabulated function with first 
and second derivatives by 
Hermitian formula of 
second order 



QATR, DQATR — integration of a given 297 

function by trapezoidal rule 
together with Romberg's 
extrapolation method 



296 



QG2-QG10, DQG4-DQG32- 



QL2-QL10, DQL4-DQL32- 



QH2-QH10, DQH8-DQH64- 



-integration of a 299 
given function by 
Gaussian quad- 
rature formulas 

-integration of a 303 
given function by 
Gaussian- 
Laguerre quad- 
rature formulas 

-integration of a 308 
given function by 
Gaussian- 
Hermite quad- 
rature formulas 



*DCAR, DD CAR- -derivative of a function 
at the center of an inter- 
val 

*DBAR, DDBAR— derivative of a function 
at the border of an 
interval 

Ordinary Differential Equations 

RKl — solution of first-order differential 
equation by Runge-Kutta method 

RK2 — tabulated solution of first-order 

differential equation by Runge-Kutta 
method 

RKGS, DRKGS— solution of system of first- 
order ordinary differential 
equations with given initial 
values by the Runge-Kutta 
method 

HPCG, DHPCG — solution of general system 
of first -order ordinary 
differential equations with 
given initial values by 
Hamming's modified 
predictor-corrector 
method 



HPCL, DHPCL- 



324 



327 



331 



332 



333 



337 



314 



QA2-QA10, DQA4-DQA32~integratlon of a 

given function by 
associated 
Gaussian- 
Laguerre quad- 
rature formulas 



Numerical Differentiation 

*DGT3, DDGT3— differentiation of a tabu- 319 
lated function by parabolic 
interpolation 

*DET3, DDET3 

*DET5, DDET5~differentiation of an 320 

equidistantly tabulated 

function 



-solution of linear system 
of first-order ordinary 
differential equations with 
given initial values by 
Hamming's modified 
predictor-corrector 
method 

LBVP, DLBVP — solution of system of 

linear first-order ordinary 
differential equations with 
linear boundary conditions 
by method of adjoint 
equations 

Special Functions 

GMMMA — gamma function 
*DLGAM — log of gamma function 

BESJ--J Bessel Imction 

BESY— Y Bessel function 
10 — I Bessel function, I 

INUE— I Bessel function 
n 

BESK— K Bessel function 



343 



350 



361 
362 

ddd 
364 
365 

366 

366 



16 Categorical Guide to Subroutines 



EXPI — exponential integral 
SICI — sine cosine integral 
CS — Fresnel integrals 



368 
370 
372 



CELl. DCELl—eomplete elliptic integral of 374 
the first kind 

CEL2, DCEL2— complete ellipticlntegral of 376 
the second kind 

ELIl, DELIl — generalized elliptic integral 378 
of the first kind 

ELI2, DELI2 — generalized elliptic integral 380 
of the second kind 

JELF, DJELF — Jacobian elliptic functions 382 



GUIDE TO SAMPLE PROGRAMS 

Data Screening 

DASCR--Sample Main Program 400 

Illustrates use of: 

SUBST- -subset selection from observa- 
tion matrix 

TAB 1— tabulation of data (one variable) 

LOG — location in compressed-stored 
matrix 

Special sample subroutines are: 

BOOL — Boolean expression 

HIST — histogram printing 

MATIN — matrix input 

Multiple Linear Regression 

REGRE— Sample Main Program 404 

Illustrates use of: 

CORRE — means, standard deviations, 
and correlations 

ORDER — rearrangement of intercorrela- 
tions 



MESTV — matrix inversion 

MULTR — multiple regression 
Special sample subroutine is: 

DATA— sample data read 
Polimomial Regression 

POLRG— Sample Main Program 408 

Illustrates use of: 

GDATA — data generation 

ORDER — rearrangement of intercorrela- 
tions 

MINV — matrix inversion 

MULTR — multiple regression 
Special sample subroutine is: 

PLOT— output plot 
♦Stepwise Multiple Regression 

*STEPR— Sample Main Program 413 

Illustrates use of: 

CORRE — means, standard deviations, and 
correlations 

MSTR — storage conversion 

*STPRG — stepwise multiple regression 

LOG — location in compressed-stored 
matrix 

Special sample subroutines used are: 

*STOUT — sample stepwise regression 
output subroutine 

DATA — sample data read subroutine 

Canonical Correlation 

MCANO— Sample Main Program 418 

Illustrates use of: 

CORRE— means, standard deviations, and 
correlations 



Categorial Guide to Subroutines 17 



CANOR — canonical correlation 

_ MINV — matrix inversion 

NROOT — eigenvalues and eigenvectors of a 
special, nonsymmetric matrix 

EIGEN — eigenvalues and eigenvectors of a 
symmetric matrix 

Special sample subroutine is: 

DATA — sample data read 
Analysis of Variance 
ANOVA — Sample Main Program 
Illustrates use of: 

AVDAT — data storage allocation 

AVCAL — L and A operations 

MEANQ — mean square operation 
Discriminant Analysis 
MDISC — Sample Main Program 
Illustrates use of: 

DMATX — means and dispersion matrix 

MINV — matrix inversion 

DISCR — discriminant functions 

Factor Analysis 

FACTO — Sample Main Program 

Illustrates use of: 

CORRE — means, standard deviations, and 
correlations 

EIGEN — eigenvalues and eigenvectors of a 
real, symmetric matrix 

TRACE — cumulative percentage of 
eigenvalues 

LOAD — factor loading 

VARMX — varimax rotation 



422 



425 



429 



Special sample subroutine is: 

DATA — sample data read 
*Kolmogorov-Smimov Test: 

*KOLM — Sample Main Program 433 

Illustrates use of: 

*KOLMO — one-sample test 

*K0LM2 — two-sample test 

*SMIRN — Kolmogorov-Smimov limiting dis- 
tribution function 

*NDTR — normal distribution function 
Triple Exponential Smoothing 

EXPON— Sample Main Program 439 

Illustrates use of: 

EXSMO — triple exponential smoothing 
Matrix Addition 

ADSAM — Sample Main Program 441 

Illustrates use of: 

MADD — matrix add 

LOG — location in compressed-stored 
matrix 

Special sample subroutines are: 

MATIN — matrix input 

MXOUT— matrix output 
Numerical Quadrature Integration 
QDINT— Sample Main Program 443 

Illustrates use of: 

QSF — numerical quadrature integration 
(Simpson's rule) 

Runge-Kutta Integration 

RKINT—Sample Main Program 445 



18 Categorial Guide to Subroutines 



Illustrates use of: 

RK2 — Runge-Kutta integration 
Special sample function is: 

FUN — definition of differential equation 

Polynomial Roots 

SMPRT— Sample Main Program 447 

Illustrates use of: 

POLRT — real and complex roots of 
polynomial 

Solution of Simultaneous Equations 

SOLN — Sample Main Program 449 

Illustrates use of: 

SIMQ — solution of simultaneous equations 

LOG — location in compressed-stored 
matrix 

Special sample subroutines are: 
MATIN — matrix input 
MXOUT— matrix output 

Special Sample Subroutines 

BOOL— Boolean expression 452 

DATA— sample data read 452 

FUN— definition of differential equation 452 

HIST— histogram printing 452 

PLOT— output plot 452 

MATIN— matrix input 453 

MXOUT— matrix output 454 

*STOUT — stepwise regression output 454 

ALPHABETIC GUIDE TO SUBROUTINES WITH 
STORAGE REQUIREMENTS 

The following table lists the number of characters 
of storage required by each of the subroutines in 



the Scientific Subroutine Package. The figures 
given were obtained by using Basic Programming 
Support FORTRAN (Tape), Version 3, Level 0. 
The use of other FORTRAN compilers on System/ 
360 may cause deviations from these figures. 

The double-precision version of the subroutines 
in the Scientific Subroutine Package are listed 
immediately following their alphabetized single- 
precision coimterparts. Main line routines are 
asterisked. 



Name (Label) 

ABSNT (ABSN) 

ACFI (ACFI) 

DACFI (DACE) 

*ADSAM (ADSA) 

AHI (AHI) 

DAHI (DAHI) 

ALI (ALI) 

DA LI (DA LI) 

* A NOVA (ANOV) 

APCH (APCH) 

DAPCH (DAPC) 

APFS (APFS) 

DAPFS (DAPF) 

APLL (APLL) 

DAPLL (DA PL) 

APMM (APMM) 

DAPMM (DAPM) 

ARAT (ARAT) 

DARAT (DARA) 

ARRAY (ARRA) 

ATEIG (ATEI) 



Storage 




Required 




(Bytes) 


Page 


428 


28 


1214 


245 


1286 


245 


13244 


443 


1084 


243 


1116 


243 


760 


241 


784 


241 


14624 


425 


1492 


263 


1548 


263 


1602 


260 


1626 


260 


836 


271 


860 


271 


4694 


283 


4728 


283 


3004 


265 


3090 


265 


670 


98 



4538 



167 



Alphabetic Guide to Subroutines 19 



Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


ATSE 


(ATSE) 


1022 


251 


CINT 


(CINT) 


364 


109 


DATSE 


(DTSE) 


1050 


251 


CNP 


(CNP ) 


340 


198 


ATSG 


(ATSG) 


852 


248 


DCNP 


(DNP ) 


364 


198 


DATSG 


(DTSG) 


892 


248 


CNPS 


(CNPS) 


442 


199 


ATSM 


(ATSM) 


1124 


250 


DCNPS 


(DNPS) 


482 


199 


DATSM 


(DTSM) 


1148 


250 


CONVT 


(CONV) 


538 


97 


AUTO 


(AUTO) 


624 


59 


CORRE 


(CORR) 


2950 


32 


AVCAL 


(AVCA) 


802 


50 


CROSS 


(CROS) 


750 


60 


AVDAT 


(AVDA) 


926 


49 


CS 


(CS ) 


906 


372 


BDTR 


(BDTR) 


3354 


78 


CSP 


(CSP ) 


352 


201 










DCSP 


(DSP ) 


376 


201 


BESJ 


(BESJ) 


1466 


363 


CSPS 


(CSPS) 


458 


202 


BESK 


(BESIt) 


2022 


366 


DCSPS 


(DSPS) 


506 


202 


BESY 


(BESY) 


1968 


364 


CSRT 


(CSRT) 


978 


113 


BISER 


(BISE) 


1182 


87 


CSUM 


(CSUM) 


502 


110 


BOOL 


(BOOL) 


164 


452 


CTAB 


(CTAB) 


826 


112 


BOUND 


(BO UN) 


784 


27 


CTIE 


(CTIE) 


746 


115 


CADD 


(CADD) 


550 


107 


*DASCR 


(DASC) 


6848 


403 


CANOR 


(CANO) 


2836 


47 


DATA 


(DATA) 


308 


452 


COPY 


(CCPY) 


500 


95 


DEAR 


(DEAR) 


1252 


327 


CCUT 


(CCUT) 


716 


114 


DDBAR 


(DDBA) 


1354 


327 


CDTR 


(CDTR) 


3390 


81 


DCAR 


(DCAR) 


1308 


324 


CELl 


(CELl) 


544 


374 


DDCAR 


(DDCA) 


1392 


324 


DCELl 


(DCEl) 


584 


374 


DCLA 


(DCLA) 


392 


106 


CEL2 


(CEL2) 


718 


376 


DCPY 


(DCPY) 


394 


95 


DCEL2 


(DCE2) 


774 


376 


DET3 


(DET3) 


554 


320 


CHISQ 


(CHIS) 


1220 


68 


DDET3 


(DDT3) 


594 


320 



20 Alphabetic Guide to Subroutines 



Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


DET5 


CDET5) 


752 


322 


GDATA 


(GDAT) 


1764 


39 


DDET5 


(DDT5) 


832 


322 


GELB 


(GELB) 


2640 


137 


DGT3 


(DGT3) 


738 


319 


DGELB 


(DELE) 


2674 


137 


DDGT3 


(DDGT) 


770 


319 


GELG 


(GELG) 


1882 


121 


DISCR 


(DISC) 


2532 


53 


DGELG 


(DELG) 


1920 


121 


DLGAM 


(DLGA) 


826 


362 


GELS 


(GELS) 


1990 


133 


DMATX 


(DMAT) 


1170 


52 


DGELS 


(DELS) 


2028 


133 


EIGEN 


(EIGE) 


2556 


164 


GMADD 


(GMAD) 


288 


98 


ELIl 


(ELIl) 


836 


378 


GMMMA 


(GMMM) 


826 


361 


DELIl 


(DELI) 


900 


378 


GMPRD 


(GMPR) 


570 


99 


ELI2 


(ELK) 


1254 


380 


GMSUB 


(GMSU) 


288 


99 


DELI2 


(DEL2) 


1356 


380 


GMTRA 


(GMTR) 


358 


100 


EXPI 


(EXPI) 


1032 


368 


GTPRD 


(GTPR) 


566 


100 


*EXPON 


(EXPO) 


8952 


440 


HARM 


(HARM) 


5988 


276 


EXSMO 


(EXSM) 


620 


62 


DHARM 


(DHAR) 


6070 


276 


* FACTO 


(FCTO) 


11212 


432 


HEP 


(HEP ) 


398 


205 


FACTR 


(FCTR) 


1586 


126 


DHEP 


(DHP ) 


422 


205 


FMCG 


(FMCG) 


2820 


225 


HEPS 


(HEPS) 


454 


206 


DFMCG 


(DFMC) 


2956 


225 


DHEPS 


(DHPS) 


486 


206 


FMFP 


(FMFP) 


3580 


221 


HIST 


(HIST) 


1778 


452 


DFMFP 


(DFMF) 


3702 


221 


HPCG 


(HPCG) 


5560 


337 


FORIF 


(FRIF) 


990 


274 


DHPCG 
HPCL 


(DHCG) 
(HPCL) 


5744 
5606 


337 
343 


FORIT 


(FRIT) 


946 


275 


DHPCL 


(DHCL) 


5798 


343 


FRAT 


(FRAT) 


912 


269 


HSBG 


(HSBG) 


1440 


169 


DFRAT 


(DFRA) 


944 


271 


10 


(10) 


546 


365 


FUN 


(FUN ) 


186 


452 


INUE 
JELF 


(INUE) 
(JELF) 


768 
1254 


366 
382 


GAUSS 


(GAUS) 


430 


77 


DJELF 


(DJEL) 


1416 


382 



Alphabetic Guide to Subroutines 21 



Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


*KOLM 


(KOLM) 


7952 


438 


MFGR 


(MFGR) 


2092 


127 


KOLMO 


(KLMO) 


1704 


63 


DMFGR 


(DMGR) 


2120 


127 


KOLM2 


(KLM2) 


1514 


65 


MFSD 


(MFSD) 


904 


158 


KRANK 


(KRAN) 


1598 


69 


DMFSD 


(DMSD) 


906 


158 


LAP 


(LAP ) 


408 


208 


MFSS 


(MFSS) 


2688 


152 


DLAP 


(DAP ) 


432 


208 


DMFSS 


(DMSS) 


2664 


152 


LAPS 


(LAPS) 


472 


209 


MFUN 


(MFUN) 


446 


117 


DLAPS 


(DAPS) 


512 


209 


MINV 


(MINV) 


1874 


118 


LBVP 


(LBVP) 


8000 


350 


MISR 


(mSR) 


2856 


33 


DLBVP 


(DLBV) 


8256 


350 


MLSS 


(MLSS) 


2020 


145 


LEP 


(LEP ) 


400 


212 


DMLSS 


(DMLS) 


2004 


145 


DLEP 


(DEP ) 


424 


212 


MOMEN 


(HOME) 


1288 


85 


LEPS 


(LEPS) 


464 


213 


MPAIR 


(MPAI) 


1380 


70 


DLEPS 


(DEPS) 


496 


213 


MPRC 


(MPRC) 


810 


115 


LLSQ 


(LLSQ) 


2938 


160 


DMPRC 


(DMPR) 


822 


115 


DLLSQ 


(DLLS) 


2986 


160 


MPRD 


(MPRD) 


944 


102 


LOAD 


(LOAD) 


490 


56 


MSTR 


(MSTR) 


590 


96 


LOG 


(LOG ) 


492 


97 


MSUB 


(MSUB) 


942 


101 


MADD 


(MADD) 


942 


101 


MTDS 


(MTDS) 


1436 


142 


MATA 


(MATA) 


790 


103 


DMTDS 


(DMTD) 


1428 


142 


MATIN 


(MATI) 


1180 


453 


MTRA 


(MTRA) 


552 


102 


*MCANO 


(MCAN) 


8196 


421 


MULTR 


(MULT) 


1356 


37 


MCHB 


(MCHB) 


2286 


148 


MXOUT 


(MXOU) 


1440 


454 


DMCHB 


(DMCH) 


2270 


148 


NDTR 


(NDTR) 


488 


78 


MCPY 


(MCPY) 


410 


94 


NDTRI 


(NTRl) 


758 


83 


*MDISC 


(MDIS) 


15368 


428 


NROOT 


(NROO) 


1940 


166 


MEANQ 


(MEAN) 


1708 


51 


ORDER 


(ORDE) 


682 


36 



22 Alphabetic Guide to Subroutines 



Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


PADD 


(PADD) 


474 


171 


PROBT 


(PROB) 


2466 


44 


PADDM 


(PDDM) 


510 


173 


PRQD 


(PRQD) 


4572 


183 


PCLA 


(PCLA) 


282 


173 


DPRQD 


(DPRQ) 


4636 


183 


PCLD 


(PCLD) 


314 


177 


PSUB 


(PSUB) 


476 


171 


PDER 


(PDER) 


350 


175 


PVAL 


(PVAL) 


302 


174 


PDIV 


(PDIV) 


794 


172 


PVSUB 


(PVSU) 


714 


174 


PECN 


(PECN) 


848 


178 


QATR 


(QATR) 


1128 


297 


DPECN 


(DPCN) 


862 


178 


DQATR 


(DQAT) 


1190 


297 


PECS 


(PECS) 


746 


180 


QA2 


(QA2 ) 


330 


314 


DPECS 


(DPCS) 


766 


180 


QA3 


(QA3 ) 


376 


314 


PERM 


(PERM) 


1024 


232 


QA4 


(QA4 ) 


422 


314 


PGCD 


(PGCD) 


566 


177 


DQA4 


(DQA4) 


462 


315 


PHI 


(PHI ) 


1390 


88 


QA5 


(QA5 ) 


468 


315 


PILD 


(PILD) 


402 


175 


QA6 


(QA6 ) 


514 


315 


PINT 


(PINT) 


344 


176 


QA7 


(QA7 ) 


560 


315 


PLOT 


(PLOT) 


2500 


452 


QA8 


(QA8 ) 


606 


316 


PMPY 


(PMPY) 


506 


172 


DQA8 


(DQA8) 


678 


316 


PNORM 


(PNOR) 


258 


178 


QA9 


(QA9 ) 


652 


316 


POINT 


(POIN) 


1144 


89 


QAIO 


(QAIO) 


698 


316 


*POLRG 


(PLRG) 


9282 


411 


DQA12 


(DAI 2) 


894 


317 


POLRT 


(PLRT) 


2086 


181 


DQA16 


(DA 16) 


1110 


317 


PPRCN 


(PPRC) 


704 


231 


DQA24 


(DA 24) 


1542 


318 


PQFB 


(PQFB) 


2252 


193 


DQA32 


(DA32) 


1974 


318 


DPQFB 


(DPQF) 


2384 


193 


+QDINT 


(QDIN) 


2916 


445 


PQSD 


(PQSD) 


382 


176 


QG2 


(QG2 ) 


442 


299 


PRBM 


(PRBM) 


2400 


189 


QG3 


(QG3 ) 


468 


299 


DPRBM 


(DPRB) 


2476 


189 


QG4 


(QG4 ) 


538 


300 



Alphabetic Guide to Subroutines 23 



Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


DQG4 


(DQG4) 


598 


300 


DQHS 


(DQHS) 


622 


310 


QG5 


(QG5 ) 


576 


300 


QH9 


(QH9 ) 


616 


310 


QG6 


(QG6 ) 


638 


300 


QHIO 


(QHIO) 


652 


310 


QG7 


(QG7 ) 


676 


301 


DQH16 


(DH16) 


982 


311 


QG8 


(QG8 ) 


738 


301 


DQH24 


(DH24) 


1342 


311 


DQG8 


(DQG8) 


814 


301 


DQHS 2 


(DH32) 


1702 


312 


QG9 


(QG9 ) 


776 


301 


DQH48 


(DH48) 


2422 


312 


QGIO 


(QGIO) 


838 


302 


DQH64 


(DH64) 


3142 


313 


DQG12 


(DG12) 


1030 


302 


QL2 


(QL2 ) 


330 


303 


DQG16 


(DG16) 


1246 


302 


QL3 


(QL3 ) 


376 


304 


DQG24 


(DG24) 


1678 


302 


QL4 


(QI^ ) 


422 


304 


DQG32 


(DG32) 


2110 


303 


DQL4 


(DQL4) 


462 


304 


QHFE 


(QHFE) 


434 


294 


QL5 


(QL5 ) 


468 


304 


DQHFE 


(DQHE) 


482 


294 


QL6 


(QL6 ) 


514 


305 


QHFG 


(QHFG) 


414 


293 


QL7 


(QL7 ) 


560 


305 


DQHFG 


(DQHG) 


454 


293 


QL8 


(QL8 ) 


606 


305 


QHSE 


(QHSE) 


478 


296 


DQL8 


(DQL8) 


678 


305 


DQHSE 


(DQHS) 


542 


296 


QL9 


(QL9 ) 


652 


306 


QHSG 


(QHSG) 


462 


295 


QLIO 


(QLIO) 


698 


306 


DQHSG 


(DHSG) 


514 


295 


DQL12 


(DL12) 


894 


306 


QH2 


(QH2 ) 


324 


308 


DQL16 


(DL16) 


1110 


306 


QH3 


(QH3 ) 


370 


308 


DQL24 


(DL24) 


1542 


307 


QH4 


(QH4 ) 


406 


309 


DQL32 


(DL32) 


1974 


307 


QH5 


(QH5 ) 


452 


309 


QSF 


(QSF ) 


1286 


291 


QH6 


(QH6 ) 


488 


309 


DQSF 


(DQSF) 


1358 


291 


QH7 


(QH7 ) 


534 


309 


QTEST 


(QTES) 


710 


71 


QH8 


(QH8 ) 


570 


310 


QTFE 


(QTFE) 


382 


290 



24 Alphabetic Guide to Subroutines 







Storage 








Storage 








Required 








Required 




Name 


(Label) 


(Bytes) 


Page 


Name 


(Label) 


(Bytes) 


Page 


DQTFE 


(DTFE) 


422 


290 


RTWI 


(RTWI) 


770 


215 


QTFG 


(QTFG) 


370 


289 


DRTWI 


(DRTW) 


804 


215 


DQTFG 


(DTFG) 


402 


289 


SADD 


(SADD) 


434 


104 


RADD 


(RADD) 


538 


107 


SOLA 


(SCLA) 


420 


106 


RANDU 


(RAND) 


310 


77 


SCMA 


(SCMA) 


430 


108 


RANK 


(RANK) 


672 


71 


SDIV 


(SDIV) 


470 


105 


RCPY 


(RCPY) 


500 


94 


SE13 


(SE13) 


460 


255 


RCUT 


(RCUT) 


716 


113 


DSE13 


(DE13) 


500 


255 


RECP 


(RECP) 


224 


117 


SE15 


(SE15) 


588 


256 


*REGRE 


(REGR) 


13736 


407 


DSE15 


(DE15) 


620 


256 


RHARM 


(RHAR) 


1660 


281 


SE35 


(SE35) 


564 


258 


DRHARM 


(DRAR) 


1762 


281 


DSE35 


(DSE3) 


604 


258 


RINT 


(RINT) 


376 


109 


SG13 


(SG13) 


648 


253 


RKGS 


(RKGS) 


2878 


333 


DSG13 


(DSGl) 


696 


253 


DRKGS 


(DRKG) 


3018 


333 


SI CI 


(SICI) 


1192 


370 


*RKINT 


(RKIN) 


2704 


446 


SIGNT 


(SIGN) 


1170 


72 


RKl 


(RKl ) 


1420 


331 


SIMQ 


(SIMQ) 


1286 


120 


RK2 


(RK2 ) 


770 


332 


SINV 


(SINV) 


1092 


119 


RSLMC 


(RSLM) 


1830 


124 


DSINV 


(DSM) 


1080 


119 


RSRT 


(RSRT) 


1034 


112 


SMIRN 


(SMIR) 


700 


66 


RSUM 


(RSUM) 


502 


110 


SMO 


(SMO ) 


542 


61 


RTAB 


(RTAB) 


826 


111 


*SMPRT 


(SMPR) 


1792 


449 


RTIE 


(RTIE) 


778 


114 


SMPY 


(SMPY) 


434 


105 


RTMl 


(RTMI) 


1510 


217 


*SOLN 


(SOLN) 


11754 


451 


DRTMI 


(DRTM) 


1582 


217 


SRANK 


(SRAN) 


1260 


73 


RTNI 


(RTNI) 


724 


220 


SRATE 


(SRAT) 


1534 


92 


DRTNI 


(DRTN) 


770 


220 


SRMA 


(SRMA) 


442 


108 



Alphabetic Guide to Subroutines 25 



Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


Name 


(Label) 


Storage 

Required 

(Bytes) 


Page 


SSUB 


(SSUB) 


434 


104 


DTEUL 


(DTEU) 


924 


238 


*STEPR 


(STEP) 


11584 


417 


THEP 


(THEP) 


712 


207 


STOUT 


(STOU) 


1684 


454 


DTHEP 


(DTHE) 


768 


207 


STPRG 


(STPR) 


3200 


41 


TIE 


(TIE ) 


640 


74 


SUBMX 


(SUBM) 


512 


31 


TLAP 


(TLAP) 


776 


210 


SUBST 


(SUBS) 


888 


28 


DTLAP 


(DTLA) 


820 


210 


TABl 


(TABl) 


1636 


29 


TLEP 


(TLEP) 


716 


214 


TAB2 


(TAB2) 


2806 


30 


DTLEP 


(DTLE) 


772 


214 


TALLY 


(TALL) 


1206 


27 


TPRD 


(TPRD) 


904 


103 


TCNP 


(TCNP) 


678 


200 


TRACE 


(TRAC) 


560 


55 


DTCNP 


(DTCN) 


726 


200 


TTEST 


(TTES) 


1794 


86 


TCSP 


(TCSP) 


706 


203 


TWOAV 


(TWOA) 


1108 


74 


DTCSP 


(DTCS) 


754 


203 


UTEST 


(UTES) 


1064 


75 


TEAS 


(TEAS) 


2024 


234 


VARMX 


(VARM) 


2914 


56 


DTEAS 


(DTEA) 


2096 


234 


WTEST 


(WTES) 


1488 


76 


TETRA 


(TETR) 


2038 


90 


XCPY 


(XCPY) 


670 


96 


TEUL 


(TEUL) 


844 


238 











26 Alphabetic Guide to Subroutines 



SUBROUTINE DESCRIPTIONS AND LISTINGS 



Listed below are the subroutines. A brief descrip- 
tion precedes those subroutines that require further 
clarification. 

STATISTICS 

Data Screening 

Subroutine TALLY 



Subroutine BOUND 



SUBDCUTIhE TALLT 

fURFGSE 

CAICUIATC TOT*!., «*N, ST*NO*PO DEVIATinN, 
FOd EACH VARUBLE IN A SET (OA A SUBSETI ni 



DBSERVAriONS 



OeSCBIPTION aF para-^eters 

« - OBSERVATION MATRIX. NO BV NV 

S - INPUT VECTOR INCICATING S08S€? Of A. ONLY THOSE 

C«$E«¥AIIO*iS WITH A NON-ZERO S<JI ARE CONSIOeRCO. 

VECTOR LENGTH IS NO. 
TCTAL - OUTPUT VECTOR OF TOTALS OF EACH VARIABLE. VfCTOR 

LENGTH IS NV. 
AVER - OUTPUT VECTOR OF AVERAGES OF EACH VARIABLE. VECTOR 

LCHGTH IS NV. 
SO - OUTPUT VECTOR Of STANDARD DEVIATIONS CF EACH 

VARIABLE. VECTOR LENGTH IS NV. 
VMIN - OUTPUT VECTOR OF NININ* Of EACH VARIABLE. VECTOR 

LENGTH IS NV. 
VfiAX - OUTPUT VECTOR OF NAXINA OF EACH VARIABLE. VECTOR 

LCNCTf IS NV. 
NO - NUMBER OF OBSERVATIONS 

*iV - NUNBER OF VARIABLES FOR EACH OBSERVATION 
lER - ZERO. IF NO ERHOR. 

- I, IP S IS NULL. VNIN--I.E75. VNAX-SD-AVER- I .F7i. 

- 2. IF S HAS ONLY ONE NON-ZERO ELEMENT. VNIM«VNAX. 

so*o.a 

RENARKS 
hCKE 

SUBRCUTINES AND FUNCTION SUePROGRANS REOUlREO 
hCkE 

PEThCC 

ALL OBSERVATIONS CORRESPONDING TO A NnN-IERO CLEHENT IN S 
VECTOR ARE ANALYZED FOR EACH VARIABLE IN NATRIK A. 
TOTALS *M ACCUKULATEO *».0 fININUfl AHO HAXINUH VALUES ARE 
FGUhO. FCLL0MIK6 THIS. PEANS AND STANDARD DEVIATIONS ARE 
CALCULATED. THE DIVISOR FOR STANDARD DEVIATION IS ONE LESS 
T^AN THE NUNeER OF oeSERVATIONS USED. 



SUeRCUTIKE TALIYIA.S,TCTAL.AVEB.SO,VNIN,VN*X,NO.NVI 
CIMNSION A(l».SUI.TOTAL(ll,«VERai,S0<II.VNIN(ll.VPAX(ll 

CLEAR OUTPUT VECTORS AND IMTIALIZE VNIN.VMAX 

iEF*0 

CO 1 K*l.NV 

TOTALfKI-C.O 

AVERIKI-I.OETS 

SCIK)«I.CE75 

Vfi|N(KI>-I.OE79 

1 VPAX(KI*t.0ET9 

TESI SUBSET VECTOR 

SCNT-D.C 
CC 7 J-l.NG 
IJ>J-NC 
IFISIJII ZwtfZ 

2 SCNT-SCNT*L.O 

CALCULATE TOTAL. MINIMA, MAXIMA 

CO 4 l*ltNV 
IJ-tJ*»iC 

TOTALdl-TGTALdi^AdJI 
IFlAIIJI-VMINmi 3.4.* 

3 vHINdl-AtlJI 

A IFIAIIJl-VHAXI 111 6.6.5 

5 VHAXdl-AdJI 

6 SD(1I"SC1IMAI 1J1*A( IJI 
T CONTINUE 

CALCULATE MEANS AND STANDABO OEVIA' JNS 

IF (sc»>Tie.a.9 
a lER-i 
6C re IS 

9 CO 10 1-1. NV 

10 AVERdl-rOTALdl/SCNT 
IF ISCKT-l.OI ii,u*ia 

11 IER-2 

00 12 1-1. NV 

12 SOdl-C.O 
GC TO 15 

13 DC lA 1-1. NV 

lA S0dl-SaRT(A6S((SO( ll-TOTALU MTOTALI I l/SCNTI/(SCNT-I .01 1 1 
IS RETURN 
END 



TALI 10 

.TALL 20 

TALL ^0 

TALL AO 

T*Ll 50 

TALL 't'l 

TALL 70 

TALL ^O 

TALL ID 

TALL ion 

TALL 110 

TALI 120 

TALL ITi 

TALI 14f> 

TALL 150 

TALL 16*1 

TALL 170 

TALI IRO 

TALL l<»0 

TALL 70O 

TALL 210 

TALI 270 

TALL 2in 

TALI 240 

TftLt 2^0 

TALI 7^9 

TALL 270 

"TAlt 7«0 

TALL a-lO 

TALI ?9I 

TALI 2«f7 

TALL ?*»! 

TALI 2*»4 

TALL ^00 

TALI 310 

TALL 3?0 

TAlt 1?0 

TALL UQ 

TALI 150 

TAIL 160 

TAIL "^TO 

TALL i«0 

TALL 390 

TALL AOO 

TAL^. -411 

TALL A20 

TAlt 430 

TALL 440 

.TAtt 450 

TALL 460 

TALL 4T0 

TALL 4B0 

TALL 490 

TALL SOO 

TALL 510 

TALL 511 

TAIL 520 

TALL 530 

TALL 540 

TALL ^50 

TALL 560 

TALI 570 

TAIL 5B0 

TALL 590 

TALL 6D0 

TALL 610 

TALI 620 

TALL 630 

TALL 640 

TAtt 650 

TALL 660 

TALL 670 

TALL 600 

TALL 690 

TALL 700 

TALL 710 

TALL 720 

TALL 710 

TALL 7*0 

TALL T50 

TALL 760 

TALL 770 

TALL 7B0 

TALL 790 

TALI 600 

TALL 801 

TALL 802 

TALL 803 

TALL 810 

TALL 820 

TALL 821 

TALL 822 

TALL 823 

TALL 824 

TALL 825 

TALL 826 

TALL 830 

TALL 840 

TALL 950 



k SuaSETl OF OflSERVATICNS THE NUMBER 
flETNEEM AND OVER TMG GIVEN SOUNOS 



SUBROUTINE BOUND 

PUR PCS E 

SELECT FROM A SET (OR 
OF CBSERVATIONS UNDER. 
FOR EACH VARIABLE 

USAGE 

CALL aOUNO UtStBLOtBHI.UNOER.BETMfOVERtHC.NV.lERt 

DESCRIPTION OF PARAMETERS 

A - OBSERVATION MATRIXt NO BY NV 

S - VECTOR INDICATING SUBSET Of A. ONLY THOSE 

CflSERVATIQNS WITH A NOM-ZERO S(JI ARE CnNSlOEREO. 

VECTOR LENGTH IS NO. 

- INPUT VECTOR OF LOUER BCUNOS ON ALL VARIABLES. 
VECTOR LENGTH IS NV. 

- INPUT VECTOR OF UPPER BOUNDS ON ALL VARIABLES. 
VECTOR LENGTH IS NV. 

UACER - OUTPUT VECTOR INDICATING, fCR EACH VAR|ABLE« hUMBER 

OF OBSERVATIONS UNDER LCIiE« BOUNDS. VECTOR LENGTH 

IS NV. 
ecu - CITPUT VECTOR lACICATIHC, «R EACH ViflABLE. NUMBER 

OF OBSERVATIONS ECUAL TO 0» BETWEEN LOMER ANO UPPER 

EOUNCS. VECTOR LENGTH IS NV. 

- CUTPUT VECTOR lAOlCATING, FCR EACH VARIABLE, NUMBER 
Of OBSERVATIONS OVER UPPER BOUNDS. VECTOR LENGTH 

IS hv. 

- AUHtlER Of CeSERVATlCHS 

- NUMBER OF VARIABLES FOR EACH OBSERVATION 

- 2ER0. IF NC ERHCR. 

- I. IF LOmER B0U»>C is GREATfR THAN TmC UPPER BOUND 
FOR SCPE VARUBLi 



50 



80 



6LQ 



Oh I 



CVEP 



IE* 



RfPAPRS 

».ChE 

SUBRCtTlNES ^NC FUNCTION SUflPROGRAMS REQUIRED 
hCh.t 

EACI- RCh ICBSEPVATIONI CF PATRIX A WITH CORRESPCNDING 
ACH-2ERC ELtPEAT IN S VECTCR IS TESTED. OflitRVATIONS ARE 
CCPPAREC VITh SPECIFtEO LOhER ANO UPPER VARMBLE BOUMOS AND 
« CCUfcT IS KEPI IN VECTCRS UNOCR. tETbEEN. ANC OVER. 



SUSRCUlIIkE ECtAC(A.S«eLC«BHl.UACER.BETU.CVER,MC.NVI 
ClPEI^SICf *a>.SUI.HCIl»«BM(ll,UNO£R»II.BETh(ll,CVERIII 

CLEAF CUTPtI VECTCRS. 

lER-C 

CC IC l>l*AV 

IF (eLCdl-fl»iI(Ill IC.lO.tl 

11 lER-1 

CC TC I! 
IC CCIttlKLE 

CC 1 R-l.NV 

IKCERIKMC.C 

BETIilKl-C.O 

1 CVERIKI-C.O 

lESI SUBSET VECTOR 

CC e j-i*Ac 

IJ-J-AC 
IFISIJJI 2.6*2 

CCPPARE CeSERVAIICNS kilTH BCUNOS 

2 CC T I-l.AV 
IJ-IJ*fC 
IftAdJl-CLCdll 5.3.3 

3 IFIAdJl-EHIdl) 4.4,« 

CCUA1 

4 (EIb.lll-EEThdl*1.0 
CC TC 1 

« U^CERI n>LNCERIll«l.C 

GC TC 1 
« CVERdl-CVERd)*l*C 
1 CCMIhLE 
I CCATIALE 

12 REIURA 
EAC 



AO<JN 
ROUN 
BOUN 
BOUN 

aouN 

BOUN 
BOUN 
90UN 
BOUN 
BOUN 100 
BOUN 110 
BOUN 120 
SOUN 150 
ROUN 140 
BOUN 150 
AOUN 160 
BOUN 170 
BQUN 180 
BOUN 190 
BOUN ZOO 
SOUN 210 
RQUN 220 
BOUN 2 30 
BOUN 240 
80UN 250 
BOUN 260 
BOUN 270 
SCUM 280 
BOUN 290 
BDUN 300 
BOUN 310 
BOUN 320 
BOUN 330 
BCUN 3)1 
BQUN 332 
BOUN 333 
BCUN 340 
BOUN 350 
BCUN 360 
BCUN 370 
BOUN 380 
BCUN 390 
BCUK 400 
BCUN 410 
BCUN 420 
eCUN 430 
eOUN 440 
BCUN 450 
BOUN 460 
.BCUN 4T0 
SOUN ABO 
BOUN 490 
BOUN 500 
BOUN 510 
eCUN 520 
BCUN 530 
BOUN 531 
BCUN 532 
BOUN 533 
BCUN 534 
BOUN 535 
BCUN 536 
BCUN 540 
BCUN 550 
BOUN 560 
BCUN 5 70 
BCUN 580 
BOUN 590 
BOUN 600 
8CUN 610 
BOUN 620 
BCUN 630 
BOUN 640 
BCUN 650 
BCUN 660 
BOUN 670 
BCUN 680 
BOUN 690 
BOUN TOO 
BCUN 710 
8GUN 720 
BOUN 730 
BCUN 740 
eOUN 750 
BCUN 760 
BCUN 770 
BCUN TBO 
BOON 790 
BOUN 800 
BOUN 810 
BOUN 820 



Statistics—Data Screening 27 



Subroutine SUBST 



Subroutine ABSNT 



SLCDCLlIOiE SliBSr 

CCniVE * SUBSET VECTOR IhOICATING hHICH CBSEii VATIOKS l*i A 
5€T h«VE S«tlSFI€0 CEftT«l^ CQNOITICNS ON THE VAftlABieS. 

USACE 

CALL SieSr (A.C«R«a<SfhC«AH(NCl 

f»»MfettR £ MLS1 6E OEflfiEC BV AN EXTEflNAL STATEMENT Ih THE 

CALLlhC mCGRAI' 

CESCRIPTICN CF PAHAMEIEHS 

A - CeSERVATICk MATRIII. tiC BV NV 

C - IM>IT HATflX. 3 BT fCi CF CQNOITICNS TG BE CONSIDERED. 
Tl-E flRST ELEMENT Cf EACH COLUMN OF C REPHESENTS THE 
hLfSEIi CF THE VARIABLE (COLUMN OF IHE HATRU Al TO BE 
TESTCCt ThE SECCNC CLENENT Of EACH CCLU»•^ IS A 
RELATIONAL CODE AS FOLLOWS 

1. FCS LT (LESS THANI 

2. FCR LC KESS THAN OR CCUAL TO) 

3. FOR EC (EQUAL (O > 

A. FCR KE (NQI ECUAL TCI 
5. FCR 6£ (GREATER THAN OR ECUAL TO) 
«. FCR CT (GREATER THANI 
IFE TKIRC ELEKEfiT CF EACH CO(.Ur(N IS A giANTITV TO BE 
USEE FCR CCNPARISCN hlTH THE OBSERVATIOh VALUES. FOR 
EXAMPLE. TfE FOLLCtiING CCLURN IN C 
2. 
S. 
12. i 
CAUSES TfE SECOND VARIABLE TO BE TESTED FOR GREATER 
IHAK CR ECUAL TO 42.9 
R - hCRKlhG VECTCR USEC TC STORE 1*.TERNE0IA1E RESULTS CF 
leCVE TESTS ON A SINGLE OeSCRVATION. IF CCNOITIQN IS 
SATISFIES. RllJ IS £ET TO 1. IF IT IS NCT, AIM IS SET 
10 C. VECICR LENGTF- IS NC. 
E - hAfE CF SLBRGUIINE TC BE SUPPLIED BV THE USER. IT 
CCNSISTS CF A BOOLEAN EXPRESSION LINKING THE 
IATER*iECIATE VALUES SIOREO IN VECTOR R. THE BOOLEAN 
CPERATCRS ARE ••• FCH'AND", ■•■ FCR 'CR*. EAANPLE 
SLBRCUTINE BCCLIR.TI 
CIHE^SICN R(3> 
T-K(II*(R(2}*R(3)) 
RETLRh 
ENC 
THE AeCVE EXPHESSICh IS TESTED FOR 
«(1) .AN0.(R(2 I .CR.RISI) 
S - CUIPUf VECTOR INDICATING. FCR EACH CBSERhATIOtt. 

NHETHER CR NCT PROPCSITION B IS SATISFIED. IF IT IS* 
Sill IS NCN-ZERO. IF IT IS NCT* Sill IS ZERO. VECTOR 
LENGTH IS NC. 
AC - HLPBER CF CBSERVAT ICkS. NO MUST BE > OR • TO 1. 
AV - NUHCER OF VARIABLE!. NV NUSI BE > OR - TC L. 
AC - AUPEER Of BASIC CCACITIONS TC BE SATISFIED. NC MUST BE 
GREATER TKAN OR EQUAL TO I. 

REPARKS 
ACAE 

SLBRCUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

e THE AAME Of ACTUAL SLCRCUTINE SUPPLIEC BV THE USER MAY 
BE DIFFERENT (E.G.. BCOLI. But SUBROUTINE SU8ST ALWAYS 
CALLS IT AS e. IN CRCER FOR SUBROUTINE SUBST TO 00 THIS, 
THE *>*P€ Cf THE USER-SUPPLIED SUBROUTIhE PUST -SE 
CEFINEC BV AN EXTERNAL STATEMENT IN THE CALLING PROGRAM. 
THE NAPE MUST ALSO BE LISTED lA THE "CALL SUBST*' 
STATEMENT. (SEE LSACE ABOVE! 

PETFCC 

IfE FCLLOhING IS 00N£ FCR EACH CBSERVATICN, 

CCACITICN MATRIX IS ANALYZED TO DETERMINE tiHICH VARIABLES 

ARE TC BE EXAMINED. INTERPECIATE VECTOR R IS FCRMEO. THE 

eCCLEAN EXPRESSION I IN SLBROUTINE fli IS THEN EVALUATED TO 

CERIVE THE ELEMENT IN SLBSEI VECTOR S CORRESPGNOING TO THE 

CeSERVATICN. 



ELCRCLTlfE SUBST ( A .C .R.I.S.NC .NV.NCI 
CIPEASICA A(l).CUI.R(tl.S(ll 

CC S 1«I.AC 

IC-I-hC 

tt'-2 

CC 8 J>1.AC 

CLEAR P VCCTCR 
l"(J»-C.C 

LCCAIE ELEPEAT lA CBSEAVATICA MATRIX AND RELATJCNAL CODE 



iO 



70 



A"A*2 










IZ>C(K) 










lA'IC^I. 


• AC 








IGC-C<K* 


11 








FCRF 


D « 


ECTCR 




C-AIIAI- 


CIK4 


21 






CC TCII. 


2.3 


A, 


i»€i 


ICO 


IF(C) ). 


£.« 








IFICI I. 


I.tl 








IF(C) (• 


1t« 








irui ). 


E*T 








IFICI E. 


1.7 








iftct e. 


ttr 








fiiji-i.C 










CCMIKLE 










CALCLLATC 


S 


VECTCP 


CALL eiR 


.511 


)) 






fCTLRA 










EAC 











SUBS 

.sues 
sues 

SUBS 
SUBS 
SUSS 
SUBS 

sues 

sues 

SUBS LOO 

SUBS 110 

SUBS L20 

SUBS ISO 

SUBS 140 

sues ISO 

SUBS 160 

sues 170 

SUBS IBO 

SUBS 190 

SUBS 200 

SUBS 210 

sues 220 

sues 290 

sues 2A0 

SUBS 2)0 

sues 260 

sues 270 
SUBS 2B0 
SUBS 290 
SUBS 300 
SUBS 310 
SUBS 320 
sues 330 
SUBS 340 
SUBS 350 
SUBS 360 
SUBS 370 
sues 3B0 
SUBS 390 
SUBS 400 
SUSS 410 
sues 420 
SUBS 430 
SUBS 440 
SUBS 4S0 
SUBS 460 
SUBS ^70 
SUBS 460 
sues 490 
SUSS SOO 
SUBS 510 
SUBS 320 

sues S30 
sues S40 

SUBS 950 
sues 560 
SUBS 570 
suss 971 

sues 900 

SUBS 590 
suss 600 

sues 610 

suss 620 
suss 630 
SUBS 640 
>SUBS 650 
suss 660 
SUBS 670 
SUBS 680 
SUBS 690 

sues TOO 

SUBS 710 
sues 720 
SUBS 730 
sues 740 
sues 750 
sues 760 
sues 770 
sues 780 
sues 790 
SUBS BOO 

sues BIO 

sues B20 

sues S30 

SUBS B40 
SUBS S50 
SUBS S60 
SUBS S70 

sues seo 

SUBS S90 

sues 900 
sues 910 

sues 920 
SUBS 930 
sues 940 
SUBS 950 
SUBS 960 
SUBS 970 
SUBS 9eo 
SUBS 990 

sueSLOoa 

SUBSIOIO 
SUBSL020 
SU8S103Q 
SUS51040 

suesioso 
suesi040 

SUeSlQ70 

suesioso 

$UBSt090 
SUASltdD 
SUBSIIIO 

suesii20 
suesti3o 
suesii40 
sues 1150 

SUBS1160 
SUBSL170 



SLenCLIlAE AGSAT 

FLRFCSE 

lEST MISSING CR ZERC VALLES FOR EACH CBSEfiVATICN IN 
M'IRII A. 

USACE 

C«LL ACSAI lA.S.NC.NVI 

CESCfilPUCA CF PARiPEIERS 

A -■ CeSERVATICK MATRIX, ftC BT NV 

S - ClTPLT vector of LEKGTH #«0 INCICATINC It'E fOLLOUING 

CCCES FCR eACf- CfiSERVATICN. 

I Tl-ERE IS NCT A PISSING CR ZERC VALUE. 

C Al LEAST CKE VALLE IS MISSING OH ZERO. 
AC ' AUPEER CF CBSERVAT ICAS. NO MLST BE > OR > TO I. 
AW - KLPEER OF VARIABLES FCR EACH CeSCRVATIOh. HV MUST BE 

CREITER It-AN OK EOL'L TC 1. 



MCI^CC 

i ItSI IS MACE FCR EACH RCM ( CBSERVATICNI OF THE MATRIX A. 
IF Tt-ERE IS NCT A MISSIAG OR ZERO VALU£« 1 IS PLACED IN 
<(Jl. IF AT LEAST CNE VALUE IS MISSING OR ZERC. O IS PLACED 
lA S(Jl. 



BO 



<UeRCLTlAE AIShKA.S 
CIMEASICA A(l I. SOI 

CC 2C J>I.AC 

IJ-J-AC 

S(JI«1.C 

CC IC I-l.NV 

IJ<IJ«AC 

IFtAllJll IC.S.IC 

: su)-c 

CC TC 2C 
IC CCMIACE 
2C CCMIKLE 

HETLAh 

EAC 



ABSN 
.A8SA 
ABSN 
ABSN 
ABSN 
ABSN 
ABSN 
ABSN 
ABSN 90 
ABSN 100 
ABSN 110 
ABSN 120 

ABSN no 

ABSN 140 
ABSN ISO 
ABSN 160 
ABSN 170 
ABSN ISO 
ABSN 190 
ABSN 200 
A8SN ZQI 
ABSN 210 
ABSN 220 
ABSh 230 
ABSN 240 
ABSN 250 
AeSN 260 
ABSN 270 
AesN zeo 

ASSN 290 
ABSN 300 
ABSN 310 
ABSN 320 

ABSN 330 
.ASSN 340 
ABSN 3Sa 
ABSN 360 
ABSN 370 
ABSN 3B0 
ABSN 390 
ABSN 400 
ABSN 4L0 
ABSN 420 
ASSN «30 
ABSN 440 
ABSN 450 
ABSN 460 
ABSN 470 
ABSK 4B0 
ABSN 490 
ABSN 500 



28 Statistics — Data Screening 



Subroutine TABl 

This subroutine tabulates, for a selected variable in 
an observation matrix, the frequencies and percent 
frequencies over class intervals. Interval size is 
computed as follows: 



UBO - UBO^ 
UBO - 2 



(1) 



where UBO = given lower bound 

UBO = given number of intervals 
UBO = given upper bound 

If UBO^ = UBO3, the subroutine finds and uses the 
minimum and maximum values of the variable. 

A table lookup is used to obtain the frequency of 
the ith class interval for the variable, where 1=1, 
2, . . . , UBO„. Then each frequency is divided by 
the number of observations, n, to obtain the percent 
frequency: 



P. = 
1 



lOOFj 
n 



(2) 



In addition, the following statistics are calculated 
for the variable: 
n 



Total: T= 2 X.. 
i=l " 

where j = selected variable 

— T 

Mean: X = — 
n 



Standard deviation: 



(3) 



(4) 



s = 




n 

2 X.. 
i=l "^ 



(5) 



n 



;(.ef>CLTIhE TABl 

'^'"e'nie fCK est Y«l«tie n »« c«S£«v«llc«. mi«i« iok » 

MlilX SueSeil. IH£ f«£ai«CY »IIO ftOCINT fREOOEKCY OVER 

cilei cuss ii.iei>»»LS. ii. «ooiiic«. cicuKu fo« the s««f 



CESCDIPIlCh CF PARAfETEVS 

« - CeSERVITlG*! H«TRI)i. NO BT NV 

S - INfUI »ECIO» CIVI»6 SO»S£I OF «. ONLY thOSE 

ceSEavlTICNS kllH I COHnESFCNOINC NCN-IE«a SIJl ««E 
C0^S10t>EC. VECICK LENCIH IS NO. 
fCvaH - 1EE V««UBLE TC EE TAeULAIED. NOVM l-UST BE GREATER 
IH4k CR EOURE IC 1 RNO LESS THIN OR ECURL TO NV. 
«N0 U'PER LIHII OF VRRIRBIE TC BE TREULRTEO 
IN USCfll. U80(2I RNO UBOOI RESRECTIVELV. IF 
LCRER LINIT IS tCL«L TC OPRER UNIT. THE PROCRRH 
OSES T^E NINmUN RNC NOIROR VALUES OF THE VARIRBLE. 
NUHflER OF INTERVALS. UBCIZl. NUST INCLOOE TMO CELLS 
FOR VALLES UNCER ANO ABOVE UNITS. VECTOR LENCTH 
IS 3. 



- COIPCI VECTOR Cf fRECOENCIES. VECICR lENGTN IS 
bEC(2l. 

- QUIFUI VECTOR CF RELATIVE FREautNCIES. VECTOR 
LENCTF IS LBQCI. 

- CUTPU1 VECTOR CF SURNARV STATISTICS. I.E., TOTAL 
AVERACE, SIANOARC DEVIATION. PININUR ANO NAXINUH 
VECICR LENCTI- IS 5. IF S IS NULL THEN ICTn,*»E(l«GET«Bl 
ARC STANOARO OEVIAHON ■ C, NIN-LEIS ANO NAX v'-ETSTABl 

- N0N6CR OF CBSERVATICNS. NC RUST BE > CR • TO X 

- NLNEER CF VABIAELES FOR EACH CeJEBVAIICN. NV RUST 
EE GREATER THAN CR EQUAL TO 1. 



TABl 
TABl 
TABl 
TABl 
TABl 
TABl 



TABl 
TRBl 
TABl 
TAB! 
TABl 
TABl 
TABl 
TABl 
TABl 
TABl 

tEIECC ^*" 

\tl INTCBVAL SKE IS CAICCIATED FRCP THE GIVEN INFCRNATICN TABl 

C» CPTICNALLt FRCB ThE PIMPUN ANC PAXWLH VALUES FOR TABl 

VARIAEIE NCVAR. T^E FRECIENCIES ANO PERCENI FREOUENCIES ARE TABl 

TUN CALCUlATtC ALONG hllh SUPPARV STATISTICS. TABl 

Iff CIVISCR FLR SIAKCARC GEVIAtlCN IS CNE LESS THAN TFE TABl 

RLPEER CF CBStPVAIlCNS LSCC. '*»[ 



REPARRS 
NCRE 

SL6RCLTUES ANO FLkCTION SIBPRCGRRNS RECOUEO 
NfRE 



TABl 


10 




TABl 


JO 




TABl 


30 




TABl 


«0 




TABl 


50 




TABl 


60 


VC 


TABl 


TO 




TABl 


BO 


•n 


TABl 


ta 


ICC 


TABl 


100 


10! 


TABl 


no 




TABl 


120 




USI 


130 




TABl 


IRO 




TABl 


150 




TABl 


lAO 




TABl 


170 




TABl 


lao 




TABl 


no 




TABl 


200 




TABl 


?10 




TABl 


220 




TABl 


290 




TABl 


240 




TABl 


250 




TABl 


260 




TABl 


2T0 




TABl 


2B0 




TABl 


2«0 





cifEfcsiCK Aui.sm.ttfCtii.fKEcm.Pcmi.siAisui 

C'LCLl'It »'l^ *»<[ f*' 
hflfk-UCET:) 

ij*f>c*(Kcvitt-n 

cc 3C J-liKC 

IJ-IJ*l 

IflSlJH KtlC.lC 
IC lf(*llJI-VMM i;,2C,2C 

i; vfih>>llJi 

2C Cft«(lJl-%^*»» JC.3C.25 
3C CCkllkLE 

lF(CEC(ll-UeCI3ll *C,3«.*C 

35 iec(ii»vnh 

CtC*F CtlPLI #«€*! 

cc S% l*UUh 

F^ECd l-C.C 
4* CC11II-C.C 

CC 5C 1-1.3 
5C 5I«IS(1I-C.C 

C'LCLl'ie IKTEPVil SUE 

£iM-*«sin<t!Ci3i-ueciin/iij8Cii»-i.on 

IISI *LeStI VtCICB 

SCM-C.C 
IJ-I>C*<I'CVJR-I) 
cc 7S J'l.KC 

IJ-IJ'l 

55 SCM"JCM*i.C 

CCVCtCF ICT«L AKC FftECUE^CHS 
il^lSlll-STJISdl*'! IJI 

CC CO 1-1. IMX 

lF(*IIJl-tefP> IC.tC.ftO 
AC CCfclUCE 

IFUClJt-ierf I 15.45.«5 
61 F»iClll>fcl-FlteCliK*>l*l<0 

CC IC I! 
7C F»CCIIl*f«tCtll*l.C 
75 CCf^llfiLE 

If l!C*iin«.lC5*l« 

C#lCLt>TE |i£l.*1IV( FBECUCfcCltS 

7S CC CC i>i.if>f> 

iC FCKJI-FRECdl^lCO.C/SCM 

C#LCLl<H »'C»K 'fcC 51ANC*RC CCVIAHC^ 

IF(£C*>I-1.<]I e!.«5.SC 

<1i1S(3l-C.C 

CC U S\ 

STJlsl3l-SC«IUeS(l$I*lSlJI-SI*lSlU«SIiTS(lI/SCMI/lSCHT- 

CC ICC 1-1.3 

LCClll-kCCUl 

DCKHA 

CftC 



300 
310 
320 
33G 
340 

3 SO 
360 
36 L 
370 
380 
3«1 
3^0 
%00 
410 
420 

4 30 
440 
450 
460 
470 
400 
490 
500 
Slfl 
520 
530 
540 



T4HI 550 

TA&I 5f>0 

Tifll 570 

T*ei 5"fO 

1*61 b<iO 

T*8l 600 

i>ei 610 

Titfil 623 
T»ftl 630 
1*ei 640 
TAdl 6«0 
TABl 660 
T«6l 670 
TlBl 680 
TABl 690 
TkBl 700 
T*8l 710 
TAdl 720 
T*6l 730 
TA61 740 
T*Hl '50 
TABl 760 
T*Bl 770 
TAfll 740 
TAfll 790 
TASt 400 

T*ei aio 
T&61 820 
TASl 930 
TABl 340 
Ttei 950 
TABl 860 
TABl 970 
TABL 9110 
TA8I a90 
TABl 400 
TAMI 910 
TABl 920 
TABl 930 
TA61 940 
TABl 950 
TABL 960 
TABl 470 
TABl 9S0 
1*01 ^90 
TASllOOO 
TASIIOIO 
TAeil020 
TAB11030 
TAB11040 
TAB 11 050 
TAB11060 
1*611070 
TAfltlOflO 
T*6il090 
T AS 11 LOO 
TABllLIO 
TAB11L20 
TABl 1130 
fAB11140 
TABILISO 
TA6tLI60 
TAeillTO 
TABLLIBO 
TABIL190 
TABLL200 
TABtl20l 
TASlt2L0 
TAeil220 
TA811230 
1*811240 
TABL1250 
T*ail260 
T*B11270 
T*eil280 
TAB1129Q 
TA81130a 
TABIlJtO 
TAB11320 
r*BlI)3Q 
TAB11340 
7*811360 
TAB11360 
TAB11370 
T*Blt3a0 



Statistics — Data Screening 29 



Subroutine TAB2 



Standard deviation: 



-This subroutine performs a two-way classification 
of the frequency, percent frequency, and other 
statistics over given class intervals, for two se- 
lected variables in an observation matrix. 

Interval size for each variable is computed as 
follows: 



s = 



S X^- { S X. I /n 

n - 1 

Frequency matrix 



(4) 



UBO 



k = 
J 



3j 



UBO. 



UBO 



(1) 



where UBO, . 
™2J 



2j 

given lower bound 



given number of intervals 
giver 
J = 1, 2 



UBO . = given upper bound 
3j 



If UBOii = UB03i, the subroutine finds and uses the 
minimum and maximum values of the ]*•" variable. 

A frequency tabulation is then made for each pair 
of observations in a two-way table as shown in 
Figure 6. 

Symbols - and < in Figure 6 indicate that a count 
is classified into a particular interval if the data 
point is greater than or equal to the lower limit of 
that interval but less than the upper limit of the same 
interval. 

Then, each entry in the frequency matrix, Fij, is 
divided by the number of observations, N, to obtain 
the percent frequency: 



lower < 


FU 


F22 










bound 


"^21 












< 














1 












upper 














bound ^ 








-_JV_ 








< 




^. < 






^ 



lower 
bound 



Figure 6. Frequency matrix 



upper 
bound 



Second variable 



lOOF.. 

a_ 

N 



where i = 1, 2, ... , UBO 
j = 1, 2, ..., UBO, 



(2) 



21 
22 



As data are classified into the frequency matrix, the 
following intermediate results are accumulated for 
each class internal of both variables: 

1. Number of data points, n 

n 

2. Sum of data points, .S Xj 

"^ 2 

3. Sum of data points squared, S ^j 

i= 1 

From these, the following statistics are calculated 
for each class interval: 

n 

S X. 
i=l ^ 



Mean: X= 



(3) 









TABZ 


10 








..TIB2 


70 








itei 


30 


<Lft<C».IU£ Itti 






riiB2 


40 


fL^fCtt 






T»a2 


60 


FthfCK^ » IhC-h*» CL«!:SlFIC«fICK fCft IhC Vil<a|*dLES 


IN 


AK 


r«82 


TO 


CeSEt)»ATIC^ PAIHIK (LK i filKIX SUaS£1l CF TI-£ fRtCUE^CV« 


1*82 


SO 


Fff-CtM tMCtCtftCV, AM. CIH:t» STAII&I1CS CVEft CIV€N 


ClASS 


TAe? 


90 


IMtHV^LS. 






T*a2 


100 

ito 


tS*C( 






1AB2 


120 


C'll T«lf24«.S.KljW,tGC.FHt<..PCr,$r*n,ST<lf2.^C.^V) 






1162 
T*82 


HO 
MO 


CESCOIFIICK Cf P«R4fEIE*)S 






i*e? 


IM 


t - Ceit*M*1lCK fATPlX. KC AT ^v 






TAaz 


140 


S - IfcPtT ((CCICR (itlrlKG SUBSfcT Cf *. CNLlf IMCSE 






f*82 


no 



CeSEOVATICNS kllt^ A CC«tt££PCKCIKG ^0^-ZeRC S(J} AOE TAB^ lao 

CCKSICtHt:C. VEC1CX tENCTti IS KC. TAB2 190 

V<P|A€LES 1U «E Ct^C!iS-IAeLtATfC. hCVfll IS VARIABLE T »b2 200 
It hCV<2) IS vAttlAflLE 2. WECTtft LENGTH IS 2. NCVTAB2 210 
r'CST GE GPtAUK IhAK CR CCU/L IC I ANO LESS THA^TA62 211 

CH CCLAL IC KV. rAH2 212 

3 t!V 2 *'ATt)|I CUlKG LChEH ll*<ir. ••U*'eCfl CF TAB2 220 

JhrtrDVALS. ANC LFF£)> Llfll CF BCft^ VAKrABLES TC HE TABZ 230 

lAet'LATfC (fIffSI CCLUMN FCK VARIMLt I. SECONC TAB2 2«0 

CCLUft, rCf) WAAIAeiE 21. IF LChEH LIHI1 IS EOUAL TO TAB2 2S0 

LFPLf) IIKIT fCH VAHIABLE It ThE PfiOQfAl* LSES ThE TA62 260 

PlhlfLf ANC MAKIHLP VALUE! CN EAC*- VAMIA6LE. hLJMBER TAB2 270 

Cf IKtCKVALS rest IftCLUCE IkO CELLS FCR UNOEM kttO 7AB2 290 

Ai;CVE LlfUS. TA82 290 

CLIfLI fAIfllK CF FHECUEKCICi IN It-E IbC-hAV TAt)2 100 

CLASSIFICATICK. CflCE4 CF f-AIRIIi IS IMl HV INT2. 7*02 )tO 

kt<(i)E IkTl IS tt-E hOfBED CF IKIER^'LS CF VARIABLE 1 1162 MQ 



;i« I 



AftC 1M2 IS IhE KLfBtrt CF I*iT£RMALS CF VAMIAOLE 2. 

ifkii Ai^c iKf2 r\.<t ae specified th the secono 

fCSITKK CF MLSPECriVE CQLLfN Of LiBC fAlftfK. 
CLiPUr HATMIK CF PERCEM FMECUfNCIES* SAr£ OttOER 
AS FREC. 

CtlPLT PATttll St''^ARU[^G ICIflSt ''EA^<, AND 
SIAhCAHC CCVIAIICKS FCK CAC»i CLASS I^IERVAL OF 
VAfllAtflE 1. CMltR CF ^ATHJJI IS J 0Y JKfl, 

Stt\2 - S4¥k ti SIATl liLl C*£« fcANUBLE 2. CRCE« UF HAfRK 

IS 3 ev l*.T2. 
fC - KLMIEI) CF CBSERVAIICfkS. KC f(.SI BC CREATE" THA^ 

C« ECCAL IC 1. 
K* - fcLfBEt* Of VARIAELES FC« CACi- CBSEBVAIICh, hV 

PCS! EE GfEAIER IFAK CO ECUAL tO 1. 



PCPAf«< 

IF i IS KLLL* 



CUTPCT AHEAS ARE S£ I IC ZESC 



SLCRCLIIKES AKC FLKCIIGM SiePRCGRAPS PECtlREC 



PET^CC 

lAIERVAL SUES FCR Bfll*- VARIABLES ARE CALCULATEC FROM THf 



TAB2 S90 

IAfi2 140 

TAB2 3^0 

IA62 SAO 

rAB2 )ro 

rAB2 SBO 
TAB2 )40 

TA62 ^00 

lASZ 410 
TAd2 420 
TA62 430 
TAB2 431 
IAS2 440 
rAB2 441 
TAfl2 450 
IAB2 460 
IAB2 470 
1*82 4«0 
IAB2 490 
TAB2 SOO 
1*62 SIO 
1*82 520 
7A62 SJO 



ElVth INFCRPAIICh CR CPTICkALLV FRCP It'E rihlNtP *N0 fAlinUHT*e2 540 



30 Statistics — Data Screening 



CftrfLCfEC. f4l«ICCS S1«T1 «f<C SI«I2 <t*<ft*M 1/ ||.C TOTALS. 
Hik%, AkC SlikC'fiO OEVUIIONS ««E T^e». C*ICLL*1E0. 
It-C CIVISC* fC« STANCAfC CtVlATICh IS CNE LESS ThAN THE 
KLVKCti Cf CeSEKVAIlOhS tECC ■«■ EACH CLASS IMCAVAL. 



SLERCLIIAE IAe21i,S.f>av.CBC.FIICC.PCT*!l'll.*TAT2.fi|C.I^Vl > 
Clf>Ef>SICA A<ll.S(ll.)kOV(2I.U8C(3.2l,Ffl£eill.PCni>,SlATini« 
lSlA12(il,<IKltSI 

ci<<E»sjCf keco.21 



CC i 1-1*3 



II AC. tC« AC 



5 kBCd.JJ-lCCM.JI 

CiTCHIilfkE LlliIIS 

CC AC f-1.2 

If lt£C(l«II-ueC43 
IC VfU^l.CCIS 

VfAX*-l.CC7: 

IJ*AC*IACbU)-lt 

CC 3$ J-l«lkC 

IJ-IJ«1 

IFfSUII 1S.3S,IS 
IS If UCUI'VMM 2C.jS.2S 
2C V^IA-A<IJ> 
2« 1FUIU1-V»AX} IS.)?, 10 

3C vria-AiiJ) 

3S CChflhtl 

tBC(l.ll-%^IA 

ICCO.ll'^fAli 
AC CCA1lhL€ 

CJLCi.lAI£ IhTEVVAL SI2E 

A! CC SC 1*1.2 

sc siM(ii>/tisi(i.ec(3.ii-uec(i.i ti/dficw.i i-z.cti 

CLE40 CCTPLI mm 
IKTI-l.eCI2.ll 

IKT1-IAIl*IM2 

CC !S l-l.lhTT 

Ft-ECIl MC.C 
55 FCT(I)-C.C 

lhTV-3*IMt 

CC tC I'l.lKIV 
tC 5UTI I I l-C.C 

[M2-3*I»T2 

CC bi 1-1. IMZ 
t; :1AI2III-C.C 

lESI £Le<E1 kECICR 

ECKT-C.C 
lAIY-IMl-l 
IA1)i-IhT2'l 
IJ-KC« lACVI 11-1 ) 
lJ]r-AC«l»iVi;)-l} 
CC SS J-l.KC 
IJ- IJ*1 

IFtStJJI 1C.SS.K 
7C SCA1-£ChT«l.C 

C/LCLl^lt FlieCUEKCI€S 

1E»Fl>i.EC(ltl)-SIK1|ll 
CC 15 M-I.IKTY 
Uff l-TEr*'i«SiK1(l) 
IFIfriJI-IEffl) e0.7S.7S 
TS CCATIKLE 
l>-IfTl 

ec itt-»A<it-ii*i 

STATlllt>l*<TA1invvi«AIIJI 

IY*"IY*«1 

!1A11(IV>I>S1«T1II«TI*I.C 

iVY«ivy.i 

STJI1IIYYI-5IAIII1TY1*41IJI«A<|J) 

1E»f2-L£Cli.2)-SlKT(2J 

CC ti IV-l.IKTX 

IEff2*TE»F2«SIKII2l 

|F|A(IJ«]-ICfP2l fC.ES.ES 
6! CCKrihLE 

lH'IKIf 
^C Ijf-IK I1«(IJ<-1 l«IY 

fHktllJU'fUiCt IJFI'l.a 

i*>3«n*-]i«i 

SIAT2<l»l-ST«12(IXt*A(lJXJ 

II-IX41 

S1/l2(lr)-S(«12(lXl«].C 



IX 



im 



ST/l2(l»l>STAT21II|«AiIJ)'tAA( IJVt 
S; CCMIM.E 

IF iscki tsa.iii.se 

C«i;.LlATE fEPCEhl FRECUEKCIES 

Sf CC ICC I'l.lHI 
ICC fCI(U'F»tt<l 1"1CC,C/SCM 

C^LCLIAU TCIALS. ''EAhS. $1JKC«RD CtYlHICKS 



CC 12C 1-1. IMI 



IJ> 



-UY. 



.IK 



HC>lKT«l 

U^Fl'Sl«1l(lxYf 
!i.»'-:ii«t 1 1 i«Y-i J 

U I rE»'»^l-I.Cl 12C.lCt 
let SI<fni<C»<C.C 

CC ic (i; 
IK £iAii<i:c)<s(.ciiAes((i.t«ii{ isci-SL*>*su'«/TE»'pn/(T€»ri-i.ai m 

Hi £T'I1 (l>YI*!u^/l£r'Fl 
I^C CCMIfLf 
l*li--l 

Cr t^C 1-1. IM2 

ISC-I^Ji.] 
Jt^f2'< im tlKfi 
5L^>SWW(lJix-l 1 

iKiEcFi-i.cj Hc,i;;.i>c 

121 SI«I2I l<tl<C.C 

CC Tc n; 

13C SUIJdKMSCHIKEStlSTAIil ISC J - SU^'SL^/ fE^-F^ I /I Tfc^f 2- I . CI I I 
lit !T«I2CI*>I-<C*'/Itrf2 



1AS2 )50 
TAe2 )«0 
TAB2 STO 

tab; 5ao 

TAe2 )90 
TAB2 600 

..tab; 610 
tab; 620 

TAB2 630 
1*02 6A0 
TAB? 650 
TAB2 660 
TA82 6T0 
TA62 ««0 
TAb? 690 
TAB? TOO 

TA[)2 no 

TAB2 720 
TAB? 730 
TAB2 7A0 
TAH2 r50 
tab; FAC} 
I»82 T70 
T«d2 780 
TAB2 790 
TAB2 BOO 
TAB2 fllO 
tab; RZO 
TAe2 830 
TAe2 4A0 
TAB2 aw 
TAB? 860 
TAB? aTO 
TAB? a«o 
TAB2 040 
TAa2 900 
TAB? 910 
TAB2 420 
TAB2 933 
T«B? 94n 
TAP? 950 
TAR? 960 
TAB? 970 

iAe2 igf) 

TAB? 990 
TAB21000 
TAB21010 
TAfl?La20 
TAB?La30 
TAS21040 
TA821050 
TA6?ta«0 
TAd2l070 
TAB210BO 
TAB21090 
TAB2IIO0 
TAB211L0 
TAe21120 
T«e21130 
rAB2ltA0 
TAB21190 
TAB2UB0 
TAB211T0 
TABfltBO 
TAB21I90 
TAB? I 200 
TAB2L210 
TA621220 
TAe?l?30 
TAB212A0 
TA6212S0 
TAB21260 
1AB21270 
TAB21280 
TAB21290 
TAB2130O 
TAa21310 
TAe21320 
tA821l30 
TAB213A0 
TA621350 
TAe21)A0 
TAB21370 
TAB21380 
TAB21390 
rAB21A00 
TA8?tAia 
rAB2IA20 
TAB?lA)a 
TAe2lAA0 
TAe2lAM 
TAB?1A60 
TA821AT0 
TAe2LA80 
TAB21A90 
TaB21500 
TAB21SI0 
TAB?15tl 
TA82tS20 
TAe21'i30 
TAa2l5AO 
TAe215S0 
TAe21560 
rA8?1570 
1Ae21S80 
TAB21S90 
TAB21600 
TAB2U10 
rAB?16?0 
TAB21630 
TA0216AO 
TAB?lti50 
TAB21660 

TA62I6B0 
TAA21690 
TAB2I700 
TAe217lO 
TA821720 
TAB21T30 
TAB21TA0 
TAB?t7S0 
TaH?1760 
TA6217TO 
IA821Te0 
TA821790 
TAd?lft00 
TA621B10 
TAB?1820 



(AC CCAIULE 

CC ISC 1>I.2 
CC ISC J-1.2 

ISC cecd.jl-hecd.j) 

1^1 JltlCHh 



Subroutine SUB MX 



TA421B30 
TAe2UA0 
TAH?ia50 
TAB21860 
TAB?ia70 



SCfMCLIIhE C(.efl 

fCPFCJE 

tA££C LK ktCtCf S CCNIttEC FHCf* SCtiRCLT IKE SUfaSf OR AHSNT, 
ins SLCRCUIIKE COPIES FRCf A IA«G€« fATRlJt CF CBSEHVATICN 
CATA « SltiSCI fAlNIX CF IF^CSE C tiSEfivA f 1CK$ kf ICH HAVE 
<AIISFlEt CERT«lh CCKCIIKK. THIS SLBRCL1INE IS fia«fALLV 
LUC FHICH K SIATISriCAL AKALTSES lE.C, fULIIPLE R^GRES- 
£ICK. FACICti AKALYSISI. 



20 



CSACE 

CALL SLEfX 



(A.C.S.KC.K%,K) 



SUBM 

sue** 
sua* 

SUBM AO 

SUB** 50 

SU8f< 60 

SUBM TO 

SUBM 80 

StBM 90 

SUBM 100 

SUBM 110 

SUBM 120 

SUSM 130 

sufin tAO 

SU8M 190 
SUBM 160 
SUSf 170 
SUBM 180 
SUBM 190 



CEHfilFTICK CF PAIiAfET£t<S 

A - IKFLI fATRlK UF CeSEfVAI ICKS. NC ET KV. 
I - CClFLl MAIKIX QF C VSEAhAIKK! , Ik BT KV, 

S - IKFLI VECTCR CF LEKCTf- KU CCKTAIhING THE CODES OERIVCD SUBM 200 
FitC^ SLBACCTIKE SL€ST CH idSKI. Subh 210 

AC - KLfEEf) CF CfcSEHVAT ICKS. hC MlSI BE > QR - TC I. SU8H 220 

hi • KLffltP CF VAKlABLtS. KV HUSI BE > OR ■ ?C 1. SU6M 230 

K - CtlFcT WAHlAeLE CLKTAIKIKC ?»-e ftbHBEfi CF KCK-2ERC C00CSSU8M 2*0 



IK ^ECTCK S. 

AEt-AAKS 

FAI^iX C CAN fiE IN Iff 5AfE LCCATICK AS »'Afft|)i A. 

SLCFCLIiKES AKC FCKCIICK £iefRCGRAI>S AEQUIREO 
KCKE 

»'EI^CC 

IF Sill CCKTAIKS A NCK-^ERC CCOE« I-TH QBSERVAIIOf^ IS 
CCFItC FHCr TFE IhPUT rAtPIX 10 THE OLTPUT nAIRIX. 



SLEPCLIIKE StEMA I A.C , S .KQ ,hV .K ) 
CI^CKSICK AUI.CID.Sdl 

L-C 

LL-C 

CC 2C j-l.KV 

CC I* l-l.f«C 

l-L*l 

IF(S(in 15. IS, IC 
IC U-ll«t 

CULI-A(LI 
IS CCKIIhLE 
2C CCKIIKLE 

CCCK1 KCK-2ERC CCCES IN VECTCR S 

K-C 

CC 3C 1*1. KC 

IFlSdd 3C. 3C. 2i 
2S K-K*l 
3C CCKIIKLE 



AEILRK 
EKC 



SU8M 290 
SUBM 260 
SUBM 270 
SUSP 280 
SUBM 290 
SUBM 300 
SUBH 910 
SueH 320 
SUeM 330 
SUBM 3A0 
SUBH 390 
SUBM 360 
..SUBM 370 
SUBM 380 
SUBM 390 
SUBM AGO 
SUBM AlO 
SUBM 620 
SUBM 630 
SUB* AAO 
SUBM 650 
SUBM 660 
Sue*" A 70 

SUBM 680 

SUBM 690 

SUBM 500 

SUBM 510 

SUBM 520 

SU8M 930 

SUBM 560 

SUBP 550 

SUBM 960 

SUBM 570 

SUBM 5B0 

SUBM 990 

SuBM 600 

SUBH 610 

SUBM 620 



Statistics — Data Screening 31 



Correlation and Regression (see Smoothing, 
Factorization) 

Subroutine CORRE 

This subroutine calculates means, standard devia- 
tions, sums of cross-products of deviations from 
means, and product moment correlation coefficients 
from input data Xj^^, where i = 1, 2, . . . , n implies ob- 
servations and j = 1, 2, . . . , m implies variables. 

The following equations are used to calculate 
these statistics. 

Sums of cross-products of deviations: 
n 



E 



> - I'^ir^ilfik-^ 



n n 



where j = 1, 2, . . . , m; k = 1, 2, . . . , m 



i=l 



X. 



m 



(2) 



(These temporary means T: are subtracted 
from the data in equation (1) to obtain compu- 
tational accuracy. ) 



11 

E 



fi(ifCS 






SIAhCARC CiVUTIChSt SfS CF C*iCSS-Pf«OOUCrS 
A*tC CCRAECA11CK CCEFf |C lENTS. 



tS«CE 

It 

IC 



IL CCROE (h.f.IC.X.xe^O.STC.RX.R.e.C, 



Tl 



cctn 

COKR 

COR* 

cc«o 
ccitfi 

CCRU 

cc«« 

COAft 
CORS 
CCRR 
CCRB 
CCRR 
CQRR 
CCR8 



Ch Cf P*R*ffT£RS 

- hktfBlR CF ca^CRVillCHS. »> fLil QE > 

- KLretR CF v*Rueti<. n t<tsi be > cb 

- tPIlCfc CCCE FCR IfPLi Oil* 
C IP CAT« ARE TC fC REAC I*. ffCP IMPLI DEVICE IK TMECCRR 

SfECHL SUBRCtlUE NAPED CATi. (SEE SUeROUIINES CGRR 
LSCC ei TtilS JteRCCTIfcC BELCb.l 
1 tP ALL CATA AH[ ALREACV Ifi CCRE. 

- If IG-C. It-E V*LIE Cf n IS C.C. 

IF IC-lf X IS ThC IhPUT r'ATDIK <*• BY »> ) CONTAINING 
CATA. 

- CLTPLF VfCICR CP tENCIH 

- CLIPtT VtCIOB CF lENGTh 
CCVIATICMS. 

- CllPi.1 PAIRIX (P t PI CChMINlhG mi*$ CF CROSS 
PftCCCCIS Cf 0t:VlA1I0f>S FAC HEAN&. 

- CtlPLT PATRIX ICMV UPPER TRIA^GUtAR PORTION OF THE CORR 
SYI'f*ETRIC f*A1Rl)i CF t* tlV f} CChTAINIhG CORRELATION CORR 
CCEfFlCIEMS. (SICRAGE HOCE CF tl 

- CLTPCl VECTCR Cf LChGTh R CCRtAINING THE OIACCNAL 
OF Ift PATRIX Of SUPS Cf CRCSS-PRCDUCIS Of 
CEVIATICftS FRC*' »EAh5. 

- .CRiClhC VECTCR Cf ^£^tiT^ P. 

- hCRKlKC VECTCR CF LENGTh P. 



CCfTAIMNG PEAKS. 
CC^1AIhI^G SIAhOARO 



CORR 
CCBR 
CORR 
CORR 
CORR 
CCRR 
CORR 
CORR 
CCRR 
CORR 



Ci:*i£ 



ClTII 
MA(i 



kILL hCT ACCEPT A CCkSIAKI VECTCR. 
ES JhC fL^CIIO^ SLeFRCCRAPS AECtlRCC 

,ci - ins SLflRCLl^^E ^uST e£ ppcvloEo ei ri-e user. 

U> If IC-C, ins SCeRGtTIKE IS fHPECTEO TC 

FLRMSf A^ CfiSERVATION l^ VECTCR fRCH AN 
EXtEkNAL ISPUT CEVICE. 

{2» If IC-1, Tt-IS SLBBCLTIKE IS ^C^ tSED fiV 

CCRRE tLi ftsi emsT ih 4pe ccck. if user 

HAS NCI iLPfLlEC A SUeXOClINF fcAfED DAIA, 
IhE FCLlChUG IS SLCCESTfO. 

SLeRC;,IIN€ CAIA 

HEILRK 

EKC 



fBCCi.Cl-PCP€fcT CCBRELATJCfc CCtFFICIENTS ABE CCRPUTED. 



X. 



Means: X. = 



where j = 1, 2, , . . , m 
Correlation coefficients: 



(3) 



^Jk 



Jk 



(4) 



4% i 



kk 



where j = 1, 2, . . . , m; k = 1, 2, .... m 
Standard deviations: 



s. 


yjn-1 


where 


j = 1, 2, 



(5) 



SbEfiCLIIhE CCI^RE (^ ,P, ICi X * xefR .S1C«RX .B tB .0. II 
CIPE(>SICf Kdl.liBARUt.SIOI l).BK<l).RIll.ei 11*0111.111) 



If A tCLELt FBICISICH VtRSICf CF IMS RCtTIKC IS CESIRCOt THE 

c l^ cCLfh 1 SHCCLC ec heccved fhc*" ii-e ooueLe precisiom 

STATE^EkT kt-ICI- FCLLChS. 

CCUELE FDECISICK xeAR t STC«RX*R (e>T 

Tt-E C PLSI ALSO EE REPCVEC FBCR OCUfiLE PRCCISION STATEMENTS 
ArP£AfI*>G Ih ClhCf RClJTlf^££ LSEO IK CCNJUKCTIOh k I TH fHIS 
BCCTIhE. 

T^E CCUBLL PRECISICh VERSICK CF THIS SUBACUTINE RUST ALSC 
CCI>T<II» CCUfiLE PRECISICN fCBIBAK flihCTJCNS. SCRT ANO ABS IN 
SIAIEPEfiT 22C MLS1 BE Ct-AhGEC 10 OSQRT AMD &«es. 



Ikll lAl WATlCh 

CC ICC J-1«P 
CI Jl-C.C 
ICC T(JI«C.C 

CC IC2 I-l.K 
IC2 Rdl-C.C 
fK*K 
L-C 

IFIICI IC:. I21t ICS 

CATA ABE ILBEACY IR CCBE 

IC; CC ICE J-l.P 
CC ICI l-l*h 

ICI KJI-TIJMXIL) 

xeAClJl-IUI 
ICE M JJ-IIJl/Ffc 

CC Hi I-l.K 

JX>C 

l-I-K 

CC lie J-l.> 

L«L*I» 

Cl.t«X(L t-ltJt 

lie eij>>eij)*c(j f 

CC II* j-l.P 
CC lit P>1.J 
JP-JB*! 
li; PIJKI-RIJKKCIJ ■•C(l< I 

CC IC let 



fidt Ce<EFViTICh< AhC CAUULAIf lEfPCAiPV 
PEAKS FfCP IhESE CAIA IK T(JI 

IF<|k-PJ I3C. 13C* Hi 

XH-K 

CC IC 1?1 

CC 14C 1-I.KK 

CALL CAIA IP.C) 

CC MC J-l.P 

T(JI-T(J)«CIJI 

L>L4l 

RXU l-C Ut 

FXX-XX 

CC 19C J't.f 

XCAdUI-l IJI 

1IJI-T( JI/fKK 



127 
13C 



13< 



CCRR 
CORR 
CCRR 

CCRR 
CORR 
CCRR 
CCRR 
CCRR 
CORR 
CCRR 

cnBB 

CORR 

CORR 
CCBR 
CCRR 
CCRR 
CCRR 
CORR 
CCBR 
CCRR 
CCRR 
CCRR 
CORR 
CCRR 
CORR 
CCRR 
CCRR 



60 
TO 
RQ 
90 
100 
110 
120 

no 

140 
150 
1«0 
ITO 
180 
190 
200 
2L0 
220 
230 
240 
250 
260 
2T0 
zao 
290 
300 
310 
320 
330 
340 
350 
360 
370 
340 
390 
400 
410 
420 
430 
440 
4»0 
460 

4 TO 
460 
490 
^00 
SIO 
520 
530 
540 
550 
560 

5 TO 



CORR 5 BO 
CCBR 590 
CORR 600 
CORR 610 
..CCBR 620 
CORA 630 
CORR 640 
CORR 650 
CCRR 660 
CORK 670 
CCRR 6R0 
CCRR 690 
CORR 700 
CQRR 710 
CCRR T20 
CORR 730 
CORR 740 
CCRR 750 
CORR 760 
CQRR 770 
•CORR r«o 

CORR 790 
CORR SCO 
CQRR 110 
CCRR A20 
CORR a 30 
CORR 840 
CORR 850 
CORR 860 
CORR 870 
CORR 860 
CORR 890 
CORR 900 
CORR 910 
CQRR 920 
CORR 930 
CORR 940 
CORR 990 
CORR 960 
CORR 970 
CCRR 980 
CORR 990 
CORRIOOO 
CORRIOIO 
CQRR 1020 
CCRR1030 
CCRR1040 
CORR 1050 
CORR 1060 
CGBRIOTO 
CCRRIOBO 
C0RRL090 
CQRRllOO 
COBRIUO 
CCRR 11 20 
C0BR1130 
CCBR1140 

cmim 

CCRR 1160 
CCRR 11 TO 
CORRIISO 
CCRB1190 
CCRR1200 
CCRRl2tO 
CCRRI220 
CCRR1230 
CCRR124a 
CCRR1250 
CORR 1260 
CCBR12T0 
CCRR 1280 
CCRR1290 
CCRBISOO 
CCRR 1310 



32 Statistics — Correlation and Regression 



CflCLL^U H.H CF CSCSS-PKCtCCIS Cf OCVI'TICtiS 
ffCP lefFCKiflV ftAhi fCR m CeSCf<«*IICf)S 

t«c 

cc lec 1-1. KK 

JK-C 

cc lie J>],f 

UC L(J)-DJi(ll-l|J| 
cc 1«C J>l,f 

cc lec K'l.j 
lac fiiJKi-»(jKi«ccjf*ciK j 



iFtF'-i'Ki ;c;, 2c; 



Iti 



C R(#C TFE 0£;i CF CBSEftVillChS CKE 41 A II^E, SU* 

C 1^£ CeStFV*IJCf, «h£ CiiCULJlTf strs Cf CUCSS- 

C FfCCLCTS Cf C£VUtKl.S FROM l£fPQRiBV HEAKS 

la; KK-h-nn 

cc ;CC I-I.KK 

Jt("C 

C«IL cut tf.CJ 

cc ISC j*l.^ 

CIJ)-CIJI-I<JI 
KC CIJ)-E(Jl*C«Jl 
cc iCQ J>1*» 
cc iCC K-]<J 

2CC i)UK)>(!lJt>)*C(J)*CfKl 

c 

C C/Lt:LL«I( *'Eih£ 

C 

2C! JK-C 

cc UC J>l.f 

ie4fi{ji*]ie>f)(jt/Fiii 

c 

: JCJLSI iCVS CF CfCSS-PftCCUCTS CF OEVIiTIChS 

: f*tP TEfFCRAft CE'NS 

cc <IC D-l.J 
JK-JKtl 
21C R(JKI-f(JKi-flJt*e(Kt/F>. 

C4LCLl'1E CCRXEL'lICh CCEFFICUfTS 

Jt<«C 

cc ;^c j'l,*- 

^«-JK«J 

HQ flt(Jt* 5(.RI1 <e5(fl|jt()ll 
cc ilC J'ltf 

cc 2;c »-j.* 

«(i-J*Iii*H-K)/2 
l«f*(J-l MR 

Pint j-KCjm 
i-r* o-i Mj 

ti» II )-fi(J(I| 

IF1STC(J>«STCIKI1 3:t, 122* 22'. 
lit fUlO-C.C 

CC 1C <JC 
22; »i|JK>-f IJKI/ISTCI J1«5IC(K)) 
2JC CCMIfCE 

CAtCLLilE SIAhCiXC CEVUTICKS 

Fh<5CPT(Fh- UC I 
cc <^C J«l,^ 
J«iC SKlJI-!ICIJl/fR 

CCPV IfE CI»GCfc»L CF TfE »'»I1'I> Cf SllfS CF CCCSS-PSCCUC TS CF 

ctviAt lc^s Ft-c*- ^'E*^s. 



cc i'.C i.i,^ 
2^c e(ii>f»a I 

Er.C 



ccaPH2o 

CCAS1130 

C0MR1)40 

CCRMH50 

CCBS1360 

CORRIITO 

CCRRiasO 

CC0R1390 

CCftRL^OO 

CGHRl^lO 

C0RH1S20 

CORitMSa 

CCRRM^O 

COBOHSO 

CQRR1460 

CORRI^TO 

CCRRt^eO 

CGARl'^90 

C0R«1500 

CCRP15I0 

CQRItLSZO 

C0IIIII)30 

CORK 1540 

CCRA1990 

C0ltRtS60 

COtt«l570 

CCRR1S«0 

CCflftlSSO 

C0RR16OO 

CCftftt610 

C0RRt620 

C0RR1630 

CQRitl640 

CCRR1650 

CCflR1660 

C0RR1670 

CCRRUSO 

CCRfll640 

C0ftR170O 

CCRRinO 

CCitiilT20 

CCRftlT30 

CCRRlTiO 

CCRR17»0 

CCRR1760 

CCRR1770 

CCftR17aO 

CCRfll790 

CGRRiaOO 

caRKisio 

CORftlSZO 
CaRRU30 
CCRRLS^O 
CCRR18&0 
CCRR1860 
CCR(tia70 

coRRiaao 

C0RR1S40 
CCRftl900 
CCRRI910 
C0RR1920 
CCRRI930 
CCRRLI^O 
CCRR1950 
CCRR1460 
CCRRlirO 
COHR19B0 
CCRR1990 
CCRR2000 
CORR23IO 
CPflR202O 
CCPR20JO 
CCRR2340 
C0RR2050 
CCRR2060 
CCRR20TO 
CCIIR20S0 
CCRR2a90 
CORRZIOO 
CCRR2I10 
CC«R2120 
CCft«2130 



Subroutine MISR 

This subroutine computes means, standard devia- 
tions, third and fourth moments, correlation coef- 
ficients, regression coefficients, and standard 
errors of regression coefficients when there is 
missing data. Effective sample sizes are also pro- 
vided. Missing observations or certain values of the 
data can be skipped at the user's option. The 
computational steps are as follows: 

1. Compute means: 



n 



^j = 



a= 1 



aj 



(1) 



where j = 1, 2 m implies variables 

n = number of nonmissing values for the jth 
variable 

2. Compute sums of cross-products of deviations 
from means for complete sets of ith and jth variables: 

n 

a= 1 



Z) (^ai-^) £ (X 



a= 1 



a= 1 



aj -^j 



Xi) 



(2) 



where x^, xj = means of ith and jth variables com- 
puted as above 
n ' = number of sets where the ith and jth 
variables are botii present 



3. Compute product-moment correlations: 



^ij 



IJ 



<3) 



4. Compute regression coefficients, intercepts, 
and standard errors of regression coefficients: 



a. ith variable as independent and jth variable 
as dependent; 



1] 



S.. 



Regression coefficient: b- • = 



(4) 



Intercept: ajj = xj - bjj x^ ' 



(5) 



Statistics— Correlation and Regression 33 



standard error regression coefficient: 



^jj " ""ij ^JJ 



'b,-i 



ij (n - 2) Sji 



(6) 



b. jth variable as independent and ith variable 
as dependent: 



ij 
Regression coefficient: b4j^=-^7^ 



n 



(7) 



■'JJ 



Intercept: a^j^ = Xj - b^j^Xj 



(8) 



Standard error of regression coefficient: 



Sbji^ 



Sii - rjj Sii 



(n ' - 2) Sjj 
5. Compute standard deviations: 






(9) 



(10) 



where n = number of nonmissing values for jth 
variable 

6. Compute skewness and kurtosis, s and k: 
n 
Let/ij.= Y) (Xq. -X.) Vn 
J cT^l J •' 

Then Sj = M3j/ (/^2j) ^^^ 

andkj = (fX4/M2j) "3 

Note: This subroutine cannot distinguish between a 
blank and a zero. Therefore, if a blank is 
specified as a missing data code in input cards, 
it win be treated as (zero). 

For reference see B. Ostle, Statistics in Re- 
search. The Iowa State College Press, 1954, 
chapter 6. 



(11) 
(12) 



Purpose 

COMPUTE MEANS, STANDARD OtVMTIOMS. StCtotNESS AND KURTOSlS, 
CCRRELATinN COtt-F ICItNTS, RtGftESSIPN COEFf ICI tNTSt *ND 
SIANOARO CRROfS OF P6GfiESSlGfi CCEFFICI€"«tS WHEN THEt^E *<>£ 
MISSING DATA POINTS. THi USER IDENIIflES THE HISSING OATA 
Br MEANS Of * NUHERIC COOe. THOSE VALUES MOVING THIS CODE 
ARt SKIPPED in COMPUTING THE STATISTICS. IN THE CASE OF 
CORRELATION COtff IC lENTS, iNV PAIR Of VALUES ARE SHIPPED 
tllHER ONE OF iMtM ARE MISSING. 



USAGE 

CALL MISR <N0< 



M,X,COOEiK6AR,STOi5<tEb,CURr,R,N.A,B,S»ieB) 



CODt 



xeAC 
SIO 



CURT 



NUMERIC 



MISk 
MISR 

MISB 

HISR 
HISR 

MISF 
MISR 
HISR 

MISP 

MtSR 
MISR 

HEMISf 

F MISR 
HISB 
MISK 
HISR 
MISR 
MISR 
HISR 
HISR 
MISR 
HISR 
HISR 



uEiCfilPriON OF PARAMETERS 

NO - NUMBER OF UBSCRVATIONS 

H - NUMBEF OF VAQIABLES 

X - INPUT DATA MATRIX OF SIZE NO X M. 

INPUT VECTOR OF LENGTH H, WHICH CONTAINS 

MISSING DATA COOE FOF^ EACH VARIABLE. ANV OBSERVATION MISR 

FOR A GIVEN VARIABLE HAVING A VALUE EQUAL TO THE COOEHISR 

UILL BE DROPPED FOR TmE COMPUTATIONS. MISR 

OUTPUT VECTOK OF LENGTH M CONTAINING MEANS MISR 

OUTPUT VECTOR Of LENGTH H COKTAINIHG STANDARD DEVI- MISR 

ATIONS 

CUTPUT VECTOP Of LENGTH H CONTAINING SKEWNESS 

OUTPUT VECTOR OF LENGTH H CONTAINING KURTOSIS 

OUTPUT MATRIX OF PRODUCT-MOMENT CORRELATION 

COfFFICIENTS. THIS WILL BE THE UPPER TRIANGULAR 

MATRIX ONLY, SINCE THE H K M MATRIX OF COEFFICIENTS 

IS SYMMETRIC. <STORAGE MODE II 

- OUTPUT MATRIX OF NUMBER OF PAIRS OF OBSERVATIONS USEDMISR 
IN COMPUTING THE CORRELATICN COEFFICIENTS. ONLY THE MISR 
UPPER TRIANGULAR PORTION OF THE MATRIX IS GIVEN. 
(STORAGE HOOE II 

- OUTPUT MATRIX (M BV M» CONTAINING INTERCEPTS OF 
REGRESSION LINES (Al OF THE FORM Y"A*BK. THE FIRST 
SUBSCRIPT OF THIS MATRIX REFERS TO THE INDEPENDENT 
VARIABLE AND THE SECOND TO THE OEPWOENI VARIABLE. 
FOR EXAMPLE, Ad, 31 CONTAINS THE INTERCEPT OF THE 
REGRESSION LINE FOR TWO VARIABLES WHERE VARUBLE I 
IS INDEPENDENT AND VARIABLE 3 IS OtPENOENT. NOTE 
THAT MATRIX A IS STORED IN A VECTOR FORM. 

- OUTPUT MATRIX IM BY Mt CONTAINING REGRESSION 
COEFFICIENTS IB) CORRESPONOI NG TO THE VALUES OF 
INTERCEPTS CONTAINED IN TME OUTPuT MATRIX A. 

- OUTPUT MATRIX IM BY MI CONTAINING STANDARD ERRORS 
OF REGRESSION COEFFICIENTS CDRRESPONDi NG TO THE 
COEFFICIENTS CONTAINED IN THE OUTPUT MATPIK B. 

NO ERROR. 

IF NUMBER Of NON-MISSING DATA ELEMfNTS FOR J-TH 
VARIABLE IS TWO OP LESS. IN THIS CASE. STOIJI. 
SKEWUI, ANO CURTIJI ARE SET TO 10»«75. ALL 



lER 



MISR 
HISR 
MISR 
HISR 
HISR 
MISR 
HISR 



MISR 
HISR 
MISR 
MISfl 
HISR 
MISR 
HISR 
HISR 
HISR 
HISR 
HISR 
MISR 
HISR 
MISR 
HISR 
HISR 
MISR 
HISR 
HISR 
MISR 



VALUES OF R, 



ANO S RELATED TO THIS VARIABLE MISR 



ARE ALSO SET TO 10**75. 
2, IF VARIANCE Of J-TH VARIABLE IS LESS THAN 

10»«I-20I. IN THIS CASE, STDIJl. SKEM(J), AND 
CUCTIJ) ARE SET TO 10»«75. ALL VALUES OF P. *i 
B. ANO S RELATED 10 THIS VARIABLE ARE ALSO SET 1 
10**75. 

REMARK S 

THIS SU6R3UIIME CANNOT DISTINGUISH A BLANK AND A ZERO. 

THEf^EFORE, If A BLANK IS SPECIFIED AS A MISSING DATA CODE 

INPUT CAROSt IT WILL BE TREATED AS (ZERO). 

SUBSOUTINES ANO FUNCTION SUBPROGRAMS PEQUlRED 

NONE 



METHOD 

LEAST SQUARES REGRESSION LINES ANO PRODUCT- 
LATION COEFFICIENTS ARE COHPUTED. 



(OMENT CORRE- 



SUfiROUTINE HISR (NO,M, R, COOE , "BAR, STO,SKE W,CURT ,R .N, A, 6, S . lER I 



DIMENSION XIU.COOEdl.XBARUI.STOd) 
DIMENSION A( 1 I ,fl< II. Sd) 



.SKEWIII .CURT(I) tRIll.Nt II 



COMPUTE 


MEANS 






lEH-O 








1 = 








DO 20 J-1. 


.H 






FN-0.0 








XBARlJI-0. 


,0 






DO 15 l-l. 


NO 






L-L»l 








IFIXILI-COOEI Jll U. 


15, 


l^ 


fN-FN*l.O 








XBAR(J)<=XBAR( JUXUI 






CONTINUE 








IFIFNI Ifc, 


, 16, 17 






XBAR( J1«0. 


,0 






60 TO 20 








).BAR(JI"KBAHIJ)/FN 






CONTINUE 








SET-UP 


WORH AREAS 


ANO 


TE 


L = 








00 55 J=l, 


tH 






LJJ=NO*(J- 


-1( 






$REWUI>0, 


.0 






CURT t J 1 = 0. 


.0 






KI=M*( J-l) 






«J=J-H 








00 5* 1=1 


,J 






Ki=M*i 









DATA IS MISSING 



TII-O.O 




TJJ=0.0 




TI J--0.0 




N1J»0 




LI«NO*M 


-11 


L J=LJJ 




L = L*I 




00 38 K= 


UNO 


LI'LI'l 




LJ«LJ»I 




IF( X(L1 1- 


-COOE 


IFIKILJI- 


-COOc 



100 
110 
120 
130 
1*0 
150 
160 
170 
180 
190 
200 
210 
220 
230 
2*.0 
250 
260 
270 
260 
290 
300 
310 
320 
330 
3*0 
350 
360 
370 
3B0 
390 
*00 
*I0 
*20 
*30 
**0 
*50 
*60 
470 
*60 
*90 
500 
510 
520 
530 
5*0 
550 
560 
570 
580 
590 
600 
610 
620 
630 
6*0 
650 
660 
670 
680 
690 
700 
710 
720 
730 
7*0 
750 
760 
770 
780 
MISR 790 
niSR 800 
HISR 810 
MISR 820 
HISR 830 
HISR 6*0 
MISR 850 
HISR 660 
MISR 870 
HISR 660 
MISR 890 
HISR 900 
HISR 910 
HISR 920 
HISR 930 
HISP 9*0 
HISR 950 
MISR 960 
MISP 970 
HISR 980 
HISR 990 
HISPIOOO 
HISRIOIO 
MISRI020 
HISR1030 
MISR10*0 
HISRIOSO 
HISP 1060 
MISR1070 
HISRIOSO 
HISB1090 
HISRllOO 
MlSRllIO 
MISFIIZO 
MI SRI 130 
H1SRI1*0 

HISR1160 
HISRtUO 
MISR1160 
MISR119fl 
HISR1200 
MISR1210 
M1SR1220 
HISRW30 
HISR12<>D 
MISR1250 
MISR1260 
MISR1270 
•^ISRUBO 
MISF 1290 
MISRiaOO 
MISR1310 



HISR 
HISR 
HISR 
HISR 
a HISR 

HISR 
HISR 
HISR 
MISR 

INHISR 
HISR 
MISR 
MISR 
NISR 
HISR 
MISR 
MISR 
MISR 
HISR 

..MISR 



34 Statistics --Correlation and Regression 



<4CiTh data ahl pRtS£Nr 

35 KX = K(I. I )-XBAa ( I I 
YY = J((l.Jl-II84R( Jl 

TJ=TJ»vy 

TJJ'iTJJtVY**^ 

I r J=IIJ*)(K«YY 

SUMX*SUnx»X(LI 1 

SUMY-SUMY*K(LJI 

1F<I-JI 30. )?. 37 
37 SKEW(J» = SREt>(J)*YY»*3 

CUPTU»-CU«T( J) •¥¥••« 
18 CONTINUE 

COMPUTE SUM Of CROS S-PfiOOUCTS Of DEVI*T10hS 

fFINIJl *0. *0, )•» 
39 FN=N(J 

B(ii«Trj-ri»rj/FN 

NIL I^NIJ 

II I-ril-TMTI /fH 
IJJsf JJ-TJ«IJ/fH 

COHPUTf STANDAPD DEVIATION, SKEUNESS. AND KU^TOSIS 

^0 If(I-Jt *7, *l, *7 
41 lftN[J-2l '.2,42,«^3 
*>i IER-1 

R(Lt=1.0eT5 

A(KI )-1.0E 75 

fl(KI»=l.Oe75 

S(KI )=:l.OE75 

GO TO *5 

*3 SIDI J»-=Rll. I 
F(LI>t.O 
AIKn=0.0 
BIK[ 1-1.0 
SIKIMO.O 



1F(ST0(J t-( i.oe 

44 iep=2 

<t5 STO( J) = U0ET5 
SKfHt J1=1.0E75 
CUPT(JI=1.0E7S 

GO TO 55 



4,i,,A',,*.b 



MISF 1320 
H ISP 1)30 
N[$A|)40 
MI5P 1350 
HISfil3«0 
HISH1370 
HISC1360 
HI SRI 390 
MISRUOO 
M15P1410 
HISPI420 

niSRi^3a 

«ISP1440 
NIS(tl4%0 
HI so 1460 
HISF1470 
HISRl'.SO 
«ISRl*90 
MlSt^lSOO 
HISftlSlO 
HISRL920 
HtSPISSO 

Mrs<ii5*o 

HIS" 1550 

HISP1560 
HISfli570 
H|Sfll5flO 
M1SR1590 
HI SO 1600 
niSfil6tO 
MISR1620 
H(SR1630 
HISR1640 
HISRIA50 
Ht&R1660 
MfSRl670 
HISftl«80 
niSR|690 
MISm700 
MISR1710 
HISftlTZO 
HESRIT30 
HI SRI 740 
MISRIT50 
KISP1760 
HISRI770 
MISRI7aQ 
MISB1790 

HtSRiaoo 

HISP1810 



46 WOP«"STOf Jl/f N 

SKEw(J) = <$KEH(J)/Fh)/(WCRK>SQRT{UOR< I I 
CU«T(JI = ((CURT(JJ/fNI/«OR(C**2)-5.0 
STO( Jl-Sttkll 5I0IJt/<FN-l.0)) 
GO TO 55 

COMPUTE R€C«tSSION COEFFICIENTS 

47 IF(N|J-2| 48,48,50 

48 lEP-I 

49 fl(L}-1.0Er5 
A(KII<l.OE75 
e<KI)>I.Of 75 
SIKI )-I.O€75 
A(KJ)=|.0E75 
BIKJ|=1.0E75 
SUJ) = l,0e75 
GO TO 54 

50 |F|TII-U.0E-20)I 52,52,51 

51 If ITJJ-C1.0E-2an 52,52,^3 

52 IER=2 

GO 10 49 

53 SUHX=SUMX/fN 
SUMV=SUHY/fN 
8(Kn=Kl.)/T 1 I 

A(KI l«SOHY-e(KI )*SUHX 

e(t(JI=RH.I/FJJ 

*(KJ)-SUMX-6(KJ1*SUMY 

COMPUTE CORkELATION COtPFICIENTS 

R(L l=RtLl/(SOftT( TIII'SORrirjJJI 

COMPUTE STANOAt-O tf-P&^S OF fEG^€SSIQN COfcFFICieNTS 

PB-P1L)**2 

SUMXi( Tjj-TJJ*Ptl/eFN-2I 

sfRn=softTisuHx/Tin 

SUMY=( TII-TII'ftPl/tFN-^l 
S(t<Jl=SOf TtSUMY/TJJI 



Mr,P1820 

M|SI'I83G 

HISPlfl4Q 

MISP1850 

M|S(tia60 

MtSP 1870 

niSt- 1880 

MISR1B90 

MU*>1<>00 

M1SB19I0 

MISP1920 

HISR1930 

H ISP 1940 

MISP1950 

H[S('|960 

HISH970 

MISK1980 

HISR1990 

HI5P2000 

MISP20I0 

MISfl2020 

HISf20i0 

MISR20A0 

HISP2050 

M ISP 2060 

HISP2070 

HISR20S0 

MISP2090 

MISR2I00 

M!SR2ilO 

MlSfi2120 

MISS2130 

HISR2140 

MISt«2l5Q 

MISP2160 

HISR2170 

MISP2iaO 

MISP2190 

HnP2200 

MISR2210 

Hrse2220 

HISR2230 

MISB2240 

MtSP2250 

HISP2260 

MJSP2270 

MISP22eO 

MI^B229Q 

MISf^230Q 



Statistics --Correlation and Regression 35 



Multiple Linear Regression 



Subroutine ORDER 



In the Scientific Subroutine Package, multiple 
linear regression is normally performed by calling 
four subroutines in sequence, 

1, CORRE - to find means, standard deviations, 
and correlation matrix 

2, ORDER - to choose a dependent variable and 
a subset of independent variables from a larger set 
of variables 

3. MINV - to invert the correlation matrix of the 
subset selected by ORDER 

4. MULTR - to compute the regression coeffi- 
cients bo, bi, b2, ...» bm, and various confidence 
measures 

The subroutine CORRE works in either of two 
ways: (1) it expects all observations in core, or 
(2) it triggers a user-provided input subroutine, 
DATA, to read one observation at a time into a work 
area. In either case, the user must provide a sub- 
routine named DATA (see "Subroutines Required" in 
the comment cards description of subroutine CORRE). 



FLFfCSE 

CChSTKCCT FfCf « L'KC£R »JI1R1K CF CCRRELATICK CCCFPICIEMS 
» SOtiSCI KAIRIJi CF lM€FiCCf)flEL*1ICh£ AKflthG IKCEPENDEN1 
ViRI^etES tKZ » V£CICR CF IKTERCCRRElAllChS Cf IKOEPEhDCKT 
V/|i|«tlES hlTh CtftHCthl V'OIASLE. ThIS £I.BRCLT1NE IS 
f'Cflf'LLV LSEt IN tl-E Pt.ffQHf*h(.t Cf fCLTIPLt AKC PCLY\CP1AL 
PECOESSICK 4<k«LVSES. 



LS'CE 

Ctll CKCEF (P. A. 



ICEP.K. I<«VE.n)(,RV> 



HCEF - 



CE^CFIFTICK Cf P*«<f£IEPS 

P - kUPBEtl CF VAHUELES ANC CROEfl Cf PaiHIll R. 

h - IhfLl PJimx CCMAIMNC CCft(tEl*TIC^ CCEFFICIEMS. 

It-lS SieOCUTlNE EXPECTS C*>LV LPPCtl TR|i^CUL&K 
fCRTICk GF TfE £V»'P£TRIC CATfUX U Hi SIOftEO (BV 
CCLtPM IK R. (£1CR*CE PCCE CF II 

T»<E SUeSCRIPT hUfl^ER CF IFE OEPEI^CENI VARIABLE. 
hLPBER CF IhCEPEfkCEM VARtAeiES IC BE IhCLUOEC 
[h THE FCRT^CCPIhE MEGRESSIOM. K PU5I et CAEATEM 
It-Ah CO ECUAL IC 1. 

lltSt - IKPUT VECTCA Cf LEhCrh K*| CCMAIMNC, IN ASCEKCINC 
CACER. Il-E SUeSCRlPI hUPUERS CF K INCEPENOENT 
VAPIAeiES TO BE lACLUOEC U T»-E fCRIfCCPl^G REGHES- 

Slc^. 

IfCK PETURMKC IC Tl-E CALLIKC RCllTINE. THIS VECTOR 

CCIilAIfcS. Ik ACCiriCK. ThE SIjBSCRIPT KUPflER OF 

^H CEfENCEhT VARIABLE JK K41 FQSITIC^. 
ft - CLIPbl tlAIRly <»> X Kl COMAIM^C I h T^MCOKRELA T IONS 

APChG IhOEPEKCEKT VARIABLES TC BE liSEC IN FnHTH- 

CCPI*<C REGR^SSIC^. 
P» - CtTPCI VECTOR Cf L£^GIt- K CCMAIfcl^C IMERCORRELA- 

TlChS CF IhOEPEKCEKI VARIABLfcS hllH CEPENOENT 

V4PIACLES. 

REPARKS 

SLERCLIIAES AfC FLhCTlCN SLEFRCGRAPS RECUIREC 

PETFCC 

F*CP I^E SLCSCPIPT MPeCS; CF tl-£ ^ARlABtfS TC BE IhCLUOED 
Ik Tl-E FCRIt-CCPIKC AECRESSICh. THE SLeROUllNE CCKSTKUCTS THE 
PAIFU RX A^C I^E VECICH RV. 



CROE 
.ORDE 
OROE 
QROE 
OROC 
ORDE 
CROE 
CROE 
CROC 
CADE 
ORDE 
OHOE 
ORDE 

CHoe 

CRDE 

onoE 

OROE 
OROE 
OROE 
OROE 
CROE 
CROE 
OROE 
C«OE 
CROE 
OROE 
CROE 
ORDE 
CROE 

naoE 

CROE 
OHOE 
CROE 
OROE 
QROE 
CODE 
0<<0E 
ORDE 
OROE 
ORDE 
OROE 
DROE 
ORDE 
OROE 
CROC 
OROE 
OROE 
CRDE 
OROE 
OROE 
OROE 
ORDE 



IQQ 
HO 
120 
130 
1*0 
150 
160 
ITO 
ISO 
ISO 
200 
210 
220 
230 
240 
250 
251 
260 
270 
280 
290 
JOO 
JLO 
120 
3 30 
340 
350 
360 
3T0 
3B0 
390 
*00 
410 
'i20 
430 



4ao 

690 
500 
510 



;ifc^CltIKt CHCER (f«H(hCEP,K,I5«VE.RX,R1l 
ClfiMlCK Kdl.lSAVEdt.RXdl.RVdl- 



IF t ECLBLE PfECISICh VERSICh CF ll-IS RCLTIhE IS CESIREO. THE 
C I^ CCLt^Pk 1 StiCULD BE REr-CVEC FRC** 1f<E OOueLE PRECISICN 
SIA1EPEM ^.^■IC^ fCLLChS. 

CCLELt (RECUICK R,R«,BY 

ll-E C PtSI AISC C£ REPUVEC FRC*' CCLELE PRECISICh STATEHEMS 
iPFE/PING iK CTHER flCUU^tE LSEC IK CC^JC^CTlC^ hlTH IHIS 
DCLTIKE. 



CCFV IMERCCHREIAT IChS CF I^CEFEKCENT VARIAELES 
.hlll- LEFEKCEfl WARIAELE 

PP«C 

CC 13C J'l.K 

1<>IS«WEUI 

IF(hCtF-Lil I2i, 123. 123 

L'hCtf «(4.2«li-t;t/2 

CC IC lit 

L-li*I^ctF•^ctf-^ctP*/^ 
Rytj)>ti ID 

CCPY A ILESET fATPtX CF INTERCCFRELAT ICKS APCNC 

[^ClF£^C£^T varIasles 

CC 13C 1-1. K, 

Ll-lSAvEIlt 

IFUl-lfl 12). 126. 12E 

l-li«ILi«L2-L2l/2 

CC TC U« 

l>L24Ui«ll-Lll/2 

► P-PHi 

FyiPPi>»lLl 

flACE TfE SCESCHIFT KUfSiH Cf I^E CEPEkCEfcT 
^'PIAElf Ih ISAVEU*!) 

JSAVE |K*l)>ikCEF' 

FETLRh 

tfC 



CROE 520 
OROE 530 
ORDE S^iO 
CROE 550 

, .OitOe b*>0 
ORDE 570 
CROE 5«Q 
ORDE 590 
CROE 600 
CROE 610 
OROE 620 
CaOE 630 
ORDE 640 
OROE 650 
CRDE 660 
CRDE 670 

.QROE 6S0 
CROE 690 
QROE 700 
ORDE 710 
CROE 720 
OROE 730 
CROE 740 
CROE 750 
CRDE 760 
OROE 770 
OROE 780 
GROE 790 
OROE 800 
CROE BIO 
OROf 020 
ORDE 930 
CRDE 840 

OROE aso 

OROE 060 
OROC 870 

CROE aso 

OROE 890 
CROC 900 
CROE 910 
OROE 920 
ORDE 9 30 
CROE 940 
OROE 950 
CROE 960 
CROE 970 
OROE 9a0 
OHOE 990 



36 Statistics — Correlation and Regression 



Subroutine MULTR 



and taking the square root of R : 



This subroutine performs a multiple regression 
analysis for a dependent variable and a set of inde- 
pendent variables. 

Beta weights are calculated using the following 
equation: 






(1) 



where r. = intercorrelation of i**^ independent 
^^ variable with dependent variable 
-1 



1] 



the inverse of intercorrelation r.. 



ij = 1,2, 

r and r.. 
ly 1] 



. . . , k imply independent variables 
are input to this subroutine. 



Then, the regression coefficients are calculated as 
follows: 



b. = /3. --^ 
' •" J 



(2) 



where s = standard deviation of dependent variable 

y th 

s. = standard deviation of j independent 

^ variable 
i = 1, 2, ..., k 
s and s are mput to this subroutine, 

y i 



The intercept is found by the following equation: 
k 



Es 



3=1 J J 



(3) 



where Y = mean of dependent variable 

X = mean of j**^ independent variable 
J 

Y and X are input to this subroutine. 
3 

Multiple correlation coefficient, R, is found first 
by calculating the coefficient of determination by the 
following equation: 



R 



= / . /3.r. 
iH ''^ 



(4) 



■ v; 



R= VR 



(5) 



The sum of squares attributable to the regression 
is found by: 



SSAR = R • D 



yy 



(6) 



where D = sum of squares of deviations from 
^ mean for dependent variable 

D is input to this subroutine. 

yy 

The sum of squares of deviations from the re- 
gression is obtained by: 

SSDR = D - SSAR (^) 

yy 

Then, the F-value for the analysis of variance is 
calculated as follows: 



SSAR/k 



SSAR(D-k-l) 



SSDR/(n-k-l) SSDR(k) 

Certain other statistics are calculated as follows 

Variance and standard error of estimate: 

2 _ SSDR 

y. 12. ..k n-k-1 

where n = number of observations 



(8) 



(9) 



^. 12. ..k J 



y. 12. ..k 
Standard deviations of regression coefficients: 



(10) 



-1 

r 
JJ 



D. 



]] 



y. 12.. -k 



(11) 



where D.. = sum of squares of deviations from 
^■' mean for jth independent variable. 
D;5 is input to this subroutine. 

j = 1, 2, ..., k 

Computed tt 

b. 



t. = e 



J 



(12) 



b. 
J 



j= 1, 2, .... k 



Statistics — Correlation and Regression 37 



SUOALUT IHt HjLiK 

PUHPQifc 

PtKfORM I. MUL(l(>Lt LlNtAK REMtSiJUh ANALYSIS FOR A 
UkPLHUtHi VAAIAaLE AND A $t\ OF INUtPENOENT VARIABLES. FHI 
iObKOO'^lNfc I^ NORMALLY USlEO IN THt PeftFOKHANCE Of NULIIPLE 
ANiy PULYNOMtAL KEGAESSION ANALYSES. 



(N,K,x6AR,sru,U,RXTRV, I SA V6 * d« SB t T (ANS I 

UtSCRiPMOH OF PARAHEFERS 

N - NUMbER UF DB^LRVAT IONS . 

K - NUM6tR OF lNl;t:PENOLNT VARIABLES IN THIS REGH£SSION. 

KtJAR - INPUT VECTOR Qf LENGTH H CONTAINING MEANS Of ALL 

VikRlABLES- H IS NUfteER Of VARIABLES IN UttSERVATIONS 
blO - INPUT VtCTUK Of LENGTH H CONTAINING STANJARO DEVI- 

ATIUNS ijF ALL YAKlAdLES. 
- INPUT VECTOR Of LENGTH H CONTAININC THt OIaCoNAL DF 

THE HAIRIX Of SUMS Uf CROSS-PRODUCTS Of JkVIATIOMS 
FRJH MEANS FUR ALL VARIABLES. 
hX - INPUT MATRIX (K X Kl CONTAINING THE |NVERS£ OF 

iNTcftCORRfcLAriLMS AMONG INOEPENOENT VARIABLES. 
R» - INPUT VECTOR OF LENGTH K CONTAINING I NTERCORRELA- 

TIJNS Of INDEPENDENT VARIA8LES Nl TH DEPENOENt 
VAKUdLE. 
ISAME - INPUT VECTOR CF LENGTH K*l CONTAINING SUSSCRtPTS Of 
INUEpEnOEnT VAftlAdLtS JN ASCENDING ORDER. THE 
SUoSCRIPT Cf THE DEPENDENT VARIASLE IS SrOfttO IN 
THE LAST. IC»1, POSITION. 
B ' GJTPUT VECTOfl Jf LENGTH K CONTAINING REGRESSION 

COiff ICIENIS. 
S8 ~ OUTPUT VECTOR Of LENdTH K CONTAINING STANOARO 

UfcVI&TIUNS Jf ftfGRESSION COEf FICIENTS. 
J - UUIPUT VECTOR OF LENGTH K CONTAINING T-VALUES. 

ANS - OUTPUT VECTOR OF LENGTH 10 CONTAINING THt FOLLOWING 

INFORMATION.. 
ANSI I) INTERCEPT 

ANSI2I MULTIPLE CORRELATION CQEFFItlENT 
ANSI 3) STANOARO ERROA Of ESTIMATE 
ANSCtl SUM OF SQUARES AT TRI SUTAtlLE TO REGRES- 
SION (SSARI 
ANSI3) DEGREES Of fREEUOM ASSOCIATED 1*1 TH SSAR 
ANSC6) MEAN SOUARE OF SSAR 
ANSCri SUM CJF SCUARtS Of DEVIATIONS fiiOH KEGRES- 

SiQN (SSOR) 
ANS<6t tEGRtti OF FREEDOM ASSOCIATED WITH SSOR 
ANS(9t MEAN SQUARE Of SSOR 
ANSdO) f-VALUE 

REMARKS 

N MUST 6£ GRtAlEft THAN K*l. 

SUBROUTINES AND FUNCTION SUBPROGRAMS REOUIRED 
NONE 

MtlHU) 

THt GAUS5-J0R0AN MtTHOO IS USED IN THE SOLUTION Of THE 
NCRMAL IwUM luNS . MEFER TO rl. U. COULEY AND P. R. LOHNES. 
'MOLTIVARlATt PRCCtUUtttS FOR THE BEHAVIORAL SCIENCES'. 
JLHN lilLEr AND SUNS, 19bZ, CHAPTER 3i AND b. OSTLEt 
•STATISTICS IN RESEARCH", THE lOWA STATE COlLEGt PRESS, 
1954, CHAPTER 8. 



SUbRCUTlNE MULTR (N,K.t X6AR, STO, tRX.RY, 1 SA VE t S , Sf , T , ANS I 
DIMENSION XtlARdl.SrDI 1) ,C( I I .RX( 1 ) .R Y( 11 . I SAVE I 1 1 ,6(1 1 . SB 1 1 1 . 
1 TUI,A|VS(1} 



IF A uOJdLi. PA£ClSlOh VtRSIUN OF THIS ROUTINE IS DESIREUi THE 
C iN CULJMN 1 SHOULO BE REMOVED FkljA THE DOUBLE PRcCISlON 
STATEMENT itHlCH fULLOWS. 

OOUHLt PRcClSJUN X6AR. STO, D. RX. RY.B< So. T.ANStRM.BG, SSAR, SSOR, Sr. 
1 FN ,FK,SSARMiSSURn,f 

THE C MUST ALiU St REMOVED FROM OGUBLE PRECISION STATEMENTS 
APPtA.*lNG IM JTHtK ROUTINES USED IN CONJUNCTION MITH THIS 
KudT 1n£. 



jO 



60 



MULT 
MULT 
MULT 
MULT 
MULT 
MULT 
MULT 

SMULT 80 
MULT 90 
MOLT 100 
MULT lie 
HUIT 120 
MULT ISO 
MULT 1*0 
NUIT ISO 
MULT 160 
NULT 170 
MULT 180 

.Mult i9o 

NULT 200 
MULT 210 
MULT 220 
WiLT 2i0 
MULT 2*0 
MULT 2^0 
HULT 260 
MULT 2T0 
MULT 280 
NULT 290 
HULT 300 
MULT 310 
HULT 320 
MULT 330 
HULT 3*0 
MULT J50 
HULT 360 
MULT i70 
HULT J80 
MULT 390 
NULT 400 
MULT 410 
HULT 420 
MULT 430 
HULT 440 
MULT 450 
MULT 460 
MULT 4 70 

Mult 480 

MULT 490 
MULT 500 
HULT 510 
HULT 520 
HULT 530 
HULT 540 
HULT 550 
MULT 560 
HULT 5 70 
MULT 5flO 
MULT 590 
HULT 6C0 
HULT 610 
HULT 62C 
HULT 630 
MULT 640 
MULT 650 
HULT 66C 
MULT 670 

.MULT 680 
HULT 69C 
MUlT 700 
MULT 710 
HULT 720 
MULT 730 

.HULT 740 
MULT 750 
MULT 760 
HULT 770 
HULT 780 
MULT 79C 
HULT 800 
MULT 610 
MULT 8 20 
HULT 830 
HULT 840 
MULT 850 
MULT 960 



iSlU.'. V£«iluN i,F IMIS SUBKOUTINL MUST AlSo 

Pf^tHSlLA FOkI«AN FuNLTIlnS. SjRT AND A(JS 

I^u. AUl 1j5 MUSI tjE CHANGED Ti^ OSCKT AND 



DtiA WL IGHIb 

OCJ lOt, J=l,i( 
ICl b( Jt=C .0 

oQ lie J=1.K 

DO UC IM,K 



♦ I 



1 IL 



j| = 



( JI*Ky< 1 )*kxi L) 
KM=C.C 

60=I.-.L 

Ll= I !)AVt< MMI 



Lff ! 



-ItNl Ut- .JtrtKHlN 



12. 



KcORtSSU>N CUiiPF ICIENTS 



L = ISAVc( I) 

5(1 > = 6( n»ISTU(LU/iTiJ(Ll I 



dJ = rf'J.o( I l*Xt)ARlLl 
dU=X3AA(LlI-Ba 



: iUM .Jf SQUARcS ATTRloUTABLfc TO REGRESSION 

SSAK = WH»D(*.l I 

: MULTIPLE CORRELATION COtfFIClENT 

12^ «M= Sy<T( AdSIRMl 1 

; iUH UF SJUARdS Jf UiEVIflliJNS FRUM RtCtESSION 

5iDrt=iJ(Li l-SSAR 

VARiAhCt OF EjTIMATt 

Fft( = N-K-l 
SY=SiDK/Fi\ 

STANDAkJ UtVEAflONS UF REGrieSSION COEFFICIENTS 

DO no J=1,K 

L1=K»( J-ll*J 

L=ISflVc(JI 
12') SB(J)= SUrlri AbS( (KX<Ll»/»J( LI l*5Yl ) 

CUKPUTtU T-VALUfS 
130 riJI^L)lJ}/S&IJl 

STAhtlJA'tU cXRGK OF tSTIMATE 
IJ^ Sr= StfKTI flliSISYJl 

F VALUc 

Fk. = k 

iSARH^SSAK/FK 
iiURH^SSDR/FN 
F=3SARH/SSuRH 

ANSI li=BU 
ANSI2) =(<A 
ANS( JJ^SY 
AHS(4)=SSAR 
ANSI &t =FK 
ANS(61=SSAKM 
ANSI 7)=SSJK 
ANS(e) = FrJ 
ANSl'yMSSDRM 
AHU IC>=F 
RETURN 
END 



MULT 8 70 

IN MULT HbO 

OAdS.MULT 890 

MULT 900 

MULT 910 

MULT 920 

HULT 930 

MULT 94C 

MULT 950 

NULT 960 

HULT 970 

HULT 980 

MULT 990 

MULTI.,CO 

MULTIOIG 

MULT 10 2? 

MULT 10 30 

MULT 1040 

HULT 1050 

MUlT 1060 

MULTIC70 

MULT 1 080 

MULT109C 

MULTUOO 

MULTlItO 

MULTU20 

MULT1130 

MULTli40 

MULTllSO 

HOLTII60 

MULT1170 

MULTliaO 

HULT1190 

MULT1200 

MULT1210 

MULri220 

MuLri2J10 

MULTU4C 

MULT1250 

MULT1260 

HULT1270 

MULT128C 

MULT1^90 

HULTIiCO 

MULT1310 

HULT1J20 

HULT 13 30 

MULT 1340 

HULT1350 

MULT 1360 

MULTJ.*70 

MULT 1380 

MULT 1390 

HULT1400 

HULT 14 10 

MULT1420 

MULI1430 

HULTt440 

MULT1450 

MULT1460 

HULT1470 

MULT 1480 

HULT149C 

MULT 1500 

MULT1510 

MULri520 

MULT1530 

MULT1540 

MULT1550 

MULT1560 

MULTISTO 

HULTlSaO 

MULT 1590 

HULT1600 

MULT1610 

MULT1620 

MULT1630 

HULTl6*0 

NULT 1650 

HULT 1660 

MULT1670 

MULT16eO 

MULT 16 90 

HULT17C0 

HULTITIO 

HULT1720 

MULT17 30 



38 Statistics — Correlation and Regression 



Polynomial Regression 

In the Scientific Subroutine Package, polynomial 
regression is normally performed by calling the 
following four subroutines in sequence: 

1. GDATA - to generate the powers of the inde- 
pendent variable and find means, standard devia- 
tions, and correlation matrix 

2. ORDER - to choose a dependent variable and 
subset of independent variables from a larger set 
of variables 

3. MINV - to invert the correlation coefficient 

matrix 

4. MULTR - to compute the regression coeffici- 
ents bp, bj, bg, . . . , bjjj, and various confidence 
measures 

Subroutine GDATA 



Then, the following are calculated. 
Means: 



i:\ 



J n 



(2) 



where j = 1, 2, . . . , p 

Sums of cross-products of deviations from means: 



o,.=EN-^i)(''«-'^i- 



jk t 



i=l 



(3) 



E5-^))Efr^"">' 



i=l 



1=1 



This subroutine generates independent variables up 
to the ixfi^ power (the highest degree polynomial 
specified) and calculates means, standard deviations, 
sums of cross-products of deviations from means, 
and product moment correlation coefficients. 

X , denotes the i case of the independent variable; 
il 

X denotes the i case of the dependent variable, 

where i = 1, 2, . . . , n 

n = number of cases (observations) 
p = m + 1 
m = highest degree polynomial specified 



where j = 1, 2, . . . , p; k = 1, 2, . . . , p. 
Correlation coefficients: 



°ij 



where i = 1, 2, . . . , p; j = 1, 2, . . . , p. 



(4) 



Standard deviations: 



4^ 



where j = 1, 2, 



(5) 



The subroutine GDATA generates powers of the 
independent variable as follows: 






(1) 



X. -X. " X.^ 

im 1, m-l 11 



where i and m are as defined as above. 



PURPOSE 

itMtRATc IfJJfcPbNDtNf VARUBLEi UP TO THE M- IH POrfgR ( TH£ 

NlCHESr OtuRfcc POLYNOHIAC SPEClfl£t)l A**0 CQHPUTt MEANS, 

STAN^ARl^ 0£V:AtION^, AND COHRfLArin COEFFICIENrS. THIS 

SUBAJUT INE IS HCJAHALLV CALLED SEFOAC SUBftOUTINcS ORDLftt 

rtlNV ANO rULTR IN THE PEAFORNAMC& Of A POLrNOHIAL 
ReCRESSlUN. 



70 



USA&£ 



GOATA tN 



.X8Aft.sri),0« SUMSO> 



GOAT 
GOAT 
GOAT 
COAT 
GOAT 
GOAT 
GOAT 

GOAT 80 

COAT 90 

COAT 100 

COAT 110 

COAT 120 

COAT 130 

GOAT 140 

COAT ISO 

GOAT l&O 

GOAT 170 

COAT lao 

GOAT 190 

GOAT 200 

GOAT 210 



DcSLBIPTION UF PAKAHETenS 

F4 - NurfBtR Of OHSEAVATIONS. 

H - Tri^ HlwrttST OeC«tE PQLTNOMIAL TO A€ fITTfcO. 

X - ltii>ijt MATRIX (N 8Y H*it . HHEN THE 5UttH0UTINE IS 

CALL^J. OATA FOR THE INOcPEMOENT VARIAALE ARE 
ilOREO IN THt FIRST COLUNN Of HATKIX X« AND DATA FQRCOAT 220 
THt OEPENOENT VARIABLE ARE STORED IN THE LAST COAT 230 

COLUMN OF THE MATRIX. UPOM RETURNING TO THE COAT 240 

CALLiwi MOur(M£f ntHtinkito fQ^t^i Of ini. imtnmttnj^MJ 2>o 

VAR[AtlL£ AAE SrOAti) IN CQ\.mi^ I THAOUCH M. COAT lid 

XaAR - OUTPUT VECTOR 0»= LENCTri n*i CONTAININO MEANS OF GOAT 270 

INJEPtftScNT ANJ OEPcNOtNT VAAIABLES. COAT 240 

STO - UUTPJT VECTOR OF LENGTH H«^l CONTAINING STANDARO COAT 290 

UEVIATlOfiS OF INOEPENJEnT AW) OEPENOtNT VAAIAftLES. GOAT iOO 
a - OUTPUT MATRIX (ONLV UPPER TAIANGULAR PORTION OF THE GOAT ilO 

Sf'iMtrRlC MATRIX OF H^l BV N«ll CONTAINING CORRELA- GOAT 320 

riOft COEFFICIENTS. 4 STORAGf HOOC OF II 
SUNSO - OUTPJT VECTOR OF LENGTH H+l CONTAINING SUNS OF 

PROUUCrS OF UEVIATIONS FRQH MEANS OF INJEPENOENT 

AND OEPENOENT VARIASlES. 



REMARKS 

N MOST dE CAtAFER THAN M*-l. 

IF M IS EQUAL TO S OR GAEATERt SINGLE PRECISION HAv NOT lE 

SUFFICIENT TO GIVE SAriSFACTQAT CONPUTATIONAL RESULTS. 



GOAT 3iQ 

GOAT 340 

GOAT iSO 

GOAT S60 

Coat )to 

COAT >«0 
GOAT 390 

Goat 400 

GOAT 410 



statistics — Correlation and Regression 39 



JNC I 1J\ SUbCKUO 



Ktl-c^ IJ J. JSILE, ' SfATUriC J IN HLSfcAHCH', IhE lU<^a SFflli 



iJBrtUUT I.-t uUATa <.^,M, J(,>:3AR. STl). J, SJMSUI 



IF A dJjaLt Pi^fcClSION Vl^SIlJN Jf THIS RUUIINt IS UtilKcJ, 
C IiN CjiUM.M i i:1JULD i)t rJf^JVCL) f^kU^I iHc DQUdLL PKtCISIJM 



UuduLC ?ri^tlSl 



SjmSJ, [ i,W 



rnt C j-IUal ALaO HE «£MUV£U f^OM JGU9Lt I'RLCISIUN SIAItMtNTS 
APPEARIfjj IN JTHEH ROUTINtS JStO IN CONJUNCriON WITH tHii 
RUUr INu. 

FHL (JUUilLt P.<i:C151JN VE«SIO''^ OF THli SU6RUUT1NL MUST ALSlJ 
CyNFAlN Ui.JliLi: PitLCISIJN FJKTRAN HJf^C H UN S . SQK T M^O ASS IN 
STArtMcNr 1^0 MUST ri£ CHAMGtd fJ OSgKI ANO OAbS. 



jCN£«Are JNL*tPcNiJt-\ T VARIABLE 
IF t,1~li ICi. 105, 90 

DO le-: i = ^,M 

Ud ICO J=t,.N 

L = L l* J 



: CALCULAIc ,4^AfJS 

105 ^«=M*l 
JF = N 
L=0 

DO 11 3 1= i,MN 
AOA'tt I I =0 .0 
JO U'J J-l.N 

._^L»1 

1 !>.■ HdA^I [ I -Xbiril I 1 txR I 
i !•; XbAr\( 1 l=SdAK( i 1/ JF 

13-: bIL}( i I =0.0 

CALCJLAIt SJMi Jr ^KaSS-PKuiJUCrS JF JtVUJIONS 

00 iii: i^i.L 

ISj D( 1 J=L .C 

UU 170 K^l.N 

DO 1 7C J=i,MM 
L2=N*( J-l)*K 

SIDI J) = iTu( J J ♦T2 

Od 170 1= 1, J 

1 1 = X1 L i )-AdaH( 1 I 
L=L<-1 

UC L»ll.»=DILJ'-Tl»T^ 
L=C 

DU 175 JM.MiH 
L>0 175 1=1, J 

i.73 LP(LJ=U(LI-iIJ( I ) = Srt>U)/OF 

DO idC i= I. IM 
l. = L*I 

tdC ilJ<iJ= SJKT( Ao.t^li-in 



LAlCULATl 



^fcLATI JN LDcFF ICIfcNIS 



L=0 

uo iyc j= 1 , MK 

JO 19C [=I,J 
L-Ltl 
UC D(L I =JI L)/(ilL-( f ) ♦j ful JI 1 



CAl.l,UL-tTc 



iT A 



.iU jlviaTuns 



DO 2;C/ I-- 1, MH 
<;CC STuU 1 = Slu( 1 l/L>r 



GOAf "liO 

dLtAr 'i'^O 

GJAF "VOO 

GJAI <,70 

GOAT •toD 

liDAT fc-JO 

.GtlAI SCO 

GUAI 5lQ 

GDAT 520 

GOAT 5iO 

GOAT 540 

.GDai 550 

GOAT 560 

GOAT 5^0 

GOAT !,ao 

GOAT 590 

GUAl 600 

to 



GUAT 



GOAT oJQ 

GOAT tao 

Goat dSO 

GDAT 700 

.GDAT 710 

&DAI 720 

GUAT 730 

GOAT 7'tO 

GDAr 7 5C 

GDAT 760 

GOAT 770 

GOAT laO 

GOAI 7SI0 

GDAT 800 



GOAT 



9iQ 



GOAT 620 

GDAT 630 

GOAT d-i-O 

&3AT B50 

GOAT tJ60 

Goat 870 

GOAT aeo 

GUAT 890 

GOAT 900 

GDAT 910 

GjJAT VZC 

GOAT 9J0 

GOAT 9^0 

GOAT q^o 

GOAT 960 

GOAT 9i0 

GLtAT -J 80 

GOAT 990 

oOA riOOO 

GOATIOIO 

GOATIO^O 

G0Ari03O 

GDATlO-^0 

GOATL050 

&OAT1060 

G0ATI070 

GOATiSSO 

GOATl.090 

GOATllCO 

GDATIllO 

GDATll^O 

GOAT1130 

GDATl UO 

G0Arii5C 

GDflTll60 

GOATll 70 

COATl 18C 

GOATI 190 

GUATI2CC 

GOflTliflO 

GoATl^^O 

GOAT12J0 

GOATW^-C 

GiJATl2^0 

GDAI1260 

GDAri270 

G0AT1250 

GDAT1290 

GGflTlJOO 

GUATl JlG 

CUATU20 

GOATIJJO 

GOAT li'tZ 

GOATlJiO 

GOATI ibO 

COAT 1370 

GLtATl360 

GOATI 390 

GOaTI'.lO 



Stepwise Multiple Regression 

In the Scientific Subroutine Package, stepwise mul- 
tiple regression is normally performed by calling 
the following subroutines: 

1. CORRE - to find means, standard deviations, 
sums of cross-products of deviation matrix, and 
correlation matrix 

2. MSTR - to save the matrix of sums of cross- 
products of deviations and to copy it to a workii^ 
matrix for the purpose of using the same data 
repeatedly 

3. LOG - to compute a vector subscript for an 
element in general and symmetric matrices. This 
subroutine is called by the subroutine MSTR 

4. STPRG - to compute regression coefficients 
and other statistics for each step of regression 

The subroutine CORRE works in either of two 
ways: (1) it expects all observations in core, or 
(2) it triggers a user-provided input subroutine, 
DATA, to read one observation at a time into a work 
area. In either case, the user must provide a sub- 
routine named DATA (see "Subroutines and Function 
Subprograms Required" in the comment cards 
description of the subroutine CORRE), 

The subroutine STPRG calls an output subroutine, 
STOUT, in order to print various statistics com- 
puted for each step of regression. The subroutine 
STOUT must also be provided by the user. 



40 Statistics — Correlation and Regression 



Subroutine STPRG 

This subroutine performs a stepwise multiple 
regression analysis for a dependent variable and a 
set of independent variables. In each step of the 
regression i = l, 2,..., q, where q is the number of 
independent variables, the abbreviated Doolittle 
method is used to calculate the following statistics: 

The independent variable enterli^ in the regress- 
ion is selected, first, by computing the amount of 
reduction of sum of squares for each variable: 



C. = 



jy 



a.. 
]] 



(1) 



where au is initially an element in the sums of 
cross-products of deviations matrix 
which will be modified in successive steps, 
j = 1, 2, . . . , q are independent variables 
(j ^ variables deleted and variables 
entered before the 1*^ step) 
y = dependent variable 
and, second, by finding the maximum (over j) of C. 

Set Si = Cj to indicate the sum of squares that 
will be reduced In the 1^ step. 

The proportion of Sj to the total is obtained by: 



D 



(2) 



and adjusted for degrees of freedom by 

R = Vl- (1-r2) (n-1) / (n-k) 

where there are k independent variables in the 
regression. 

The F-value for analysis of variance is given by 



F = 



S /k 

cum / 



(D-S ) / (n-k-1) 
cum / 



(6) 



The standard error of the estimated y is obtained 
by the use of the formula 



D-S 



cum 



y.l2.. .i V n-k-1 
and adjusted by 



(7) 



s = s y(n-l) / (n-k) 
c 

Then, the following is computed; 

2 
a 

ij 



a.. = a.. + 
]J J] a, 



(8) 



11 



where i = variable entered in the ith step 



j = V2,V2, . . . ,'^1-1 are the variables entered 
in the regression before the ith step, and 



where D =2^ (y. -y) 
j=l ^ 

n = number of observations 

If p is less than the constant specified by the 
user to limit independent variables, the analysis 
will be terminated without entering the last variable 
selected; otherwise, the following calculations are 
continued: 

The cumulative sum of squares reduced is ob- 
tained by 



^ik 



s = s + s. 

cum cum i 



(3) 



and the cumulative proportion reduced by 



'ik a.. 



(9) 



where k = 1, 2, , . . , m are variables including 

y (k ^ variables deleted and the variable 
entered in the ith step) . 

Regression coefficients are computed by: 



b. = g. 
1 ly 



Vl = ^(i-l)y-V(i-l)i 

^i-2 " ^(i-2)y"V(i-2)i'^i-l^(i-2)(i-l) 



(10) 



P = P +p 

cum cum 



(4) 



etc. 



The multiple correlation coefficient is computed and the value of the intercept as 



by 



R 



■A 



(5) 



^0 = y - E b.x 



j=i 



] J 



(11) 



statistics— Correlation and Regression 41 



where k = number of independent variables in the 
regression. 

Standard errors of regression coefficients are given 
by 



J 



a., s 
JJ y. 12...i 



(12) 



where j = vj, vg, . . . .vj are variables in the 
regression, and t- values as 



J 



Perform the reduction to eliminate the variable 
entered in the ith step: 



(13) 



Jk 



— a., -a e 
jk ji^ik 



(14) 



where i = variable entered in the ith step 

j =l,2,...,m(j7^ variables deleted or 
variables in the regression) 

k = l,2,...,m(k^ variables deleted and the 
variable entered in the ith step) 



a.. 



11 



a.. 

n 

-a... 
11 



a.. 
11 



(15) 



(16) 



For reference see C. A. Bennett and N. L. 
Franklin, Statistical Analysis in Chemistry and the 
Chemical Industry . John Wiley and Sons, 1954, 
Appendix 6A. 



:(.e(CLiiKt «ipf)c 



StPR 
.SIPR 

srpR 

STfR 
STPH 
STPd 
SIPR 



30 



io 



fLPfCJE 

IC F€«FC»P A SICPHISE Plll|PL€ KECPESSICA IMHIVSIS fO" • 

CtfihLlkl VARIiULE AhO A S£l Of INOEPEhDENT uARfABLts. AT STi., „„ 
flCf £IEP, in vlRUeiE EMEREO IHC IHE RECRESSIOK ECI/<rIC^STPR 90 

IS IHI hUCti EKPLAIKS IhE GRER1E£I APCUhf Of VARIANCE SIPR 100 

EEUEER II ANC 1H CEFCkCEM VARIABLE (I.I. Il-E VARIAeiE SIPR 110 

hlle ThE fICHEST PARIIAL CCRRELATIC^ MIH IHE CEPEhOEM STPR 120 

KRIAEIEI. AM VARIAdlE CAN BE CESICNAIEO AS IHE OEPeNOENI SIPR 130 

kXIAElE. Ak» lACEPEkCEAl VARIABLE CAl BE FORCED INTO OR SIPR lAO 

CflEIEC f»CP IKE PECRESSKA ECbAIICh, IRRESPECIIVC Of IIS SIPR 150 
CCMPIELIICN TC IfE ECLATICN. 



CSAEE 

CALL STPRC (R.A. 



C.I>eAR.|CV.PCI,ASIEf.AhS.C,B.S.T.LL«IEPI 



CESCFiFlfCA Cf FAFAPEIERS 

P - rciAL ALPBER OF VARIABLES 

► - AtPBER Cf CeSCRVAIICAS 

c - lAFLi PAIRK IP a p) Of SUPS CF CPCSS-PRCCOCIS Of 



STPR 160 
SIPR ITO 
SIPR IBO 
STPR 190 
SIPR 200 
SIPH 210 
STPR 220 
SIPR 2J0 
SIPR 240 



ICA 



1 - IKCCPCNOENI VilOMfllC TC BE fCBC£C INTO THC STPR foO 



fttCRESSICK ECUATICIk 



STP« JlO 



J^SiiSifr*^! l^ '^ CCfcSlC£R£0 U TH€ eouAnON STPft 320 



9 ' C€PEhOChT V'NIABLE 
T)-IS VCCICR MILL BE DESfAOVEC 
- * CChSlAM VALCe UCICAIIAC IHE PUCPCBTICI* Cf tHf 
ICT«4 %t(tt*HCe tC BE CKPL^IKEO BY ANY IhOEPENDENT 
V«UflLE. TI-CSE IfcCEPMOEM VAPIABLES 



PENDENT 
FALL 



SfPR 3J0 

$TP« 3«<l 

STPfl 350 

SIPR 360 

SIPR 370 



STPR 390 



ECuATICh. TO EhStRE TH*T JLt VAftI ACLE s'cN lift' IH€ 
ECLATICh. SET PCI - 0.0. 
fSIEf- CLIPtr ViCICK CF UhCTH 5 CCMAINUC IHE FCLLCtiUG 



IfcFCRPAIlCN 
kSIEFtn- 
hSUF(2(- 



^srcF<4t- 

fcSIEF(5»- 



STPR «00 
STPR 4L0 
SIPfl MO 
STPR 430 
STPR 440 
STPR 450 
STPR 460 
STPR 470 
STPR 4«0 



It-E fLPBEB CF THE CEPENOENT VARIABLE 

KlJ^'Bt* CF VifllAfiLES fCBCCC INTO THC 

RCCRESSION CCCAirOk 

ALPBtR OF VARIABLE OCLETEC FROM THE 

ECtAltCK 

t^E ^LWBER CF Tt^E LA$I STEP 

It<E fcUPBER CF IHE LAST VARIABLE EkTEREO STPR 440 

iA^'jsjAji^j'joS'TtrfiSi'ji^s"'"-- '- ^"-""■" 

AhSm- SUR CF SCUAB€S RCCUCEO BY IMS STEP STPR 520 

i^VA\' f!!i''F!M*"" °' ""^ 5"" °f SCUARtS REDUCEDSTPR 530 
AfcSOl- CUMULATIVE %Uf CF SQUARES RECUCEO OP TO STPR 540 

ANSI4I- CUMULATIVE PRCPCRIICN Of TOTAL SUM Cf 

SQUARES REOUCEO 
AhSISI- SUP Cf SCUARES Cf TH€ OEPENOENT VARIABLE 
ANSitI- MULTIflE CORRELATION COEFFICIENT 
ANS(?I- F RATIO FCR SUM OF SCUMIES CUE TO 

RECRESSICN 
ANSiai- STANCARC ERROR CF TtiE ESTIMATE IRESIOUAL 

PEAN SCCAREI 
ANS(SI- INIERCEfl CCfcSTAliT ,,„ „„ 

ANSdOI-PUCTIfLE CORRELAIICN COfFFICIENT AOJUSTCD STPR 650 

FOR CEGREES Cf FREEDOM. 
ANS<I1I-STANCARC CRRCR CF Tt<E ESTIMATE AOJUSTED 

FOR CECRECS CF FREEDCM. 

- CtlPUI VtCICR CF lEhCT*- K. kt-ERC K IS THC NUHQER OF 
INCEPENCENI VARIABLES IN TFE RECRESSICt^ EOUATION. 
TUS VCCTCR CCNIAINS THE LUMBERS Of TH INOEPEftOENT 
VARIABLES IN IFF ECtATIC*. 

- CUIPUT VECTOR OF IEN«IH R. CONTAINING IHE PARTIAL 
REGRESSICN CQEFFICIENIS CORRESPCNOING TO THE 
VARIABLES IK VECICfl L. 

- OUTPUT VECTOR CF LENGTH K, CONTAINING THE STANCARO 
ERRCRS CF The PARTIAL REGRESSION COEFFICIENTS. 
CCflRESPCNOING TC 1FE VARIABLES IN %ECTCR L. 

- CLIPLT VECTOR OF LENGTH K, CONTAINING IHE COHPUTEO 
T-VALUES CCRRESPCftCING TC TH£ VARIABLES IN VECTOR L. 

- hCHRIfcC VECTCR Cf LENGTH M 

- Ct IF T^ERt IS hC ERROR. 
I, If RESICLAL SLP CF SOUARES IS NCCATIVE OR IF THE 
FIVOTAl ELEMENT Ik IHE SIEfWiSE INVERSION PROCESS IS STPR 840 
Zf«0. Ih IhlS CAiE, THE VARIABLE WICH CAUSES THIS STPR 850 
ERROR IS NOT ENTEREO IN THE RECRESSIOK, THE RESULT 
PRIOR TC THIS SIEf IS KEIAINEO* ANO IHE CURRENT 
SEIECTICM IS TERPIKATEO. 



STPR 550 
SIPR 560 
STPR 570 
STPR 5«0 
STPR 590 
STPR 600 
STPR 610 
STPR 620 
STPR 610 
STPR 640 



STPR 660 
STPR 670 
STPR 680 
STPR 690 
STPR TOO 
STPR 710 
STPR 720 
STPR 730 
SIPR 740 
STPR 750 
STPR 760 
STPR 770 
STPR 780 
STPR 790 
STPR 800 
STPR 810 
STPR 820 
STPR 



STPR 860 
SIPR 9 TO 
STPR 880 

,.-., S'*« 890 

STPR 900 
IK AUMBER Cf CAI* PCIM! CUST BE AT LEAST GREATER THAN THE STPR 910 
MfBtfl Cf INCEPEhCENI VARIABLES PILS CfcE. FCBCED VARIABLES STPR 920 
ARE tMEREC INIO iHE RECRESSION EUATICN BEfCRE ALl OIHEB STPR 930 
I*.CEP£f.CCftI VAHIAflLES. fclTHIN THE SET Cf PORCEO VARIABLES. 
IFE CfcE TC CE CHCSEN FIRST fcILL 8E THAT CNE LHICH ElPLAINS 
1FE GREATEST APCbNI OF VARIANCE. 

IhSIEAC CF USIfcC. AS A SICPPINC CRITERION. A PRCPCRTICN QF 
IFE rCIAL VARIANCE* SCPC ClfEll CR11ERICN NAY 8£ AOOED TO 

SLeROUT|^E siclt. 



STPR 940 
STPR 950 
SIPR 960 
STPR 970 
STPR 980 
STPR 990 
STPRIOOO 



STPR1020 
STPKLOAO 



Sl.e«ClTIAES ANC FLhCIIQN SiefRCGRAPS RECUIREO 
STCUKhSICP.ANS.Lte.S.I.hSTOPl 

ins StBRCUIINE PLST BE fflCVIOEO BY IFE USER- IT IS _., ,..-»„,« 

CLIfCI RCLIIfcE hHICH hILL fRINf THE RESUtlS Cf EACH STEP OF STPR1040 
U€ REGRESSICI. AKALTSIS. K5ICP l« AN CPTICh CCOE bHICh IS STPR1050 
CfcE IF THE SIEPhlSE RCCAESSICN IS TC BE TE«M|hAT£0. AKO IS STPR1960 
iEFC If IT IS TO CONIINLE. THE L5ER PLST CONSIDER THIS IF SIPRIOTO 
£C»'£ CIFER StCPPUG CRIIERICN IFAN VARIANCE FftCPCRIIC*, IS TOSTPR1060 
Ef LSEC. srPRl090 

SIPRilOO 
^'"^'■'- STPRlllO 

IFt AEBRtVIAlEC CCCLIITK PEIHCC IS UStC 10 (II OECIOE VAR I-SIPR 1 120 
AEltS ENIERINC IN THt REGRESSICfc ANC 121 CCMPLTE REGRESSION SIPBU30 
CCEFflClEMS. REFEi* TC C. A. EEKP-EIT A^C N. I. FRANKLIN, STPR1L40 

*S1ATISIICAL ANALYSIS IK Ct-EPISIRV ANC THE CFEMKAL INCUS- STPR1I5Q 
}»\'. JCFfc kILEY AKC SCfS, H54, APPEhCU «A . SIPB1160 

STPRLITO 

SIPRllSO 

STPRI190 
SLCRCLTUE SIPAC IP .h .C . XB AR . IC I .FCT. hS lEF . ANS .L .8 .< , T ,LL , I ER » STPR 1200 

SIPR12I0 
CiPEftSICk Clll.»tARUI,ICKU),MTePMI,ANSm,LUI,e(l|,S(II.T(ll,STPRl?20 
*'-*^' ** STPR1230 

SIPR1240 
STPR 1250 

IP A CCtELE PRECI*IC\ VERSICfc CF TUS ROLIlNE IS CESIREC, THE 
C IN CCLUPN I SHCULD BE REPCvEO FRCP IHE COUBLE PRECISIOh 
STATEPENI hflCI- FCLLChS. 



CCtCLE FRECISICN C* NBAR .ANS .8 .S ,T .RC.RE 

TFE C PLST ALSC EE REPOVEC FRCP CCLBLE PRECISION STATEMENTS 
AFPEARlkC Ih CIHER RCUTINES LSEO IN CCNJUNCTICN hJTH IHIS 
ACLTIfE. 

Tt-E CCUBLE PRECISICN VERSICN CF THIS SC8RCUTINC PI.ST AISC 
CCMAU CCUBLE PRECISICN FCRIRAN FLNCTICNS. SQA I 
85, SC. 114. 132. ANC 134. MUSI EE CHANGEC TO DSCRT. 



UniJLllATICIt 

lER-C 

NfC"C 

NS1EFI3I-C 

ANSOI-C.C 

USTCF-C 

EiIfR'5!*tJ^i<:r-fic^^• *'•''"* °^ "RUBLES TO EE FORCED TO l\ll[ 
ENTER IN Ih€ REGRESSION. AhC NUMBER CF VARIABLES IC BE OELETED STPftI 



CC 3C l-l,P 

1L(I J*l 

IFMCXin 3C, 3C. IC 
IC IfllCJKU-il 15, iC, 2 
1! »FC-NFC*1 

icxff rci-i 

CC TC it 
2C kSIEFI31-NSIEPUI*l 

iLIIJ>-l 

CC IC 3C 
2! MV-l 



STPR1270 
STPR12B0 
STPR 1290 
SIPR1300 
STPRIJIO 
STPRi320 
SIPR1330 
STPR1340 
STPR1350 
SIPR 1360 
STPRISTO 
IN STAIEPENTSSTPR1380 
STPR 1390 
STPRI400 

STPR14L0 

SIPR1420 
STPRt430 
SIPR1440 
STPR1450 
STPR 1460 
STPRI47C1 
STP«14aO 
STPR1490 

STMRI500 
SIPRI5I0 
SIPR1S20 
530 
5*0 
STPR1550 
STPR1560 
STPR1570 
SI PR 1 580 
SIPR1590 
SIPR 1600 
SIPR16I0 
ST PR 1620 
STPR 1630 
SIPR1640 
STPR1650 
SIPR1660 



42 Statistics— Correlation and Regression 



kSli'llI-" 

3C ecu 1*1.1 

kSIEP(SI-fFC 

tthL It-t P-^Xl^L* kLftmt CF 51£PS 

sum stuciiCK cf ttniein 



tC 14C n 

>c-c 

If (M-kfCl 



l.cx 



stitci k€«i »«i>i»eit ic EMef i'cko focto v»iii»etES 



3t Ct 5C l-I.KFC 
■ •lOIII 

iFiiKKii ic< ;c. «c 

4! tC-llE 

■c cchiit-Le 

ct K 1! 



• eitci kf«i K«ueu IC EMtt "cic kCk-fC«C€o v»«l»eies 



5! CC IC I'l.' 

irii-'<i tc. IC. «c 
6C IfULIIII >c. K. e< 
C< lVf-llt<l 

If-f'l 1-11*1 

(|.CUYH«CllVf I/C(IF1 
]F(f>C-OCI t^. IC. It 

£4 fC'OE 
KEk'l 

7C CCMlktt 



IISI iHM-lf Ikt PKCPCKIlCk Cf IHt SCK CF Si:t»«C! «"UCEC BY 
SfCCIFlEC PFCfOIlCK 
i; IFlflCI II. 71. It 

i« If i<i,:(ei-<«ks(3i<«C)iii.7i.iE 

JI ItH-l 

CC IC i:c 

IE FE-RC/lkStSI 

IFIFE-FCII lie. EC. EC 

II I! CliE<lt« ink " E'Cil 

EC ll(kCkI-C 
L<kL)*kEh 
«kSlll>AC 
#kSI2 )-FE 
<kSI3l-<kS(3l»«C 
^kSMI-FkSt^MOE 
kSIEPMI>kc 
kSIEf(5l'k£k 

COEIIE fctllPEE CCBUCtkllCk. F-»«LUE FC« «k«HSIS OF 

v«(UkC£. »m: snkH'O efikc" of tsiik«ie 

ti- JkSlEI- !CliIUkSI«>l 

FC'kl 

H£-CkP-F€ 

|iE-l<k!(!l-<kS(3l)/BE 

»kSHI-likS(2l/«C)/l<E 
«C <kSlEI- SCmiSEI 

CIUCE B» !►£ PIVCI«l EltrEH 

lF-P*lkEk'114kEh 
FC-CIIFI 
ilrF-kEfc-P 
CC ICC j-l.P 
ltf"ltf*k 

IFILLIJII ICC. SA, SI 
94 IF(J-kEH <(. ««. " 

St IJ-k*IJ-l*«J 

C(lJl-CllJl<C<LYfl«ClL»Pl/«ll 
«1 CdYf l-CdYF 1/«C 

CC IC ICC 
SI C(lfl'l-C/»C 
let CCkllklE 

CCrfCIE SECKESSICk CCtfflCItklS 

lYf«LY4kEfc 

t(MI«CUYPt 

IflM-11 IIJ. 112. 1" 

ic; iC"M-i 

tc lie J-I.IC 

IJ-kl-J 

UK-LIU) 

lYF-iY.I'l' 

tllJI'CllYPI 

CC lie H-l.J 

IK-kl-K«l 

Pk-lllkl 

LVF*^* IfK-l >««k 

lie eiiJi'£iiJi-c<i-'F)»til«l 

CCt-FLlE IMEBCCPI 

iij <ksisi-»e<i'iPYi 

CC 115 1-1. kl 

K«-tlll 

»I.SISI-»k5l51-B(ll«>E»«l«kl 

|J.f*|KK-l)«Kk 
114 SIII-<kSI«l" SCPIICIIJIl 
11* llll-Elll/SII) 

PECCCUCI. IC EtlMkAIE IKE HSI YAPUEIE EklESED 







FEffCBf 


t 




If, 


■^•i*th- 


11 






UC I>1 


if 




ig-i-f 








.Mh-» 






If < 


'lf*l 






iriLLdit 


III 


12C 




ilt j«l 


,fi 




ij-lJ*^ 





STrAl640 
$Tr«1700 
STPftlTlO 
$TP«L720 
STPftlT30 
STPRIT40 
S1PK1T90 
S1Pftl7«0 
STMIT?0 
STfAlTSO 
STPB1T90 
STPRISOO 

STPRIS20 

STfRUBO 

STPAia^o 

STPRietO 
$1P(tU60 
STP«l«70 
STPftlSflO 
$TP(tia90 
STPR1900 

srpfti9io 

S1Pftl920 

StP«l<)JO 

STPKI940 

STPI11990 

STPP1960 

S1PR1970 

STPRl^aO 

ST PR 1990 

STPR2000 

STPR2010 

srP«2020 

STPR2030 

SIPftZQAO 

S1PB20*0 

S1PH2060 

STPR207O 

S1PR2080 

ST PR 2390 

STPft2lOO 

STPt(21tO 

S1PR2120 

5IPR2130 

SIPB21*0 

STPR2150 

STPR2160 

STPR2170 

STPR2lflO 

STPR2190 

STPR2200 

STPR22IO 

STPR2220 

STPR2230 

STPR2240 

SIPR2250 

STPR2260 

SIPR2270 

SIPR228a 

STPR2290 

STPR2300 

STPR2310 

SrPR2320 

STPR2330 

STPR2140 

SIPR2)50 

STPR23eO 

S1Pft23T0 

S1Pft23flO 

STPR2390 

S1PR2400 

$TPR2410 

STPR2*20 

STPR2430 

STPH2**0 

$T^R2*50 

STPR2460 

STPR2*70 

SrPR24«0 

S1PR2«90 

STPR2900 

STPR2S10 

STPR2S20 

STPR2530 

STP«25'iO 

STPB2550 

STPR2560 

5IPR2570 

STPR2580 

STPR2590 

STPR2600 

STPR2610 

STPR2620 

STPR2610 

STPR26*.0 

STPR26S0 

STPR2660 

$TPR26T0 

STPR2baO 

STPR26'90 

SIPR2T00 

iTP«27lO 

STPR2720 

STPR2T30 

STP«27*0 

STPR2750 

STPtt2T60 

STPR2TT0 

STPR27BO 

STPR2T90 

STPR2800 

$TPR2fllO 

$TPR2820 

STPH26W 

STPR2a40 

STPR2SS0 

SIPR2S60 

STPR2B70 

$TPR2S80 

STPR2890 

STP«2'»0n 

STPft2910 

SIPRZIZO 

SIPfi2')10 

STPR2940 

S1PR2950 



IfUllJI) 12«< Hi' m 

Ui iftj->e*> 12*. 126, 12* 

12* t(lJi-CUJ»-Clll*l«C«H(» 
12< CC».ll^t.E 

CClfl-ClIf 1/1-RCI 
I3C CCf 1 IKLC 

#CJ(.n St#KC»Kt tRRCB Of in ES1l^*1C P^C 

ccfcfricithi 

RC-f-f'SltH^t 

Pi "'s(IC)"tRIll.c-ll.c-*^sul•*^s(tll•RC) 
cm ^^t uipii sieRctii^E 

C*tl Sl(.\.t IKSTtP.MS.t.e.S.I.kSICPI 

US1 hfrEUlO thE S1fP-*ISt RCCBCSSIO* fc«S 
SCBRCUIIKE SICUT 



IFIkSTCn 


1«C. 


14C. 


1>0 


1«C tCkllME 








1>C PCItPk 
EkC 









SIP«2<1«0 
iTp«2q70 

SIPt24«0 
STPR2990 
StPRlOOO 
SIPRIOIO 
STPH3020 
SIPR3030 
fLLllFLE CCRR€l*TIO« STPR30*t) 
$TPR3050 
SI PA 3^60 
, ST PR 3070 

STPR30aO 
STPR3090 
STPRJIOO 
STPR31I0 
$TPR3120 
$TP«3130 
STPR3140 
fERMIh*1E0 IN STPR3150 

STPR31&Q 
STPR31T0 
STPR)180 
STPft3l90 
STPR3200 
STPR3210 
STPft32Za 
STPR3230 



Statistics — Correlation and Regression 43 



Subroutine PROBT 

This subroutine obtains maximum likelihood esti- 
mates of a and b for the probit equation Y = a+bX. 
An iterative scheme is used. The input to tlie sub- 
routine consists of k different levels Xj^, X2, . . . , X. 
of a stimulus applied to Nj, N2, . . . , Nj^ objects with 
Rl, R2, . . . ,Rk responses respectively. The proce- 
dures described here assume that the distribution of 
critical values is normal. The computational steps 
are as follows: 

1. Compute the proportions of objects responding 
to various levels of a stimulus: 



P. = cimiulative normal distribution value 

corresponding to Yj^ - 5 
Q. = 1 - P. 

b. Working probit: 

For Y.S5.0 
1 



y.=Y.-^+p.-J- 

1 1 



For Y. >5.0 

1 



(6) 



R. 



N. 



(1) 



where i = 1,2, . . . ,k are levels of a stimulus. 

2. Compute the initial estimates of a and b for the 
probit equation, Y = a+bX, as follows: 






m 



m /m \ 2 

_4 , 



(2) 



S^'lS^^'i 



a = Z - bX 



(3) 



where Xj = ith level of a stimulus 

Zj = 5 plus the standard normal variable 
corresponding to Pj 

m = numiber of p values which are not equal 
to 0.0 and 1.0 
3. Compute values of expected probit using the 
initial estimates of a and b: 



Y. =a + bX. 
1 1 



(4) 



yi=^i-^5^-<i-Pi)^ 

1 i 



5. Compute: 



i=l 



i=l 



So =y] N. W.X.y. 
1=1 



k 

1 

i=l 



g^iVi &i%yi 



k 

E 

i=l 



(7) 



t 

k \ Z-/ N.W.X. / 

EN.W. 
. , i i 



X] N.W. 



i=l 



(9) 



3 -^ i i'^ i k 

1=1 v-^ 

> , N.W. 



(10) 



where i =1, 2,, ,. ,k 

4. Corresponding to each value of Y, compute 
the following: 

a. Weighting coefficient for probit analysis: 



6. Compute new estimates of a and b for the 
probit equation: 



b =- 



(11) 



D 



W. 



i P. Q 
i ^i 



(5) 



where D. = density of the normal curve corre- 
sponding to the standard normal vari- 
able Yi - 5 



2^ N Wy y^ N.W.X. 

T^ 111 .''— ' 111 



i=l 



i=l 



i=l 



k " k 

Z^NW y^ N.W. 

rrr' 1 1 ,^ 1 1 



i=l 



(12) 



44 Statistics— Correlation and Regression 



7. Compute new values of expected probit and 
compare them against the values computed in the 
previous iteration: 



Y'. = a + bX. 
1 1 



DSQ = 2 (^i - ^')' 
i=l 



(13) 



(14) 



If the difference between two consecutive values of 
DSQ is less than or equal to 10"'^, go to step 8 and 
compute X^. Otherwise, set Y. =Y.', where 
i = 1, 2, . . . , k, and go back to step 4 for another 
iteration. 

8. Compute X2 for the test of the final probit 

equation: 



k 2 

Ji (R. - N.P.) 

~4-i N.P. (1-P.) 

1=1 11 1 



(15) 



where P. = cumulative normal distribution value 
^ corresponding to zj 
z. = (a+bX.) - 5 

a and b are computed for the final probit 



equation. 
9. Degrees of freedom for X : 



d.f, =k -2 
For reference see: 

(1) M.G. Natrella, Experimental Statistics - 
NBS Handbook 91 . National Bureau of Standards, 
1963, chapter 10. 

(2) D.J. Finney, Probit Analysis (2nd ed.). 
Cambridge University Press, 1952. 



(16) 



SUSROUT Ih6 PROBT 

PUP POSE 

»0 OBTAIN MAXIMUM LIKELIHOOD ESIIMAIES FOR THE PARAMeTERS 
AND B IN THE PROBIT EQUATION V = A ♦ BX. AN ITERATIVE 
SCHEME IS USCO. THE INPUT TO THE SUB^OUTlNt CONSISTS OF K 
DIFfERENT DOSAGE LEVELS APPLIED TO K GROUPS OF SUBJECTS. 
THE NlWBtR Of SUBJECTS IN £*CH GROUf RESPONDING TO THE 
PESPECTIVE DOSAGE Of THE OCUG. 



USAGE 

CALL PCDBT tK. 



.LUG.ANS. 



PR06 

.pRoe 

pBoe 

PROB 
PROB 
PROS 
PROB 
PROB 
PROB 
ANOPROB 
PROB 
PROB 
PROB 
PROB 
PROB 
PROB 

DESCRIPTION OF PARAMETERS PROB 

K - NUMREa OF DIFFERENT OOSE LEVELS OF THE DRUG. K SHOULDPBOfl 

BE GREATER THAN 2. PROB 

K - INPUT VECTOR OF LENGTH K CONTAINING THE OOSE LEVEL OF PR06 

THE DOUG TESTED. K MUST BE NON-NEC ATI WE . PROB 

S - INPUT VtCTQR Of LENGTH ¥. CONTAINING THE NUMBER OF PROB 

SUBJECTS TESTED AT EACH DOSE LEVEL PROB 

R - INPUT VECTOR OF LENGTH ic CONTAINING THE NUMBER Of PROB 

SUBJECTS AT EACH LEVEL RESPCNDING TO THE DRUG PROB 

LOG - INPUT OPTION CODE PROB 

1- IF IT IS DESIRED TO CONVERl THE DOSE LEVELS TO PROB 

COMMON LOGARITHMS. THE OCSAGt LEVELS SHOULD BE PROB 

NON-NULL IN THIS CASE. P^OB 

0- IF NCj CONVERSION IS DESIRED PROB 

ANS - OUTPUT VECTOR OF LENGTH *» CONIAIMNG THE FOLLCHiNG PROB 

RESULTS P^OB 

ANSI II- ESTIMATE Of THE INTERCEPT CONSTANT A PROB 

ANS(21- ESTIMATE OF THE PROBIT REGRESSION COEFFICIENT PROB 

B PROB 

ANS(3)- CHI-SUU4R6U VALUE FOR A TEST OF SIGNIFICANCE PROB 

CF THE FINAL PROBIT EQUATION PROB 

ANSI*!- DEGREES OF FREEDOM FOf THE CHI-S(JU*«E PPOB 

STATISTIC PRoa 

Wl - OUTPUT VfCTCR OF LENGTH K CONTAINING THE PROPORTIONS PROfi 
OP SUBJECTS RESPONDING TO THE vaSIOUS DOSE LEVELS OF PPOB 
THE DRUG ^^^^ 

W2 - OUTPUT VECTOR OF LENGTH K CCNTAIMNG THE VALUES OF THEPROB 
EXPECTED PRC8IT F0(^ THE VAF 1 OtS LEVELS CF A DRUG PPOB 

lER - 1 IF K IS NLI GREATtR THAN 2. PROB 

2 IF SOME DOSAGE LEVEL IS NEGATIVE, 0« IF THE INPUT PROB 

OPTION CCiOE LOG IS 1 AND SUME DOSAGE LEVEL IS ZECQ. PPOB 



3 IF SOME ELEMENT OF S IS NOT POSITIVE. 

4 IF NUMBER OF SUBJECTS RESPONDING IS GREATER THAN 
NUMBEP OF SUBJECTS TESTED. 

ONLY IF ItR IS lERC IS A PROBIT ANALYSIS PERFORMED. 
OTHERWISei ANS, Wl, AND W2 ARt iET IC iERD. 



THE PROGRAM HILL ITERATE ON TnE PROBIT EQUATION UNTIL 
SUCCESSIVE SOLUTIONS P^^ODUCE CHANGES OF LESS TH«N 10* 

SUBROUTINES AND FUNCTIGN SUBPROGRAMS REQUIRED 
NDTS 
NDTRI 



METHOD 

REFER TO 0. 
1952 1 



J. FINNEV, PROBIT ANALYSIS. 2N0 fD, (CAMBRIDGE. 



SUECUUTINE PROBT ( K.X. S, R . LOG, ANSt hi ,W2, lEft I 

Ul MENS ION Xll).S(ll,Rlll,ANS(t>TMttII.H2I13 

TEST WHETHER LOG CONVERSION IS NEEDED 

IEP=0 

IF(K-2»5i 5,7 
lER = 1 
CO TO 90 
DO ft I'l.K 
If <X( I ) I 12.8,6 
CONTINUE 

IFUOG-ll 16. 10. 16 
i 00 15 1=1, K 
lF(X(i 1)12,12.14 
lEfl = 2 
GO TO 90 

XI 11= ALOGlOt X( I I ) 
CONTINUE 



PROB 
PROB 
PFOB 
PROS 
PROB 
PSQB 
PROB 
PROe 
PROfi 
PflOB 
PROB 
PHD6 
PROB 
PROB 
PROe 
PROB 
PPOB 
PROB 
-PROa 
PROB 
PROB 
PROB 
PflOB 
PROB 
PROB 
PROB 
PROS 
PROB 
PROB 
PROB 
PROB 
PROB 
PROB 
PROB 
PROB 
PROB 
PROe 
PROB 
PROB 
PROB 



100 
110 
120 
130 
I'^O 
150 
160 
170 
180 
190 
200 
210 
220 
2 JO 
2*0 
250 
260 
270 

2ao 

210 

300 
310 
320 
330 
340 
350 
360 
370 
380 
390 
400 
410 
420 
430 



490 
500 
510 
520 
530 
540 
550 
560 
570 
580 
590 
600 
610 
620 
6 30 
640 
650 
660 
670 
660 
690 
700 
710 
720 
730 
740 
750 
760 
7T0 
7S0 
790 
BOO 

aio 

620 
830 
840 
850 
B60 
8T0 



Statistics— Correlation and Regression 45 



COMPUTE P«OPO«TIOhS Of OBJ£CrS H6SO0NOINC 

16 00 U l«l,K 
IFIS(I)-«1I1I 1T,18|IB 

17 lER-^ 

GO TO 90 

18 CONTINUE 

20 -00 23 I'UK 

IF(SCI 1121.21.22 

21 l€R=3 

GO in 90 
12 Kid t'OT I 1/SI II 
2 3 CONTINUE 

C0HPUT6 INITIAL ESTIMATES OF INTEFCEPT AND PROBIT PECRESSION 
CO£Ff ICIENT 

WN'O.O 

xe«R=o.o 
SNwy=o.o 
SXK=0.0 
SXY=0.0 

DO 30 1=1, K 

P>U11 I ) 

IFIPI 30. 30. 2* 
2* IF(P-l.O) 25. 30. 30 
25 HN=HN+1.0 

CALL NDTBl IP.Z.O.ieP) 

Z=Z*5.0 
XeAR«XBAP«X< I I 
bNMY"SNWY«Z 
&XXiSXX*X( I l**2 

sxY=sxr*x(i i*z 

30 CONT INUE 

B=l SXY'-(XBAR«SNHYI/WNI/(SXX-I XBAR*XfiARl /HNl 

XBAR-XBAR/MN 

SNWY = SNWY/'WN 

A=SNWY-B*X8A« 

00=0.0 

COMPUTE fcXPECTED PROBIT 

00 31 1=1. K 

31 H2n ) = A*B*X1 I ) 

33 SNW=0.0 
SNWX^O.O 
SNWy=0.0 
SNWXXi-O.O 
SNWXY=0.0 
00 50 r=l,K 

r=w2(n 

FIND A WFIGHTING COEFFICIENT FOR PROBIT ANALYSIS 

O-Y-5.0 

CALL NOTF IDtPtZ) 

U=1.0-P 
W=(Z*ZI/IP*QI 



pROB eao 
PROe 090 
PR OB 900 
PAOe 910 
PflOe 920 
PROe 930 
PROB 940 
PR06 950 
PROe 960 
PROB 970 
PROB 980 
PROB 990 
PPOBIOOO 
PROBlOtO 
PROB 1020 
PROB 10 30 

pRoeio^o 

PR0B1050 
PROBlObO 
PR061070 
PftOBlOaO 
PR0B1090 
PROBUOO 
PR06I1 10 
PROB 1120 
PRDeU30 
PROBUOO 
PR0B1150 
PR081160 
PROB t 170 
PROS U 80 
PRn8U90 
PRDBI200 
PROB1210 
PROB1220 
PROB1230 
PROei2«0 
PROBliSO 
PR0&1260 
PR0ei270 
PRQ812aO 
PR061290 
PROB I 300 
PROB 1 3 10 
PP 061320 
PROB1330 
PR0613*0 
PPO61350 
PR061360 
PROB1370 
PfiCBUflO 
PR0B1390 
PR0B1400 
PR08H10 
PR091420 
PRQB1*30 
PR0BU40 
PR061<i50 
PRQBl^fcO 
PROei^TO 
PR0B14B0 
Pft0eiA90 
PR061500 
PR0BL510 
PROB 1520 
PROB1530 
PROB 1 5*0 



Cn««PUTt WORKING PROBIT 

IFIY-5.01 35, 35, 40 
3t. WP = ( V-P/21 *wt 1 I I/Z 
5D TO « 

*iO t«p-( Y^Q/ii-d.o-wm M /z 

SUM INTEFMEOIATE deSUCTS 

AS *.N=H*S( I 1 
SNM=SNM*WN 
SNMX = SNWX*HN«XI I 1 

ShWY=SNfciY»WN«WP 
SNUXX=SNMXKtHN*X( 1 )«>2 

50 SNWXy=SNWXy»WN*xn l-fcrP 

COMPUTE NEW ESTIMATES Of INTERCEPT ANO COEFFICIENT 

ItAR-SMWX/SNtf 

^XX- SNI»Xa-( MtakI • ( MMK I /Shu 
SaV>SIIUIlt-(SHWII*(SNHVt/S«U 

A-SN«V/&«Ui-e«X6M 

EKAHtNC iHf CHAMCtk 1*1 V 

SKX-0.0 

DO 60 1-1, K 

V-A«S*Xfll 

0«H2(1I-T 

SXX-tJ[X4'O«0 
60 H2(|I*V 

IFtI USIOO-SXK* I-41.0E-T1 I 
4 3 bO-SXI 

fiO TO 93 



•S. A). 63 



STOUt INfERCC^r AMD COCff ICIENT 

«4 ANSI 1 1 -A 

ANSI2)>8 

COHMiTf CMI-SQUME 

*NSI>)-0.0 
00 TO I*l.K 
V-II2UI-5.0 

CALl MOTIt (¥4^,01 

•A-P(1I-51II«P 
00-SIII*f*t 1.0-*l 
70 AMSOI-ANSISI+AAVU/OO 

DCCItECS OF FMEEOOH FUR CMl-MUME 

ANSI4I-K-2 

80 ftCTVHN 

40 OC 100 I-l,ft 

HKII-O.O 
100 H2(i»-0.0 

00 110 1-1.4 

110 ANsin-o.e 

CO TO to 

EMO 



pRoeisso 

PR0ei560 
PR0B15T0 
PROBlSBO 
PROB 1590 
PROS 1600 
PROB 1610 
PROdl620 
PRnBl630 
PR0B1640 
PR0B1650 
PROB 1660 
PR0BI670 
PROB I 680 
PRC1B1690 
PR0B17OO 
PR0B1710 
PR061720 
#M>aiTM 

nuMlTM 

PMMITM 
MCMITftO 
MI0BIT7* 

»«MIWO 

M0*l«20 
fWMUM 

MoaitM 
mtoaiMo 
pRoataro 
noftftMO 

MUM1890 
MHMI400 

ntosivio 
r«o»tv20 
rmisi^io 

MfMtVW 
MUWIVMI 
PR0ai«40 

p«oai««o 

MCMIWO 

pffoanMO 

raCMMLO 

»«oa»i20 
pRocn»o 

PftOU040 
MKM20S0 
MIOC20M 
»«O«2«T0 
fM»2O«0 
P«oa209O 

raoaiioo 

P1UM2110 
pRoazizo 
P«0B21M 
MttM2t«0 
PWWZI50 
MO«2140 
MCM2IT0 

Moaiiaa 

PMM2200 

*«oa22ia 



46 statistics — Correlation and Regression 



Canonical Correlation 

In the Scientific Subroutine Package, canonical 
correlation analysis is normally performed by 
calling the following five subroutines: ' 

1. CORRE - to compute means, standard devia- 
tions, and correlation matrix 

2. MINV - to invert a part of the correlation 
matrix 

3. EIGEN - to compute eigenvalues and eigen- 
vectors 

4. NROOT - to compute eigenvalues and eigen- 
vectors of real nonsymmetric matrix of the form 
B-1 A 

5. CANOR - to compute canonical correlations 
and coefficients 

The subroutine CORRE works in either of two 
ways: (1) it expects all observations in core, or 
(2) it triggers a user-provided input subroutine, 
DATA, to read one observation at a time into a work 
area. In either case, the user must provide a sub- 
routine named DATA (see "Subroutines Required" in 
the comment cards description of subroutine CORRE). 

Subroutine CANOR 



«ii ^2 



^ = ^21^ 



(3) 
(4) 



The subroutine NROOT calculates 

eigenvalues (X.), with associated eigenvectors, 

of R-1 A, where i = 1, 2, .... q. 

For each subscript i = 1, 2, . . . , q, the 
following statistics are calculated: 

Canonical correlation; 

CANR = yj Xj 

where \^ = i^" eigenvalue 
Chi-square: 



5 (p + q + 1)J log^A 



X^ = - [n-0 
where n = number of observations 



(5) 



(6) 



This subroutine performs a canonical correlation 
analysis between two sets of variables. 

The matrix of intercorrelations, R, is parti- 
tioned into four submatrices: 



R 



r^i 


^2] 


L^i 


^2] 



(1) 



R = intercorrelations among p variables in 



R 



12 



the first set (that is, left-hand variables) 

intercorrelations between the variables in 
the first and second sets 



R„, = the transpose of R 
21 ^ 12 



R 



22 



intercorrelations among q variables in the 
second set (that is, right-hand variables) 



The equation: 



rJ' R , R,^ R,„ - XI 
22 21 11 12 



= 



(2) 



is then solved for all values of A, eigenvalues, in 
the following matrix operation: 



A = II. (1 -X.); 
1=1 J 



Degrees of freedom for x : 

DF = [p-(i-l)] [q-(i-i)J 
i set of right-hand coefficients: 



k ki 



where v = eigenvector associated with X. 

k = 1, 2, . . . , q; 
i"-" set of left-hand coefficients: 



q 

1 

k=l 



E V \ 



^j CANR 



where \ t., i = T= R~ R,„ 



1 



1, 2, ,.., p 



(7) 



(8) 



(9) 



Statistics — Correlation and Regression 47 



triCUI INt C4Mjr< 



CUHi'UTE THc i.ANU.MiCAL CJKKfcL*TlUNi btlWtEN TwU SETS OF 
VAKlAdLtS. t-ANUH li NJRMAILY PfittfcL/tO 

rut co«K[. 



All to suc^kou- 



lAM,CAN«,CH1 SO.NL>f .COfcfK 



JciCRiPTJUN Ot PARAHeT;:«S 

N - NUMOc« Of (JjbtRVAF lUNS 

rfP - iML/HScR Of Ltfl HArtl> VA^lAbLti 

MO - NUMtitK Q^ RIGHT HANu tfwKIAiJLES 

RK - IhPufl MATHIX iJMy UCPfcR TRIANGULAR HUKTION Of TH£ 

SV.IMtlKiC MATRIX Uf^ H K M, WHtHt M = HP . My | 

CONTAiHiNG CURRtLATIUN CUfcf F IC 1 ENTS. (Sfu^AGE MODE 

OF Jl 
-tl.uTS - UUTPUT VECTOR Of L thGTH HU CONTAINING tliicNVALUtS 

CQHPUTEO IN IHt NRJUT SUBHOUTINE. 
-.LAM - uUTJ-jr veCTUR Of L£NoTH mQ CONTAINING iArtSOA. 
CliNx - UUTt-iJT VECTOR OF LfcN&fH hU CONTAINING CANONICAL 

CUflRtLATiONS. 
CMlSg - OUTPJT VECTOR OF LcNGTM NQ CONTAINING THt 

WAlUES of CHI-iOUARt5. 
tiUF - DUrPJI VtCTOR OF LENGTH HU CONTAINING THE DEGREES 

Of ftteeoOM ASSOClATtO kith CHI-SOOARcS. 
CCtFk - OUTPUT MATRIX ^HQ X MO) CONTAINING MQ SfTS OF 

RIiiHr HANii COtFflClENri COLUMNWISE. 
COtFL - UUTPjr MAIRiX CMP X HJ) CONTAINING MQ S£ I s Of 

Ltf^T HAND COtFf ICItNFi COLUMNWISE. 
R - WORK MATRIX IM X rtJ 

REMAR^b 

Tht NUrtBcK JF LEFT HANJ VARIAtiLti (MPI SHOUCO dc GREATER 
IMAN OR cUUAL lO THE NJMStR OF RIGHT HANu VAR|AcH.£S ( MQ ) , 
IHt VAlUcS Of CANONICAL CORRELATION. LAMSOA, CHl-SQUARE. 
JEGRttS Uf fREfcOOH, ANJ CANONICAL COEFFICIENTS ARE COhPUTEO 
3NLr FOR THOSC eiGE.VVALUFS IN AOOTS WHICH ARE GREATER THAN 
ItM. 

SUBROuriNES AWO FUNCTION SUBPKOCiKAMS REQUIRED 

■ilNV 

NRJOI {i^HlCti, IN TURN, CALLi fht SUBROUTINE EIGEN.) 

HtTHOO 

RfcFcH TO W. H. COOLcT ANJ P. R. L0HNE5, 'MULT 1 '/ARI ATE PRO- 
CtLtURES FUR THif BEHAVIORAL SCIENCES', JOHN WILEY AND SONS, 
19o2, CHAPTEr* 3. 



SOSROUTiNt CANOR (N,MP,MQ, RR.ROOTS, WL AH,CANR ,CHI SO. NDf ,CO£f R, 
I CO£FL,RI 

01 MENS 10^ RRU»,R00TS(U,«tAH(il,tAN«Ul,CHISQ(ll.NOflll,COEFRIil 

1 caefnutRcii 



IF « JOUilLE PRECISION VERSION OF THIS ROUTINE IS OESIR£0, THE 
C IN COLUMN 1 SHOULD bt REMOVED FROM THE DOUbtE PRtClSION 
SIATEMcrtr NHICh FOLLOWS. 

UUUiiLL PR^:i$ION RR, ROOTS, WLAM.CANR.CHJSQ.COEFR.COEFL.R.DET, SUM 

THE C HOST ALSO 8t' REMOVED FROM DOUBLE PRECISION STATEMENTS 
APPtAriL^G IN UTMEk RUUTIi^lS UScO IN CONJUNCTION WITH THIS 
^ JU T I :^c . 

THd OOJdLE PRcClSlON VERSION OF THIS SU6«0uTINt MUST ALSO 
CONTAIN OOJBLc PRiECISIJN FORTRAN FONCTIONS. SORT In STATEHfiNT 
Lbb rtJST dt Cri&MGtSi TO OSJRT. ALOG IN STATEHENT ITS MUST BE 
CHANGcJ TO OLJG. 



PARIirjON INTERCORRELATIunS AMQi^G left MANO VARIABLES, BETWEEN 
LEFT ANO ilGHT HANJ VARIABLES, AND AMONG RIGHT HAND VAAIABLtS. 





Dfi 


105 


Ul,H 




00 


Kb 


J = 1.M 




IFI I-J) 


132. 103, 103 


10? 


L=l 


[+(j« 


J-J)/2 




yO 


TJ 1 


:-4 


ICi 


L=J*(1* 


l-I)/2 


iU4 


NI = 


= Ni*i 




105 


R(N1MRR(LJ 




L = MP 






t>0 


I'Dd 


J=^.MP 




Nl^ 


= H«( J 


-il 




00 


108 


I=i,MP 




L = L*l 






Nt = 


'Nl*l 




lOB 


R(L}=R(N1I 




N2^ 


^MP*1 






L = 






00 


110 . 


J=N^,M 




NI^ 


■!^*li 


-I) 




JJ 


no 


I=i,MP 




L-L*l 






Nl = 


^Nitl 




IK 


COEFLIL 
L=C 


1=R(N1) 




00 


123 


J^.-i2,H 




NP 


'M«l J 


-IW^P 




00 


liC 


I = \2 , M 




L^L*l 






ftl = 


Ni*l 




l^C 


CL'E 


F'<(l; 


I=R1NIJ 



;a.^unical muATiCN 



L=MP*MP*1 

H^LtMP 

CALL Ml NV (ti,MP 



C Af.U i t 
.CANO ^C 
CANu 30 
CANO 40 
CANU 5Q 
CANO 60 
CANO 70 
CANO 60 
CANU 90 
CANO lUO 
CANU lie 
CANO 12C 
CANU I3G 
CANO MO 
CANO 150 
CANO 160 
Canu 170 
CANO 180 
CANO 190 
CANO 200 
CANO 210 
CANO 220 
CANO 230 
CANO 240 
CANO 2 50 
CANO 260 
CANO 270 
CANO 2^0 
CANO 290 
CANO 300 
CANO 310 
CAMO 320 
CANO 330 
CANO 340 
CANO 350 
CANO 360 
CANO 370 
CANG 380 
CANO 390 
CANO 400 
CANO 410 
CANO 420 
CANO 430 
CANO 440 
CANO 4i>0 
CANO 460 
CANO 470 
CANO 4ao 
CANO 490 
CANO 500 
CANO 510 
CANO ^20 
CANO 530 
CANO 540 
.CANO 550 
CANO 560 
CANO 5 70 

CANO sao 

fCANO 390 
CANO 600 
CANO A 10 

.CANO 620 
CANO 6 30 
CANO 640 
CANO 650 
CANO 660 
CANO 6 70 
CANO 6S0 
CANO 690 
CANO 7 CO 
CANO 710 
CANO »20 
CANO 730 
CANO 740 
CANO 750 
CAM) 760 
CANO 7 70 
CANO jao 

.CANO 790 
CANO BOO 
CANO a 10 
CANO 820 
CANO 8 30 
CANO 640 
CANO 850 
CANO 860 
CANC 8 70 
CANO S80 
CANO S90 
CANO 900 
CANO 910 
CANO 920 
CANO 930 
CANO 940 
CANO 9 50 
CANO 960 
CANO 970 
CANO 9a0 
CANO 990 
CANOIOOO 
CANOIOIO 
CANOI02C 
CANU1030 
CAN01C40 
CANO1050 
CANOIObO 
CAN010 70 
CAN0108Q 
CAN0109C 
CANOllCC 
CANOUlO 
CAN01I20 
CANOlliO 

CANIJllSO 
CANJUbC 
CAN01I7C 
CAN0I18C 
CAN01I90 
CANO1200 
CANG1210 
CAN01220 



>_AL;jL\lt I - 

JO l-rC 1 = 1, MP 

■M2-0 

JU IJJ J--1,MJ 
\l = l-Hil 

«OJTStJ)-0.0 
UU IJU K=ttMP 
Nl: Vl»HF 

RuoISI J J =RujTS( Ji 

CO 141. J=l,MJ 



< INI l*CUEFC(M2l 



calcol aFl a = r^ I • r 

L=MP*MJ 

N3=L*I 

00 160 J=l,MlJ 

M=0 

OO I<>C I=1.nC| 

N2=MP*( j-1) 

SUM=0.0 

UU iSD K=1,hP 

f41 = Nl*l 

N2=N*'*I 
I5L SUM=SUM*CUEFL(N1)«R(N21 

L = l«l 
16C R(L>=SJM 

cALCULmTL tlyt.Nl/ALUES WITH ASSOCIATED EIGENVECIJRS Of THE 
iNVtRSc OF R2^ • A 



«J,R(NJ),C0EFR,R0J1S,R(L» J 

1. 2. .... HJ, CALCULATE THE FOLLOWING 

00 2iC 1=1, MQ 
C 

C TEST WHtT^1ER cIGENVALUE IS GRcAT£R THAN ZERO 
C 

iF(RUOTS(l)l ^^0, 220, lo5 

c 

L CANONECflL CORRELATION 

C 

lo!J LANR(1I= 3u«I(R0UTS(in 

L 

WLAM( 1 I =1.0 
LO 1 7C j= I rHiJ 

I7C wLA.M(n=.JLAMm*ll.O-RCJCTS(J)) 

FN=i>( 
FMP=MP 
fHO=MJ 
1?5 tHi5JliJ=-(fN-C.5*( FMptt-Mu+l.OI I *ALOG( WLAK (IJ I 

; JtGREtS UF FRtEJOM FOR CHI-SJUARE 

Nl=I-l 

NDF(II=If^P-NU*IMg-NI) 

l-TH SET OF RIGHT HANU COEFFICIENTS 

N1=HU»( I-l) 
K2=H0»( I-ll+L-i 
00 IBC J=l,MJ 
Ni=Nl+l 
N2=N2*l 
IBC C0tPR|Nll=R(N2) 

I-TH StT OF Li:fl HAND COEFFICIENTS 

00 2:C -- I, MP 

M = J-MP 

N2=Hg*( I-l) 

K=M^»( |-1J*J 

COEFLIK,J=0.0 

CO 190 Jj=l,Ma 

M = N1*MP 

N<;=Nt*l 
19C C0£FL(KI=C'JefL(KI*RlMI»COtFR(N2 J 
200 CG£FL(»(I = CJEFcUI/CanR( IJ 
21C CONTINOt 
Z2C kETukN 

LNO 



CANO 1 2 iO 
CANU1240 
CANO 1 2^0 
CANCt260 
CANO1270 
CANUI2e3 
CAN01290 
CAhOI30C 
CANai3I0 
CANO1320 
CANOI330 

CANUt 340 

CAN01i50 

CANOU60 

CANOliTC 

CAN01380 

CANU1390 

CANai400 

CAN0141Q 

CANOI420 

CANO1430 

CAN01440 

CANO1450 

CAN014&0 

CANL14 7C 

CANai4S0 

CAN01490 

CANOI500 

CAN01510 

CAN01520 

CANai530 

CAN01540 

CAN01550 

CANO1560 

CANQ1570 

CAN01580 

CANU1590 

CANO1600 

CANQ1610 

CAN01620 

CANai6 3Q 

CAN0t640 

CANU16S0 

CAN01660 

CAN01670 

CAN016Q0 

CAN01690 

CAN01700 

CANQ1710 

CANO 1720 

CAN01730 

CAN01T40 

CANO1750 

CANO1760 

CAN01770 

CAN01780 

CANO1790 

CANOldOO 

CAN01810 

CANOiaZO 

CANO IB 30 

CAN0ia40 

CAN018SC 

CAN01U60 

CAN01B70 

CAN01B80 

CAN01S90 

CAN01900 

CAN01910 

CAh01920 

CAN01930 

CAN01940 

CANOL950 

CANOt960 

CAN01970 

CAN019aO 

CANO1990 

CANO2C00 

CANO20 10 

CANa2020 

CANU2030 

CANO2040 

CAN02050 

CANO2060 

«,ANO20r0 

CAN020S0 

CAN02090 

CAN021D0 

CAN02L10 

CANO2120 



48 Statistics— Correlation and Regression 



Design Analysis (see Smoothing, 
Factorization) 



Regression, 



jjLftt 



Jl i-S 



AViJAl 



In the Scientific Subroutine Package, analysis of 
variance is normally performed by calling the fol- 
lowing three subroutines in sequence: 

1. AVDAT - to place data in properly distributed 
positions of storage 

2. AVCAL - to apply the operators sigma and 
delta in order to compute deviates for analysis of 
variance 

3. MEANQ - to pool the deviates and compute 
sums of squares, degrees of freedom, and mean 
squares 

Subroutine AVDAT 

This subroutine places data for analysis of variance 
in properly distributed positions of storage. 
The size of data array X required for an 
analysis-of-variance problem is calculated as 
follows: 

k 
n = n (L. + 1) (1) 

i = 1 

where L = number of levels of i factor 
i 

k = number of factors 

The input data placed in the lower part of the 
array X are moved temporarily to the upper part 
of the array. From there, the data are redistributed 
according to the equation (4) below. Prior to that, 
multipliers, sj, to be used in finding proper posi- 
tions of storage, are calculated as follows: 



J- 1 

s = n (L. + 1) 
^ i=i 



(2) 
(3) 



where j = 2,3, . . . , k 

Then a position for each data point is calculated 
by the following equation: 



k 
3=2 



S = KOUNT + Z S. . (KOUNT. - 1) 

i = 9 



("LAcfc t>ATA FJ^ ANALYSIS OF VikUNCfe IN PftOPtHLY UlSIRIBUItU AVOA 
("USITlUNi :]f ifURAOt. THIS SUOftUUTlNt 15 NUtiMALL,? fUl.LO«tU AVOft 
BY LALIS IJ AVCAt AND MEANQ SUBROUflNti IN THt PtkfURMANCE 
iif AKALV:.1S UF VARIANCE fJR * CClHPttTfc FACTOklAL OtSlGN, 



USAG£ 



CALL mVJAT U.LEVtL.N.X.L.ISrtf.KUOnn 



AVCiA 

AVOA 
AVOA 
AVOA 
AVUA 
AVOA 
AVOA 
AVOA 
AVDA 
AVOA 
AVUA 



iwKIPIlON U? PARAMLICRS 

K - NUiiBtK OF VARlAEJLES IFACttJftS). K HUSI tl£ .GT. ONE 

LtVEL - iNPUr VcCrOK OF LtNtifH K COKTAINING LEVELS (CATE- 

iiOXKit t*!THlW EACH VAKIA6LE. 
h - TOrAL WUMefcR OF UAIA POINIS ktAU IN. 

X - iJHlN IHt SUBRUUIUt IS CALLED* THIS VcCTJR CONTAINS AVOA 

DATA IN LOCAriJNS X( 1 ) THMJUGH K(Nl. UPDN RE lURNI NG AVOA 

ro THc Calling roufinc. the vector contains the oataavoa 
IN PR3PERLV ReyiiFRiaumo tocATiuNS of vecior x- avd* 

THt LtNGTri OF VECTOR X IS CALCULATED liV (l» ADDING AVCA 
QNt TO tACH LEVcL Of VARIABLE ANO lit OBTAINING THE AVDA 
CJfWLATIVE PRtiJUCT Of «LL LEVELS. I THE LENGTH OF AVUA 

X = |L£VEL(ll*ll*<LEVCLI2l*lI*-..*(LeVtL(KI*l).» *VCA 

L - UUIPiiT VARIABLE CUNTAlNINfi- THE POSITION IN VECTOR X AVOA 

HNtKE THE LAST INPUT DATA IS STORED. AVOA 

ISTtP - UUTPJT VECTOR OF LENGTH K CONTAINING CUNfftOL STfPS AVO* 
i<HlCH ARE USED TU LOCATE MTA IN PRuPEK POSHiONS AVUA 
Uf VECTOR X. 
WOAMNU VtCTOR Of LENGTH K. 



KOUNT 

?,WUT UATA MUST BE ARRANGEJ Hi THt FOLLOWING MANNER. 
CONilOti* THE j-VARIABLE ANALYSIS W VARIANCE DtSlGN. MHErE 
ONE VAKIABlE has 3 LEVELS ANO THE OTHER TwD VARIABLES HAVE 



AVOA 
AVOA 
AVOA 
AVOA 
AVCA 
AVDA 
AVOA 



2 caVELS. THE DATA MAY BE KEPfttSfcNTEO IN THE FORM X< I , J,R) , AVDA 



I'^l.^tS J = i.2 K«l,2. IN A.*«A«iI|«& DATA, THE INNER 
iUbSCHIPT, NAMELY I, CHANGES FIRST. MHfcN 1=3. THE NEXT 
INN=ft SUBSCRIPT. J, CHANGES ANU SO ON UNTIL 1=3, J=2, AND 
K = 2. 

SUBtOUriNES A.sil) FUNCTION SUBPRQliRAMS RtOUIREO 

NCNe 

METHOD 

THE METHOi) IS BASEO ON THE TtCHNlQUt DISCUSSED BY H. O. 
riARTLLY IN 'MATHEMATICAL METHODS FOR DIGITAL COMPUTERS*, 
EDITED dY a. RALSTON AND ri. iJILFf JOHN HUEY AND SONS, 
l9o2, CHAPTER 20. 



SuaRnuTINE AWJAl IK-LEVEL, N.X.L.ISTSP.KOUNTl 
01 MENS I CN LEVELUI,X(U,1STEP(U.K0UNT(II 



IF A DUUdLE PRECISION VERSION OF THIS ROUTINE IS OfcSIREO. THE 
C IN COLUMN I SHOULD flt RtMUVtO (-ROM THE OOUBlE dhECISION 
SIAItMfcNT i*hICH FOLLOWS. 

DOUBLE PRECISION X 

TMc C MUST ALSO UE RcMOVtJ FROM JUUBLfi PRECISION STATEMENTS 
APPEARING IH OTHER ROUTlNtfS UScO IH CONJUNCTION WHH THIS 
ROUTINE. 



AVOA 

AVOA 
AVOA 
AVOA 
AVOA 
AVOA 
AVDA 
AVOA 
AVOA 
AVOA 
AVOA 
AVOA 
AVOA 
AVOA 
AVOA 



(4) 



CALCULAIfe TOTAL (lAT A AREA HfidUIRiO 

M=LtVELm*l 

00 1C5 1=2. K 

105 M=M*(LtVcL( Il'll 

HOVE DATA TO TriE UPPER PARI OF THE ARRAY X 
FOR THt PU.^POSl OF REARRANGEMENT 

N1=M*1 
N2=N*1 

DO 107 1=1, N 
Nl=Ni-l 
N2=N2-1 
IJ7 KlNI)=X(N£l 

CALCULATE MJLTIPLlcRS TO BE USEO IN FINOING STORAGE LOCATIONS FOR 
INPJT DATA 

ISIcPt 1(=1 

DO Lie 1=2. K 
11 C lSlEP(II»ISTtPU-ll-lL£VEL(I-ll*n 

DO 11^ 1=1. K 
115 KOUNT ( I )=1 

PLACt DATA IN PROPER LOCATIONS 

Nl=Nl-l 

DO IJi t=l,N 

l=KCUNT( 1) 

L*U Uj J^^iK 
12C L=L*1 SffcPt JI'lx.OJNr ( J t-I ) 

N 1 = N 1 ♦ I 

X(L1^X{M) 

00 liO J=l,«. 

IF(KUU.MT(J»-LcVEL( J)) 12^. 125. 124 
U4 KOUrtHJ»=<UUNT( Jl*l 

GO TO US 
U3 KUJNT(J1=1 
1 JO CUNTINJE 
I ji CiiNTlNjE 

END 



100 
110 
1^0 
130 
l<rC 
150 
160 

iro 

ISO 
190 
20C 
210 
220 
2 30 
2-*0 
250 
260 
2 70 

2 SO 
290 
300 
31C 
320 
ilO 
340 

3 50 
360 
3T0 
380 
390 
400 
*10 
420 
430 
44C 
450 
460 
470 
48C 
490 
500 
510 
520 
530 
540 

AVDA 550 
AVOA 560 
AVOA 570 
AVOA 5B0 
AVOA 590 
AVOA 600 
AVtyA 610 
AVOA 620 
AVOA 630 
AVDA 64C 
AVOA 650 
AVOA 660 
AVOA 670 
AVUA 660 
AVOA 690 
AVOA 700 
AVOA 710 
AVOA T20 
AVOA 730 
AVOA 740 
AVOA 750 
AVOA 760 
AVDA 770 
AVDA TBO 
AVDA 790 
AVOA BOO 
AVOA SIO 
AVDA 820 
AVDA 83C 
AVDA 840 
AVOA 850 
AVOA 860 
AVOA 870 
AVOA 800 
AVOA 890 
AVOA 900 
AVOA 9L0 
AVOA 920 
AVOA 930 
AVOA 940 
AVOA 950 
AVOA 960 
AVDA 970 
AVUA 9S0 
AVUA 990 
AVDAIOOC 
AVOAIOIO 
AVDAL020 
AV0A1930 
AVDAia40 
AVOA 10 SO 
AVUA1060 
AVUAia70 
AVOA1080 
AV0AL090 
AVUAUOO 
AVDAUIO 
AVOAU<!0 
AV0A1.130 

AV0AU50 



.th 



where KOUNT; = value of j subscript of the data 
to be stored. 



The subroutine increments the value(s) of sub- 
script(s) after each data point is stored. 



Statistics — Design Analysis 49 



Subroutine AVCAL 

This subroutine performs the calculus for the gen- 
eral'k-factor experiment: operator S and operator 
A. An example is presented in terms of k = 3 to 
illustrate these operators. 

Let x^jiQ denote the experimental reading from 
the a*^ level of factor A, the b**^ level of factor B, 
and the c™ level of factor C. The symbols A, B, 
and C will also denote the number of levels for each 
factor so that a = 1, 2, . . . , A; b = 1, 2, . . . , B; 
and c = 1, 2, .... C. 

With regard to the first factor A: 

operator ^—' = sura over all levels a = 1, 2, . . . , 
A, holding the other subscripts at 
constant levels, and 



operator i\= multiply all items by A and sub- 
tract the result of S from all 
items 



S 
a 



In mathematical notation, these operators are 
defined as follows: 



E 



A 



abc .be ^-^ "abc 

a a = l 



-E 



(1) 



A^ 



abc 



Ax 



abc 



- X 



be 



(2) 



The operators 2 and A will be applied sequentially 
to all factors A, B, and C. Upon the completion 
of these operations, the storage array X contains 
deviates to be used for analysis-of-variance 
components in the subroutine MEANQ. 



SUtKtOUTINE AVCAl 

*»UitPOSE 

PtAFURH TH£ CVCUlUS Of= A FACTOAJAL EK^CKIHENT USING 
Uf'EfUTCm il&MA AND OPEilArLtR D&LtA. ThI & %0tit^OiJXlHt IS ' 
PRtC£UEJ dY SUeAOuriHt AOVAr ANO t'OLLOWEO BV SUaROUTIN£ 
HEAHii IN THE PERFCfMANCE OF ANACYSIS OF VAAIANCE FOR « 
C(WPi.c:T(: FACrORI*!. UfcSI&N. 



20 
30 

AO 



TO 



CALL AVCAi, liCtLEVEL. 



XtL*ISrEP>LA$ISI 



AWCA 
.AVCA 
AVCA 
AVCA 
AVCA 
AvCA 
AVCA 
AVCA 
AVC A 90 
AVCA 100 
AVCA tlO 
AVCA 120 

AVCA no 

AVCA 1^0 
AVCA ISO 
AyCA 160 
AVCA I TO 
AVCA ISO 
Ave* 190 



JcSLRlPnUN QF PAKANtTEftS 

K - NJNBtft Of VARJASLES IFACTOII&). K HUSr BE .CT. ONE 

LEVEL - iMPUr VECrOft OF LEN&TH K CONTAINIKG LEVELS (CATE- 

GOAUSt WITHIN em;h VWIABU. 
X - INPUT Vector containihc oata. oata hAve been placeoavca zoo 

IN vector K eV SUSROUriNE AVOAT. the LEMCTH of X AVCA 210 
IS U£VELUI«ll*(LEV£L(2l>tl«...«|LEV£LKl»ll. AVCA 220 

L - Trtd POSITION In VcCTOR X WHERE THJE LAST INPUT DATA AVCA iJO 

IS LOCATEO. L HAS BEEN CALCULATES BY SuaaOUTIME AVCA 240 

*VUAT. AVCA 250 

ISTkP - INf>ur VECTOR Of LENGTH K CONTAINING STORAGE CONTROL AVCA 260 



STcPS WHICH HAVE BEEN CALCULATED |Y SUdftOUTIMC 
AVOAT . 
LASTS - UOAKING VECTOR OF LENGTH K. 

RtfrtAA<S 

THIS SUBROUTINE NUST FOLLOW SUMQUTINE AVOAT. 



AND HIMCTION SUaPROGRAHS REQUIRES 



SJSKOUTINtS 

NONc 

HtTHOO 

THE NETHOO IS dASbO ON THE TECHNIQUE OISCUSSEO BY H. O. 
HARTLEY IN *N ArHEHAFlCAL WfTHOOS FOK OIGUAL COMPUTERS- , 
EOtTEO 0V A. AALSTON ANO H. UlLff JOHN WILCY ANO SUNS* 
I9&^> CHAPTER 20. 



SUdftOUTINE AVCAL (<*t.£VEL*X.L, I STEP.LASTSI 
DIMENSION LEVELUI.XIll.ISTEPI 1 1. LASTS! II 



IF A OUUSLE PRECISION VERSION Of IHI $ ROUTINE IS OESlREO, THE 
C IN CULUHN 1 SHOULD BE REHOVtO FKON THE OOUSLE PRECISION 
STATENtNT WHICH FOLlOmS. 

DOUBLE PKtClSION XtSUH 

THE c MUST Also ae REnovEp fmuh oousu precisiom stajehents 

APPEARING IN 0IH6R MOUriNES USEU IN CONJUNCTION UITH THIS 

ROUTINE. 



C CALCULATE THC LAST OATA POSITION Of EACH FACTOR 

C 

LASTSII}>L*I 
OU U3 1 = 2. K 
145 LASTSd l>=LASTS( I'lMISTEPI I) 
L 
': PERFORH CALCULUS OF OPERATION 

ISC DO 175 1*1, K 
t«l 
LL-l 
SUN>0.0 
NN-LEV£L| II 
FN-NN 

INCHE-ISTEPIII 
LAST>LASTS(II 

: SICHA UPERAflON 

1^1> tXj loO J>1,NN 

SUH-SUN-l^XlLI 
16C L-L»INCRc 

GkLTA UPcHATION 

00 165 J=1.NN 

XILLI=FN*X(LL1-SU^ 
IbS LL = LL*tM:RE 

SOH^O.O 

IF(L-L*Sri 16T, 175, ITS 
ls7 IFU-LAST*InCREI 16B, 16t., l ?C> 
lot) t=L*lNCR-. 

LL=LL»IMCrtE 

GO TO l^b 
ITL L = L»If«lLKL*l-LASr 

LL - LL • 1 fJC KE • I -L AS I 

GU TJ 155 
1 /5 Cu.4TlNJt: 

KtTJRh 

EI40 



AVCA 270 

AVCA 2ao 

AVCA 290 
AVCA 300 
AVCA JIO 
AVCA 120 
AVCA 3)0 
AVCA 340 
AvCa 3S0 
AVCA )60 
AVCA 370 
AVCA 3ao 
AVCA 390 
AVCA 400 
AVCA 410 
AVCA 420 
•.AVCA 430 
AVCA 440 
AVCA 4M) 
AVCA 440 
AVCA 4 70 
..AVCA 4«e 
AVCA 490 
AVCA 500 
AVCA 510 
AVCA 520 
AVCA 5)0 
AVCA 540 
AVCA 5 50 
AVCA 560 
AVCA S70 
AVCA 5«0 
AVCA 590 
.AVCA 600 
AVCA A 10 
AVCA 620 
AVCA A JO 
AVCA 640 
AVCA 650 
AVCA 660 
AVCA 670 
AVCA 680 
AVCA 690 
AVCA 700 
AVCA 710 
AVCA 720 
AVCA 730 
AVCA 740 
AVCA 750 
AVCA 760 
AVCA 770 
AVCA 7«0 
AVCA 790 
AVCA aoo 
AVCA 8l0 
AVCA ^20 
AVCA 430 
AVCA 440 
AVCA 850 
AVCA a60 
AVCA 670 
AVCA 880 
AVCA 890 
AVCA 900 
AVCA 910 
AVCA 920 
AVCA 930 
AVcA 940 
AVCA 950 
AVCA 960 
AVCA 970 
AVCA 9«0 
AVCA 990 
AVCAI OCO 
AVCAtClO 
AVCALCI23 



50 Statistics — Design Analysis 



Subroutine MEANQ 

This subroutine performs the mean square operation 
for the general k-factor experiment in the following 
two steps: 

1. Square each value of deviates for analysis of 
variance stored in the array X (the result of the 
operators 2 and A applied in the subroutine 
AVCAL). 

2, Add the squared value into summation 
storage. In a three-factor experiment, for 
example, the squared value is added into one of 
seven storages (7 = 2"^- 1) as shown in the first 
column of Table 1. The symbols A, B, and C in 
the first column denote factor A, factor B, and 
factor C. 

After the mean square operation is completed for 
all values in the storage array X, the subroutine 
forms sums of squares of analysis of variance by 
dividing the totals of squared values by proper 
divisors. These divisors for the three-factor ex- 
periment mentioned above are shown in the second 
column of Table 1. The symbols A, B, and C in the 
second column denote the number of levels for each 
factor^ 

The subroutine, then, forms mean squares by 
dividing sums of squares by degrees of freedom. 
The third column of the summary table shows the 
degrees of freedom. The symbols A, B, and C 
denote the number of levels for each factor. 

Table 1. Table Showing Summation Storages, 

Divisors to Form Sum of Squares, and 
Degrees of Freedom (Subroutine MEANQ) 



Designation of Store 


Divisor [Required to 


Degrees of Freedom 


and of Quantity Con- 


Form Sum of Squares 


Required to Form 


tained in it 


of Analysis of Variance 
ABC- A 


Mean Squares 


(A)^ 


(A-1) 


(B)2 


ABC-B 


(B-1) 


(AB)2 
(C)2 


ABC-AB 


(A-1) (B-1) 


ABC-C 


(C-1) 


(AC)2 


ABC- AC 


(A-1) (C-1) 


(BC)2 


ABC-BC 


(B-1) (C-1) 


(ABC)2 


ABC- ABC 


(A-1) (B-1) (C-1) 



SJaKiXiTlNf HBAt*^ 

CtmfJTB SJM OF SUUAH£S« QEGHEES Of FKEEOON* AMO lUAN SOtMKE 
JS(N& THt IfcAN SQOAUt OUcHAfO*!.. THlS SU»ROUr|IC HOMULiT 
FOt.L0.4S CALLS JO AVOAr Anu AVCAL SUtAOUflNES IN THC ^E*- 
FOrtMANCE Of AHALY&IS OF VAKlAftCC fO« * CONfLETt: ^ACfOAIAi 
UcSlGN. 

USAiiE 

CALL HtANS (ikfLcVEL.K.CNtAN*SUNSQ,M>f *SNEAN«HST£'tlUlUNT« 
LASTS) 

OdSCKIpriON JF PWAMETEAS 

A - filiH^i* OF VARIABLES iFACrOASl* K HUSt dE .AT. ONE. 

LtVt:!. - IMf*U! VECrCM Of LiHCIH <C CWrAINlNG CEVELS fUfC- 
G0KI£S» WITHIM EACH VAKIAtLL. 

K - IN^UT VECrUK CJMTAXNIMt; TME AESULT OF THE SIGMA ANO 

OcLTA OPEAArjAi. rH£ LEMSTH OF I I S 
(L£tfELIll*I)*^(Lttf£L(2l«ll*...«(LeVEL4KMll. 

iiMcA.^ - OliTPjr VARIAULc CaMTAlNlfMS GRAND McAN. 

suH^j - ouTpjr vECTOH lohtaihIhh ami of squares, ihe 

L£N«^rH OF SOMS^J IS 2 fO THE K-TH POMEA MINUS ONE* 
*2**A»-J. 

Hjf- - jurpur vector containinc ae&rees of frceoon. the 

LENGTH Of HOf IS ^ TO THE K-TH POWEA MINUS OME« 

(2**A)-1. 
SHtAN - OUTPUT VECTOR CJNTaIN|*M MEAN SQUARES. THE 

LENGTH OF SMEAN IS 2 TJ THE A-TH POilEA MINUS OMC< 

<2***t»-l- 
NSTEP - WORKING VECTOR Of LEM&TH K. 
KUlNT - riORKINC VCCfUA Of ICNGTH K. 
LASTS - WOAAINC VECTOR OF LENGTH K. 



SUBROUTINES ANO FUNCTION SUaPROCAAMS REClUlREO 

NONE 

METHOO 

THE HEIHOO IS BAsEU CN THe TECHNIQUE 01 SCUSSEO BY H. 0. 
HA.1TLEV IN *HAIHEMAT1CAL METHOUS fOR OlfrlTAi COMPUTERS*! 
EUiTEO a> A. RALSTON AnU H. HIlF* JOHN UILEV AND SONS, 
IV62, CHAPTER 2C. 



SUbROUTINE McANg IK .LEVEL . H,&MCAN, SUHSQ»MOf.$N£AN.NST£P«M>U«T. 

LASTSl 
DIMENSION LEV£Lm.mi.SUMSQUI.NOFll».S«tANIl»,«TEfUI. 
KOUNTUItLASTSIl) 



IF A DOUBLE PRECISION VERSION Of THIS ROUTINE 15 DES 
C IN COLUMN 1 SHOULD BE REHUVEO fKOfI THE DOUBLE PREC 
STATEMENT UHICH FOLLOHS. 

UUU6LE PRECISIUN X.CMEAN.&UMSg.&NEAN.FNl 

THE C HUSr ALSO BE REMOVED FROM OOUftlE PRECISION STA 
APPEARING IN OTHER ROUTINES USES IN CONJUNCTION WITH 
ROUT INE . 



IREO, THC 
I SI ON 



CALCULATE TOTAL NUHUR OF DATA 

N'LEVELIII 
UC IbQ I«2.K 
i5C h-N*t€VEL(ll 

SET UP CONTROL FOR NEAN SQUARE OPERATOR 

LASTSUI'LtVELIlt 
00 17S 1*2. K 
I?e LASISin-LEVELUI*! 
NN«I 

CLEAR IHE AREA TU STORE SUMS OF SQUARES 

LL-I2*«».I-1 

HSTEPf II>1 

DO laO I<2fK 
laC MSTtPlI»»«STEP«I-i**2 

bU m l-l*LL 
lib SUHSOlI l>0<0 

PERFuRN MEAN SQUARE OPERATOR 

00 190 I'l.K 
190 aOunTI I }-0 
2CC L-0 

00 260 I>1*K 

IF(KUUNT(1)-LASTS(1 n 2LC« 2>0. 210 
21C IFIL) 22C. 220, 240 
ilL KGUNTII l«K(>UNT<l t«l 

IFIKOUNTID-LEVELd II 230. 230. 250 
23C L=l*MSTEPIU 

CLi TO 2bC> 
2'i.C IFIAQUMTI I»-LEVEL1I It 23C'. 260, 230 
2bQ KOUNIIIt'C 
2(tC CONTINUE 

IKLI 28S. iaS, 2T0 
27C SUMSQ(l.l«SUMSQUI»HNNI«KIN«» 

NN-NN4^1 

GU TO lOii 

CALCULATE THE 6KANU MEAN 

265 f« = IH 

GMtAN=K|NM|/fN 

LALCULATc FIRST JIVISUi REOUiRLO TU FORM SUM Uf SQUARES 
OlViSOK, MHICH IS tOUAL TO uECKEfcS Qf fMEDON. REQUIRED 
HtAH SwUARtS 

UO 310 I>2.A 
dU MSTEPlI l-C 
NN«G 

Nsrtpi 1 i>i 

NU2- t 

JO J43 l=i»< 

IFI risTcP* in JiO, i-tC, 350 



MEAN iO 
MAN 20 
HEAN M 
MEAN 40 
MEAN SO 
MEAN 40 
HEAN TO 
H£tM to 
MEAN 90 
NcAN LOO 
MEAN UO 
MEAN 120 
NCAN IM 
HEAN 140 
NCAN ISO 
HEAN 140 
NCAN 170 
MEAN 1W> 
NCAN 190 
HEAN 200 
MEAN 210 
NCAN 220 
MEAN 230 
MEAN 240 
MEAN 290 
MEAN 240 
MEAN 2 TO 
HEAN 2*0 
HEAN 290 
MEAN )00 
N&M 310 
NCAN i20 

Mean >90 

MEAN 140 
HEAN 3*0 
MEAN »40 

HEAN ITO 
HCAM MO 
MEAN )90 

MEAN 400 
MEAN 410 
MEAN 420 
MEAN 430 
MEAN 440 
MEAN 450 
MCAN 4*0 
MEAN 4T0 
NEAN 4M 
MEAN 490 

.MEAN SOO 
MEAN SIO 
MCAN S20 
HCAM 530 
MEAN »40 
MEAN S90 
NCAN S40 

■MEAN STO 
NCAn 5«0 
MCAN 590 
MCAN «00 
MEAN 410 
MEAN 620 
NCAN 630 
MCAH 640 
HEAN 650 
NEAN 660 
MEAN 670 
HEAN 6M 

•MEAN 690 
MEAN TOO 
MEAN no 
HE AH 720 
HCAN 730 
NEAN 740 
HCAH T50 
HCAN 760 
HEAH 770 
NEAN TRO 
HEAN 740 
HEAN aOO 
HEAN «10 
HEAN 120 
HEAH BIO 
HEAN 940 
HEAN tSC 
NEAN MO 
NEAN §70 
MEAN BBO 
MEAN S90 
HEAN «0C 
MEAN 910 
HEAN 920 
MEAN 9M) 
HEAN 940 
HCAN 990 
HEAH 9*0 
NEAN 970 
NEAN 9B0 
HEAN 990 
HEANIOOO 
HEANIOIC 
HCAH1020 
HCAN1030 
HCAN1040 
NEANlOSO 
HE AM 060 
HE AN 10 TO 
HEANIOBO 
HEAH1090 
HCANt I 00 
HEAHIUO 
HE AN 1120 
HEAN1I30 
MCANU60 

HEAN1160 
MEANUTO 
AMD SEC OHO HE AN 1180 
TO fORM NEAN1190 
NEAN1200 
HEAHl2iO 
HEANU20 
NEAN123C 
HEAN1240 
HEAN125C 
MEAN1260 
MEAN1270 
HEAN 1200 
MEAN1290 



TENCNTS 
THIS 



Statistics — Design Analysis 51 



'«^-N^>J•(lfeVt:L^ I I -I I 

NM=NN*1 

ttOH UHt-NOi 

IHNM-LL) 3*i. 3T0t 3rC 
i^5 OU >«0 1=1, K 

3t7 MSilEPf 1 )-c 
bO TO 3*0 

GO TU 3^0 
3AC CJNtlNUi 
3/1. KtlUKN 

tNU 



34r, 3$0t s**/ 



HEANllOti 
M£AM1310 

H£ANt340 
NEAN13M 
ft£«N13*0 

KEANliaO 

nE*Nl«uo 
l(£<NI«10 

MtAN1430 
ltE<Nl«<.0 
NEAN14M 
MC*ni«aO 
IIEANU70 
IIEAN144C 



Discriminant Analysis 

In the Scientific Subroutine Package, discriminant 
analysis is normally performed by calling the fol- 
lowing three subroutines in sequence: 

1. DMATX - to compute means of variables in 

each group and a pooled dispersion 
matrix 

2. MINV - to invert the pooled dispersion matrix 

3. DISCR - to compute coefficients of discrim- 

inant functions and evaluate the 
functions for each observation 
(individual) 



Subroutine DMATX 

This subroutine calculates means of variables in 
each group and a pooled dispersion matrix for the 
set of groups in a discriminant analysis. 

For each group k = 1, 2, .... g, the sub- 
routine calculates means and sums of cross- 
products of deviations from means as shown 
below. 

Means: 



Jk 



i = l 



X. 



ijk 



\ 



(1) 



th 



where n, = sample size in the k group 
j = 1, 2, . . . , m are variables 



Sum of cross-products of deviations from means: 



. k) 



where j = 1, 2, .... m 
£ = 1, 2, ..., m 

The pooled dispersion matrix is calculated as 
follows: 



D = 



k = l 



g 
k = l 



(3) 



where g = number of groups 



52 Statistics— Discriminant Analysis 



S Ju^Oul Inc 



L(Jn*>IJit Ss^fuS OF 



hUK ALL THL ^KOUPS. NJ-iMALLr 

N THt I'LRFOK'^ANCt UF 



.LMtAN* 



.OHAT 
OM&T 
OMAT 
UMAT 
DHAT 
UHAT 
OHAT 



PJULEO 

IHIS SUB 

DISCkIHINaNI jtfgALYSlS.OMAl 

DMAt IOC 

OHAT 110 

OMAT UO 

DMAT 130 

DMAT l^rO 

OHAT 1^0 

OHAT 160 

OHAT ITO 



N J*- PAKA«tre«S 
NUHBtK Clf^ CROUPS 
NUHdtk OF VAKUSLtS (MJil Bt THE SAMt FUK ALL 

■ ;;'ur'iECTUR UP .tN.lM K CONTAINING SAHPLE SIZES Of DNAJ 180 

nPu;';.cT.K C...AIM.. .am^_.. !t!L!:r^?.^^?l^*- SSIf 152 



CJNIAINI.MS DATA IN THE MAJVJNtM kOUI 
1 tNl iu a 3-DIM£NSiONAL FOUTMAN ARRAY, XU.l.H. 
tw 1 n XI3 Uil. tK. THE FIRST SUdSCRI^T IS OMAT 2Z0 

flsE Aii^tK. U itCUNLJ ^UbSCKIPT IS VARlAflLfc NUMBEftDHAT 230 
AUJ THc TMIRJ iUeSCHlPT IS CKOUP NUNBE.<. THE 
U^Jri JF VtCrC** X IS taOAL TU the TGTAL NU«BtR Of U«AT ^,0 

jArA, POINTS. r»M. .^HtHt r =• n(ii*i-iI2I 

UUTPUr HAT**! 

;S,'.'T.";« M X ". CO.,.,mNO fOCLtO ..SPt«SION. DMAT ^^0 

^dRKlNG VECrCK JF LtJJoTH H- 



DMAT 2*0 

UHAT 2 50 

OMAT 260 

'^MWrCUNlAUiNG McANS OF VARU6LES DH*T HO 

OMAT zso 



""?«t\u«Btk Of VMUSLli -USr BE GR6ATM THAN 0« tOUAI. TO 

IMt NU"9eK Of GROUPS. 
SUokiJUTlNii MO fONCIlON SU9P.<0GKAHi R£OUlRfcC> 

NONE 

""'JSer rj •O«0 CIi«POH» PROGRAMS HANUAL-, EUlTtO 8? «. J. 
S^N UCLA. l^o*. ANJ I. -. ANOCSON, ■ 1 NIROUUC F I ON TO 
SimCARlA^E UAfiirK.L ANALYSIS-, JOHN HUEY AND SONS, 
I9!ja. StLTlON 6.6-6.6. 



SUSROUTlNt OHAIX (K,rt,N.X,AoAft.J.CM£AN) 
UiNENSim Ml).X( U,X6Afi(ll,0U(.CH£ANt U 



tt i n.Uiol t PHtClSlUN Vt^SlUN UF THIS ROUTINE I5 OfcSiRtO. THE 
J%i COLUMN Tsni^LD b. R.NOV.U FkOH THE OQUfiU PRECISION 
SIAIEH£KT WHICH fOLLCwS. 



JOUfaLt PRtClSlON XdAR.D.CMtAN 



r^c r NH^T AiSO d£ RfcMUVFJ FROM OJUaLE PR£CISION STATEMENTS 
Ipp.Ar'n- IN J^HER ROuTINcS USED IN CONJUNCTION .1 TH THIS 
ROUTINE. 



INITIALISATION 

MM''M*N 

DO IOC l-l.MM 
:• 0( I I^O.O 

CALCUCATt MtANS 



L-0 

LN'O 

yO le.0 NG=1,'^ 

N1=N(NGI 

FN^Nl 

00 13C J*1.N 

LH"L«*l 

XBAft(LM»=O.0 

C-O 1^0 I=liM 

L"L*1 
i^C XbA«(LMI = XfaAR(LHI*XU) 
i3C XBARaMJ«XBAfi(»-HI/FN 

: CALCULATE SUHS OF CROSS-PRODUCTS Of JtVIATlCNS 

LMtAN=LM-M 
OU 150 I=liNl 
H.=N'»*I-^l 
00 l'*C J=1.M 
Ll=LL*Nl 
N2=LrtEAN+J 
lAC CMtAN(JI = x*lLl-XDA*<lNZl 

LL-C 

00 i5C j*l.M 

,.-0 l:>0 JJ^t.'* 

iSC D(LLP=U(LLl*^«t6NlJ»*CMtANtJJl 



CALCULflTL TH 

LL^-R 

QO 170 1=1. ^ 
, H.=LL*N( I i 

f N^LL 

oO 160 i=l.«f 
: DU t=0( II/fN 

KgruftN 

tNO 



PCGLEC 



tRSlt; 



UMAT 300 
OHAT 310 
DMAT 320 
OHAT 330 
DHAT 340 
OMAT 350 
OMAT 360 
OMAT 370 
DmAT 380 
OHAT 390 
UHAT 400 
OHAT 410 
OMAT 420 
OMAT 4 30 
DMAT 440 
.OMAT 450 
OMAT 460 
DMAf 4T0 
OMAT 4d0 
OMAT 49C 
.ONAT SOO 
OHAT 5 10 
OHAT 520 
DMAT 5 30 
OMAT 540 
OMAT 550 
OMAT 560 
OHAT 5 70 
UHAT 580 
DHAT 590 
OMAT 6CC 
OHAT 610 
..DMAT 620 
OHAT 6 30 
OMAT 6'-C 
OMAT 650 
DHAT 660 
DHAT 670 
DMAT 660 
OMAT 690 
OHAT TOO 
DHAT 710 
OMAT 720 
DMAT 730 
OMAT 740 
OMAT 750 
DHAT 760 
OMAT 770 
OMAT TtJQ 
DMAT 790 
OHAT 8CC 
DMAT 810 
OMAT 9 20 
DMAT B30 
DMAT B40 
OMAT B5C 
OHAT 860 
DHAT 87C 
OMAT B80 
OMAT a*yo 
OMAT 900 
OMAT 910 
OMAT 9?0 
OHAT 930 
DHAT 940 
DMAT 950 
OMAT 9oO 
DMAT 9TC 
OMAT 980 
DMAT 99C 
UNATLOOC 
OHATICIC 
OMAT1C20 
DMAT1C30 
OMAn040 
OrtAT105C 
0M4T106C 
0MAT107C 
l)HAT108C 
DMATIC9C 

omaTiico 

OMATllIC 

DMAT112C 



Subroutine DISCR 

This subroutine performs a discriminant analysis by 
calculating a set of linear functions that s^rve as 
indices for classifying an individual into one of K 
groups. 

For all groups combined, the following are 
obtained. 

Common means: 
g 



X. = 



k = l 



(1) 






k = l 
where g = number of groups 

= 1, 2, .... m are variables 



J 



\ 



X. 



jk 



. , th 
= sample size in the k group 

th , th 

= mean of j variable in k group 



Generalized Mahalanobis D statistics, V: 



m m 



V 



=i; z ^ij E "k%-^i><^3k-^. 



.) (2) 



1=1 j=l 



k=l 



where d.. = the inverse element of the pooled 
^•' dispersion matrix D 

V can be used as chi-square (under assumption of 
normality) with m(g-l) degrees of freedom, to 
test the hypothesis that the mean values are the 
same in all the g groups for these m variables. 

For each discriminant function k* = 1, 2 g, 

the following statistics are calculated. 



Coefficients: 



ik* 



Ed X. 
ij 3 

3=1 



jk 



(3) 



where i = 1, 2, . . . , m 
k = k+ 



Constant: 



m m 



ok* 



= -^/' E E '^jiV'^ik ^'> 



J = 



1 1=1 



statistics — Discriminant Analysis 53 



For each i^h case in each k^h group, the following 
calculations are performed. 

Discriminant functions: 



m 



k* Z— ^ jk i]k ok + 

j = l 



(5) 



where k* = 1, 2, . . . , g 

Probability associated with largest discriminant 
function: 






(6) 






where f - the value of the largest discriminant 
function 

L = the subscript of the largest dis- 
criminant function 



PURPOSE 

tOK^urf A S€T Of LllttAR FUMCflONS l#1ICH SCKVE AS IWICCS 
fCk CIASSIFVII«C M IKDlVlbUAL IMTO DM OF SEVCHAI. UOU^S. 
NQRHAltr THIS SUCfiOUriNE |S USCO U THt r€llfOIIHMC£ Of 
i>ISCRIM|NANt AMALVSIS. 



20 

30 

40 



40 



USAGi: 
CALL 



>UCft (<.H*h.x.>»Ali,0.CH£AN»VtC*r*L6l 



DISC 
.DISC 
DISC 
OiSC 
DISC 
OISC 

01 &c 

01 &c 
DISC 

OISC too 

OiSC 110 
AISC no 
OISC 130 
OISC I4C 
01 &C ISO 
OISC 16C 
OISC 170 



c uescRifricN cjf pu.nMiicK% 

C K - HUH6£R 0#- (.ROUPS. * huSt BE GACArCR IHAN OME. 

C N - hUM6£il Of VAR: ABLES 

C M - |W»yT VfcCTOR U(^ i£*»GTH K COMTAlfiJNG SAMPLE SW£S Of DISC i»0 

C CROWS. oiiC IM 

C K ' IWUT V€CTOK UiHJAlHltA OATA IN fHt HAM£t EOUJVA- OISC 200 

C LEMT ro A 3-bilH6NS10NAL POKTfU*! AJIRAT, aU*1«11« OISC 210 

C X(2,l,ll. X(3.1,ll, £fC. ThC fiRST SUbSCftlPT IS OISC 220 

C CASi MMBER. Th£ ^tCGNO SUfiSCAIfT IS VAAUtlf HUMCftOISC 230 

C AHO rHE iHiRt SUBSCRIPT IS GROUP NUMBER. TMC OISC 2« 

C LCMGTH Of VECTOR J( ]S EQUAL TO THE TOTAL MUMw« Of OISC ZM 

C OATA POINTS. T«H< ««AE T > M IUNl2l«...«llUI. OISC MG 

C t&AH - IhPUf NATRlX I M K K> CONTAINING NEANS tf N VAIII AOIESOISC 2T0 



DISC MO 

OISC 290 

DISC 300 

OISC 310 

OISC 32C 

OISC 330 



IN A oaoups 

- INPUT MATRIX IM X HI CONTAINING THE INVERSE Of 

POOLED 0ISP£RS10f4 MATRIX. 

CMdAA. - OUTPUT VECTOR OF LENGTH N CONTAINING COMMON MEANS. 

V - UUrPJI VA*l|AoLt CONTAINING G£N£UL12cO NAHAlANO»|S 

D-SOUARE, 

C - UdTPJl NATftU (M*l K K| CONTAINING TH£ COEFFICIENTS OISC 3*0 

OF iilSCRIMlNANT FUNLUuNS. THE FIRST POSITION Of DISC J5C 
«ACH COLUMN (fUNCIIOh) CONIAJNS THt V*LUc OF TMt OISC 360 

CONiTANT FOR THAT FWiCIICN. oiSC 3T0 

P - UJT|>JT VLCTOR CONTAINl*tC THt PROBABILITY ASSOCIATiO OISC 3B0 

milH Tm£ LARGEST iiliCH-tHlHAHl FU*4CTIUMS OF ALL CASESOI&C 390 
IN ALL ChCUPS. CAiCULATtO RESULTS ARfc SIOREO IN THCOISC AOO 
«ANN£R EbUlVALEMT Tu A Z-OI MEMS J ONAL AREA I THE O I SC « IC 

FMST SUOSCRIPT IS CASc NUHAER, ANC THE SECOND OISC A20 

SUoSCHIPT IS GAJUP NUMdERI. VECTOR P HAS LENGTH OISC 43C 

tOJAL TJ THE TOTAL WiMBcR OF tASES, T IT - N(1MN(2I0ISC «40 



*N(A>). 
LC - iiUTPuT VECTOR C0NTA|r«lMC THE SUBSCRIPTS OF THE 

LAii&ti^T OISCRJHINAKT FUNCllQMS STORED IM VECTOR P. 
THc LENJTH uF VECTuI^ LC IS THE SANE AS THE LEtCTH 

uf VEtTQR P. 



REMARKS 

THE NLMoEK OF VAklAM.ES MUST 
THt hUHB£f^ OF GkOuP^. 



EE wREATER THAN CA EQUAL TO 



SUbAOJliNE> ANO FUNCTION SUSPRJGRANs AeCUIREO 
NCNE 

Ht1H(J> 

kim. TL 'oMo CO^PuTEA PMJCKAMS MAMUAL • , EtITEO «T to. J. 
JIaGK, uCLA, 1«o*, ANO T. «. AhuERSON, •INTROOUCTim TO 
MULTIVARIATE STATISTICAL ANALViJi', JOHN hiLET AmO SONS. 
1958. StCTIUfti *.«-(>.£. •""-»» 



OISC 4SC 

OISC 4«0 

OISC 4TC 

OISC ABC 

OISC «90 

one ioc 

disc SIC 
OISC S20 
OISC 530 
OISC 44S 
OISC 5 SO 
OISC SAO 
OISC 5 70 
OISC SdO 
OiSC 590 
OJSC 400 
OISC *10 
OISC 620 
OISC 630 



iUdK^uTlNt ulSCF. lK.,H,h,X.X6AA,tJ.CHt:AN,V.C«P,L5l 
olMENilUN N4 II.XI tt .hUAHl il.Lt 1 I tCntiANI II.CIIUPII I ,LC1 tl 



If * JJUdLc fKECISIuN VthilDN UF THIS RCUTJW IS OESIREO, «H£ 
c I."« COLJK.K 1 SHOULD be -KtMCrfED FRCM The OOUBLfc PRECISION 
iTArcML.VT bHJCH FULLLhS. 

.JjLe PkECISIuN fct-AF., U,f MLAj,,,v,C,i.u«,P,PL 

The C HOil ALSO tt RtMOVci. FAOM CJUBLt PRECISION STATEMENTS 
^PPtAAl-^G H OtHtft RuuriNtS US6j II, COhJUNtTlUN .IIH THIS 
ROoriNE. 



THc L>CJo(.c PKcClSloN Vt:i.SI3N LF Th!S SUbROUT I Nt MUST ALSO 
CONTAIN OiJUiiL; P*cCISU\ f-ORTknH ^jNCTiONS. 
2S0 MJiT ae i.'iU^GtO Tu (Jt«P. 



EXP, IN, STATEMENT 



«Tt COmmUm -iLAf^S 



00 Ul I^f.K 
IOC Ni = Nl.«N(l I 

DC llL 1=1, K 
IK P(l MN( II 

UO IK I-I.p; 

LMEANd | = C 

Ml=|-H 

CO l^~ J=l,K 

liC CMtA,-!! i I = CMtAN( i I *PCJl*XbAR[Ni 1 
13C CMttM 1 l = CHeANl J )/f NT 

C«LCoL4Tt 'jtMcRALUED MAHALA^OblS SQUARE 

L«e 



C(LI = Ad«<(L|-CMeAK< J I 



DO 16C J=1,M 
DO l&O l<l.N 
NI-l-M 

N2=J-M 

SUM-CO 

00 I5b XJ=1,K 

15C SUM-^SUMtPI IJ (♦C(,'<1| •CINZI 
L«L + I 

I6f V=V*DUI*SJN 
C 
C CALCULATfc TMt COcFFtCILNTS OF Ul SCRI -^INAMT FUMCTIOMS 

N2-0 

DC 19C KA=i,n 

DO ITC 1*1. M 

n;*m2*i 

nc p(i i^xcAntN^) 

iQ«IM*l»»(HA-IMl 

SUM=C.C 

DC 16L Jil.M 

M-J-M 

DO 160 L^l.M 

M>Nl*M 
1«C SUM^SU.'1*0tNl)«P| JMPUI 

C< IU)--<SJH/2.u) 

OC 19C 1=1, M 

M-l-M 

IkJ-IUt'l 

ClUl^O.C 

00 190 J>=1.M 

hl>.^l*M 
19C C(lUI<C(lJUD(NI}«P(J) 

: FOR EALM CASE I,M EACH GROUP. CALCULATE*. 

' DlSCKIMI^ANT FUNCTIONS 

LbASE=C 
M-0 

OG 2TC Ki^l.K 
NN=NUGI 
DO 260 lc:l.NN 
L-I-«N*Lo*St 
00 29^ J'L,H 
L"L»fcN 
2:C of J)*XIL1 
N2*C 

00 i^O KA=1,K 

N2-N2»l 

SUH>:C('<^) 

DC iir J=l,h 
N2-N2*l 
2IC &UM=SJ'4»CIN2I«.;( J) 

22C XdAR|<A|=>uM 

TNf LARGEST JISCAIHIhANT F JMC T UN 



SUM=«d4'<( 1 I 

|F(SU«-Xb4R(JlI 
<;3C L-J 

SUM'toARIJl 

24t COklimt 



PkOoA:;IlIIy asSjciate:. kiih the URitST 



£i»C PL = t'L» £XPUoA-.(Jl-StJ'<) 



aC P(MI=1.0/PL 



oiscRiNiNANf Function 



.DISC 6-tO 
DISC 6SC 
OISC 660 
OISC 6TC 
OISC ABO 
>0I$C 690 
DISC 70C 
OISC 710 
OISC 720 
OISC T3C 
OISC 740 
OISC 7SC 
DISC r6C 
OISC 77C 
OISC 7oC 
OISC 79C 
DISC 800 
OISC 61C 
Disc 82C 
OISC 830 
OISC BOD 
•-■•OISC bSO 
OISC 860 
OISC 67C 
DISC BBC 
OISC B9C 
UISC 9CC 
OISC 91C 
OISC 9 2C 
DISC 9iC 
OISC 940 
OISC 950 
DISC 9t,0 
OISC 970 
OISC 9d0 
OISC 99C 
OISCICCO 
OISCIOIO 
01SC132C 
0ISC1C3C 
OISCL04O 
OISCIQSC 
0ISC1060 
01 SCI 070 
OISCIOBO 
OISC1090 
OISCllOC 
OISClllO 
01 SCI 120 
JISC113C 
0ISC1140 
OISC1150 
0ISCIt60 
OISCU70 
0ISC1180 
0ISC119C 
DlSCliCO 
OISC12L0 
OISC1220 
OISC1230 
OI$CL24.C 
OISC1250 
OISC 1260 
OISC127C 

oi$ci2ao 

O1SC1240 
OI$C1300 
OISC1310 
O1SC1320 
OtSC13iO 

oiscia^o 

01 SCI 350 
01SC136C 
OISCtlTO 
OI$C1380 
0ISCL390 
OISC140C 
DISC1410 
0ISC1420 
OISCU30 
01$C1440 
OISC1A50 
O[SCL660 
0ISC14T0 
OtSClASO 
0ISC149C 
0ISC1500 
0ISC1510 
OISC1520 
OISC1530 
OISCISAO 

oiscisso 

0I$C1S6C 

Discisrc 

OISC 1580 
01 SCI 590 
0ISCL6CC 
01SC16I0 
0fsCl62C 
01 SCI 6 30 
OISC 1640 
OlSClbSO 
OISCI660 
OISC16T0 
OISC 168C 
0ISC169C 
OISCITOO 
OISCI710 
0ISC1T20 

.oiscirio 

-OISCITAC 
'OISCITSO 

oisGiriio 

OISCITSO 
01 SCI 790 
OISCIBCO 
DISC 18 IC 

OISCU20 

oisciaso 

DISC184C 
OISCi35C 
OlSClBbO 

01SC1B70 

oiscia60 
Qtscia9o 

0ISC19OC 



54 statistics— Discriminant Analysis 



Factor Analysis (see Eigenanalysis) 

In the Scientific Subroutine Pack^e, factor 
analysis is normally performed by calling the 
following five subroutines in sequence: 

1. CORRE - to find means, standard deviations, 

and correlation matrix 

2. EIGEN - to compute eigenvalues and assoc- 

iated eigenvectors of the correlation 
matrix 

3. TRACE - to select the eigenvalues that are 

greater than or equal to the control 
value specified by the user 

4. LOAD - to compute a factor matrix 

5. VARMX- to perform varimax rotation of the 

factor matrix 
The subroutine CORRE works in either of two 
ways: (1) it expects all observations in core, or 
(2) it triggers a user-provided input subroutine, 
DATA, to read one observation at a time into a 
work area. In either case, the user must provide 
a subroutine named DATA (see "Subroutines Re- 
quired" in the comment cards designation of sub- 
routine CORRE). 



Subroutine TRACE 

This subroutine finds k, the number of eigenvalues 
that are greater than or equal to the value of a 
specified constant. The given eigenvalues X^, Ag, 
\„ must be arranged in descending order. 



where j = 1, 2, . . . , k 

m = number of eigenvalues (or variables) 
k =£ m 



Cumulative percentages for these k eigenvalues 



are: 



Sl.eFCL11h£ 1KACE 



"• <fEClFIEI! ev Ift U5S«. IHIS SU«- 

SECt.EKC€ Cf CILLS TO SUB- 

«K0 VAtm IN IHf PER- 



TRAC 10 

TRAC 20 

TRAC 90 

TRAC *Q 

TRAC 50 

TRAC AO 

TRAC TO 

TRAC BO 

TRAC 90 

TRAC 100 

TRAC 110 

TRAC 120 

TRAC 130 

TRAC 1*0 

TRAC 150 

TRAC 160 

TRAC ITO 

TRAC 100 

TRAC l^o 
200 
210 

,S R e« «. WiriMSMWriu-iMSARi IX STCRACE. TRAC 2M 

(SICRACE Root r.f II 



C» ECUAl IC » CCkSIAM 

RCLTIRE RCRRAILV CCCt-RS 

RCLIIRES CCRRE. ElGEk. 1RACE. ICAC 

fCllH^C€ Cf • FACTCR AXAITSIS. 



LSACE 

CAll TRACE IR.R.CCR.R.CI 

CESCflfTICA Cf PAtlRElERS 

; - RUPBER Cf VARIAELES. " '"ST BE > CI 
INPUT RATRIX ISVRRETRIC ARC SICREO 



IR CCRRRESSEO 



«(R /lIK C1.1.Y IFftR IRIAROU t1 CCL1.« I« CORE! T.AC 

tcMAlillic EIGERVAIUES IK <="""" VArJ^J^'LJ^llMllc 



Cc"sliRruiEC TC CECICE KR RA«Y EICENVAIUES TO 
RETAIR. CURUlATIVt RERCERfACE Cf EICERVAIOES 
"icJ ARE CREAIiR THAR CR ECCAl TC THIS VALUE IS 



' CRE.IERT^AN C. ECOAL TC CC .« IS THE RUHOER Of 

r - fllfu'vECIOR Cf 1E^(;I^ R CCNTAIKIRC OjROLATHE 

' ReJcEMKE Cf EIGERVALUtS RflCH ARE OREATER THAN 

CR ECtjAL TO CCR. 
RERARRS 
RCRC 

SiemURES ARC ECRCIICR SiefRCCRARS RECUIREC 
ACRE 



■lERCLlIRE TRACE IP.R.CCk.i 
LIRE><ICR Rdl.Clll 



jL^ m 
i = l 



lie 



(1) 



TR*C 230 
TH*C 2*0 
TAAC 250 
TRAC 260 
TR*C 270 
r.)Z'V>llA^U CCRT.1R.RC THE RO-.E. Of -^-ACUEST.AC 2.0 

TRAC 300 
TflAC 310 
TRAC 320 
TRAC 330 
TRAC 340 
TRAC 390 
TRAC 360 
TRAC 3 TO 
TRAC 380 
TRAC 390 
TRAC *00 

Ut CL^LlATlVt feRCENlAGf FGR £ACh ClGEHVAHje. ^^^^ ^^^ 

,T«AC *50 

TRAC *60 
TRAC 470 
TRAC *80 
TRAC 490 
.TRAC 500 
TRAC 5tO 
TRAC 520 
TRAC 530 
TRAC 5*0 
TRAC 550 
TRAC 560 
TRAC STO 
TRAC 580 
TRAC 590 
TRAC 600 
TRAC 610 
.TRAC 620 
TRAC 630 
TRAC 640 
TRAC 6S0 
TRAC 660 
TRAC 670 
TRAC 680 
TRAC 690 
TRAC 700 
TRAC 710 
TRAC 720 
TRAC 730 
TRAC T40 
TRAC 750 
TRAC 760 
TRAC TTO 
TRAC 7B0 
TRAC 790 
TRAC too 
TRAC fllO 
TRAC A20 
TBAC 8^0 
TRAC 840 



.< t rriflif RflfCI<lC^ VER<ICH CF IhlS PCLTIKE IS CtSIRCO, tHt 
SIATCCtM hHICf fClLChS. 
CCI.ei£ FPECISlCh R.C 

Tl-t C ftM ALEC f£ RE.'CVEC FRC^ DCLBte PBtClEICf fl^^HEUS 
IpPE*Ril:G IK CTHER RCLTIhES LSEO U COKJUKCTICN hITH THIS 



l-C 

CC ICC 1-1. K 

t-l*l 

ClII-RUI 

<c-c 

Tt<i h^El^fc^< I-^^ EiC£Kt«*ti:E is Greater 

Tt-Af CR ICL#L IC Tt-E CCKSUKT 

CC IK l«l.f 

IKCUl-CtM 12C. ICS. IC5 

|i«|t«l 

c(ii»cn)/ff 



P1.TE CLfLLATlVt fERCEKTACE Cf EIGEKVUtES 



CCn 

CC 13C l"i.l« 

Cll»-C(ll«CU-ll 

tiEICRK 

EfC 



Statistics — Factor Analysis 55 



Subroutine LOAD 



Subroutine VARMX 



This subroutine calculates the coefficients of each 
factor by multiplying the elements of each normal- 
ized eigenvector by the square root of the cor- 
responding eigenvalue. 



a.. = V 



4S 



(1) 



where i = 1, 2, 
J = 1, 2, 



ra are variables 



k are eigenvalues retained 
(see the subroutine TRACE) 



10 



fLflfCSE 

CCfftlE « f«C1Cf) rATHIK (LCAOINC) FROI' EIGCHVALUES AND 
JSSCCIAKC ElCEdiVECTCRS. IHIS SUBRCLIINE NOIIfAlLV OCCUBS 
I*- » SiCLthCt CF CALLS 1C SCeRCtTI».ES CORfie, EIGCN. TRACE. 
LC/C. AhC VAR^Jr IN T»-E P£HFORMAKC£ Cf A FACTCR ANALYSIS. 



LSACE 

CALL LCAC (K. 



K*R<VI 



LOAO 
.LQAO 
LCAD 
LGAD 
LOAD 50 
LCAO 60 
LOAO 70 
LQAO 80 
LCAO 40 
LQAO 100 
LCAO 110 
LCAD 120 
LCAO 130 
LOAO L40 
LCAO 190 
LOAO 160 
LCAO 170 
LOAO ITI 
LOAO ISO 
LCAD 190 
LCAO 200 
LCAO 210 






CESCPlPIICh CF PAOifETfRS 

P - kLI-etR CF VARIAtLES. 

K ' hVfatft Cf FACTORS. K MUST BE CRE«1ER IHAN OR ECU«L 
IC 1 AhC LESS T^A^ CR ECUAl TC M, 

R - A PATRIJc (Srrit^ETRIC AKC SICREC IN CCPPRESSEO FCRf 
hilh ChL* tPPER TRIANGLE ET CCLUMf. IN COREI CCN- 
TAiKUE EIGENVALLES IN CIAGCNAI. EIGENVALUES ARE 
ARRAKCEC IN OESCENCINC CROCK. AND FIRSl K 

EtCENViLUEii ARE LSEC BY THIS SU8RCUTINE. THE CRDER LQAO 220 
CF FATfliK R IS P CY H- ONLV ►•♦(N»l»/2 ELEMENTS ARE LOAO 230 
IN SICRACE. IS1CRACE PCCE CF II LCAO 240 

ti - kFEN l»-IS SUSRCLTINE IS CttLtC, PATRIX V (f K Nl LCAO 250 
CONTAINS EICENVECICRS CGLCKhhISE. UfCh RCTUftftlNG TOLCAO 260 
It-E CALLINC PKCCRAN. MATRIX V CONTAIf^S A FACTCR LOAO 270 
PAIRU t¥ V K|. LCAO 280 

LCAO 290 

LCAD aoo 

LCAO 110 
LCAO 320 

SLEPCLTINES ANC FLNCTIGN SUEFRCCRAI'S RECUIREO LCAO 130 

••C^E LGAD 340 

LOAO 390 

''ETt-CC LCAO J60 

NCfif^LIiEC EICENUECTORS APE CCNVERTEO TO TH£ FACTOR PATTERN LCAO 370 

eV PbLllPLYINC ftt ELEMENTS OF EACH VECTOR SY THE SQUARE LOAD 380 

tiCCT CF T^E CCPRESPONOINC EIGENVALUE. LCAO 340 

LCAO 400 

* LOAO 410 

L0*0 420 
LCAO 430 
LOAO 440 
LOAO 450 
.LCAO 460 
LCAO 470 
LCAO 480 
LOAO 490 
LCAO 500 
LOAO 510 
LCAD 520 
LCAO 530 
LCAO 540 
LCAO 550 
LCAO 560 
LCAO 570 
LCAD 580 
LCAO 590 
LCAO 600 
LCAO 610 
.LCAD 620 
LCAO 630 
LCAO 640 
LCAD 650 
LCAO 660 
LCAO 670 
LCAO 680 
LCAO 690 
LCAO too 
LCAO 710 
LCAO 720 
LCAO 730 



SiefiCllI^t LCAC (R.K.R.V) 
Cir'EKS]C^ Rdl.Vdl 



IF t CCLELE PRECI£ICN VEf(:iCI> CF THIS ROLTIKE I! CESIREO. THE 
C IN CCLLPN 1 ShCLLO BE REPCVEO FRCH THE OOUeLE PRECISION 
SIAItfENI *I-ICH fCLLChS. 

CCLELE FRECISICN R.V*SC 

TFE C PLST ALSO E£ REMOVEC FRCP UCueLE PRECISION STATEMENTS 
APFEARINC IN CTHER ROLTINES CSEO IN CGNJLKCriCN h I TH THIS 
RClllNE. 

1»-E CCLSLE PRECISICN VERSICN CF THIS SLBRCUTINE PLST ALSC 
CCNTAIN CCLCLE PRECISICN FCRIRAh FONCTICNS. SORT IS STATEMENT 
ISC PLST EE CfiNCEC TO CSCRT. 



JJ"C 

CC l«C ^-l.K 

15C £C- SCFIIRIJJ}) 
CC UC I-l.P 
L-L41 

UC VILl«SC«VILi 
FETCRN 



This subroutine performs orthogonal rotations on an 
m by k factor matrix such that: 



^kf?/? 




( 



(1) 



is a maximum, where i = 1,2 m are variables, 

j = 1, 2, . . . , k are factors, a^. is the loading for 
the ith variable on the j*^ factor, and hf is the 
communality of the i*^ variable defined below. 
Communalities: 

k 



where i = 1, 2, . . . , m 
Normalized factor matrix: 

b.. = a../ /h^ 

y ij/ V 1 

where i = 1, 2, . . . , m 
j = 1, 2, .... k 

Variance for factor matrix: 



(2) 



(3) 



i 

c 4- 

J ( 



-? {<H •.■.)■ 



(4) 



where c = 1,2,... (iteration cycle) 



Convergence test: 



If V - V , £ 10 
c c-1 



(5) 



four successive times, the program stops rotation 
and performs the equation (28), Otherwise, the 
program repeats rotation of factors until the con- 
vergence test is satisfied. 



Rotation of two factors: 

The subroutine rotates two normalized factors 
(bjj) at a time. 1 with 2, 1 with 3, . . . , 1 with k, 

2 with 3 2 with k k - 1 with k. This 

constitutes one iteration cycle. 



56 Statistics— Factor Analysis 



Assuming that x and y are factors to be rotated, 
where x is the lower-numbered or left-hand 
factor, the following notation for rotating these two 
factors is used: 



x^^ yi 



^2 ^2 



X y 

m •'m 



cos<p 
sin(p 



-sin</5 

cosd) 



^1 ^1 



^2 ^2 



X Y 

m m 



(6) 



where xi and yi are presently available normalized 
loadings, and Xi and Yj, the desired normalized 
loadings, are functions of «, the angle of rotation. 
The computational steps are (a) throu^ (e) below. 

(a) Calculation of NUM and DEN: 

A =Z^(x. +y.) (^i-yj) 



B = 2 



J^^'ih 



(7) 



c = Sr^'^i+yiX'^i-yi^ + '^yi] 

i •- 
[(X. + y.) (X. - y.) - 2x. y.] 

D = 4Xl<^i^yi) ^^i'^i^ ''i^i 
i 

NUM = D - 2AB/m 

DEN = C - [ (A + B) (A - B) ] /m 

(b) Comparison of NUM and DEN: 

The following four cases may arise. 

NUM < DEN, go to (bl) below 

NUM > DEN, go to (b2) below 

(NUM + DEN) - €*, go to (b3) below 

(NUM + DEN) < e , skip to the next rotation 

* e Is a small tolerance factor. 



(bl) tan 4 61 = |NUM|/|DEN| (8) 

If tan 40 < e and 

(i) DEN is positive, skip to the 
next rotation. 

(ii) DEN is negative, set cos<^ = 

sin*= (V§)/2 and go to (e) below. 



If tan 4 - e J calculate: 



-i/v; 



cos40 = 1/Vl + tan 40 

sin4:0 = tan4e • cos4e 

and go to (c) below. 

(b2) ctn40 = |NUM|/|DEN| 

If ctn4e < e, set cos4e = and 
sin4e =1. Go to (c) below. 

If ctn4e s e, calculate: 



(9) 
(10) 

(11) 



.^/^ 



sin4e = l/"Vl + ctn 40 
cos4e = ctn40 • sin40 
and go to (c) below. 



(12) 
(13) 



(bS) Set cos40 = sin4e = {■\J2)/2 and go 
to (c) below. 



(c) Determining cose and sin0: 



cos2e = ^(l + cos4e)/2 
sin20 = sin40/2cos2e 



cose = -y/(l + cos2e)/2 
sine = sin20/2cose 
(d) Determining cos<^ and sin<^: 
(dl) If DEN is positive, set 
cosi^ = cos e 

sin(j) = siaS 

and go to (d2) below. 

If DEN is negative, calculate 



(14) 
(15) 

(16) 
(17) 



(18) 

(19) 



cosd) = 



2 n ^^ - a 

— cose + ^- sme ^20) 



Statistics — Factor Analysis 57 



s,n<P =|— cose-— sine|^21) 
and go to (d2) below. 
(d2) If NUM is positive, set 

cos<A = I cos I (22) 

sin-/' = I sin(^ | (23) 

and go to (e) below. 

If NUM is negative, set 

cos'/' = |cOS(^j 

sin0 = -|sini;6| 

(e) Rotation: 



X. = X. COS0 + V sinrf) 
1 1 •'i ^ 



Y. = X. sin0 + jj cos<; 
where i = 1, 2 m 



(24) 
(25) 

(26) 
(27) 



After one cycle of k(k - l)/2 rotations is completed, 
the subroutine goes back to calculate the variance 
for the factor matrix by equation (4). 



Deno rmaliz ation : 
a.. = b.. • h. 

where i = 1, 2, , . . , m 
J = 1. 2, .... k 

Check on communalities: 



Final communalities f 

i 

Difference d 

i 

where i = 1, 2, ..,, m 



(28) 






j=l 



h' -f' 



(29) 



(30) 



VA«H 
VAftf 
VAPM 
WAR*! 



SieaCLIHE KC»f.llv CCCKS It, 1 StCttUt CF CALLS m \tM IaVL 

VARH 
VARK 
VARf 
VARH 

VAKM 
VAR*! 
VARf 



Ct A KCICR AkAlVSIS. 



lf.»,A,NC,IV,f,f.c,It«l 



C<A(I 

CALL VAfRA 

CfSCflFtlCk CF PARARFIbRS 

t - IkfLl IS IFE CRlciklL FACICR RAIRIx. AKC OITRCI IS 

IM RCIAHC fACICR RAIRI,. UE CKCER CF MIRI, i 



VARM 
VARM 
VARM 
VARH 
VAHM 



»t - ciiPii VARIAeU cckiAimc ikf KI.UER Cf HERAIIC 

CVCttJ RtRfCRKtC. litRAiiON 

(■AIJl, fC« EAC^ IIERAIICA CVCIE. I«E VARI^cI pJJcr'"; 

ic ift FiRsi ^u.,,,c^ cicu is also cauIiaiIo! JIJI 

ins REA^S f.I n.i .ARi.KCES ARE SICEO l' "ciCR VARR 
VtCtcl'l ,\ W. "-"EH*!. Ih£ LENOIH Cf 

* ' \'ill\.l,TlVn\." "'"'■ ' "MAIMKC I^E ORICIN.L 



VARR 
VARM 



VARM 
VARR 

A'fii^^R^^M^'ir/.^jij'iiii^'.'-'jj^t.ENCEs;:;: 

VAftn 

VARK 

VAftV 
VARf 
VAR*' 
VAR" 

VARIH 

VARM 
VARf 

VARH 
VARM 
VAR** 

VARH 

e;i'wM.;;'';rtI.^r;*!i!'»r*5 "5CRIB6C I*, -CCRUTCR P«CGRA« ""^ 

fCt- V^tHfAii RCIAtICK Ih fACTCR AhALVSIS* BY Tf€ SAMf AltTMfia uiam 

ICLCATIC.AL AKC PSYChCICG ICAL «.SU«i.|Ni:vCLAfJ!!%c!! ;?'";; 

' ' VARf 

VARH 



*'***' '*"^ CRICIfcAt AhU FINAL CC(«!«l.KALI I I€S. ' 
ifP - £|IRCR IhCICATLR 
I£R"C - hC tKRCD 

lER-l - CCKVERGCKCe WAE hCT ACMieVtO l^ 50 CYCL€S 
CF KCTA1ICK 

if V*RWhCI CCffutti; AFICR EACh riERATICN CVCU OCES hCl 

iuJucJ/" "■■" stcc€<<..t Ti.es. T.£ UflRCiTiSe srjfl 

SLenCLTlhtS AfcC FLKCnCK StePRCCRA^S RECUIREC 



80 
93 

100 

110 
120 
130 
UO 
ISO 
lAO 
170 
180 
190 

eoo 

2ZQ 
2J0 
240 
250 
260 
270 
2M 
290 
300 
310 
320 
J30 
140 
350 

asi 

352 
35 3 
35* 

360 

aro 

aao 

390 
400 



£LeRC(.TlhE VAR.y C »f .* ihC . TV .1- ,F ,0, lER t 
CI»€ASICh AdI.TvitJ.HdI.FIII.Cdl 



IF / tCteit PREtlSICh VERSKfc CF IhlS ftObTINC I£ CESIREO. 
C Ih CCLlifh I ShCULC BE REfCWCO FRO»i TMt OOUtlE RRKISIGh 



410 

420 
430 

440 
450 
460 
470 
4B0 
490 

soo 

.VARM 510 
VARH 520 
VARN 530 
VARM 540 
VARH 550 

VARM 5«0 

VARH 570 

THE VARC 580 
VARM 590 
VARH «00 



CCOeit FRECISKI. A.I*.^.f.C,TVCT,C0NS,AA,ea,CC.00,U.I,B,C0S4T. VARM T\l 

I SJMf,TA«4f.SIftP.C0SP,CTh4T,CQS2T,SIN2T.C0ST,SINTVARH JJo 

«».:<-![l!r'.^^^ " OCf'OVED FBCR DCtiLE PRECISIOK STATEWKTS 
iPPeJ«l#.G Ik CThtB ROUTINES ISEO It, CCHJUhCIION hITH THIS 



fiCLTIfE. 

^^t cctete precisick versick cf this suaftcuii« h,st alsc 

CCMIU CCUeiE MECISiah FCRTBAW FOfcCIIOhS. $QRf 

li;. i<C. 230. 35C, AhO 355 PCS" "- 

SIATtPffcTS 2€C, 32C, ANC 375 PUSI BE CMAkCEC TO CABS. 



C IhllUlfJiTlCk 

C 

IER*C 

EFS-C.CCllt 
IVtI-C.C 
IL»R-1 
kV'l 
»C-C 
Fk>P 

FF^«Fk«Fh 
CChS-C.)CIlC<e 
C 
C CAlCLlAlt CBiGlkAl CCPPL^ALI1IC< 

CC IK I>|*P 

mi-c.c 

CC lie J*1.K 

L«Pt|J-|MI 
lie M1I>FIIMA(LI«AIL) 
C 

C CALCLLAIE hCfPAll/EC FACTOR PATRH 

C 

CC lie i>i.p 
115 mi- sctiUhdii 

CC 12C J-l.K 
l*P«IJ-|M( 
lie *(i. |-«u t/n I ) 
Ct TC 13; 

c 

t C<ltLL*U V4ri|«^Lt fCB FALICh I'dKIK 

I3C fV«KV»l 

IVlt-Ttr(fV-ll 

CC 15C ^'I.K 
«A>C.C 

ft«f.C 
tP-^«(j-d 

CC 14C i-l.^ 

i-i.e*i 
cc-Aai«/(t» 

/A.*A«CC 

i4( Ee-te<c:«cc 

15C IHH)-UUVI«Uh»te-AA*AAJ/EfK 

iFUv-;ui6C,i;;,is; 

l^t IEH>| 

CC IC 4K 



fCKfCPf cc^v£RC(^ct usi 



VARH 630 
VARM 640 
VARM 6)0 
VARM 660 
VARH 670 
VARH 680 
- STA1EMENTSVARN 690 
BE CHAKG60 TO CSCRt. A«S IN VARM 700 
VARM 710 
VARH 720 

VARM 730 

VARH 740 
VARM 750 
VARH 760 
VARH 761 
VARM 770 
VARM 790 
VARM 790 
VARH 800 
VARH 810 
VARM 820 
VARH 830 
VARH 840 
VARH 850 
VARM 860 
VARH 870 
VARM 880 
VARM 890 
VARH 900 
VARH 910 
VARM 920 
VARH 930 
VARM 940 
VARM 950 
VARM 960 
VARH 970 
VARM 980 
VARM 490 
VARVIOnO 
VftKflOlO 
VrtBMiO?0 
VAHI«1030 
VAR-1040 

VAOKIOSO 

VAkMlOAU 
VAB-1070 
VAR'IOHO 

VABOllOO 
VARflUO 
V«RPH2n 
VAilKUJO 
VAKM1140 
VAMt-llSO 

vafif 1160 

Vft«Hlt70 

VARHliaO 
VAHfllgl 
V«HMU8? 
VABMI190 
VARRl^fOO 

v•RMl^|o 



58 Statistics— Factor Analysis 



itc if(i!UfcU-mn-na-ni iic. ik. iso 

lie KC*fC*l 

lf(^c->t ISC. ISC, *!C 

fCmiCfc Cf 1*C FACTCKS CCKTIUCS UP ic 
ISC CC *iC v-J,ll 

II-J«1 

CILCLL«TE fLf *^C Cth 
iA-C.C 

te-c.c 

CC'C.C 

tc-c.c 
ia-Li«i 

14-4.2*1 

1»I*T 
CC-CC«tLt1l*tL-f) 

iiC ee-ce«i 

c cc^^»^;lsc^ cf m.^ *m: ct^ 

If ii-Ei itc. i*C. !2C 
SMC If KMfcl-tfSI M2C. iSC, i5C 

c fci.^ • CEK IS CPeniP t^ak cp ectn ic tet 

c 

itc LCS*l-CCfcS 

CC ic itc 

ifcc iJfcii' #EStn/ ttstei 

lflltt^h}-i¥ii 3CC. 2SC, 29(J 

CL IC itc 

;CC If <E ) 2 IC. hiC, *2C 
21C ilM^-CCKS 

CC5F«CCM 

CC IC 4CC 

C ^c^ IS tft'iiP T^*^ t£K 

c 

;ic cu^i- «es(i/Ei 

'3C MH*1-1.C/ <CBTU.C*C1K*I»CINA11 

CC K 35C 

34C CC£*I-C.C 

<II»4T-J.C 

c tnsenht CCS h-ei» *nc si* if'EU 

MC CCSiT- SCIiTUl.C«CCS*Il/i.C> 

»5« CtSl- 5CP1(«I.C«CCS2II/2-Ct 
SIM-ilfil/li-C^CCSTl 

C tt^t(i^i^^ tcs ft-i *^c sih ph 

IHCI 3K. J7C. 3£C 
3tC CCSP-CCSl 

Ct IC 2tC 
'TC CCSf CC^i•CCSI•CC^S•SIM 

.J- Muf ji;iccfcS»ccsi-cc*.s*siMl 

3«C IMII 2SCt 3SC, *CC 
2SC SI^F■rlI^F 



fEDfC^f «CT<UCh 



*CC CC *IC i-i.*- 
t3"ll*I 

«-*(L31»CCSP**U*l*SlfcP 

*a4J— *a3i«si*p«*(iA»»cosp 

41C «(13)-4I 
42C CChlULf 
CC IC I3C 

*3C CC A4C 1-1. f 
CC **C ,•!.<( 

*«C ilL)«*lt l"»-tl I 

: CftC* C^ CC''»'Lf.*L»ll€5 

c 

^C-I>\i-1 
CC *5C I'UP 
45C mi-KlMUlt 
CC *K I-l.** 
f(l)-C.C 

CC *ec j-i.* 
l-^«tJ-II*l 

46C flll'Fli t»*ll J'/ltl 
*7C CU»-KiI-f(l) 

»EIt<f> 

ff'C 



VAAM1220 
VARH1240 

V*flMl2TU 
Vt(tH12<ia 
VAR*'»2'»0 
VARr<130n 
VARflllO 
V*RI*1320 
VARf 1330 
VAftHl340 

VARI'1360 
VARf<13 70 

VARKl^OO 

VARfl-«20 
VARFl^SO 
VARM1440 
VARr<14%0 
VARH1460 
VARr<1470 

VARfl^eO 

VARf 1490 
VARfL^OO 

VARH1S20 
VARf 1530 

VAftfl»1iO 
VARf 1560 
VARr<l%70 
VAttMDflO 
VARf 1^90 
VARK1600 
VAAPL610 
VARf L620 
VARH1630 
VARHL640 
VARf 1690 
VARf 1660 
VARf 1670 
VARfUaO 
VARM1640 
VARf*l700 
VARf 1710 
VAR>'L770 
VARf'lTSO 
VARf 1T40 

VAflf irso 

VARMII6Q 

VARflTTO 

VARf ireo 

VARMITSO 

VARf ISOO 

VAR«18tO 

VARH1820 

VARf 1830 

VAAflS^O 

VARRieSO 

VARM1860 

VARflSTO 

V ARM 1 880 

VARf 1890 

VAAfl^OO 

VARf 1910 

VARf 1420 

VARfl930 

VARf 1940 

VARf 14S0 

VARHL960 

VARf 1970 

VARf 1980 

VARf 1990 

VARNZOOO 

VARf2aiO 

VA«f2020 

VARf 2330 

VARf2040 

VAB-205O 

VARf 2060 

VARf 2070 

VARfZOaO 

VARf 2090 

VARf2lOO 

VARf2L10 

VARf212n 

VAflf2130 

VARf2140 

VARf 2150 

VAAM216a 

V»R'"2X70 

VAfiM21B0 

VARf2l90 

VAR«'2200 

VAAf22lG 

VARf2220 

Vft«''2230 

VARf2240 

VAR«2250 

VARf2260 

VARf2270 

VftRH22B0 

VARf 2290 

VAftf2300 

VARM2310 

VARf 2320 

VARf233a 

VARf 2340 

VARf2)50 

VA«f2360 



Time Series (see Smoothing) 
Subroutine AUTO 

This subroutine calculates the autocovariances for 
lags 0. 1, 2, .... (L-1). given a time series of 
observations Aj^, Ag, . . . , A^^ and a number L. 



n-j+1 



R. 



j n-j+1 



y^ (A. - AVER) (Aj^._j^- AVER) (1) 



1=1 



where AVER 



n JL^ 1 



i=l 



n = number of observations in time 
series A 

j = 1, 2, 3, . . . , L represent time 
lags 0, 1, 2, .... (L-1) 



WBAGjriNE AJTO 

""^fo^iHO »jrxav«iA.*C£S of sesits a fOR L*ts o tq l-i. 

USAi^E 

C*U AJTJ (A*NA.RI 

WHt3S£ AUruCOVAHIMKE IS 0£SMtO. 
M - *.eHGTH Of THE VECTOR *. ,. «^ « ■ , 

t. - AUTJCaVMUHCe IS CAtCUtATtO FOR L*CS OF 0. 1, 2f... 

« - JjTRUr VECTOR OF LtlWitH t CONTAINING AyjoCOVAftlAliCtS 

OF iCRlES A. 

""iSt^EhlilH Of R IS UlffeREMT f.*0f IM£ LENCTh Of A- N KUJf 
lf*iRe;i'R ?«« L. If HOf, R4U IS S« T TO ZERO UiO «Tl«l* 
IS «AQ£ TO TrtC cALCiNC PROCRA*!. 

SUBROUriNaS and fUNCTIUW SliafRO«Af$ REOUIREO 
■mCH€ 



6C 



1 00 



fETHOJ 

OF fOWER SfecTRA 



OtiCRldta IN R.d. atACKMAW AM J.K. TJKEV. •!« HE*SU««IIT 
- DOVER fuatlCATlOwS I»*C., i»£- *0«t, l«». 



su«Rauri*t£ AUTU (a.h.l.R) 

OINENSION AUt.RUI 

CAlCUtATE AVtAAGE Of TIME SERIES A 

AVtK=C-0 

lf<M-4.l iO.iiC.lOO 
$0 RUI-O.C 

RETURN 
LCC CO llO l-L«*l 
lie A«a«AviR*A« l> 

fH-N 

*VER*AVER/FN 

CACCiiL*TE AurUCOVARIAMCtS 

bO 130 J-ltL 

NJ-N-J*! 

SUM-CO 

DO 120 l-L.MJ 

IJ-IO-1 
120 SW*-SO<1*U(ll-AVER)*IAlIJ|-AVERI 

fNJ-NJ 
13C RlJl-SJM/fNJ 

ME TURN 

ENO 



AUTO 
AUTO 
AUTO 

Auro 

AUTO 
AUTO 
AUTO 
AUTO 
AUTO 
AUTO 
AUTO 110 
AUTO 120 

Auro IM 

AUTO 140 
AUTO 150 
,AUTO 160 
AUTO ITO 
AUTO 180 
AUTO 190 
AUTO 200 
AUrO 210 
AUTO 220 
AUTO 2)0 
AUTO 240 
AUTO 250 
AUTO 260 
AUTO 270 
AUTO 280 
AUTO 29C 
AUTO 300 
AUTO )I0 
AUTO 320 
.AUTO 3M 
AUTO 340 
AUTO 350 
AUTO 360 
AUrO 370 
AUTO 380 
AUTO 390 
AUTO 400 
AUTO *10 
AUTO 420 
AUTO 430 
AUTO **0 
AUTO 450 
AUTO 440 
AUTO 470 
AUTO 480 
AUTU 44C 
AUTO 500 
AUfO 510 
AUTO 520 
AUTO 530 
AUTO 540 
AUTO 55C 
AUT Q 5*0 

AUTO sro 

AUTO 580 
AUTO 5«C 
AUTO 600 



Statistics— Time Series 59 



Subroutine CROSS 

This subroutine calculates the cross covariances of 
series B lagging and leading A, given two time 
series A^, A2, . . . , Aj^ and Bj, B2, • • • , B^ and 
given a number L. 

(a) B lags A: 

n-j+1 
Rj = ;4^ ^ (Aj - AVERA) (Bi+j_i - AVERB) 

i =: 1 

(1) 

(b) B leads A: 



n-j+1 



Sj = 



Sq+I ^ (A.+j_i - AVERA) (Bj - AVERB) 



1 = 1 



(2) 



where AVERA 



n / ^ 1 



100 



PUKt»CSt 

TO UNO THc CROSSCOVArtlANCtS Of ScRlfcS A HIIH !.EKI£S 6 
ItaHlCH LtAt>S ANO LAGS A). 



CALL CROSS 1 A,B,N,L,K.S) 

dtSCKit'T lUN aF PAftAM£IERS 

A - INPUT VfcCrOR 01- LENGTH H CgnTaInINC FIRST TIME 

SfcRItS. 
d - INPJI VECTOR OF LENGTH N COnIAIMNO SEConO TIM£ 

iERltS- 
N - LtN&TH Of SERItS A AND S. 

L - CKJiSCOVAKlANCE IS CALCULATED fO« LAGS ANO LfcADS Of 

0. 1. I L-l. 

K - OUTPUT VECrOK Of LENGTH L COKTAINING CROSiCOVARI- 

AmCcS Of A kilH B, MHc<4t 6 LAGS A. 
S ~ CUIfUI veCTCJH OF LENGTH L CJSTAINING CROSSCOVARI- 

AhCcS OF A U[TH U, HHcR£ B LEADS A. 

(tEMARKS 

N HUSr Be uREATER THAN L. If HOT, ft(l) AhO SUl ARE SET TO 
iERO AND RtTURN IS «AOE 10 THt CALLING PAOGRan. 

sua-iouriNts and function subprograms required 

NONE 

McTHOO 

dtSCRIBcO IN R.e, 6LACKMAM ANJ J.W. TUKEV, 'THE MEASURMENT 
Of POWER SPeCTRA', OOVEK PUBLICATIONS INC., NEW YORK, 1959. 



SueRUUT !,<«(: C.<USS (A.A > N.L, R. S ) 
DIMENSION A( l>td(II .Rl 1I,S( II 

c«Li:uLAre AvERAces Uf series a and a 

fN = N 

AVERA^C .0 

AVERb=0.0 

If IN-l »50,5Ci ICO 

«t 11 =C.C 

SUMO.O 

RETURN 

00 ii,C (il.N 

AVtRA = AVERA».A( I J 

AVtRd=AVERB*iH I » 

AVERA=AVERA/FN 

AVERa=AVERe/fN 



2C 



i=l 



CALCULATE CR05SC0VARIANC£S'0f SERIES A AND B 

DO 130 J=l,i. 

NJ=N-J*1 

SU««=0.0 

SUrtS'0.0 

DO 120 I'IrNJ 

U»I*J-1 

SliHR-SJhR*-! A( I I -AVEKAl*<6l IJ I -AVERB) 
12C SUNS'$UHS«<A(IJ)-AVERA|*(e(n-AVtRBl 

fNJ=MJ 

R{ JI=SJHR/FNJ 
IJO SIJ|=SJMS/FNJ 

Re TURN 

END 



CROS 
-CROS 
CROS 
CROS 
CROS 
CROS 
CROS 

CROS ao 

CROS 90 

CRGS iOO 

CROS 110 

CROS 120 

caos 130 

CROS 140 

CROS ISO 

CROS 160 

CROS 170 

CROS lao 

CROS 190 
CROS 200 
CROS 210 
CROS 220 
CRGS 230 
CftOS 2*0 
CROS 2^0 
CAOS 260 
CROS 270 
CftOS 280 
CROS 2 90 
CROS 300 
CROS 310 
CROS 3 20 
CROS 333 
CROS 3*0 
CROS i50 
CROS 360 
..CROS 3TC 
CROS 330 
CROS 390 
CROS *00 
CAOS 410 
CROS 4 20 
CROS 4 JO 
CROS 440 
CROS 450 
CROS 460 
CROS 470 
CROS 480 
CROS 490 
CROS 500 
CRGS 310 
CROS 520 
CROS 530 
CROS 540 
CROS 550 
CROS 560 
CROS 570 
CROS SSO 
CROS 590 
CROS 600 
CROS 610 
CROS 620 
CROS 6 30 
CROS 640 
CROS 650 
CAOS 660 
CROS 670 
CROS 680 
CROS 690 
CROS 700 
CROS 710 



AVERB 



= "^ E ^ 



i=l 



n = number of observations in each 
series 

j = 1, 2, . . . , L represent time lags 
(or leads) of 0, 1, 2, .... (L-l) 



60 Statistics— Time Series 



Subroutine SMO 

This subroutine calculates the smoothed or filtered 
series, given a time series Aj, A2, . . , , A^^, a 
selection integer L, and a weighting series Wj, 
W2, .... Wn,. 



R. = "y^ A • W. 

where p = j • L - L + k 
k = i - IL + 1 
i = IL to IH 



IL = ^^^ . 1 



(1) 



IH = n - 



L (m-1) 



(2) 
(3) 



L = a given selection integer. For ex- 
ample, L = 4 applies weights to every 
4th item of the time series. 

m = number of weights. Must be an odd 
integer. (K m is an even integer, any 
fraction resulting from the calculation 

of ^ ^"^"•^^ in (2) and (3) above will be 

Li 

truncated. ) 
n =^ number of items in the time series 

From IL to IH elements of the vector R are filled 
with the smoothed series, and other elements with 
zeros. 



iUc'^GUIlNE iHJ 



TO iMQCJTri Jh FiLTtfl StftltS A flV WtlGHTS W. 



CALL SMo ( A,N.M,M,L.Rt 



Tine seRUS Data. 



. SMU 
SHD 
SMO 
SMO 
SMO 
SMO 
SMU 
SMO 
SHO 
SHQ 
SHO 
SHO 
SHO 
SMO 
SHO 
SHO 
SHO 
SHO 



JtSCRIPTIUN Qf f»ARArtLTfckA 

A - INPUT VECruK OP t.£N<jTH N CJNTAINlN;; 
.4 - LtNGTH OF StftlfcS A. 

4 ~ INPUT </tCTaK Of LENGTH K CONTAIfJlNG nEIGHTS. 

1 - NUMbtk Ur iTtHS IN WtlGMI VECTOR, M MUST BE AN 000 

IHTtGER. (If M IS AN tVEN INTtGER, ANY FkACTION 

RtSJlIiNu fRDM THE CALCULATION Of (L*lH-ll)/^ IN (II 

ANL> (21 tiELOM MILL BE TRUNCATED.} 

^ - SEi.ECTIU'iJ iMTcGt-l. FOR fcXAKPLt, L = U MEANS THAT WEIGHTSSHD 

ARE A^'PLItU TO EtffcRr 12-Trt ITEM QF A- L = l APPLIES SMO 

HEIGHTS TO SUCCESSIVE ITcHS Of A. FOR HaNTHLY OATAt SHO 

L=l^ GIVES VEAft-TO-Y£AR AVERAGES AND L=I GIVES HONTH-TO-$MO 

HuhlTH AWcRAGES. SHG 

.1 - OUTPJT VECTOR OF LENGTH N. FCOH IL TO IH ElEHENTS OF SHO 

iHt VECTOR ft ARc FILLeo WITH THE SHOOTHED SERIES AND SHC 

OTHtR tLfcMENTS WITH ZERO, rfHERE SHO 

H. = lL*(H-in/2*l (l> SHO 

iM=N-tL*lH- 1)1/2 (21 SMO 

SMO 

REMARKS &HO 

N MUST BE GRtATCR THAN OR EdUAL TO THE PRODUCT Of L»H. SMO 

SMO 

SUtiHOuriNES ANO FUNCTION SU8PR0GRAHS KEQUtRED SMO 

NONE SHC 

SMO 

METHOD SMO 

■<EFt« TO THE ARTICLE 'fOflTRAN SU8RQUTINES FOR TIHE SERIES SMO 

ANALYSIS'. 8V J. R- HEALY AND B. P. BOGERT. COMHUNICATIONS SHO 

OF ACH, V.6. NO.l. JANUARY, 1463. SHO 

SHO 

SMO 

SHO 
SHO 
SMO 
SHO 
SHC 
SMO 
SHO 
SHO 
SHO 
SHO 
SHO 
SHO 
SHO 
SHO 



SUSROUTINc SHJ I A«N. W , M,L 1 R) 
DIMENSION A( l)iM( 1) >R( 1} 

INITULlZATlON 

00 110 1=1. N 

R(n =c,c 

IL=IL«<M-11 l/i*l 

iH=N-(L*(M-n \ri 

SMOOTH SERIES A dY WEIGHTS W 

00 120 I=lLtlH 

K=I-lL*l 

DO 12c J=i.M 

IP=( J*LI-L*K 

Rl Il-R( I)*A( iP)«W(j ) 

RETURN 

END 



SHO 
SHO 
SHO 
SHQ 
SHO 



100 
110 
120 
130 
140 
150 
l60 
170 
180 
190 
200 
210 
220 

2 30 
2<»0 
250 
260 
270 
280 
290 
300 
310 
J20 
330 
3*0 
350 
360 

3 70 
390 
390 
400 
410 
420 
430 
440 
450 
460 
470 
480 
490 
500 
510 
520 
530 
540 
550 
560 
570 
380 
5 90 
600 
610 
620 



Statistics — Time Series 61 



••' %x 



Subroutine EXSMO 

This subroutine calculates a smoothed series S, 
S2. • • • . Snx, given time series Xj, Xg, 
and a smoothing constant a . Also, at the end of the 
computation, the coefficients A, B. and C are given 
for the expression A + B(T) + C(T) /2. This ex- 
pression can be used to find estimates of the 
smoothed series for a given number of time periods, 
T, ahead. 

The subroutine has the following two stages for 
i = 1, 2, . . . , NX, starting with A, B, and C either 
given by the user or provided automatically by the 
subroutine (see below) . 



(a) Find S. for one period ahead : 

S. = A + B + 0. 5C (1) 

(b) Update coefficients A, B, and C: 



A = X. + (1 - a) (S. - X.) (2) 

1 11 



B + C - 1. 5 (a ) (2-Q') (S. -X.) (3) 



C = C - (a ) (S. - X.) (4) 

where a = smoothing constant specified by the user 
(0.0 < a < 1.0) 



EjtSM 


10 
20 
30 


EXSH 


EXSh 


*n 


EXSH 


90 


EXSH 


60 


EXSN 


70 


EXSH 


ao 


6XSH 


90 


EXSM 


100 


EXSH 


110 


EXSH 


120 


EXSH 


MO 


; exSh 


t«0 


EXSH 


ISO 


EXSH 


uo 


HAN EXSH 


iro 


EXSM 


180 



SUbMtAJTIKt £XSHJ 

t'URPOSE 

FiJ fiNU THE TRIPLt fcXPJNENTlAL SHOOThED SEHIES S OF THE 
GIVEN ScrtlES K. 

USAGE 

CALL CXSHO (XtNX*AL(A,d.C. SI 

JESCRIPriGN Of PAKAHETERS 

X - INPUT VECTOR Of LEN&IH NX CONIAtNlNG FIHE SCRIES 

Ot-TA WHICH IS rO HE EXPONLNTI ALLY SHaaTHED. 
NX - THE NUHBEfi OF ELENfchlS IN X, 

AL - SHJCJTHING CONSTANT, ALPHA. AL MUST BE GREATER Tl 

ZErtQ ANi) LtSS THAN ONE. 

A.fl.C - COcfFlCitNTS OF THE PREDICTION EUUAriQN HHtRt S IS EKSM 190 

PKEOICTcO T PEklOOS HcMCE liV EXSH 200 

A * d#r + C*T*T/2, tXSM 210 

AS INPUT— If A=6=C«C, PRDCRAH MILL PROVIOC INMIAl. EXSH 2Z0 

VALUE!!. IF AT LtAST ONE OF AfBtC IS NOT ZEROi exSM 230 

PftOURAH klLL TAXt GIVEN VALUES AS INITIAL VALUES. EXSH 2+0 

AS OJTPUI-- A.B.C CONTAIN LAFESr, UPOArCO CQfcfFI- EXSH ZbQ 

CUNTS OF PREOICTION. EXSH 260 

S - OUTPUT VECTOR Jf LENGTH NX CONTAINING IRIPLt EXSM 270 

EXPONENTIALLY SHOOTHEO IlHE SERIES. EXSH 280 

EXSH 2V0 
EXSM 300 
EXSH 310 
EXSH 320 
EXSH 33C 
EXSH 340 
EXSH 350 

HETmOO EXSM 360 

RtrER TO K. 6. BROWN. 'SMOOTHING^ FORECASTING AND PREOICTIONEXSH 370 
Of OISCRtTE T IMt SERIES** PRENTICE-HALL, N.J., 1963, EXSM 3aO 

PP. 140 TO 144. EXSH 390 

EXSH 400 



REMARKS 
NUNt 



SUHROUTINES ANO FUNCTION SuePROGRAMS REQUIRED 
NONE 



SU8RUUTINC EXSMu IX,NX*AL*A.> 
DIMENSION XI II, SI II 



IF A'B = C-C'.0, GENERATE INITIAL VALUES OF A, S, ANO C 





IflAI 140, UOt 140 


no 


IFiai IW, 120. 140 


uo 


IFICI 14-3, 130, 140 


lie 


C = XUI-2.0*XI2I+XO) 




a=«(2)-X( 1(-1.5*C 




A=Kll)-B-0.5*C 


140 


6E-1.0-AL 




aEcue=BE*ae*e£ 




ALCUa«AL*AL*AL 



00 THE FULLOMlNG FOR \'l TO NX 
00 150 I-l.NX 

FINU S(l) FOR ONE PLRIOO AHEAO 
Sm«A*8*0-5*C 

UPDATE COEFFICIENTS A, 6, ANO C 
DIf = SI I 1-XII I 

A3X(n»eEcuB*oif 

E=b*C-1.5*AL*AL*(2.0-*LI»OIF 

L-C-ALCUB»D1F 

RETURN 

END 



..EXSM 410 
EXSH 420 
EXSH 430 
EXSH 440 
EXSH 4S0 
EXSH 460 
EXSH 4 70 
EXSH 4S0 
EXSM 490 
EXSM 500 
EXSH 510 
EXSM 520 
EXSH 530 
EXSH $40 
EXSH SSO 
EXSH S6C 
EXSH 370 
EXSM 590 
EXSH 590 
EXSH 600 
ExSH 610 
EXSH 620 
EXSH 630 
EXSM 640 
EXSH 650 
EXSH 660 
EXSH 670 
EXSH 660 
EXSM 690 
EXSH 700 
EXSH 710 
EXSH 720 
EXSH 730 
EXSH 740 



If coefficients A, B, and C are not all zero (0.0), 
take given values as initial values. However, if 
A = B = C =0,0, generate initial values of A, B, 
and C as follows: 



c = x^ - 2X2 + X3 



B = X - X - 1. 5C 



A = X - B - 0.5C 



(5) 
(6) 
(7) 



62 Statistics — Time Series 



Nonparametric Statistics 

Subroutine KOLMO 

Given a sample of n independent and identically dis- 
tributed random variables Xj^, Xg, . . . , X^^ with 
continuous cumulative distribution function F(x), 
this subiroutine tests the difference in absolute value 
between the empirical distribution Fn^'^^ ^^^ theo- 
retical distribution F(x), using Kolmogorov- 
Smimov's limiting distribution. 

For this purpose: 

1. The order statistics {x(i)] are determined 
from the set {xi} by sorting [x^jinto a nondecreasing 
sequence. 

2. The empirical cumulative distribution function 
Fjj(x) is computed. This is the following step-func- 
tion: 



X <x 



F (X) = < k/n 
n \ 

1 



(1) 



^(k)^"<"(k+l)='^^'"''^-' 



X, . ^x 
(n) 



3. The maximum deviation D in absolute value 
between the empirical and theoretical distribution 



is computed: 



D = Max 

^ _oo<x<°° 



|F^(x) - F(x)| 



Since F (x) and F(x) are nondecreasing functions , 
the result is: 

D = Max |f^ [x^J -F [x^JI 

Isksn 

D is a random variable, and L(z) is the limiting 
cumulative distribution function of n^/^ D^^: 

lim Prob [n^/^ D^ < z] = Uz) 

n-»<» 



4. Finally, 
z = nl/2 



D„ 



and the probability of being greater than or equal 



to the computed value of 

P = 1 - L(z) 
are computed. 



mg grea 
nl/2D 



Generally, theoretical distribution functions are 
to be included by the user, as specified in the pro- 
gram. However, four functions are evaluated in 
KOLMO, as follows: 



/ 



dF(t) = F(x) 



(1) 



is evaluated at the points of the set [X^^}, where 
F(x) is one of the following: 

• The normal pdf with mean u and variance s^ 

• The exponential pdf with mean u and variance 



• The Cauchy pdf with median u, and first quar- 
tile s - u 

• The uniform pdf with endpoints u and s 

Any user-written pdf should evaluate (1) above, 
using the parameters u and s at his convenience. 
Instructions given in the program KOLMO should 
be followed. 

Lilliefors (1967> notes that critical values de- 
termined by this test are not correct when one or 
more parameters are estimated from the sample. 
The user should refer to his article for notes on 
approximations which may be considered if such 
estimates are used. 

For references see: 

(1) W. Feller, "On the Kolmogorov - Smimov 
limit theorems for empirical distributions", 
Annals of Math. Stat. , 19, pp. 177-189. 

(2) N. Smirnov, "Table for estimating the goodness 
of fit of empirical distributions", Annals of 
Math. Stat. , 19, pp. 279-281. 

(3) R. Von Mises, Mathematical Theory of Prob- 
ability and Statistics . Academic Press, New 
York, 1964, pp. 490-493. 

(4) B.V. Gtoedenko, The Theory of Probability. 
Chelsea Publishing Co. , New York, 1962, pp. 
384-401. 

(5) H. W. Lilliefors, "On the Kolmogorov-Smimov 
test for normality with mean and variance un- 
known", J. A. S. A. , 62 (1967), pp. 399-402. 



Statistics — Nonparametric Statistics 63 



SUa^nuTINE KOLHO 

PURPOSE 

TESTS THE OrFFEqENCF BETWEEN EMPIRICAL *N0 THFQRETrCAL 
[)I STc laj-'iOMS USING THf KOLWOOROV-SMIBNOV TEST 



KnL«0(X,W, i.PPnp, IFCODiU.';, lER) 



50 



OeSCFIPTIQN OF PJIRAMEIERS 

X - INPUT VECTOR OF N INDEPENDENT OBSFRVAT 1 ONS. ON 

RfTURN FRHM KOLMO, X MAS BEEN iORTEO IMTfl A 
HCNnTONIC NON-PECREASINC- SEQUENCE. 

N - NUM'^FP OF OBSftVATlON; IN X 

I - OUTr'UT VARIftBLE CONTAINING THE GREATEST VALUE MIT 

PfSPECT in X PF SORT 1 Nl ♦teSCFNtXl -F ( X ) I WHERE 
F(X) IS A THEORgTICAL 0ISTRI6UTI0N FUNCTION AND 
F^(X) AN EfPIFICAL DISTCIBuTlDN FUNCTION. 

PROB - OUTPUT VARIABLE CONTAINING THS PROeAfilLITY OF 

THE STATISTIC eeiNG GREATER THAN DR EOUAl TO I IF 
THE hVPOTHESIS THAT « IS fRON THE DENSITY UNDER 
CONSTDERATIDN IS TRUE. E.G., PROB > O.OS IMPLIES 
THAT ONE CAN REJECT THE NULL HYPOTHESIS THAT THE SET KLHO 260 
IS FROM THE DENSITY UNDER CONSIDERATION WITH 5 PER KLMO 270 



HLMO 
.KLMO 
KLHO 
KLHO 
KINO 
KLHO 
KLHO 
KLHO BO 
KLHO 90 
KLHO 100 
KLNO 110 
KLHO 120 
KLHO 130 
KLMO 140 
KLHO 150 
KLHO 160 
KLHO 170 
KLHO 180 
KLHO 190 
KLHO 200 
KLHO 210 
KLNO 220 
KLHO Z30 
KLMO 240 
KLNO 250 



PROS 



CENT PRDflABUITY OF BEING INCORRECT. 

SHIRNII). 

A CODE DENOTING THE PARTICULAR THEORfllCAL 
PROPABILITY DISTRIBUTION FUNCTION BEING CONSIDERED. 

= 1 FIX! IS THE NORMAL PDF. 

= 2— -fIXI IS THE EXPONENTIAL PDF. 

= 3 F(XI IS THE CAUCHV PDF. 

= 4 fix) IS THE UNIFORM PDF. 

= 5 FIX) IS USER SUPPLIED. 

KHFN IFCOD IS I OR 2, U 15 THE MEAN OF THE DENSITY 

GIVEN ABOVE. 

NH£N IFCOO IS 3. U IS THE MEDIAN OF THE CAUCHY 

DtNSITV. 

WHEN IFCOO IS 4. 

UNIFORM DENSITY. 

WHEN IFCOO IS 5. 



U IS THE LEFT EMDPOINT OF THE 



KLHO 280 
KLHO 290 
KLMO 300 
KLHO 310 
KLHO 320 
KLMO 330 
KLHO 340 
KLHO 3S0 
KLMO 360 
KLHO 370 
KLHO 380 
KLMO 390 
KLHO 400 
KLHO 410 
KLHO 420 
KLMO 430 



METHOD 

FCR REFERENCE. 



IS USER SPECIFIED. 
WHEN IFCOD IS 1 OR 2, S IS THE STANDARD DEVIATION Of KLMO 440 
DENSITY GIVEN ABOVEr AND SHOULD BE POSITIVE. KLHO 450 

WHEN IFCOO IS 3. U - S SPECIFIES THE FIRST QUARTILE KLHO 460 
CF THE CAUCHV D£NSITY. S SHOULD BE NOh-ZFRO. KLHO 470 
IF IFCDO IS 4, S IS THE RIGHT ENOPOINT OF THE UNIFORNKLNO 480 
DENSITY. S SHOULD BE GREATER THAN U. KLHO 490 

IF IFCOn IS 5. S IS USER SPECIFIEO. KLNO 500 

ERROR INOICATOP WHICH IS NON-ZERO IF 5 VIOLATES ABOVEKLHO 510 
CONVENTIONS. ON RFTURN KG TEST HAS flEEN HAOE* AND X KLHO 520 
AND Y HAVE BEEN SORTED INTO HONOTONIC NON-DECREASING KLHO 530 
SEQUENCES. lER IS SET TQ lERO ON ENTRY TO KOLHO. KLHO 540 
lER IS CURRENTLY SET TO ONE IF THE USER-SUPPLIED PDF KLHO 550 
IS REQUESTED FOR TESTING. THIS SHOULD BE CHANGED KLHO 560 
tSEE REHARKSl WHEN SOHE PDF IS SUPPLIED BY THE USER. KLHO 570 

KLMO 580 
KLNO 590 
KLHO 600 
KLNO 610 
KLNO 620 
KLHO 630 
KLNO 640 
KLNO 650 
KLNO 660 
KLHO 670 
KLNO 6S0 
KLHO 690 
KLNO 700 
KLNO 710 
KLMO 720 
KLMO 730 
KLNO 740 
KLHO 750 
KLNO 760 
KLNO 770 
KLHO 7B0 
KLNO 790 

KLMO aoo 

KLMO 810 

KLMO 620 
KLHO 830 
KLMQ B40 
KLMO 850 
ON THE KCLMOGOROV-SMIRNOV KLHO 860 



N SHJULD BE GREATER THAN OR EOJAL TO 100. C SEE THE 
KATHFM4TICAL DESCRIPTION GIVEN FOR THE PROGRAM SMIRN. 
CONCEKMNG ASYMPIOTIC FORMULAE} ALSO. PROBAeiLITY LEVELS 
OETE'l'ilNEn BY THIS PROGRAM HILL NOT BE CORRECT IF THE 
SAME SAMPLES ARE USED TO ESTIMATE PARAMETERS FOR THE 
CONTINUOUS OISTRieuTIONS WHICH ARE USED IN THIS TEST. 
ISEE THE HATHEHATICAL OESCRlPTtON FOR THIS PROGRAHI 
F(XI SHOULD BE A CONTINUOUS FUNCTION. 

ANY USER SUPPLIED CUHULATIVE PROBABILITY OISTRISUTION 
FUNCTION SHOULD ?E CUOEO BEGINNING WITH STATENENT 26 BELOW 
AND SHOULD RETURN TO STATEHENT 27. 

DOUBLE PRECISION USAGE II IS DOUBTFUL THAT THE USER WILL 

HI5H TO PERFCKH THIS TEST USINS DOUBLE PRECISION ACCURACY. 
IF ONE WISHES TO COMMUNICATE WITH KOLHO IN A DOUBLE 
PRECISION PROGRAM, HE SHOULD CALL THE FORTRAN SUPPLIED 
PRGCRAP SNGL(X) PRIOR TO CALLING KOLHO, AND CALL THE 
FORTRAN SUPPLIED PROGRAM DBLEIXJ AFTER EXITING FROM KOLHO. 
(NOTE THAT SUfiOCUTINE SHIflN DOES HAVE DOUBLE PRECISION 
CAPABILITY AS SUPPLIED BY TH S PACKAGE.) 



SUBROUTINES AND FUNCTION SUBPROGRAMS REOUIPEC 

SHIRN. NOTR, ANC ANY USER SUPPLIED SUBROUTINES REQUIRED 



SEE < 1 J W. FELLER- 



LIMIT THEDRcKS FOR EMPIRICAL DISTRIBUTIONS- 
ANNALS OF MATH. STAT.t 19, 1948. 177-189, 
(2) H. SMIRNPV — TABLE FOR ESTIMATING THE GCCDWESS OF FIT 
OF EMPIRICAL Dl STR IBUT IONS — ANNAL S OF MATH. STAT., 19, 
1946. 279-2B1. 

131 R. VON HISES — MATHEMATICAL THEORY OF PROBABILITY AND 
STATISTICS — ACADEMIC PRESS, NEW YORK, 1964. 490-493, 
14) 8.V. GNEOENKO — THE THEORY OF PROBABILITY — CHELSEA 
PUeHSHlNG COMPANY, NEW YORK, 1962. 384-401. 



,I,,Z,PR0B,1FCQ0,U.S,IEPI 



SUBROUTINE KOLMC(X 
DIMENSION Xt 1) 

NON DeCREBSINC nRJEBlNG CF Kdl'S (DUBY MtlhDO) 

IEB = 

DO 5 1=2, N 

IFIX( I t-K( I-IJ H . 5,5 
TEWP^Xl I J 
IM=I-1 
00 3 J = 1 , I M 
L=I-J 

IFtT£«P-X(L 1 I2,'.,'- 
X(L*H = K(L) 
I CONTINUE 
X( IMTEMP 
GO xa 5 
X1L*1I=TFMP 
CONTINUE 

coMPjies MAXIMUM aEvunoN DN ^H AasaLUTE value between 

EMDl:(I(;aL IND THETRETiCAL DISTRIBUTIONS 



NMl^' 


N-I 






XN = N 








DN = 


-0 






FS=0 


.0 






IL=1 








DC 7 


1 = 


u . 


NM1 


J=f 








IF(XI 


IJ)- 


K<j 


• 1) 



KLHO 870 
KLMC 6 80 
KLHO 890 
KLNO 900 
KLMO 910 
KLNO 920 
KLMO 930 
KLMO 940 
KLMO 950 
KLMO 960 
..KLMO 970 
KLHO 980 
KLNO 990 
KLMOIOOO 
KLMOIOIO 
KLM01020 
KLM01030 
KLM01040 
KLM01050 
«LM01060 
KLM01070 
KLMOIOSO 
KLH01090 
KLHOllOO 
KLMOl 110 
KLN01120 
KLMOL 130 

KLHOl 150 
KLHOl 160 
KLHOl 170 
KLM0I180 
KLM0U90 
KLHO) 200 
KLM01210 
KLM01220 
KLM01230 
KIM01240 
KLM01250 
KLMOl 260 
KLHai270 
KLHGI260 
KLM01290 



8 J=N 
<) IL=J»I 

f I-FS 

FS=FLOAT(J(/XN 

IF(!FCnD-2H0.n.l7 

10 IFfSlU, U,12 

11 iefi=i 

GO TO 29 

12 I =( X( J)-UJ/S 
CALL NOTRIZ.Y.OI 
GO ro 21 

1? IF IS III, 11,14 
1^ I=IX(J|-U)/S*1.0 
IF(z Ji5, 1'., 1/. 

15 Y=0.0 

GO Tr 27 

16 Y=l.-EXP(-i:) 
GO TO 2 7 

17 IF( lFC00-4|ia,20,26 

18 IFIS ll", II, 19 

19 V=ATANnX(JI-Ul/Sl»0.3iei099.0.5 
GO TO 27 

20 IFIS-UUl. 11 ,21 

21 IF(XiJ)-UJ.''?,?2.23 

22 T=0.0 

GO TO 27 

23 IFIX(JI-SI25, 25,24 

24 Y=I.O 

GO TO 27 

25 V=(X(J1-JI/(S-U» 
GO TO 2 7 

26 IER=1 

GO TO 29 

27 EI"AaS(Y-FI| 
cS=AeS(Y-FSt 
DN=AMAK] ION, EI, ESI 
IF( IL-N)6,8,28 



COMPUTES Z-ON»SQRT(N) AND PROBABILUY 



29 Z=ON*rORT(XNI 

CALL SMIRNU.PRO 
PROB= I.O-PROB 

29 RETURN 
END 



KLM0I300 

KLM01310 

KLMOl 320 

KLM01330 

KLMOl 340 

KLMOl 350 

KLM01360 

KLMOl 370 

KLMOl 380 

KLH01390 

KLMOl 400 

KLMOl 4 10 

KLM01420 

KLHQ1430 

KLMOl 440 

KLMDl'.^O 

KLMOl 460 

KLH01470 

KtM01480 

KLM01490 

KLM0I500 

KLMOISIO 

KLMO1570 

KLMOl 530 

KLMOl 540 

KLMQ1550 

KLMOI560 

KLMOl 570 

KLH015aO 

KLM01590 

KLHai600 

KLM01610 

KLH01620 

KLM01630 

KLMO1640 

KLMD1650 

KLHOt660 

KLH01670 

KLM0t6B0 

KLH01690 

KLMOl 700 

KLM01710 

KLHOl 720 

KLHOl 730 

KLH01740 

KLMOl 750 



64 Statistics — Nonparametric Statistics 



Subroutine KOLM2 

Given a sample of n i. i. d. (independent and identi- 
cally distributed) random variables X. and a sample 
of m i. i. d. random variables Y, this subroutine 
tests the difference between the two empirical dis- 
tribution functions Fjj(x) and Gj^^Cy) using 
Kolmogorov-Smirnov's limiting distribution. For 
this purpose: 

1. The sets X and Y are sorted into the ordered 
sets {X(i) }and {Y(i)], which are nondecreasing se- 
quences. 

2. The empirical cumulative distribution func- 
tions Fj^(x) for the set X, and Gj^fy^ for the set Y 
are computed. For example, 



X < X 



(1) 



F(x) = {k/n x„.. x<x ;k=l....n-l 



(k) 



x, s X 
(n) . 



3. The maximum difference in absolute value 
between the two sample distribution functions is 
computed: 



D 



m,n 



max F (x) 
' n 
X, y 



G (y) 
m 



D, 



is a random variable 



. ^. Ann 
The statistic^ ^^5^ i^m, n 

with limitii^ cumulative distribution function 
L(z), which is described under "Subroutine 
SMIRN" in this manual. That is, 



lim 



m,n-+ «=, «> 



m,n 



< z } = L(z) 



4. Finally, the probability (asymptotic) of the 
statistic ,,y^^ Dm „ being not less than its com- 
puted value, under the assumption of equality of 
the two theoretical distribution functions from 
which X and Y were taken, is computed: 

P = 1 - L(z) 

For reference see: 

(1) W. Feller, "On the Kolmogorov-Smirnov limit 
theorems for empirical distributions". Annals 
of Math. Stat. , 19, pp. 177-189. 



(2) N. Smirnov, "Table for estimating the goodness 
of fit of empirical distributions", Annals of 
Math. Stat. . 19, pp. 279-281. 

(3) B. V. Gnedenko, The Theory of Probability. 
Chelsea Publishing C!o. New York, 1962, pp. 
384-401. 



SUtSaui INE KUL«? 



TEiTS THE DIFFEflENCE BtlweEK TMO SAMPLE DISTRIEUTIDN 

fi;NCTic»iS usiwr, the kolkcgopov-smibmov test 



,Y,N,M,£,P«Ce) 



KLKZ *0 

KLM2 50 

RLM2 60 

KLK? 80 

KLH? 90 

KLH2 LOO 

KLH2 ItO 

tiL'*2 120 



KLM2 



Of SCRIPT IPN Of PA«*HfTERS KLM2 

X - INPUT VECTCff OF ^ INDtPEND€NT OBSCl" V* TI CNS. ON KL«2 

RETURN FROH KOLM?, X h»S SEEN SORTED INTO A 
MONOTONIC hDN-DPC«EASING SEOlrtNCE. 

T - INPUT VECTOR Dp H INC»EPENOENT C6SERVAT IONS. ON 

RETURN FRCK «0LK2. T HAS BEEN SOOTED INTO A 
MONOTONIC NON-OrCf-EASING SEQUENCE. 

H - NUM^GR OF CBSERVATIQNS IN K 

M - NUMBER OF OeSERVATIGNS IN ¥ 

I - OUTPUT VAftlABLE CONTAINING THC GREATEST VALUE KlTH 

PESPECT TO THE SPECIFUM OF X *N0 V OF 
SORT( (M«NI/|M*Nn*ABS(FN( XJ-GMCYll WHERE 
FNtK) IS THE EMPIRICAL OlSTftlBUTION FUNCTION OF THE 
SET (XI AND GMtYl iS THE EMPIRICAL DISTRIBUTION 
FUNCTION Of THE SET (Y). 

PROe - OUTPUT VARIABLE CONTAINING THE PROeABILITY OF 

THE STATISTIC BEING GREATER THAN OR EQUAL TO Z IF 
THE HYPOTHESIS THAT X AND Y ARE FROM THE SAME PDF IS KLM2 
TRUE. E.G., PROB= 0.05 IMPLIES THAT ONE CAN REJECT KLM2 
THE NULL HYPQTHf^SIS THAT THE SETS X 4N0 Y ABE FROM KLM2 

THE SAME DENSITY WITH 5 PER CENT PRDflABILIIY OF BEINGKLM2 
iNCGRHECT. PROfl = 1. - SMIRNIZK 



KLM2 
KLM2 
KLM2 
KLM2 
KLM2 

¥im2 

KLM2 
KLM2 
KLM2 
K.LM2 
KLM2 
KLM2 
KLM2 
KLM2 



130 
lAO 
150 
160 
170 



REMARKS 

N AND H SHOULD BE GREATER THAN OR EQUAL TO 100. (SEE THE 
MATHEMATICAL DESCRIPTION FOR THIS SUBROUTINE AtJD FOR THE 
SU9RDUTINE SKIRN, CONCERNING ASYMPTOTIC fORMULAEJ. 

DOUBLE PRECISION USAGE IT IS DOUBTFUL THAI THE USER WILL 

WISH TO PERFORM THIS TEST USING DOUBLE PRECISION ACCURACY. 
IF ONE WISHES TO COMMUNICATE WITH K0LM2 IN A DOUBLE 
PRECISION PROGRAM, HE SHOULD CALL THE FQHTOAN SUPPLIED 
PGOCRAM SNGLIKI PRIOR TO CALLING KDL«2. AND CALL THE 
FDRI51AN SUPPLIED PROGRAM DBLEIXI AFTER EXITING FROM K.0LM2. 
(NOTE THAT SU9R0UTINE SMIRN DOES HAVE DOUBLE PRECISION 
CAPABILITY AS SUPPLIED BY THIS PACKAGE.! 



SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
SMIRN 



METHOD 

FDR REFERENCE. SEE (II W. FELLER— ON THE KOLMDCOfiOV 

LIMIT THEOREMS FOR EMPIRICAL Dl 5TR IBUT IONS-- 

ANNAL5 OF MATH. STAT., 19, 19*8- IT7-189, 

(21 N. SMIPNOV — TABLE FQl^ ESTIMATING THE GOODNESS OF FIT 

OF EMPIRICAL 9ISTRIBUTI0NS— ANNALS OF MATH. STAT.. 19, 

ig^q. 279-281. 

(3) R. VON MISES--MATHEMATICAL THEORY OF PROBABILITY AND 

STATISTICS — ACADEMIC PRESS, N^W YORlC, 19«A. 490-493, 

14) B.V. GNEDENKO — THE THEORY OF PROBABILITY — CHELSEA 

PUBLISHING COMPANY, NEW YORK, 1962. 384-401. 



SUBROUTINE K0LM2 I K , Y ,N ,M, Z , PRQBI 
DIMENSION X( 1),Y{ 1) 

SORT X INTO ASCENDING SEQUENCE 

DO 5 1=2,N 

IF(X(I)-XII-1I11,5,5 

TEMP=X(I } 

IM-1-1 

DO 3 J=1,IM 

L=[-J 

IFtlEKP-xlL 1 12. '•.A 
• XlL*lI»X(LI 
1 CONTINUE 

XI llxTEKP 

GO TO 5 
. X(L+II=TEHP 
i CONTINUE 

SORT Y INIC ASCENDING SEQUENCE 

DO 10 1=2,« 

If (Y( I l-Y( I- U It, 10, 10 
, TEMP=Y(n 
IM=I-I 

DO 8 J = l,I»i 

LM-J 

fF(TEMP-r(L» IT, 9. 9 
Y(L* 1)=Y(L» 
. CONTINUE 
YI II=TEHP 
GO TO 10 
Y(L*11=TEMP 
CONTINUE 

CALCULATE D = A8S(FN-GMJ OVES THE SPfCTflUM OF X AND 

XN=FLOAr(NI 

XN1=I./XN 

XM=FLCAT(MI 

XM1=1./XM 

0=0.0 

1=0 



KLM2 
KLM2 

KLM2 
KLM2 

KLM2 

KLM2 
KLM2 
KCM2 
KLM2 
KLM2 
KLM2 
KLM2 
KLMZ 
ICLM2 
RLM2 
KLM2 
KLM2 
KLM2 
KLM2 
ltLM2 
tCLM2 
IRNOV KLM2 
- ltLM2 



200 
210 
220 
230 
240 
250 
260 
270 
280 
290 
300 
310 
520 
330 
340 
350 
360 
570 
380 
390 
400 
410 
420 
430 
440 
4 50 
460 
470 

4 80 
490 
500 
510 
520 
530 
540 

5 50 
560 
5 TO 
580 
590 
600 
610 
620 
630 
640 
650 
660 
670 

KLM2 680 
KLM2 690 
KLM2 TOO 
KLM2 710 
KLM2 720 
KLM2 730 
x;LM2 740 
KLM2 750 
KLM2 760 
KLM2 770 
KLM2 780 
KLM2 790 
KLM2 600 
KLM2 810 
KLM2 830 
KLM2 830 
KLM2 840 
KLM2 850 
KLH2 860 
KLM2 870 
KI.M2 680 
KLM2 890 
KLM2 900 
KLM2 910 
KLM2 920 
KLM2 930 
KLM2 940 

nn2 950 

KLM2 960 
KLM2 970 
KLM2 980 
XLM2 990 
KLM21000 
KLM21010 
KLM21020 
KLM21030 
KLM21040 
KLM21050 
KLM2I060 
KLM21070 
KLM2I080 
KLM21090 
KLM21 100 
KLM21II0 



KLM2 
•tLM2 
KLM2 
KLM2 
KLM2 
KLM2 
KLM2 
KLM2 
KLM2 
.KLM2 



Statistics— Nonparametric Statistics 65 



J = 

I =0 
II IF(>tlMll-Y<J»ini?,l),IB 

GO in I* 

1 i K = 

It 1= i ♦ I 

iF(i-Nn5,?i,^i 

I »> IF«X( I«t l-XI I t 1 I*., l^, Ift 

16 If IK HT, 18, I T 

CHoor-f; THf-: hakimum uitfFKtNct, D 

17 n=AMA)Clin,AftSIHnAr( l MXNl-FtOAl (J1*XM1 I) 
IF(L iZZt 1 1.2? 

IH J=J»I 

IF(J-M) l'*,^0,?(J 

II in ft J»l I -Y) JM 1 1. IB, 17 

GO m 17 

?1 1 = 1 

GO TO Ih 

CALCULAIt THF STATISTIC 7 
22 Z=0»SOHI I(XN*XM1/I XNtKMI I 

CALCULAff THE PKOSABlLllY ASSOCUTtO MITH Z 



CAIL SHIOMI jT.poi 
PHD«= l.n-IJUDO 
Rf TURN 
END 



r^) 



KLN?1120 
KLK2I1)0 

KLn2l 150 
KLM?! 160 
KLH711T0 

KLH21180 

KIM21 190 

KLH71200 
KLM?l?10 

KLM212?0 
KLM21?»0 

KLM2I250 
KLM7I2A0 

KLMP12T0 
KIH212flO 
KLM?1?<10 
KLH?1 JOG 
KI-M21310 

KLMilHO 
KLM2I 1*0 
KLH2U50 
KLM?I 160 
Kl H21 jro 

KLM2neo 

»((.M21 190 
KlM?l/,00 
«I_M?1^I0 
KI.M?14?o 
KLM71410 
KLM2I<.*0 
KLM2MS0 



Subroutine SMIRN 

This subroutine computes the values of Kolmogorov- 
Smirnov's limiting distribution for a given argu- 
ment X. 







X s 



L(x) 



(1) 



1 - 2 Z (-1) exp (-2k\^) X > 
k=l 



L(x) is the limit (Kolmogorov) of the cumulative 
distribution function of .v/n^D . and of (Smirnov) 
[mn/(m+n) ] ^'^ D^ where: 



m,n 



Dj^ is the maximum, over all x, of the difference 
I F,^(x) - F(x) I between the sample distribution 
function F^(x) and the continuous theoretical dis- 
tribution function F(x), and 

D^ jj is the maximum, over all x, of the 
difference between the two sample distribution 
functions Fj^(x) and Gjj(x), from two independent 
samples of sizes m and n. 

When X is very small, the series (1) converges 
slowly, but, using Jacobi's Theta-functions 
e2(u,t) and e^(u,t): 



e„(u,t)=2 X) exp aTr(k+l/2) t] cos[(2k+l)u] 
^ k = 



k-1 2 

e (u.t) = 1 - 2 X; (-1) exp (iTTk t) cos (2ku) 

k = 



and using the Jacobi imaginary transformation 

-1/2 
e^ (0,t) = (-it) 62(0, -1/t) 



it follows that: 

L(x) =e^ (0, 21x^77) 



= (7^/x) XI exp C-(2k-l)^ 17^/8x^3 

k=l 

which converges quickly when x is small. The 
computation here uses, with errors Ej (x), i = l, 2: 



66 Statistics— Nonparametric Statistics 



r . 



X ^ 0<.27 



(y27r/x) X exp C-(2k-l)^77^/8x^] + 



k-1 



L (x)=< 



where: 



E (x); 0.27 <x< 1,0 



,c^ k-1 2 2 

1-2 X) (-1) exp (-2k X ) + E (X) 

' k = l ^ 



1.0 ^x< 3.1 

3ol ^ X <oo 

-15, 



E (x) < 6 (10 ) when x < 1 



Eg (X) < 10 



-20 



when X S: 1 



For reference see: 

(1) E. T. Whittaker and G. N. Watson, A Course of 
Modem AnalysiSo Cambridge University Press, 
Cambridge, England, 1952, pp. 462-476. 

(2) W. Feller, "On the Kolmogorov-Smirnov limit 
theorems for empirical distributions", Annals of 
Math. Stato 19, pp, 177-189o 

(3) N. Smimov, "Table for estimating the goodness 
of fit of empirical distributions", Annals of 
Math. Stat. 19, pp. 279-281o 



SLCDCLIlhC SflDK 

FLfFCSC 

CC^FbTCS VilLUCS OF JH LIflTINC OISIR ICUTICK FIKC.IION FCA 
11-C KCi.l*CGCDCV-$MIANCV SI#I|ST|C. ' 

LUCt 

CES<niP11Clt Cf 9»fitftJ(»S 

> - 11-C ARCtfehT OF It-E SfilRN fb^CTIQN 

V ' It-E RESLLTJthT SI'IRf FUhCTICfc VALiJE 



IS SET TC ItfC IF X IS ^CT CREAICP Ihttk 0.27. AhC IS SE1 



S»|ft 
.SM|R 



SFIft 
SI'IR 
S*I« 
SMIR 
S»'|R 
SKIR 
S"IR 
S*'|R 
SfIR 
SMIR 

S"m 

S^-IR 
St'lR 



JQ ChE IF % IS kOT LESS If«K 3.1. KCLRACV TESTS mEKE MOE SfIR 



OCFERIilAC 1C ll-E T464.C CHiEK IK ThE REFfiREnCE BELOta. 
It>C ARGUfEKIS. >- 0.62. »hC » - i,»1 CAVE RESLLTS WHICH 
CIFFER FRCf IfC SKIRhCb TiflLkS BY 2.<i AMC l.« Ift THE 3TH 
CECIfAL FLACE. ILL CTt-EK RESULTS Sl-Ch£0 Sr-ALLER ERRORS. 
ihC tRRCR SRECIFICAriChS ARE GIVEK I*. ThE ACCLRACV TACLES 
lA THIS RAKUAL. IN OCLCIE FRECISICh fCQ£« TtiESE SAME 
ARCUMCfcl! RESLLTEC Ih ClFFEREfcCES fRCf TASLEC VALUES BV 3 
tt^C 2 IK IFE STt- CECIRAl RlACC. |T IS hCTEC I*t 
llRCtiFEk IRfFCRENCE CCLCkl IhAI FCt HIGH SICRIfiCANCE LEVELSSRIR 
<£AT. .CL AhC .CSI ASVftPTCTIC FCRRULAS GIVE VALUES WHICH AflESfIR 
TCC I-ICF I ev l.S RER CEAI bHEN N • SO. TI-AT IS. AT HIGH SRIR 
SlCl^lflCAhCE LEVELS* THE ^VROIHESIS flf NO CIFFERENCE MILL BESnlR 



SnIR 
Sf IR 
S-IR 



SRIR 

S«IA 

SRIR 



RCJECIEC ICC SCLCCH USUC ASYHPIOIIC FORRULAS. 

StCFCLTIRES ANC FLKCIION SLERRCGRAPS RECLIREO 
RCKE 

RETfCC 

ll-E HEft^CC IS CE&CRI6EC CV k. FELLCR~CH T»-E KCLfOCCROV- 
SflRKCV LIRIT TFECREKS FCR ERRIRICAi CI STRiSLIIChS- AKMIS 
CF RAT»-. SIAT.« 1^. IS^fl. 117-189. SV fi. SRIRKOV — TABLE 
FCR ESIlRAIIfcC THE CCCCRESS OF FIT CF EMPIRICAL 
CISTHieLliCKS- Ahl^ALS CF RATH. STAT.* IS. l«4fl. 279-281. 
ARC GIVEh ll> LIROCREN. STATISTICAL IHECRV. ThC RACRILLAN 
CCRRARV. R. v.. 19«2. 



St'IR 
SRIR 
SRIR 
SNIR 
SRIR 
SflR 
Sf|« 
S^'IR 
SNIR 
S^IR 
SCIR 



SLBRCLIIhE SR1RR(>.VI 

CCUeLE FOEClSICh I .C 1 .C2.g4 .CE . t 

IF A CCLELE FRECISICR VERSICf CF T^IS RCtTIhE I! CESIREO. THE 
If> CCLURN CRE OF Tl-E DOUBLE PRECISIOR CARC ABOVE SHOULD BE 
HE^'ChEC. AfC TfE L IK CGLLRR CKE CF THE STATEfERTS KURBEREC 
C 3. C S. ANC C a SeCLLC SE REMCVEC* AKO THESE CARCS 

<I-CLLC REflACE TfE SIATEfERTS RURBEREO 3, S, JHC B. 
iiESFECtlVELY. ALL RCLTIKE! CALLIRC INIS ROUTINE RUST ALSO 
FRCVlCE CCLCLE PRECISIGK ARGLRERTS TC THIS RCtTIRE. 



St-IR 

..SMIR 

SRIR 

SRIR 

SMIft 

SRIR 

CSRIR 

SMIR 

S-IR 
S-IR 
S**IR 
SRIR 
SKIR 



IF(li-.211 1.1.2 
I ^-C.C 

EC TC S 
i IFIli-I.CI3.t.< 
3 CI"E>F(-1.23»ICiyx*»i) 

3 CI-C£XFI-l.2 331CC5 5Cl341T0/*««il 
C2-C1*C1 

C^-C24C2 

If IC«-l.CE-2£}4,5,5 

4 Ct-C.C 

5 Y-(2.scet2a/«i"Ci*u.c*Cfl»{i-c»cs«Geii 

! 1-(2.:C«e2e2 7<%e3 1CCt./XI«Ql*(l.CCC«G8*(l.C0a*C8«CBI I 

CC TC « 
t IFIH-!.l IE. 1.7 
7 »-I.C 

CC TC S 
£ Cl-tAFI-i.C-Ji**) 
C Ci-CEXFI-2.CCC*a«AI 

(.2-Cl*Cl 

C4>C2*(;2 

C«-C«4C4 

Y*i.c-2.c*ici-c4«ce«(':i-cei I 

S FEICRR 
ERC 



.SRIR 
SflR 
SPIR 
SRIR 
Sf-IR 
SRIR 
SRIR 
SKIR 
$r>IR 
SRIR 
Sf-IR 
SflR 
SR!R 
Sf-IR 
S"I« 
SRIR 
S^-IR 
SRIR 
SRIR 
SRIR 
SRIR 
SRIR 
SKIR 
SVIR 
Si'IR 
SRIR 
SRIR 



SO 
lOO 

no 

120 
130 
1*0 
150 
160 

iro 

IBQ 
190 
200 
210 
220 
2 30 
240 
250 
260 
270 
200 
290 
300 
310 
320 
330 
340 
350 
360 
370 
360 
390 
400 
410 
420 
430 
440 
450 
460 
470 
460 
490 
500 
510 
520 
5 30 
540 
550 
560 
570 
SSO 
5S0 
600 
610 
620 
630 
640 
650 
660 
670 
660 
690 
700 
710 
720 
730 
740 
750 
769 
770 
780 
790 

aoo 

810 

820 
830 
840 
850 



Statistics — Nonparametric Statistics 67 



Subroutine CHISQ 

This subroutine calculates degrees of freedom and 
chi-square for a given contingency table A of ob- 
served frequencies with n rows (conditions) and m 
columns (groups). The degrees of freedom are: 



d.f. = (n - 1) (m - 1) 



(1) 



If one or more cells contain an expected value less 
than 1.0, chi-square will be computed, but the error 
code will be set to one. 

The following totals are computed: 



(2) 



T. = 2_^ A..; i = 1, 2, .,., n (row totals) 

j=l 

n 

T ~ y^ A .; j = 1, 2, . . . , ra (column totals) 
i=l ' (3) 



GT = 22 '^- (grand total) 
i=l 

Chi-square is obtained for two cases. 

(a) For 2x2 table: 



(4) 



x'=. 



GT 



^11 ^22 - ^12 ^1 



GT 
2 



<^ll"^12)(^l"^22>(^ll"A2l)(^12-^^2) 



(b) For other contingency tables: 



n m 



i=l j=l 



(a.. -E.V 



(5) 



(6) 



sudRouriNe cmisq 

PURPDiE 

CUHPUTt CHI-SQUARE fROM A CONTIN&ENCV TASLE 

USAGE 

CALL CHISy(A,N,M,CS,NLiFtI£RR,rR,rC) 

OtSCRIPTION OF PARAMerERS 

A - INPur MAFRIK, N BV M, CONTAINING CDNTiNGENCY FABLE 

N - NUMdER OF ROWS IN A «t i. t ,«oi.i: 

H - NUMBER Of COLUMNS IN A 

CS - CHl-SqUARE (OOTPUri 

NOF - NUMBER OF DEGREES OF FreEUOM (OurPUTI 

lERR - tfiROft CODE (OUTPUTI 

- nokhal case 

1 - expected value is less than l.o in ong or 

more cells 
3 - number of decrees of freedom is zero 
tr - work vector of length n 
tc - work vector of length h 

REMARKS 

If ONE OR MORE CELLS CONTAIN AN EXPECTED VALUE (I.E , 

THEORETICAL VALUEJ LESS THAN 1.0, CHI-SQUAR£ WILL BE 

COMPUTED. aUT ERROR COOE WILL 8E SET TO 1. 

SEE REFERENCE GIVEN BELOt*. 

CHI-SQUARE IS SET TO l£RO IF EITHER N OR M I S ONE IErroR 

CODE 3). 

SUbROOriNES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

DESCRIBED IN S. SIECfiL, 'NONPARAMETRIC STATISTICS FOR THE 
BEHAVIORAL SCIENCES', MCGRAW-HILL, NEw YORK, 1956, 
CHAPTER 6 AND ChAptER b. 



SUBROUTINE CHISQi A, N,M,CS . NOf , lERR, TR, TCJ 
DIMENSION A) II, Tftll I, TCd) 
C 

NM=N*M 
l£RR=0 
CS=0.0 
C 

C fINO DEGREES OF FREEDOM 

C 

NDF"{N-I)»(M-1I 
IFINOFl 5,5,10 
5 1ERR=3 
RETURN 
C 

C COMPUTE TOTALS OF ROWS 
C 

10 00 90 1=1, N 
TRdl-O.O 
Ij-I-N 
DO 90 J=1,N 
IJ=IJ4-N 
90 TR( 1 l = rRt I)4^AI IJI 

c 

C COMPUTE TOTAtS OF COLUMNS 

C 

U-0 

DO 100 J«1,M 

TC(J)=O.C 

00 100 1=1, N 

IJ-IJtl 
100 TC(J) = TCIJI«AUJI 

: COMPUTE GRAND TOTAL 

Gt»0.0 
DO lie I-l.h 
lie GJ=l.T*TRtl\ 

: COMPUTE CHI SQUARE FOR 2 BY 2 TAdLE (SPECIAL CASE) 

lF(NM-4( 130*120,130 
1<;0 CS''GI*(A6S(A( ll*A|4)-A(2l*A( 3) )-GT/2.0l**2 /(TCI 1 1 *rC (2 I *TrU ) 
l*rR(2ll 

RETURN 

CUMPUTE CHI StjUARE FOR OTHER CONTlNCiNCy TABLES 

130 IJ-C 

00 140 J=1.H 
DO 1<>C l=l,N 
Ij=Ij*l 
£=TR(II*TC(J)/GT 

IFie-l.OI 135, 1*C, 14C 
1J& lERR^l 
14C CS=CS*(A( IJ)-E(*( At lJ|-E)/£ 

RETURN 
END 



CMIS 
..CHIS 
CHIS 
CHIS 
CHIS 
CHIS 
CHIS 
CHIS 



80 

CHiS 90 
CHIS 100 
CHIS 110 
CHIS 120 
CHIS 130 
CHIS 140 
CHIS 150 
CHIS 160 
CHIS 170 
CHIS 180 
CHIS 190 
CHIS 200 
CHIS 210 
CHIS 220 
CHIS 230 
CHIS 240 
CHIS 250 
CHIS 260 
CHIS 270 
CHIS 260 
CHIS 290 
CHIS 300 
CHIS 310 
CHIS 320 
CHIS 330 
CHIS 340 
CHIS 350 
CHIS 360 
CHIS 3 70 
CHIS 380 
CHIS 390 
CHIS 400 
CHIS 410 
..CHIS 420 
CHIS 430 
CHIS *40 
CHIS 450 
CnIS 460 
CHIS 470 
CHIS 480 
ChJS 490 
CHIS 500 
CHIS 510 
CHIS 5 20 
CHIS 530 
CHIS 540 
CHIS 550 

CHIS Sf^rt 

CHIS 570 
CHIS 580 
CHIS 590 
CHIS 600 
CHIS 610 
CHiS 620 
CHIS 630 
CHIS 640 
CHIS 6S0 
CHIS 660 
CHIS 670 
CHIS 660 
CHIS 690 
CHIS 700 
CHIS 710 
CHIS 720 
CHIS 730 
CHIS 740 
CHIS 750 
CHIS 760 
CHIS 770 
CHIS 780 
CHIS 790 
CHIS 800 
CHIS 810 
CHIS 620 
CHIS 8 30 
CHIS 840 
CHIS 850 
CHIS 860 
CHIS 870 
CHIS 8S0 
CHIS 890 
CHIS 900 
ChIS 910 
CHIS 920 
CHIS 930 
CHIS 940 
CHIS 950 
CHIS 960 
CHIS 9 70 
CHIS 980 
CHIS 990 
CHISIOOO 



T. T. 

where E = -J— L 
ij GT 



i = 1, 2, ..., n 
j = 1, 2, ..., m 



68 Statistics — Nonparametric Statistics 



Subroutine KRANK 

The subroutine computes the Kendall rank correla- 
tion coefficient, given two vectors of n observations 
for two variables, A and B. The observations on 
each variable are ranked from 1 to n. Tied obser- 
vations are assigned the average of the tied ranks. 
Ranks are sorted in sequence of variable A. 
A correction factor for ties is obtained: 



T =y^,— ^ for variable A 

a -^ 2 



T =y^,-^ for variable B 

b ^ 2 



(1) 



where t = number of observations tied for a given 
rank 

The Kendall rank correlation coefficient is then 
computed for the following two cases: 



(a) if T^ and T^ are zero, 

S 



T =- 



(2) 



-n(n-l) 



where n = number of ranks 

S = total score calculated for ranks in vari- 
able B by selecting each rank in turn, 
adding 1 for each larger rank to its 
right, subtracting 1 for each smaller 
rank to its right 



(b) if T^ and/or T^ are not zero. 



T = 



>/F(^-^ ^/f 



(3) 



•1)-T^ Jin(n-1)-Tj^ 



The standard deviation is calculated: 



/ 2(2n + 5T 
^j 9n(n-l) 



The significance of t can be measured by 

T 



(4) 



(5) 



TtSI CLRKELATIOh fc£Il.fcN TWO VARUSLtS BV MEANS Of KtNOALL 
rtANK C0R«ELATION COcfflCldNT 



CALL KRAN«(I A.e.K^Nt TAU.SO.Z.NR) 

OtSCRU'TION Of PARAH£IfcBS 

A - IHPUX WECTOh OF N QdS€B WATIONS fOR FIRST VARIABLE 

B - [MPUr l/tCrUR Of N OaSeftVAllOHS for second VARIAetE 
R - GUTl'UT VtCTOR OF RANKED DATA Of LENGTH i*N. SHALLEST 

obset^vAriuN IS ranked i. larust is ranked n. ties 

ARt ASSIGNED average Of UtO RANKS. 
N - NUMbEK Of 06SERVATIIJNS 

TAU - KfeNOALL RANK CORKELATlUN COtfFIClENT (QUTPUTl 
SD - STANDARD DEVUTlCiN (OOTPUT) 
I - TtST OF SIGNlflCANCE OF TAU Ih TERMS OF NORMAL 

disthibut;un iuutput) 

NR - coot, FUR UNRANrttU DATA IN A ANU 6. i FOR RANKEO 
DATA IN A AND b IINPUTI 

REMARKS 

SD ANJ I ARE SET TO iCRQ IF N IS LCSS IHaN TEN 

SUBROUTINES AND FUNCTION SU8PR0CRAHS MQUIREO 

RANK 
T It 

NtTHOO 

DESCRIBEU IN S. SIEGEL, « NONPARAHETRIC STATISTICS FOR THE 
tJtHAVIORAL SCIENCES', HCGRAW-HILLt NEW VURK, 1956. 
CHAPTER 9 



SUBRliUT INE KRANKtAi BiR.N. TaU, SD, 2<NR1 
DIHENSICN A(1),6U)<RI1I 

SDsO.O 
Z-O.C 
FN«N 
fNl=N*(N-l) 

DfcTERMINE WHETHtR DATA IS RANKED 

If(NR-ll »t 10* % 

RANK DATA IN * AND B VECTORS AND ASSIGN TIED OBSERVATIONS 
AVERAGE Of TIED RANKS 

5 CALL RANK (A.R.N) 

CALL HANK (e.RCN-^l t .N) 
GO TO 4C 



BC 



MOVE RANKED DATA TO R VECTOR 

10 DO 20 l^^l.N 
20 Rdl'^Ad) 

DO 30 1-1 .N 

J«I+N 
30 R( J]'ii( 1) 

SORT RANK VECTOR R IN SEQUENCE OF VARIABLE A 

« lSOftI*0 

00 50 I-2.N 

IF(R(1I-A(I-LI) A5.50.50 
4* IS0RT=IS0RT+1 

RSAVE=R(II 

R( n=R( l-ll 

R(I-1»=RSAVE 

I2-I*N 

SAVER-^Rd^l 

A<l2l = ;)(l2-i) 

R(I2-11=SAVER 
SCI CONTINUE 

IfllSURTI <rC. 55*40 

COMPUTE S UN VARIABLE B. STARTING WITH THE FIRST RANK. AOO 1 
ro S FOR EACH LARGER RANK TO ITS RIGHT AND SUBTRACT 1 fOR EACH 

SMALLER RANK. REPEAT FOR ALL RANKS. 

55 S*O.C 

NH-N-1 

DO 60 i>:l,NM 

J=>N*I 

00 toC L=I*N 

K«N*L 

If(RtK)-RlJH 56,60,57 
5b S-S-1.0 

GU TO 60 
57 S"S*l.i) 
6C CONTINUE 



cuMPuit neo score i«oex for bqth variables 



CALL IlEtRiN.KT.TAl 
CALL TIE(R(N«I1 .N.KT.Td} 

COMPUTE TAU 

IFiTAI 70.65,70 
65 IFfTBI TC,o7,7G 
67 lAU=S/lC.5*fMI 

60 TO dC 

TC TAU=5/( ^saR^^c.5•F^^i-TA^)*(_saRT(o.5*FNl-TB)lI 

COMPUTE STANOAHU DEVIATION ANU / If N IS iC OR LARGER 



dC If(N-lJ) 9C, 

d5 SD=(S-tiI((2.l 

Z-IAj/iD 

JC RETURN 
tND 



3.ti5 

MFi«J»f N*5.C1 l/(9.0*FNnn 



KRAN 10 
KHAN 20 
KRAN 30 
KRAN 40 
KRAN 50 
KRAN 60 
KRAN 
KRAN 
KRAN 40 
KRAN 100 
KRAN lie 
KRAN 12C 
KRAN 13C 
KRAN 140 
KRAN 150 
KRAN 160 
KRAN 170 
KRAN 180 
KRAN 190 
KRAN 200 
KRAN 210 
KRAN 220 
KRAN 230 
KRAN 24C 
KRAN 250 
KRAN 260 
KRAN 2 TO 
KRAN 280 
KRAN 290 
KRAN 300 
KRAN 310 
KRAN 320 
KRAN 330 
KRAN 340 
KRAN 350 
KRAN 360 
KRAN 3 70 
KRAN 300 
KRAN 390 
KRAN 400 
KRAN 410 
KRAN 420 
KRAN 4 30 
KRAN 440 
KRAN 450 
KRAN 460 
KRAN 470 
KRAN 480 
KRAN 490 
KRAN 500 
KRAN 5 to 
KRAN 520 
KRAN 530 
KRAN 540 
KRAN 550 
K RAN 5 60 
KRAN 570 
KRAN 580 
KRAN 590 
kRAN 600 
KRAN 610 
KRAN 620 
KRAN 6 30 
KRAN 640 
KRAN 650 
KRAN 660 
KRAN 670 
KRAN 6B0 
KRAN 690 
KRAN 700 
KRAN 710 
KRAN 720 
KRAN 730 
KRAN 740 
KRAN 750 
KRAN 760 
KRAN 770 
KRAN 780 
KRAN 790 
KRAN 800 
KRAN 810 
KRAN 820 
KRAN 830 
KRAN 840 
KRAN 850 
KRAN 860 
KRAN 8 70 
KRAN 880 
KRAN 890 
KRAN 900 
KRAN 910 
KRAN 920 
KRAN 9 30 
KRAN 940 
KRAN 950 
KRAN 960 
KRAN 970 
KRAN 980 
KRAN 990 
KRANIOOO 
KRANIOIO 
KRAN1020 
K.RAN1030 
KRANIC40 
KRAN1050 
KRAMO60 
KRAN1070 
KRANlOaO 
KKAN1090 
KRANILOO 
KRANlitO 
K RANI 120 
KRAN1I30 
KRANtl40 

KRANI160 
KRANU70 
KRANUdO 
KRAN1190 
KRANI2C0 



Statistics — Nonparametric Statistics 69 



Subroutine MPAIR 

This subroutine performs the Wilcoxon matched- 
pairs signed-ranks test, given two vectors of n ob- 
servations of matched samples. The computational 
steps are as follows: 

1. For each matched pair, determine the signed 
difference (df) between the two scores. 

2. Rank these d's without respect to sign. In 
doing so, (a) disregard those d's equal to zero (0), 
and (b) with tied d's, assign the average of the tied 
ranks. 

3. Affix to each rank the sign (+ or -) of the d in 
step 1 above. 

4. Compute T = the svun of positive ranks or the 
sum of negative ranks, whichever is smaller. 

5. Compute mean: 



SUBROUTINE MPAIR 



KfK+1) 



H = 



where K =the total number of d's which are not 
zero (0). 

6. Compute standard deviation: 



11) 



-i 



K(K+1) {2K+1) 



24 



7. Compute Z: 



Z = 



(2) 



(3) 



Z is approximately normally distributed with zero 
mean and unit variance. 

8. Compute the probability, p, associated with 
the value as extreme as Z by the subroutine NDTR. 
Note: p is the probability for a one-tailed test; 
thus for a two-tailed test, the user should 
double tiie value of p. 
For reference see: 

(1) S. Siegel, Nonparametric Statistics for the 
Behavioral Sciences . McGraw-Hill, New York, 
1956, chapter 5. 

(2) F. Wilcoxon, Some Rapid Approximate Sta- 
tistical Procedures , American Cyanamid Co. . 
Stamford, Conn., 1949. 



KPAI 

.HPAI 
HPAI 
HPAI 
MP* I 
MPAI 



100 
110 
120 



PU«i»Oi£ 

P€»FOfiM THE WILCOXON M*TCMEO-^A I«S SICNEO-RANKS TEST, GIVEN iipA 
two V€CrO«S OF N OBSERVATIONS OF THE HATCHED SAMPLES. MPAI 

1PAI 

USAGE „p4, 

CALL HPAII^ <NtA,fi.K,r,2,P,0,EtL.IE) MPAI 

MPAI 

DESCHIPnON OF PARAMETERS MPAI 130 

N - NUMBER OF OSSERVATIONS IN THE VECTOItS A ANO B MPAI 140 

A - INPUT VECTOR OF LENGTH N CONTAINING DATA FROM THE FIPST MPAI 150 

S*"»*<-E MPAI lAO 

B - INPUT VECTOR OF LENGTH N CONTAINING DATA FROM THE SECONOMPAl ITO 

S*MPt.E HPAI laO 

tC - OUTPUT VAPIABLE CONTAINING THE NUHSEn OF PAIRS OF THE MPAI 190 

M»TCH€0 SAMPLES WHOSE DIFFERENCES ARE HON ZERO 101 MPAI 200 

r - OUTPUT VARIABLE CONTAINING THE SU« OF IH= RANKS OF PLUS MPAI 210 

OR MINUS DIFFERENCES, WHICHEVER IS SMALLER MPAI 220 

I - VALUE OF THE STANOAROIZED NORMAL SCORE COMPUTED FOR THE MPAI 250 



WILCOXON MATCHED-PAIRS 51 CNEO-RANKS TEST 
P - COMPUTED PRORABILITV OF OBTAINING A VAIUE OF I AS 

EXTREME AS THE ONE FOUND 8Y THE TEST 
O - WORKING VECTOR OF LENGTH N 
E - WORKING VECTOR OF LENGTH N 
L - WORKING VECTOR OF LENGTH N 
IE- l< IF SAMPLES A AND B ARE IDENTICAL. 

OTHERWISE. IF IE*i, THEN T«P-0, ANO Z-=-lO*«T5 

REMAPKS 

THE COMPUTED PftOeAftlLTV IS FOR A ONE-TAILED TEST, 
MULTIPLVING P 8V 2 WILL GIVE THE VALUE FOR A TMO-TAILEO 
TEST. 

SUBROUTINES ANO FUNCTIONS SuePROSRAMS REQUIRED 
RANK 
NDTR 

METHOD 

REFER TO DIXON ANO HASSEY. AN INTRODUCTION TO STATISTICAL 
AN^LrSIS (MC GRAW-HILL. 1S57I 



SUBROUTINE MPAIR <N, A, B.K, T,2 .P. D,E,L . IE I 
DIMENSION Atl}.B<l),D<II,E(ll,LlI) 



FIND DIFFERENCES OF MATCHED-PAIRS 

eiG=o.o 

DO 5 5 I=1,N 
OIF-A(I)-B(I) 
IFIOIFI 10, 20. 30 

DIFFERENCE HAS A NEGATIVE SIGN (-> 

10 L(I I=>1 
GO TO 40 

DIFFERENCE IS ZERO (01 



20 LII)-2 

K-K-1 
GO TO 40 

DIFFERENCE HAS A POSITIVE SIGN K*\ 

30 LI 1 1-3 

40 Olfs ABSfOIFI 

IF<6IG-D1F1 45r 50* 50 
45 BIG«01F 
SO OtII'OlF 

55 CONTINUE 

IFIKI 57,57,59 
57 IE-1 

T-0.0 

Z— I.0ET5 

P«0 

GO TH 100 

STORE A LARGE VALUE IN PLACE OF DIFFERENCE IN ORDER TO 
ASSIGN A LARGE RANK (LARGER THAN Kl. $0 THAT AftSOLUTE VALUES 
OF SIGNED DIFFERENCES WILL BE PROPERLY RANKED 

59 BIG=BIG*2.0 
00 65 1=1, N 
1F(LII)-2I 65, 60, 65 

60 D(I)>eiG 
65 CONTINUE 

CALL RANK (D,E,N) 

FIND SUMS OF RANKS OF (♦) DIFFERENCES ANO (-» DIFFERENCES 

SUMP-0.0 

SUMH=0.0 

OO BO I'' UN 

IF(LII)-2t TO, 80, 75 
70 SUMM=SUMM*E (It 

GC TO 80 
75 SUMP:='SUMPi-£( II 
60 CONTINUE 



SET 



SMALLER SUM 



85 T-5UMP 

CO TO 95 
90 T=SUMM 

COMPUTE MEAN, STANDARD DEVIATION, ANO Z 

95 FK=K 

U=FK»{FK*1. 01/4.0 

S= SQRIHFK«(FK»I.01«(2.0»FK*l,0l)/'4.OI 
Z=IT-Ut/S 

CCWPUTE THE PROBABILITY OF A VALUE AS EXTREME AS Z 

CALL NDTP (i.P.BIGI 

lOT RETURN 
FNO 



MPAI 240 
HPAI 250 
HPAI 260 
MPAI 270 
MPAI 2S0 
HPAI 290 
MPAI 300 
MPAI 310 
MPAI 320 
MPAI 330 
MPAI 340 
MPAI 350 
HPAI 360 
MPAI 370 
HPAI 380 
MPAI 3<>0 
HPAI 400 
MPAI 410 
MPAI 420 
HPAI 430 
HPAI 440 
HPAI 450 
...MPAI «60 
MPAI 470 
MPAI 480 
MPAI 490 
MPAI 500 
HPAI 510 
HPAI 520 
HPAI 5 30 
MPAI 540 
HPAI 550 
MPAI 560 
MPAI 570 
MPAI 580 
MPAI 590 
HPAI 600 
MPAI 610 
HPAI 620 
MPAI 6)0 
HPAI 640 
HPAI 650 
HPAI 660 
MPAI 670 
HPAI 680 
HPAI 690 
HPAI TOO 
MPAI 710 
MPAI 720 
HPAI 730 
HPAI 740 
HPAI 750 
HPAI 760 
MPAI 770 
MPAI 780 
HPAI 790 

MPAI eoQ 

HPAI 810 
MPAI B20 
MPAI 830 
HPAI 840 
MPAI 850 
HPAI 860 
MPAI 870 
MPAI 880 
MPAI 890 
HPAI 900 
MPAI 910 
MPAI 920 
MPAI 930 
HPAI 940 
HPAI 950 
MPAI 960 
HPAI 970 
MPAI 980 
HPAI 990 
MPAILOOO 
HPAI 1010 
HPAI1020 
HPAI1030 
HPAI 1040 
HPAI 1050 
MPAI 1060 
HPAtia70 
MPAI1080 
MPAI1090 
NPAIl 100 
NPAIllIO 
MPAI 1120 
MPAIl 130 
MPAI1140 

m\{\Kt 

HPAIlt60 
HPAI 1170 
MPA 11180 
HPAI 1190 
MPAI 1200 
HPAtt2lO 
HPAIt220 
HPAI1230 
MPAI 12*0 
HPA[1?50 
MPAI 1260 
MPAI1270 
HPAI1280 
MPAI1290 
HPAII300 

MPAI1310 

HP* 1 1 320 



70 Statistics — Nonparametric Statistics 



Subroutine QTEST 



Subroutine RANK 



This subroutine determines the Cochran Q-test 
statistic, given a matrix A of dichotomouS data with 
n rows (sets) and m columns (groups). 
Row and column totals are calculated: 



m 



L = y! A., (row totals) 
' j = l ^J 

where i = 1, 2, , . . , n 



G = T^ A (column totals) 
J iti « 

where j = 1, 2, . . . , m 

The Cochran Q statistic is computed: 
m „ / m \; 



(m-1) 



Q = 



m 
L 1 



1=1 J \j=i ^ 



n 



m 



E L. - E l; 



i = l 



= 1 



The degrees of freedom are: 
d.f. = m-1 





RSQ^O.O 




Gt)=O.C 




DO 20 1=1. N 




rfl=o.o 




IJ=1-N 




UO ID J=l.M 




IJ=IJ+N 


K 


TR=rR*A(lJl 




GO«GO*IR 


ZC 


kSg=RSJ*TK*TR 




CuMPUTt SU 




CSii=0.0. 




IJ = 




00 'fO J = 1,M 




lC*u.C 




DO 3C I=1,N 




1J=1J*1 


iC 


Tc=rc*A(ij» 


4C 


CSQ-CSO*TC»rC 



CuMPUTt SUH OF SQUARES UF CQLuMh TOTALS. CSO 



COMPUIt COCHRAN vj TEST UALUe 



UNU DcGKEtS OF FRgEOOM 



(1) 



(2) 



(3) 



(4) 



6RCjriNE QTeSI 

rtPCSt 
TEST WHEIHcR IHRtE OR MJttt MATCHEC GROUPS OF UICHOtOMOUS 
DATA iJlF^fcR SIGMEICANTLr BY THE COCHRAN Q-TtST 



OtSCklPTIGN Of PARAMETERS 

A - INPUT MATRIX. N BY M, OF OICHOTOMOUS DATA (0 AND 11 

M ' NU«6tft OF SETS IN EACH GROUP 

^ - NUMBER Of GROUPS 

J - COCHRAN Q STATISTIC lOUTPUTI 

,^0F - hOMbErt OF DEGREES UF FRccdOM (OUTPUTl 



SUBROUTINES AnU FUNCTION SU8PR0GRAMS REQUIRED 
NONE 

METHOD 

UtSCRIBEO £N S. SIEGEL. • NONPARAME TRIC STATISTICS fOR TH£ 
dEHAVlOHAL SCIENCES', MCGRAUHHILL . NEW YORK, 1956, 
CHAPTEH 7 



SUfiRUdTINc OTESTU,N,M,Q,NDF) 
DIMENSION All) 

COMPUTE SUM OF SQUARES OF ROM TOTALS, RSQ, ANO GRANO TOTAL Of 
ALL ELEMeNTS, CO 



*0 



70 



N0F=M-1 
RETURN 
tND 



QTES 

.QTES 
QTES 
QTES 
QTES 
QTES 
QTES 
QTES 
QTES 
QTES 100 
QTES UO 
QTES 120 
QTES 130 
QTLS 140 
QTtS 15C 
QTtS 160 
QTES ITO 
QTtS 180 
QTES 190 
QTES 2C0 
QTES 210 
QTES 220 
QTES 230 
QTES 240 
QTES 250 
QTES 260 
QTES 270 
QTES 280 
QTES 290 
QTES 300 

.QTCS 310 
QTES 320 
QTES 330 
QTES 340 
QTES 350 
QTES 360 
QTES 3TO 
QTES 380 
QTES 390 
QTES 400 
QTES 410 
QTES 420 
QTES 430 
QTES 440 
QTES 450 
QTES 460 
QIES ^70 
QTeS 4S0 
QTES 490 
OT£S 500 
QTES 510 
QTES 520 

gTES 530 

QTES 540 
QTES 550 
QTES S60 
QTES 5 70 
QTES 580 
QTES 590 
QTES 600 
QTES 610 
QIES 620 
QTES 630 
QTES 640 
QTES 650 
QTES 660 
QTES 670 
QTES 6S0 
QT£S 690 
QTES TOO 



SUartCUTINt BANK 



PURPOSE 

AANK A VECrOrt OF VALUES 



OcSCRIPTIOV JF PARAMtTERS 

A - INPUT VECTOR OF N VALUES 

'I - OUTPJT VECTOR OF LENGTH N. SMALLEST VALUE IS RANKED I, 

LAAGci7 IS RANKED H. TltS ARE ASSIGNED AvtRA^E OF TIEO 

RANKS 

fl* - NUMftfcR UF VALUES 



SU6-1UUTINES ANJ FUNCTION SUaPROGRANS RtQU(R£U 
NONE 

METHOD 

VECTOR IS SEARCHED FOR SUCCESSIVELY LARGER ELEMENTS, IF Tl 
JCCJR, THEY ARE LOCATED ANO TrttIR RANK VALUE COMPUTtU. 
FOR EXAMPLE, IF 2 VALUES ARE TIEO F0« SIXTH RANK. THEY ARE 
ASSIGNED A RANK Of 6.5 (>|6»7|>'ai 



SUeRJUriNE RANK(A,R,N) 
JIMENSICN Al 11, «( 1) 

INI T I ALU AT ION 

DO 10 1=1, N 
10 R(l t=O.C 

FINO RANK OF DATA 
DO 100 1=L.N 

TEST WHEThER UATA POINT IS ALRtAJY RANKED 
If iKlI ) ] 2C, 2C, 100 

UA!A POINT TO 6£ RANKED 

2C SMALL=D.O 
EQUALED .0 
X=Atl] 
DO 50 J=l,N 
IF(AIJt-Xl 30, 4C. SO 

COUNT NUMeER OF DATA PUlNyS hHICH A«t SMALLER 



3o SHALL=5MALL*l.O 
GO TO 50 

CL1U'*T NUMBER OF DATA POINTS WHICH ARE EQUAL 

40 E0UAL=E0UAL*1.0 

k(J)=-1.0 
5C CONTINJfe 

TEST FOR TIE 

If (EQJAL-I.CI 6C, 60, 7C 

SrO^E RANK OF UATA PLINT *H£Rt NO TIE 

6C RU » = SHALL*l.O 
GO TJ ICO 

CALCULATE RAf-K JF TIFC DATA ''OiNTS 

70 P=SMALL ♦ (EQUAL ♦ i.OI*C.5 

l)0 9C J = I . N 

if(R(JJ*l.Cl 9C, dC, 9C 
8C a(JI=P 
■JC cONflNJE 
lOC CGNlINUd 

nETURN 

END 



RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
HANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 

RANK 

RANK 
RANK 
RANK 
^ANK 

RANK 
RANK 

RANK 
HANK 
ESKANK 
RANK 
RANK 
RANK 
RANK 
.RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 

RANK 

RANK 
RANK 

RANK 

RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RAN< 
RANK 
RANK 
RANK 
RANK 

RANK 

HANK 
RANK 

rakk 
RANK 
RANK 
RANK 
RANK 
HANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 
RANK 



100 

no 

120 
130 
140 

150 
160 

1 70 

IBG 
190 

^03 

210 

2 20 
230 
240 
250 
260 
270 
260 
290 
300 
510 
320 
330 
340 
350 
360 
170 
3B0 
390 



4bO 

470 
480 



5 30 
540 
550 
560 
iTO 
580 
590 
600 
blO 

6 20 



6 70 

6 80 
690 
700 

7 10 
720 
7 30 
740 
750 
760 
7 70 
7dO 
790 

aco 

dlO 
820 

a 30 

840 

a-50 

d60 



Statistics — Nonparametric Statistics 71 



Subroutine SIGNT 

This subroutine performs a sign test, given two 
vectors of n observations of two matched samples. 
The computational steps are as follows: 

1. Find the s^ of the difference between the two 
numbers of each pair. 

2. Find K =the number of pairs whose differ- 
ences are not zero (0). Disregard those pairs 
whose differences are zero (0). 

3. Find M n^the number of (+) differences or the 
number of (-) differences, whichever is fewer. 

4. H K is less than or equal to 25, the probability 
associated with a value as small as the observed 
value of M is given by the binomial distribution as: 



M 

= s 

i=0 



(?) 



P^Q^- 



(1) 



where P =Q =0.5 

\ij il (K-i)' 



The equation (1) is rewritten to simplify the calcu- 
lation as follows: 



P =■ 



i=0 ^^ 



,K 



(2) 



If K is greater than 25, the probability is calculated 
by the normal approximation to the binomial distri- 
bution as follows: 



Mean: 



y =KP=-K 



Standard deviation: g = \/KPQ =- \/k 



Value of Z: 



^^ (M+0.5)-;Lt 

a 



(3) 



(4) 



(5) 



Then the probability, p, associated with the value as 
extreme as Z is obtained by the subroutine NDTR. 
Note: p computed by this subroutine is the prob- 
ability for a one-tailed test; thus for a 
two-tailed test, the user should double 
the value of p. 
For reference see S. Siegel, Nonparametric 
Statistics for the Behavioral Sciences , McGraw-Hill, 
New York, 1956, chapter 5. 



SUeftOUTINE SICNT 



StGM 
SIGN 
SIGN 



SIGN 



HEOIAN EQUAL TO ZERO. 



US«CE 

CALL SIGNT (M,A,a.K,H,P,IF 



PURPOSE 

TO PERFORM A NON-PAHAMETP IC SIGN TEST, GIVEN TWO SETS OF 

HATCHED OBSERVATIONS. IT TESTS THE NULL HVPOfHESIS THAT THEs'lGN SO 

2i"^"^"^ "I"^^- ^"" ***" °^ HATCHED OeSeRVATrOfiS HAS A SIGN 90 

^^^^ ^^^ 

SIGN 110 
SIGN 120 
SIGN 130 

oesCRIPTlON PF PARAMETERS s|cn [^ 

U - NUMBFP OF oeSERVATIONS IN SFTS A AriD S sign i^q 

A - INPUT VECTOR OF LENGTH N CONTAINING OAfA FROM THE FIRST SIGN 170 

SAMPLE, A SIGN 180 
a - INPUT VECTOR OF LENGTH N CONTAINING DATA FROM THE SECONOSIGN 190 

5'^'"**-f' B SIGN 200 

K - OUTPUT VARIABLE CONTAINING THE NUMBER OF PAIRS OF SIGN 210 

OBSERVATIONS FROM THE TWO SAMPLES WHOSE DIFFERENCES ARE SIGN 220 

NON-ZERO SIGN 230 
M - OUTPur VARIABLE CONTAINING THE NUMBER OF PLUS OR MINUS 

OIFFEPENCES, WHICHEVER IS FEWER. 
P - COMPUTED PROBABILITY OF AS FEW AS H NUHBER QF PAIRS 
■AVING THE SAME SIGN, ASSUMING THAT THE SAMPLES CAHE 



FROM THE SAME POPULATION. 
IE- 0, IF THERE IS NO ERROR. 

1, IF K IS ZERO. IN THIS CASE, 
H TO 0. 



IS SET TO 1.0 AND 



REMARKS 

IF K rS LESS THAN OR EQUAL TO 25, THE PROBABILITY WILL BE 
COMPUTED USING THE BINOMIAL DISTRIBUTION. IF K IS GREATER 

THAN 25» THE PROBABILITY WILL BE COMPUTED USING THE NORMAL 

APPROXIMATION TO THF BINOMIAL OlSTRIBUTION. 

P COMPUTED IS THE PROBABILITY FOR A ONE-TAILED TEST, THUS, 

FOR A TWO TARED TEST, DOUBLE THE VALUE FOR P, 

SUBROUTINES ANO FUNCTION SUBPRDGRAMS REQUIRED 
NOTH 

METHOD 

REFER TO DIXON ANO HASSEY, INTRODUCTION TO STATISTICAL 
ANALYSIS IHCGRAtf-HILL. 19571. 



SUBROUTINE SIGNT (N, A.a ,K,M, P, IE | 

c 

DIMENSION Al 1),P(1) 
DOUBLE PRECISION FN,F0 

: INITI ALIZATIQN 

IE=0 

K = 

HPLUS=0 

HMINS*0 

FIND (♦! OR |-» DIFFERENCE 

00 40 I«1)N 
0>AIII-BII) 
IFID) 20, 40, 30 

(-> DIFFERENCE 

20 KsK*l 

MMINS=MMIHS*1 
GO TO 40 

(♦I DIFFERENCE 

30 K«K*l 

MPLUS-HPLUS+1 

40 CONTINUE 
IFIKl 41,41,42 

41 iE«l 
P"1.0 
H«0 

GO TO 95 

42 F(C=K 

FIND THE NUMBER OF FEWER SIGNS 

IF(HPLUS-HMINS) 45, 45, 50 
45 M-MPLUS 

GO TO 55 
50 M-HMINS 

TEST WHETHER K IS GREATER THAN 25 

55 IFU-251 60, AO, 77 

K IS LESS THAN OR EQUAL TO 25 

60 P-l.O 

IFIMl 75, 75, 6S 
65 FN-=l.O 

FO-1.0 

DO TO 1= 1,M 

FI*I 

FN=fN*(FK-|FI-1.0»l 

FD=FO*FI 
70 P-P*FN/FO 

75 P=P/(2.0**<J 
GO TO 95 



SIGN 240 
S IGN 250 
SIGN 260 
SIGN 270 
SIGN 280 
SIGN 290 
SIGN 300 
SIGN 310 
SIGN 320 
SIGN 330 
SIGN 340 
SIGN 350 
SIGN 360 
SIGN 3T0 
SIGN 380 
SIGN 390 
SIGN 400 
SIGN 410 
SIGN 420 
SIGN 430 
SIGN 440 
SIGN 450 
SIGN 460 
SIGN 470 

SIGN 480 

SIGN 490 
SIGN 500 
SIGN 510 
SIGN 520 
SIGN S30 
SIGN 540 
SIGN 550 
SIGN 560 
SIGN STO 
SIGN 580 
SIGN 590 
SIGN 600 
SIGN 610 
SIGN 620 
SIGN 630 
SIGN 640 
SIGN 650 
SIGN 660 
SIGN 6T0 
SIGN 680 
SIGN 690 
SIGN TOO 
SIGN TIO 
SIGN 720 
SIGN 730 
SIGN 740 
SIGN 750 
SIGN 760 
SIGN 770 
SIGN 780 
SIGN 790 
SIGN 600 
SIGN 810 
SIGN 820 
SIGN 830 
SIGN 840 
SIGN 850 
SIGN 860 
SIGN 870 
SIGN 880 
SIGN 890 
SIGN 900 
SIGN 910 
SIGN 920 
SIGN 930 
SIGN 940 
SIGN 950 
SIGN 960 
SIGN 970 
SIGN 980 
SIGN 990 
SICNIOOO 
5IGNI010 
SIGN1020 
SIGN1030 
SIGN1040 
SIGN1050 
SICN1060 
SIGN1070 

SIGN 1080 
SIGN1090 
SIGNllOO 
SIGNlltO 



COMPUTE H£4N, ifHHQm OtVAUOHl 



K IS GREAIER THAN Z3, 

7 7 U=0,5*FK 

S-0.5«SQ«HFK) 

FM=H 

IF(FM-U) 80, 85, 85 
BO CON=o.5 

GO rO 90 
85 CON-O.O 
90 Z-(FM*CON-U»/S 



CCIM-'UIE P ASSCCIATEO WITH THE VALUE AS EXTREME AJ I 
CALL NOTR (;,P,D| 



SIGN1120 

mo I iimiii 



SICNl 140 
S1GN1150 
SIGNll&O 
SIGNllTO 
SIGN1180 
SIGN1190 
SIGN 1200 
SIGN1210 
SIGN1220 
StGN1230 
SICN1240 
SIGN1250 
SIGN1260 
SIGN1270 
SICN1280 
SIGN1290 



72 Statistics— Nonparametric Statistics 



Subroutine SRANK 

This subroutine measures the correlation 
between two variables by means of the Spearman 
rank correlation coefficient, given two vectors 
of n observations for the variables. 

The observations on each variable are ranked 
from 1 to n. Tied observations are assigned the 
average of the tied ranks. 

The sum of squares of rank differences is 
calculated: 



D = r (A. - B.) (1) 

i = l 



where A = first ranked vector 
1 

B = second ranked vector 
i 

n = number of ranks 



A correction factor for ties is obtained: 

3 

T =^ — over variable A (2) 

a 12 



3 

T =52 -— over variable B 

b "^ 12 

where t = number of observations tied for a given 
rank 



The Spearman rank correlation coefficient is then 
computed for the following two cases: 

(a) if Tj^ and 1^ are zero, 

6D 



r =!-■ „ 

S 3 



(3) 



n -n 



(b) if T^ and/or Tj^ are not zero. 



r =- 

s 



X + Y - D 



-J XY 



3_ 
where X = — — — - T 



a 



(4) 



(5) 



Y = 



3 
n -n 

12 



Tb 



(6) 



The statistic used to measure the significance of r is : 



*=-i! 



- 2 



The degrees of freedom are: 
d.f. = n - 2 



(7) 



(8) 



SJBROUriNE S««N« 

rtST CORrtELATION BtTWeEN TWO VARMSIES flV WANS OF SPCARMAN 
KANK CJRRELAriON COEFFICIENT 



DESCRHTION OF PARAMCTERS 

A - INPUT VECTOR OF N OBSERVATIONS FOR FIRST VARIABtE 

A - INPUT VECTOR OF N OSSERVATIOMS FOR SECOND VARIABLE 

A - OUTPUT VeCTOR FOR RANKED OAT*, LENGTH 1$ 2*N. SHAllEST 

OaSERVATION IS RANKED I. L ARM ST IS RANKED N. TIES 

ARE ASSIGNED AVERAGE Of TIED RANKS. 
N - NUN6ER OF OBSERVATIONS 

RS - iPEAHHAN RANK CORRELATION COEFFICIENT lOUTpUT) 
T - TEST OF SIGNIFICANCE OF RS (OUTPUT! 
NOF - NUHdER Of DEGREES OF FrEEOOH IOUTPUTI 
NR - CODE. FOR UNRANKED DATA IN A AND B, 1 FOR RANKED 

DATA IN A AND B (INPUT) 



SUBRDOTIMES AND FUNCTION SUSPROGAAHS REQUIRED 
RANK 
TIE 

HETHOi) 

DESCRIBED IN S. SIEGEL, • NONPARAHEIRIC STATISTICS FOR THE 
BEHAVIORAL SCIENCES'. HCGRAW-MILL, NEW yORK, 1956, 



SUBROUTINE SRANKl A, B,R,N,RS, T,NOF.NRi 
DIMENSION A((1.8(lltR(ll 

FNNN=N«N*N-N 

DtrfcRHINE MMETMER DATA (S RANKED 

IF(NR-1I 5, 10, 5 

RANK OAT* IN A AiyO B VECTORS AND ASSlCN TIED OBSERVATIONS 
AVERAGE QF TlEO RANKS 

S CALL RANK (A.R.NI 

CALL RANK |fl,R(N*ll,Nt 
GO TO 40 



30 



HOVE RANKED DATA TO R VECTOR 



10 00 20 1=1, N 
2C R(1I>A<11 

00 30 I>1,N 

J-I+N 

}0 R(j;=s(i) 



COMPUTE SUM OF SQUARES OF RANK DIFFERENCES 



40 D>0.0 

00 ^0 (=l.N 

J'l*H 
5C 0=D*(RI ll-Rl Jl '*(R( Il-R( J) I 

COMPUTE TIED SCORE INDEX 

KT=l 

CALL KE IR,N,KT,rSAI 

CALL Tit (R(N*l|,N, KT, TSai 



COMPUTE SPEARMAN RANK CORRELATIJN COEFnCIENT 



JFirSAt 60,55.60 
55 IFtTSdl 60,57,t.O 
57 kS=1.0-6.C*0/FNNN 

GO TO TO 
60 X«FNNN/^12.0-TSA 

\' = K + TSA-TS8 

RS=(x*y-o)/(2.o*(suRr(x*Yn) 



CUM.>UTE T AND DEGREES JF FREEDOM IF N IS 10 OR LARGER 



r«o.o 

70 IF(N-IOI 80,75,75 

75 T=RS#SQRl(FLOAT(N-^J/( l-0-«S*RSII 

ac N0F=H-2 

RETURN 

END 



SRAN 
SRAN 
SRAN 
SRAN 
SRAN 
SRAN 60 
SRAN 70 
SRAN 60 
SRAN 90 
SRAN 100 
SRAN 110 
SRAN 120 
SRAN 130 
SRAN 140 
SRAN 150 
SRAN 160 
SRAN 170 
SRAN L80 
SRAN L90 
SRAN 200 
SRAN 210 
SRAN 220 
SRAN 230 
SRAN 240 
SRAN 250 
SRAN 260 
SRAN 2 70 
SRAN 280 
SRAN 290 
SRAN 300 
SRAN 310 
SRAN 320 
SRAN 330 
SRAN 340 
SRAN 350 
SRAN 360 
SRAN 370 
SRAN 360 
SRAN 390 
SRAN 400 
SRAN 410 
SRAN 420 
SRAN 430 
SRAN 440 
SRAN 450 
SRAN 460 
SRAN 470 
SRAN 480 
SRAN 490 
SRAN 500 
SRAN 510 
SRAN 520 
SHAN 530 
SRAN 540 
SRAN S50 
S RAN 560 
SRAN 5 70 
SRAN 580 
SRAN 540 
SRAN 600 
SRAN 610 
SRAN 6 20 
SRAN 630 
SRAN 640 
SRAN 650 
SRAN 660 
SRAN 670 
SRAN 680 
SRAN 640 
SRAN 700 
SRAN 710 
SRAN 720 
SRAN 730 
SRAN 740 
SRAN 750 
SRAN 760 
SRAN 770 
SRAN 780 
SRAN 790 
SRAN BOO 
SRAN 810 
SRAN B20 
SRAN 630 
SRAN 840 
SRAN 850 
SRAN 660 
SRAN 8 70 
SRAN (180 

UhK 890 

SRAN 900 
SRAN 9t0 
SRAN 920 
SRAN 9 30 
SRAN 940 



Statistics — Nonparametric Statistics 73 



Subroutine TIE 



Subroutine TWOAV 



SUbRiiUIihE TIE > 

PURPOSE 

CALCULAFt COftRECriON F4Cro« OUt TO TIES 

USAGE 

CALL r lEiR.N, Kr, li 

DESCRIPTION OF PARAHETEfiS 

ft - INPUT vecroR Of ranks of LEf^orn n containing values 

1 TO N 
N - NUMBER JF RANKEO VALUES 
KT - IhPur CODE FOR CALCULATION OF CORRECTION FACTOR 

1 SOLVE EQUATION I 

2 SOLVE EgUATlON 2 
T - CORRECTION FACTOR (OUTPUT) 

EQUATION I T=SUN(CT**3-CTI/12 
EQUATION 2 T=SUM(C !• (CT-U /2 1 
WHERE CT IS THE NUMBER OF C6SERVATC0NS FlEO FOR A 
GIVEN RANK 

REMARKS 

HONE 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

HETHOD 

VECTOR IS SEARCHED FOR SUCCESSIVELY LARGER RANKS. TIES A«E 
COUNTED ANQ CORRECTION FACTOR 1 OR 2 SUHMEO. 



SUBROUTINE TlE(R,N,Kr,rj 
DIMENSION R(l} 

INITIALIZATION 

T = 0.0 

y=o.o 

i X=l,0E3e 

INO = 

FINtJ Ntxr LARGtST RANK 

DO 30 I=l,N 

IF(«( I)-YI 30,30» 10 
10 IF(R111-XI 20,30,30 
20 X=R(I) 

IN0=IN0+1 
3C CONTINUE 

IF ALL RANKS HAVE BEEN TESTeO, RETURN 

IFdNOI flo.go.-iu 
cr=o.o 

COUNT IIES 

00 60 1=1. N 

1F(R( IJ-XI 60. SO, 60 
50 Cr=CTtl.O 
60 CONTINUE 

CALCULATc CORRECTION FACTOR 

IFICT) 70,5,70 
7C IFUT-U 75,60, 75 
T5 T-T*CT»(CT-J. 1/2.0 

GO rO 5 

ao T=T+(CT«ci*cr-cri/i2.o 

GO TU 5 

9C RETURN 
END 



..TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
Tit 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 
TIE 

Tie 

TIE 
TIE 
TIE 
-TIE 
TIE 



TIE 

Tie 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TiE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TI£ 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 

TIE 



100 

Ito 

120 

130 

1*0 

150 

160 

170 

180 

190 

200 

210 

ZZO 

230 

240 

250 

260 

270 

260 

290 

300 

310 

320 

330 

340 

350 

360 

370 

380 

390 

400 

410 

420 

430 

440 

450 

460 

4 70 

480 

4 90 
500 
510 
520 

5 30 

540 

550 

560 

570 

580 

590 

600 

610 

620 

630 
640 
bSO 
660 
670 
680 
690 
700 
710 
7 20 
730 
740 
750 
760 
770 
780 



This subroutine determines the Friedman two-way 
analysis of variance statistic, given a matrix A with 
n rows (groups) and m columns (cases). Data in 
each group is ranked from 1 to m. Tied observations 
are assigned the average of the tied ranks. 
The sum of ranks is calculated: 

1=1 



ij 



Friedman's statistic is then computed: 



2 



12 



nm(ni + 1) 



E 



(R.) -3n(m + l) 



The degrees of freedom are: 
d.f. = m-1 



(2) 



(3) 



SU8«0UTINc TrfOAV 

PURPOSE 

TEST WHETHER A NUMflCR OF SAMPLES ARE FROM THE SAME 
^QPJLATIUN BT THE FRIEDMAN THU-WAY ANALYSIS OF VARIANCE 

uSaue 

call twoavi a.r.n, m, 



10 



HiXR.NDF.NRI 



DESCRIPTION OF PARAMETERS 

A - INPUT MATRIX, N BY H, OF ORIGINAL DATA 

R - OUTPUT MATRIX, H BY H. OF RANKED DATA 

N - NUMStR OF GROUPS 

H - NUMBER OF CASES IN EACH GROUP 

rf - WORK AREA OF LENGTH Z*H 

XR - FRIEDMAN STATISTIC (OUTPUTI 

NOF - NUMBER OF DECREES OF FREEOOP {OUTPUTI 

NR - CODE, f\ik UNRANKEO DATA IN A. 1 FOR RANKED DATA 

REMARKS 

NONE 

SUoROUTINES ANQ FUNCTION SUBPROGRAMS REQUIRED 
RANK 

HETHOO 

OtSCRiagO IN S. SieGEL. -NONPARAMETRic STATISTICS FOR THE 
dEHAVlORAL SCIENCES', MCGRAU-HlLL. NEH YORK, 1956. 



SUBRUUriNE THOAV I A,R, N,M, W, KR ,NOF,NR} 
DIMENSION A(ll,R<l),W(l» 



OETERMINE WHETHER OATA IS RANKED 
IFINR-II 10, 30, 10 



10 DO 20 1=1, N 
IJ=I-N 

IK=IJ 

00 15 J=l,M 

IJ>|J«N 
15 W( JI=A< IJI 

CALL RANK (W.M(HtlJ,M} 

DO 20 J=1,H 

IK=IK*« 

IW=M+j 
20 R( lKJ = tJ( IWl 

GO TO J5 
30 NM=N*M 

DO il I=1,NM 
iit «( I »=A( II 

CALCULATE SUM Or SQUARES OF SUMS OF RANKS 

35 RTSQ^O.C 
IR = 
DO 50 J-1,M 

«r=o.o 

00 40 l=t,N 

I«=1R+1 
-,0 «T = Rr+R( IK) 
50 RTiU=RTSJ*-RT*Rr 

CALCULATE FRIEDMAN TEST VALUE, X« 
FNM=N*(M*1) 

FH = M 

xR=(i.^.C/(FM*FNHM«RTSQ-3.0*FNIi 
FINJ UEGRfcES UF FREEDOM 

NOF=M-I 
KErURN 

LNJ 



TWO A 
....THOA 

TWOA 
TMOA 40 
TWO A 50 
TMOA 60 
TUOA 70 

TesTTHQA ao 

TWO A 90 
TUOA IOq 
TWO A 110 
THOA 120 
TWOA 130 
TWOA 140 
THOA 150 
TWOA 160 
TWOA ITO 
TWOA IBO 
TWOA 190 
TWOA 200 
TWOA 210 
TWOA 220 
TWOA 230 
TWOA 24C 
TWOA 250 
THOA 260 
TWOA 270 
rwOA 280 
TWOA 290 
THOA 300 
TWOA 310 
TWOA 320 
TWOA 330 
TWOA 340 
.TWOA 350 
TWOA 360 
TWOA 370 
TWOA 380 
TWOA 390 
THOA 400 
TUOA 410 
TUOA 420 
TWOA 430 
ruOA 440 
TWOA 450 
TWOA 460 
TWOA 470 
TUOA 480 
TWOA 490 
TWO A SOO 
TWOA 510 
TWOA 520 
THOA 530 
THOA 540 
TWOA SSO 
THOA 560 
TWOA 570 
TWOA 580 
THOA 590 
TwOA 600 
TWOA 610 
TWOA 620 
TWOA 630 
TWOA 640 
TWOA 650 
TM}A 660 

m m 

THOA 680 
TWOA 690 

TWOA roo 

THOA 710 

TWOA 720 

TWOA 730 

THOA 740 

rWCA 750 

TWOA 760 
TWOA 770 
TWOa 780 
THOA 790 
THOA 800 
TwOA 810 
TWOA 820 
THOA 830 
TWOA 840 



74 Statistics --Nonparametric Statistics 



Subroutine UTEST 

This subroutine tests whether two independent 
groups are from the same population by means of 
the Mann-Whitney U-test, given an input vector A 
with the smaller group preceding the larger group. 
The scores for both groups are ranked together in 
ascending order. Tied observations are assigned 
the average of the tied ranks. 

The sum of ranks in the larger group, R2, is 
calculated. The U statistic is then computed as 
follows: 



U- = n^n^^ 



^2 ^\ ' 1) 



R, 



where n. 



2 "2 

number of cases in smaller group 



(1) 



n = number of cases in larger group 
U = n^ n^ - U- 
if U' < U, set U = U' 
A correction factor for ties is obtained: 
.3 



La 12 



(2) 



(3) 



where t = number of observations tied for a given 
rank 

The standard deviation is computed for two cases: 
(a) if T = 



;n^ n^(n^ + n;Tl) 
= \ 12 



(4) 



C SLfPClIlht tICSI 

c 

C FtSfCif 

C lESt kl-EII-fN IkC INCEPEhCtfT GffCLPS ^RE fPC*' THE S4HE 

c fCfttiTiCfc ev f£*hs cf ^i^h-hmihcv l-T£si 

C i 

C LS«CE 

C C«LL tT£SI(«.K.M.K2.CW.URI 

C 

C CESCSIPTIC^ CF P«ti#r't1£iiS 

C i - IhPCI UECIC« CF CASE! CCNSISIIKG CF ThC IKOtPENOtiM 

C CflCUPS . SMALLER C8CLP PAECECCS LAXGEK C^CUP. LE^STH 

C IS kl'hZ. 

C H - CLIPLI VICICR CF RfMlS. SPALLEST V«LL£ 1! HANKEO 1. 

C L«PGE<T U KAMCEC h. TIES «RE «!SICNEO AVERAGE OF TIED 

C (i«lkKS. L€f^GT(- IS »«I*K2. 

C I>1 - I^LPeCR CF CASES IN SfALLEP GRCtP 

C »i - M^PEEf) Cf CASES l^ LAKGEK CflCUF 

C L - STATISTIC LSEC TC TEST HC^CCEhCITV CF THE Tt.C 

C GRCLPS ICIIPCII 

C I - fEASUPE Cf SIEMFICAfCt Of U I^ TEKfS Cf hCR(<«L 

C CISIRIIiUTICK (ClilPLTI 

C lER- C. IF AC EOflCP. 

C - It If AiL CALCES Cf ChE GRCLP AKE TIEC. 

C 

C PEPIFK! 

C 2 l£ SET IC 2EPC If N2 I! LESS Tt-Ah 2C 

C 

C HfiPClTIkE! AKC FlhCT|C^ SLPPRCCHArrS VECUlKEC 

C RfMC 

C TIE 

C 

C PETt-CC 

C CE£Ckie£C If. S. SIEGEL, ' fChPABAPEIB IC STATISTICS F0« THE 

C EIFAViCPAL SCIE^CES•« PCCRAh-MULt ^Eh rC«K, I«56| 

C CflFTEP 6 



SLEPCLllft CTESIIA.P.Kl.h2.l.n 
LIPEhSICf AUI.MIlt 

PAIvK SCOPES FRCP ECTf CPCtF TCCETFER l». ASCEhOlhC CPOER* AKD 
ASSIEh TIEC CiiSEPVAT ICNS AVERAGE Cf TIED RANKS 

h-kl4f2 

C«LL PAMi lAtPtNi 
Z-C.C 

iLf fl/MtS Ih LAHCEK CKCLP 

Pi-C.C 

hf-M*l 

CC IC I>hP.k 

ii2>P2*RII t 

CAICLIATE L 

F^<*l>i 

CF"fl««»fh2*(lfK5-*l-Cl/2.Ci-R2 
C«FfcX-l.f 
IFItF-LI ^C.2C.2C 

L»LP 

ttSI FCP h2 LESS Tl-AN 2C 

lF(fi;-2CI EC.AC.4C 

CCFFCTE SIAkCAPC CEVIATICA 

liT-1 

CALL TIEIF.h,Kt,TS> 

IFITSI ;c.£C.sc 

If t1S-IFk«f ^♦fK-FM/iil52.5l,'2 

lER-l 

CC K EC 

5-S«RT(CffH(/IFN»lfN-1.0»II«II (f ^•FH•f «-FM / J2.0 J-TS 1 1 

CC TC TC 

«>StPT<fl>»«<FK4l.CI/l2.0 

CCfFLTE I 

2-(C-Fh**C.;i/5 

FEICR^ 

EhC 



UIFS 


10 


.UTES 


20 


UIES 


30 


tTES 


40 


UTES 


50 


UfES 


60 


tiTES 


TO 


UlfS 


no 


UfES 


90 


UTCS 


100 


UTES 


110 


uies 


WO 


tTES 


no 


UTES 


140 


UTES 


150 


UICS 


160 


UTES 


in 


UTES 


180 


UTES 


190 


UTFS 


?00 


UTES 


210 


UTES 


?70 


UTES 


230 


UTES 


2*o 


UTES 


250 


UIES 


251 


UTES 


252 


UTES 


?A0 


UIES 


?T0 


UTES 


2Ha 


UTES 


7«)0 


UTES 


300 


UTES 


310 


UIFS 


120 


UTES 


330 


UTCS 


3*0 


UTES 


350 


UTES 


360 


UTCS 


3 70 


UTES 


380 


.UTES 


390 


UTES 


400 


UTES 


410 


UTES 


420 


UTES 


430 


UTFS 


440 


UTES 


*50 


UTES 


4A0 


UTES 


470 


UTES 


4S0 


UTES 


490 


UTES 


500 


UTES 


510 


UTES 


520 


UTES 


530 


UTES 


540 


UTES 


550 


UTES 


560 


UTCS 


5 TO 


UTES 


5f0 


UTES 


590 


UTES 


600 


UTES 


610 


UTES 


620 


UTES 


630 


UTES 


640 


UTCS 


650 


UI€S 


660 


UIES 


670 


UTCS 


6S0 


UTCS 


690 


UTES 


700 


UTES 


TIO 


UTCS 


720 


UIES 


730 


UTCS 


740 


UTES 


750 


UTES 


760 


UTES 


761 


UTES 


762 


UTES 


763 


UTES 


770 


UTES 


7ft0 


UTCS 


790 


UTCS 


800 


UTES 


flIO 


UTES 


820 


UTES 


830 


UTES 


840 


OTCS 


850 



(b) if T > 



'''l '^2 \ /n^ - N 



s = 



N(N-l)/ y 12 
where N = total number of cases (n + n^) 
The significance of U can be measured by 



(5) 



(6) 



where X = mean = 



"l'^2 



Z is set to zero if x).^ is less than 20. 



Statistics — Nonparametric Statistics 75 



Subroutine WTEST 

This subroutine computes the Kendall coefficient of 
concordance, given a matrix A of n rows (variables) 
and m columns (cases) . The observations on all 
variables are ranked from 1 to m. Tied observa- 
tions are assigned the average of the tied ranks. 
A correction factor for ties is obtained: 






i = l 



12 



(1) 



where t = number of observations tied for a given 
rank 

Sums of ranks are calculated: 



] 



2 \ 



i = l ^J 
where j = 1, 2, . . . , m 
From these, the mean of sums of ranks is found: 

m 



(2) 



R-^^ 



^. ^J 



m 



(3) 



The sum of squares of deviations is derived: 



m 



■c^ - 2 

= E (Y. -R) 



(4) 



The Kendall coefficient of concordance is then 
computed: 

W = — :r-^ (5) 



12 3 
— n (m - m) - n T 



For m larger than 7, chi-square is: 



sj6kuoTi\t «rtsr 



TLiT JtG^tE Jf ASSutlATIUM A«J ^G A NUMbER Uf VAftlABLfci , 



CALL VJiiTtAtH.,\,n,iriA,ti,CirtiOF,NH\ 

3<.tili>rt^A jr PAKiMtfc^i 
■» - IN-'jr lATRlA, .n tjy A, Ur CKitilNAL OAlA 
•< - OUr.'jr HAIRIX. N dY H, Jr ^aNIC£D OA TA . SMALLE ST ^ALUE 

IS r*AN<tLl I, LttR^^esr Is M.ANK^C N. flcS AKE ASSlGNtO 

AV = ^«Gt UF TitJ i*ANKS 
N - fiJHdtK Ur tfA^IA6LcS 

1 - NjHacK Jf cAicS 

rtA - «JK< A.*tA VtCrC-^ Gf Lt^jTM 2*« 
rt - KcNJlLL CJCrFlLI^»4l OF CohlCUrtUANC £ ( L)U I PuT » 

^i - CHi-sojAK= jourpjn 

><*< - LoJet J rJk :jll-<AN<cJ JAfA IN A. 1 F ^fl SAMK^O OAFA 

It* A 1 i;^Puri 



FUNCr [UiJ 'iJa 



HtEi 


n. 


.«r£j 


/O 


wrfcs 


iC 


WIES 


40 


wrts 


S(. 


"TtS 


tJ'3 


-fits 


ru 


WT£S 


dC 


WTE5 


90 


WTES 


ICI 


^rtb 


]IC 


^rts 


1^0 


^TFS 


liO 


I.TES 


UO 


WT£S 


ii>C 


-JTtS 


ibu 


MIES 


17C 


-TtS 


idJ 


wrES 


!<),■ 


rtIrS 


^00 


«IES 


^13 


WTES 


^;t 


Afci:! 


£ir. 


HftS 


A',:! 


KTES 


iljO 


wres 


<;*>j 


hTlS 


2 re 



If '^ li 



7 OK SrlALLtK 
REdUiREiJ 



( IG 



jtMAVltJKAL SC!fc.Mi,ES' 



•l^^J^iPfl^A-lt^kIC STATE STIi-i 
J;<ilW-HiLL, ME.J VQSK, 1953 



-(TfS J 70 



AUI,-^( 11 .rtA< 1) 



wres ^uG 

S.lsu-r , V.K1 wTlS -.lo 

i^tES 4^0 

*IES 4 JO 

WTES i.'tO 

WTtS -.sT' 

t-TES 4bO 

^.'-fiMJNt ''ncT^LK [JAIa i :i HA'-iKcJ „rti -. fO 

hr-J-^ JdTA rj-x All /ARIA.JlLS ASSI^-U^O (ItJ Ui>ic kVfl T 1 uNS AWtWAtEl.US h:i\1 

f ric) t^NK,i 6.40 Lo.-;Pjrc CGKncCI i JN HOR IlEj ii-uRti WTcS "^C 



r - : , ) 



JIrt 



J = 1 , N 

1) j.a.b 
= 1,.-1 



Gu Td li 
bo IC J=^i,M 

I J- I J*,.! 
CALL <J ^(^^«a 



IKJ =.*Al UJ 

CJii-iJLirc 



S'j;4S -ir HaN\ 



1>U 50 J^l.rl 



J = l. 



C J.-',^,jfi w 

i/( U r.J'r,^le<rM=^FM*FM-rU/i^. jJ-F,4 

CJ'i.'jFl Jrj^c<_S OF EREbitjl ANJ »:n 



NlJF^.^-l 



■ 10 



hTl^ 
wTtb 

»«rts ..^ 

wTt s S3 

WTtS ij 

HfLS 5? 



WIlS cC 

« I c i M : 

-Its ;>-': 

-<rts D^t 

WTLi 6 7C 

«(tS ci. 

-r.s 7..L 

^Itb 7i.- 

-Its /:v 

*Icb 7JJ 

^ILS 7-.0 

Witi 7^- 

rfiLS 7-J-; 
«rts /7c 

-Tt3 7;: 
WTtS 6z: 
v-rts diL 

^TES .151 

wTEii o-.-: 
■^rts ii7c 

uiTtS r.*'' 
wits 'iijj 

«TES ^^0 
wTiS iiJ 

KTcS 930 

-TlS *7G 

■ Te.S -y-^C 
wTt SI JOC 

w 1 6 Si: If 
wrtsio-.i: 

wTCilOiO 
wrfcSi:jo': 
WTES1C7-, 



X = n (m - 1) W 



(6) 



The degrees of freedom are: 
d.f. = n-1 



(7) 



76 Statistics — Nonparametric Statistics 



Generation of Random Variates; Distribution 
Functions 

Generators 
Subroutine RANDU 



SJt! 



(Djri 



AA.4 



I'fJS'r 

J^f>ijrii U:.lfaRHi.r jl iT.<l tJUrSC ftANUCM real NUM-fi:-*^ BtTwEEN 

ANO I.: a.-JJ i*A^i)U.1 I.^FEGtRS dtTWcEN ZERO ANJ 

»»ii. ci^M Cp^IRf UScS AS InPJT AN IMTcutK KAt^uA NuMfitt* 



CAC <A\jJ( IK , lY.Vf^ ) 

SCtiI?njN Or PAkA-lcTEKS 
IX - Fo.^ TMe URiT c.Mr-iV THIS MiJSI CONIi!."^ ANV OJi INIcGEK 

;vJMdch -IKH M^t ]^ LtSS JfGirS. AFTcI* THc riKSr fcNTRY, 

lA iHJJLO tit TH; i»i*evinuS VALJt. CF IV CGrtPUrdU BV THIS I 
SJoRJJTl Ht. ' 

lY - a HLiUuIA.MT l\'fLJ£i •ibMOO'*' fijmtR KcJUIREJ Fijk IHc NExTi 
tNIWr TJ IHIS SJ6-<3UriNE. rnt KANGc QF THIS NUMBtR IS 
b£r*-d£i. ZcRJ A,\ij 2**}i ' 

ri^L- r-it AtiiJLfANr UMt-JRdLY JlSTRloUTtt), FL2fi,Tl,^G P3INT, 
r^:i.\Dj-A .HOMdEM I.J THL J<AMJ^ Ci^ 1 . 

THli iJJKJJllN^ IS |>l':-:ii=IC Tij irSrtM/ib3 ANO WILL PSuJUCt 
^**2V ri.t*Mi aerobe RcP^AriNG. THc fc^FtRcNCE 6£LJtV DISCUSSES 
ILCJS (635i9 HuRt). kUJ PRUdLcMS, AND PRJuLEMS CuNCERNinG i 
■<A'\'Ji|.^ oiC-Ili jSl.M'j THii uE,Nfc-*AnQiVi StHEMc. M-ClARLN A NCJ 
^A^^iA^^Ii, j^iCM U. ^' 3J-d9, JISCUSS Cu.-^^^UENn 4L 
Jt..>.c\AI iL:,il IcFHOiJS A\o liSIi. THt OSt LiF r»(C i-'(._kAr0^i -je 
TH; KiNJlJ rri^L, <:\c HL^lMti n tAoLc ANO ONt PiCK.lNb (^KuiM THE 
TA^Lt. la u!^ BdNcFlT IN SJriE CAjcS. 6:p3^>) HAS SceN 
SUjjtilcJ AS A StLii WHICH rtttS b^ricR STATlSTlCflL PrtOPcRTitS 

Fl.« Ni^M a-tUcK dlli Jr THC Gti^c-iAIct; UcVIATt. 

itcOi iHuJLJ d^ CHCic.M iN ACCii.*L)ANCc Wi H THc JISCuSSlUN 
^lVi\ IN r-1E KcffcRc^Ct oElOW. ALiJ, IT ShOULU 3c NUTtO THAT 
If- PLOiTliMJ POINT kANj^'^ I'J'J^IBflS Arte OLiIKcLi,ttS ARn 
AvaUArLt rKjM ;^A^uj, THc KA-gjO-l CtiAKACIERlSriCS dF tHc 
FLoAIlNti P-jlMT DcVIATES ARt MJjiFIcC ANU IN FACT THcS£ 
JtVIAT^S hiVc HiGh t^KLid^dlLITY Jr HAVlWi A Tl^AILIN^i LCi4 
CifvUE-i ZcKQ bif I'H InEH FRACTIONAL PAnT. 



Kujf I\£S 



FU'lCIlOfti iJiPaOG^i.-IS REQUlftc3 



POrtbK .^tSlJJt MEUDO OISCUSSEO I^ IdH MANUAL C^C-SOlt, 
r<A.>-jOM MJildEfi GLNtHAIlOW AhO TcSIING 



SJd-^JUriNc - 
lY^ IX-to^^SS 
|F( W t 3.6.6 

I Y=I Y*21^7'.dit>'^?*-1 

YFL= i Y 

YFL=>'Fi,*.'ttib(>l3':- 

litTU^.V 

£.M0 



J) U, lY.VfL 1 



Vl 



RANO 


IC 


RAND 


^0 


Rm<.Jl( 


it 


RANJ 


AC 


RANC 


50 


RANO 


6C 


RAND 


7C 


KANO 


6-: 


RANu 


•)0 


RANU 


10 : 


RANU 


iij 


RANC 


!<;■- 


RANO 


1 .: 


rtAIVO 


u. 


RANU 


IS- 


RANO 


iaO 


■ ram; 


1/J 


RaNU 


IJ.. 


RANi; 


1-J' 


■RAKU 


^:o 


KANJ 


^1": 


RANG 


<;^o 


RAM> 


iy. 


RANG 


Z'>') 


RANb 


isO 


KANU 


(iDiJ 


kANJ 


^^i. 


,«A^c 


Z^j 


RANU 


l^^ 


RANO 


i-^C 


BAND 


j-lC 


ftANC 


aiO 


:'<ANd 


i >Z 


BANj 


ot'J 


RAND 


i3-: 


RANG 


io.:- 


^ANO 


J/j 


■RANG 


jr(J 


RANO 


J.J': 


KANO 


iCC 


RANU 


'.U 


RAKD 


i.^-} 


RANO 


-tJU 


RANO 


*,<.o 


RAMD 


as; 


RANO 


A&C 


RAND 


A 7 


I^ANL 


*d3 


RANO 


v9C 


RANO 


5G2 


RAND 


in 


RA.NL 


5?J 


rtAr\;D 


^30 


RANJ 


3^J 


rtA\0 


iaJ 


kancj 


atpO 


RANO 


s/ ; 


RANO 


idj 


KANO 


3qG 


RANLp 


oCO 


^AND 


3 113 



Subroutine GAUSS 

This subroutine computes a normally distributed 
random number with a given mean and standard 
deviation. 

An approximation to normally distributed random 
numbers Y can be found from a sequence of uniform 
random numbers* using the formula: 

^ K 



Y = 



i = l 



^- -"5" 
1 ^ 



(1) 



Vk/12 

where X- is a uniformly distributed random number, 
% < Xj < 1 
K is the number of values Xj to be used 

Y approaches a true normal distribution asymptoti- 
cally as K approaches infinity. For this subroutine, 
K was chosen as 12 to reduce execution time. 
Equation (1) thus becomes: 

12 
Y = X; Xi - 6. 
i= 1 
The adjustment for the required mean and standard 
deviation is then: 

Y' = Y * S + AM (2) 

where Y' is the required normally distributed ran- 
dom number 
S is the required standard deviation 

AM is the required mean 



POrPCSc 

:L.MPUT£i >i .\iuRmALLY Ulil.^loUI-J RANDOM njUMo£R 
y.tAN *iKiJ STA.^OARO OEVIATEwN 



, S , At-l , V ) 

tSC^tlPriLN bl" PARAf^CTLRS 

lA -IX MUST CUNTAIN Al^ JuJ IMcJdft NUMBEH .^ I fn NiNt GR 
LtSS DIGITS UN THE FIRST e.yTRY TU GAUSS. THLi^.tAfTER 
IT WILL CONTAIN A JiJI^URMLY uISTRISUTlJ IMc36R RANOOM 
NUMdLR GcNfcRAIEO dV The sJdRJUTINE fOR USE UW TMt NEXT 
EiiIRY li. THE SUSR-JJTIMc. 

S -TMt OcilRLiy STANJA-IlJ OtVIAfiaN Lf THE (^JRhAL 
OISTRIdu'r IJw. 

AM -Trie GtSIREO MlAN J;- THE NORMAL EI5TRI6UTI0N 

Y -THE VALUE Uf TnE CJiPuTEj NJRMAL RANOUM VARIAbLL 

EMARrtS 

IHls iuBRJJIlNE JSeS RAmJu WHICH IS MACHINE SPECIFIC 

UORUUTIN-S ANO FUNCTION SUBPROGRAMS RtJUlRcO 



lJAUS 


IJ 


.;aus 


2C 


GAUS 


3- 


GAUS 


AG 


OAUS 


5 -J 


GAUS 


6C 


GAui 


li 


GAUS 


d'l 


.;AnS 


■rc 


GAUb 


IGC 


GAU5. 


tic 


..AUS 


icO 


uAUS 


i3C 


GAUS 


lAl 


GAUS 


1 •)■:. 


.^AUi 


160 


UAUS 


1 '■- 


gAus 


UJ 


GauS 


190 


jAUS 


^cc 


GAUS 


iJIO 


GAUS 


i:*;-- 


GAd5 


;ic 


GAUS 


.^aO 


:.AGS 


2 50 



LrnuD 

JSci li U^-JlfUKM RANUQH NJMdErti TJ COHPJTE No^ MAL AANlJGM 
.tJM-Jtil^S LJY CENTRAL LIHIT THEUKi^M. Tmc RcSULT li THt-^i 
aOJUSTcJ TO MATCH THt GiVc^ rtcA.< A»ib STANDARo JcYlATIUN. 
Th^; Ui^lFJRH RANUQM .^U.^d£R i CUflPUTfeO wITHIN THc SJdRGUTINE 
AXi£ Fl-J'^jw 1Y THc PG^lH kcilUUc .'V TrtOD . 



A-C.O 

OJ 50 1=1,12 

CALL KANJUl U, lY.Yl 

Ix=IY 

A = A + v 

VMA-o.O]*i*AH 

RETURN 



* R. W. Hamming, Numerical Methods for 
Scientists and Engineers , McGraw-Hill, N. Y. , 
1962, pages 34 and 389. 



GAUS 


310 


^AUS 


iiO 


GAUS 


*3G 


Gflbi 


i'^0 


GAUS 


3^ J 


GAUS 


ibO 


.GAUS 


W<: 


GAUS 


idC 


^AUi 


ir: 


GAUS 


iCC 


GAUS 


Ai: 


GAUS 


A^O 


GAUS 


43C 


GAUS 


'.'.0 


GAUS 


A53 


GAUS 


Aftl 


GAUS 


a;': 



statistics — Generators; Distribution Functions 77 



Distribution Functions 
Subroutine NDTR 



Subroutine BDTE 



This subroutine computes y = P(x) = Prob (X £ x), 
where X is a random variable distributed normally 
with mean zero and variance one. 

^ "" 2 

P (x) = / exp (-U /2)du 

The following approximation' is used: 



P (x) = 1 - f(x) Z) a.wS X s 



where: 



i = l 

w = 1/(1 + px) 

f(x) = exp (-x^/2) /V27r 

P = 0, 2316419 

a = 0.3193815 

a =-0.3565638 

a„ = 1.781478 



This subroutine computes P=Ix (m,n)=Prob (X s x) 
where X is a random variable following the beta 
distribution with degrees of freedom (continuous 
parameters) m and n. For computation to take 
place, O^xs^l. 0.5^ms lO"''*, and 0. 5 ^ n £ 10+5, 
D, the ordinate of the beta density at x, is also pre- 
sented In the output. 

For ^ x ^ 1, L(m,n) may be written as: 

X 

I (m,n) = r f (m.n.y) dy 

where: 



f (m,n,y) 
B (m,n) 



B(m, n) 



m-l„ .n-1 

y (1-y) 



r(m) IXn) „ _ -, , , 

^y^;D-f(m.n,x) 



(1) 



a^ =-1.821256 
4 

a, = 1.330274 
5 



l^ (m, n) can be reduced to a binomial partial sum 
which can be evaluated by means of a continued frac- 
tion expansion. 



The maximum error is 7(10 ); f(x) is also presented 
in output. 



' C. Hastings, Approximations for Digital Com- 
puters. Princeton University Press, Princeton, 
N.J. , 1955. 

M. Abramowltz and L A. Stegun, Handbook of 
Mathematical Functions. Dover Publications, 



Inc. , N. Y. , equation 26. 2. 17. 



CJHPUIfS Y = P(XI - .'H,^Ar,]LIiy Tlir Ih.E RJ1\J0M VAftlAHLt 
CISTRltJUTEC: Nat.rt«LLY(C, n , IS LEiS T^AN Cft ECUflL TC x. 

ftxi, THE C'JiNATe :;r rnt NyKMfti opnsity at x, is also 

rCKPUTEC. 



uSAr.E 




CALL NOTR(X,P,CI 




Llf--.SCKlPTinN Cf CARihcTE^? 




X--1NPHI SCALftB FOR i.*H!:h PIKl 


1=; 


i'-CUTPtT PftroieiLITv, 




1--0UTPUT nf\SITV. 




ftP'lARKS 




MAXIMUM FSR^P, IS C.OOOCCO?. 




SuF.RHLf INES ftMD SU5P'<'''G;! A*1 S RF31J1R 


eo 


MGK'E 





f THro 
Pd-^eo n\' a°p=oxi«fiT iD'-.s lu r. na^ri'vcs, 4PP(^ox/«dTj(;,v^ fo^ 

DICITAL CUKPUre-iS, P'J.VC£rOiV JNIV. PScSS, PRINCETCJ, N.J,, 
!'^'^5. StE t;.UAnC\ 2o.2.n, r^ANLjerTK TF ".ATriE'-ilTl C AL 
f^UNCTIONS. AtSAr-QWII/ AND 5TEGUN, OCVEF PUBLICATIONS. I M^ . , 
hjfk YORK. 



SuHkruTIf-'t NOTP.IX 



PtO) 



AX=APS(X) 

r= l.G/l ].0t.2;i6',19*AXI 
D^C.?9F9'.2 3*E >CP( -X*X/2.0) 
P = 1.0 - 0*rt( ( ( ( I .33027AnT 
1 G.35bSft33).T * 0.3193eit>J 
(FfXU.2.2 

1 p^i.r-p 

2 ^fTuf^ 
ENO 



1.6212^6I'^I 



1. 78U78)eT 



NDTR 


10 


, .fJOTR 


zo 


NOTR 


30 


NOTR 


<.o 


NOTR 


*"} 


NOT" 


60 


I.NOrR 


70 


NHTR 


rir> 


NDT^^ 


90 


NOIR 


101 


^^0I'' 


no 


NO'-'; 


121 


NJfR 


1 30 


NDIR 


HO 


NDTR 


1S3 


NOI'i 


163 


\orfi 


17'J 


NDTC 


190 


NDTK 


I'?! 


^[)rK 


?00 


NijTr 


213 


\OTP 


??,! 


\OTP 


?10 


MOTC 


.?'.J 


NDTk 


?sa 


NOTR 


^60 


vori: 


;7CI 


NOTfl 


?flO 


NOTP 


?93 


MDIP 


)00 


NDTR 


310 


KDTfi 


irt) 


. NOTP 


33J 


Nioro 


3<;0 


NDTK 


^50 


NOTP 


JSi] 


NOTfl 


^70 


NOTrt 


360 


NOTR 


3'30 


NOTR 


40) 


NDTR 


Al ,) 


NOT« 


4?J 


NDTP 


430 


NDTrt ■ 


'i'.'i 


NDTe 


450 



Let N = m+n-1 and r = m-1. Then : 



I^(m,n) = I^(r+l. N-r) 



I (r+1. N-r) = E (^x^l-x)^-^ 
s=r+l 



(2) 



N r+1 ,N-r-l_ 

(j.+ j)'^ (1-x) s 



where ^ s ^ N 



S is a continued fraction, with 80 terms being 
sufficient for the desired accuracy„ 



S = 



1 \ \ ^2 ^2 



"so ^80 



1- 1+ 1- 1+ 1- 1+ 1 

(N-j-r) (rfi) X 

i (r + 2i - 1) (r + 2i) 1 - x 
iJN+i) X 



d. = 



i (r+2i+l) (r+2i) 1-x 



(3) 

(4) 
(5) 



78 Statistics— Distribution Functions 



TTie above continued fraction expansion of I^. (m, n) 
holds for positive m and n (integers or nonintegers), 
N 2 (m+ n £ 1), and r 2 (m a 1). In order to 
fulfill these last two conditions, if m < V, the fol- 
lowing transformation must be made before com- 
putation of Ix (m,n) can take place: 



I^ (m,n) 



^ r(m+n) 
r(m+l)r(n) 



m,. 
X (1 



X) 



+ 1 (m- 

X 



l,n) 
(6) 



The quantities on the right-hand side of equation (6) 
are those which are computed. 

It is known that Ix(m,n) = Ii-x(n. m). Thus, 
either of the two parameter sets indicated by this 
equation may be used in computing the beta integral. 
The parameter set selection is made by applying the 
following empirically derived rule: 

Let p and q be the degrees of freedom cor- 
responding to z, where z = x if x s: . 5 or (1-x) 
otherwiseo If the quantity C (p-1) - (p+q-1) 
26/5 + 2 ] is positive, use the parameter set 
corresponding to z. Otherwise, use the 
parameter set corresponding to (1-z). 



If m or n is greater than 1000, the chi-square ap- 
proximation is used: 

z, = 2m (l-x)/x is distributed as y ,with 2n 
degrees of freedom and P = 1 - P^^ ^^i) ^'^^ ^^ 
1000. 

Z2 = 2nx/ (1-x) is distributed as x^ with 2 m 
degrees of freedom and P = P^2 (^2) ^°^ ^ ^ 1000. 
If both m and n are greater than 1000, the approx- 
imation corresponding to z^ is used. 

The values of P very near zero or one may be 
somewhat imprecise. To eliminate possible mis- 
interpretation of results, if ^ P ^ 10"^ or 
s 1-P < 10"^, P is set to or 1 respectively. 

For reference see: 

(1) R. E. Bargmann and S. P. Ghosh, Statistical 
Description Programs For a Computer 
Language. IBM Research Report RC-1094, 
1963. 

(2) M. Abramowitz and I. A. Stegun, Handbook of 
Mathematical Functions. U. S. Department of 
Commerce, National Bureau of Standards Ap- 
plied Mathematics Series, 1966. 



If i X ^ 10"^ or ^ 1-x ^ 10~8, the approximation 
is made that x = or 1 respectively. P and D are 
then set according to the following table: 



s x^ 10"^ 
P = 
If: then: 

A < 1 D = 10'^ 

A = l D = l/B(m,n) 

A> 1 D=0 



^ 1-x 5 10"^ 

P = l 
If: then: 

B<1 D = 10''^ 

B = l D = l/B(m,n) 

B> 1 D = 



If either or both m and n are within 10~° of 1, the 
beta integral is solved explicitly for m = 1, n = 1, 
or m = n = 1: 



If: 



then: 



A = l, B= 1 
A = 1, B?^l 
A ?^1, B = l 



P = x 

P = 1 - (1 - x)n 



SUBROUTINE BOTR 

PURPOSE 

CChPUTES P(Xl = PROaABlLITY THAT TM£ RANDOM VARIABLE U, 
OISTRIBUTED ACCDRDINC TO THE BETA OlSTBleUTION WITH 
PARAMETERS A ANC B, IS LESS THAN OR EQUAL TO X. flA,8.Xt, 
THE ORDINATE OF THE BETA oeNSITV AT X. IS ALSO COMPUTtU* 



USAGE 

CALL BDTR{X,At 



,PtO. lERI 



DESCRIPJION OF PARAMETERS 

X - INPUT SCALAR FOR WHICH P(X1 IS COMPUTED. 

A - BETA OISTPIHUTION PARAMETER KONTINUOUSl. 

fl - BETA OISTRIflUTION PARAMETER (CONT INUOUS I . 

P - OUTPUT PROBABILITY. 

D - OUTPUT DENSITY. 

lER - RESULTANT ERROR CODE WHERE 



AND AN ERROR 



ERROR 
-I.+I CDTF HAS BEEN CALLED 

OCCURRED. "iEE CDTR, 
_2 AN INPUT PARAMETER IS INVALID. X IS LESS 

THAN 0-0 0»- Gf-EATEP THfiN l.O, 01 EITHER A OR 

a IS LESS THAN 0.5 OP GREATER THAN 10*»(*5). 

P AND O ARE SET TO -l.E7i. 
t2 INVALID OUTPUT. P IS LESS THAN UPO OF 

GREATER THAN CWE. P IS SET TO l.e75- 



SUBROUTINES AND FUNCTION SUBPROGRAMS fEOUIPEO 

DLGAH 

NDTR 

CO TI- 
ME THOO 

PEFER TO a.E. BARGMANN AND S.P. GHGSh, STATISTICA 

DISTRiauTION PR3GRAMS FOR A COMPUTER LANGUAGE. 

IBM RESEARCH REPORT RC-lOA, 1S63. 



P = x 



m 



SUSPUUTINE fiOTB(X,A,BtP.D, lei 
DOUBLE PRECISION KX.DLXX.OLI 
IXI ,SS,CC.RR.0L6ETa 

TEST FOR VALID INPUT DATA 

/FM-(,5-l.f-5ii 640,10,10 

10 IF(B-( .5-I.E-5I I bAO.^O.JO 

20 1F(A-I.E*5I 30,30,6'.U 

30 IF(tl-l.E*i>l 40,'»0,6<.0 

40 IFIXl 6<.0,50,50 

50 IF(1.-XI 6*0,60,60 



»AA,B6,r,l,G2.G3.G<.,00,PP.XD,FF,fN, 



6DTR 


10 


flOTF 


20 


eoTR 


30 


BOTR 


t.0 


BDTB 


•iO 


80TR 


60 


BDTR 


TO 


eOTF 


BO 


eOTR 


90 


BDTR 


100 


60TP 


110 


BDTR 


120 


BDTR 


130 


6DTP 


1<.0 


BOTR 


150 


BOTR 


160 


BOTR 


ITC 


BDTR 


180 


BDTR 


190 


^DTP 


200 


BOTR 


210 


BDTP 


2?0 


BDTt 


;'30 


BOTR 


2*0 


BOTR 


250 


BOTP 


260 


BDTR 


270 


BDTR 


?fl0 


BOTR 


2S0 


BOTR 


300 


BOTR 


310 


BOTR 


320 


BOTR 


330 


BOTR 


3A0 


BOTfi 


3 SO 


BOTR 


360 


BOTH 


3 70 


BOTH 


380 


30TR 


390 


BDTR 


600 


BOTR 


410 


BOTfi 


4?0 


BDTR 


430 


3DTR 


l.i.0 


BOTR 


450 


BDTP 


460 


80TR 


470 


BDTR 


4R0 


8DTF 


490 


BOTR 


500 


BOTR 


510 


BOTP 


b20 


flOTR 


530 


BDTR 


540 


BDTF 


550 


eoTR 


560 


BOTR 


570 


8DTC 


580 


BOTR 


590 



Statistics— Distribution Functions 79 



COMPUTfc LOG<eET&(A,BM 

66 = 08I.E(e} 

CALL OLGAH<AAtCI. lOK.} 

CALL 0LGAH(BB«G2.I0K) 

CALL 0LGAn(AA+BB.G3. lOKI 

0LPETA.G1»G2-G3 

TtST FOR X NEAR 0.0 OR I.O 

iF{x-i,E-e) flo«ao,7fl 

70 [f <( l.-XI-I.E-Sl 130,130,140 
80 P>0.0 

IfU-l.l 90tl00iL20 
90 D=I.E*T5 
GO TO 660 
100 00— OLMT* 

1F< 00*1.66002 I 120. 120,110 
llO 00=0€l(PIOOI 
O'SNGLIOO) 
CC TC 660 
120 0*0.0 

CO TO 660 
130 P-1.0 

IF<B-1.I 90.100.120 

SET PftOGRAH PARAHtTEaS 

140 XX-OBLE(XI 

OLXX'OLOGIRX) 
0L1K>0L0GI 1.00-KX> 
XQ-XX/) l.OO-XXl 
10^0 

COWPUTt OHOINATE 

OD=(fl*-l.O0l»DLXX*(e8-l.O0l*DLlX-DLaETA 

I FIDO- 1.680021 150,150,160 
150 IF<D04l. 680021 170.170,160 
160 D-I.E75 

RO TO 190 
170 0-0.0 

GO TO 190 
180 DD=OEXP(DD) 

D=SNGI(00) 



A OK B OR BOTH WITHIN l.E- 



DF 1.0 



190 lF<ABS(A-l.I-i.E-6I 200,200.210 
200 IFlABSO-l.l-l.E-a) 220,220,230 
210 If (*eS(6-l.l-l.E-81 260,260,290 
220 P=X 

GO TP 660 
230 PP=BB«DLIK 

IF (PP+ 1.68002) 240,240,250 
240 P=1.0 

GO TO 660 
250 PP=OEXP(PP» 

PP=I,DO-PP 

P=SNGL(PPJ 

GO TO 600 
260 PP»=AA*DLXX 

IF{PP*1. 680021 270,270,280 
270 P-0.0 

GO TO 660 
280 PP=D£XP(PPI 

P-SNGUPPI 

GO TO 600 

TEST FOR A Oft e GREATER THAN 1000.0 

290 |F(A-1000.1 300,300.310 
300 IFIB-IOOO.) 330,330,320 
310 XX=2.D0«AA/X0 

XS=SNGL(XXI 

AA=2. 00*66 

DF-^SNGLIAAI 

CALL CDTR(XS,DF.P.DUMf4Y,ieR» 

P«1.0-P 

GO TO 670 
320 RX-2.00*e&*X0 

XS=SNGLIXXI 

AA-2.D0*AA 

OF-SNGLIAAI 

CALL CDT«(XS,Of.P.OUMMY,lERl 

GO TO 670 

SELECT PARAMETERS FOR CONTINUED FRACTION COMPUTATION 

330 lftX-.5l 340,340,380 
340 IFIAA-l.DO) 350(350*360 



eOTR 600 
BOTP 610 
BDTR 620 
BOTR 630 
SDTR 640 
eOTR 650 
BOTR 660 
BOTR 670 
BDTR 660 
BDTft 690 
BOTR 700 
BOTR 710 
BDTR 720 
BDTR 7iO 
BDTR 740 
BOTR 750 
nOTR 760 
BOTR 7T0 
BOTR TbO 
BOTR 790 
BDTR BOO 
BDTR 810 
BOTR 820 
SOTR 8 30 
BOTR 840 
BOTR 8S0 
BOTR 860 
BOTR 870 
BOTR 880 
BOTR 890 
BOTR 900 
BDTR 910 
BOTR 920 
BOTH 930 
BDTR 940 
eOTR 950 
BOTP 960 
BOTR 970 
BOTR 980 
BOTi; 990 
6DTR1O0O 
BDTR 1010 
BDTR 1020 
8DTR1030 
BDTR 1040 

eoTFioso 

60TR1060 
fl0rRlO70 
•^OTFIOBO 
BDTR1090 
BOTRllOO 
eOTBlliO 
BDTR1120 
BOTR 11 30 
BDTfill40 
B0TR1150 
B0TR1160 
B0TP1170 
BDTRUaO 
BDTR 1190 
BDTP1200 
60TR1210 
BOTH 1220 
BDTR 1230 
BOTR 1240 
6DTR1250 
60TR1260 
B0TR1270 
BDTR1280 
80TR1290 
BOTR 1300 
BDTR1310 
6DTRIJ20 
B0TR1330 
BDTm340 
BOTftl390 
BOTR 1360 
BOTR1370 
S0TR1380 
BOTR 1390 
BOTR 1400 
B0TRL410 
BOTR 1420 
eOTRl430 
60rpi440 
eOTR1450 
BDTP1460 
B0TR1470 
BDTR 1480 
BOTR 1490 
B0TR1500 
BDTR 15 10 



350 RR"AA*1.00 

GO TO 370 
360 RR>AA 
370 00-0LXX/5.D0 

DO-OEXPCDDI 

00=<RR-1.00)-(RR*B6-1.00)*XK*00 4^2.00 

IFIODl 420<420t430 
380 IFIBB-l.DOl 390.390,400 
390 RR'BB^l.OO 

GO TO 410 
400 RR*BB 
410 DO=OL1X/5.DO 

0O-D£XPI00} 

00'IRR-l.D0t-(*A*RR-1.0ai*( 1.D0-XX1*D0 «^2-D0 

1F(00» 430,430,420 
420 ID-1 

FF=DLU 

0L1X*0LXX 

OLXX=FF 

X0»l.00/X0 

FF=AA 

AA'Se 



L TEST FOR A LESS THAN 1.0 

C 

430 FF=O.DO 

IFIAA'l.OOl 440,440,470 
440 CALL 0LGAH(AA»l.D0tG4,I0K) 
0D-AA*OLXX*BB«0L lX4'G3-G2-G4 
IF(D0*1. 66002) 460,460,450 
450 Ff-FF»DEXP<DO) 
460 AA=AA*1.D0 

C CnwPUTE P USING CONTlNUtO FRACTION EXPANSION 

470 FN=AA*e8-l.D0 
RR=AA-1.D0 
IU90 

XI=OFLOATIU» 

SS=< (B6-XI 1«(RR*XI ))/( l«R»2.D0*XI-l.D0)*(RR*2.00*XI ) ( 
SS=SS*XO 

00 480 1*^1,79 

1 I =80- I 
XI=OFLOAT(II) 

00=1X1*1 FN*XI I )/( tRR»2.00*XI» 1.001 •1RR»2.00*XI) » 

DO=l)D*XO 

CC=( (BB-Xl l*(RR*Xni/C IRR*2.0a*XI- 1.001 •(RR*2.D0«Xl) » 

CC=CC«XO 

SS=CC/I 1.004^00/1 1. DO-SSI ) 
4S0 CONTINUE 

SS=l-DO/( l.OO-SSt 

IFISS) 650,650,490 
490 CALL DLGAM(AA«BBtGltlO(() 

CALL OLCAn<AA*1.00.G4.IOKI 

CC-^G1-G2-G4*AA*OLHX«I8B-I.OOI*OL1X 

PP>CC*010G(SSI 

|F|PP*1.68002I 500,500,510 
500 PP-FF 

GO TO 520 
510 PP»DEXP<PP)»FF 
520 IFMO) 540,540,530 
530 PP-l.DO-PP 
540 P-SNGL(PPI 

SET ERROR INDICATOR 

IF(P| 550,570,570 
550 IF(AB$IP)-l.E-7) 560*560,650 
560 P'0.0 

GO TO 660 
570 IFIl.-Pt 580.600.600 
560 IFIA6SI1.-PI--1.E-7I 590,590.650 
590 P'1.0 

GO TO 660 
600 IF(P-1.E-6I 610,610.620 
610 P>0.0 

GO TO 660 
620 IF(t 1.0-P)-l.E--8} 630,630*660 
630 P=1.0 

CO TO 660 
640 l£R=-2 

D=-l.€75 

P=-1.E75 

GO TO 670 
650 lEP=+2 

P« l,E75 

GO TO 670 
660 IEP»0 
670 RETURN 

END 



BDTB1520 
BDTft 1530 
SOTR 1540 
BDTP1550 
B0TR1560 
60TR1570 
BDTRlSeO 
aOTR1590 
BDTR1600 
BDTP1610 
BDTR1620 
B0TR1630 
BOTP 1640 
BDTR1650 
BDTR1660 
B0TR1670 
6DTR1680 
BOTR 1690 
B0TR1700 
BOTRITIO 
BDTR1720 
BDTR1730 
BDTR1T40 
B0TR1750 
80TR1760 
BDTR17T0 
BDTR 1780 
aOTR1790 
aOTRUOO 
60TR1810 
aDTRl820 
60TR18 3D 
e0TRLB40 
60TR1850 
BOTR 1660 
eOTRlSTO 
BDTft 1880 
BOTR 1890 
BOTP 1900 

eorRi9io 

flDTR1920 

80TH930 

BDTR1940 

BOTR 1950 

BDTP1960 

80TRi970 

B0IR1980 

B0IP1990 

80TR2000 

B0TR2010 

RDTi;2020 

6DTP2030 

60TP2040 

B0Tfi2050 

BDTR2060 

BOTR2070 

S0TF20e0 

80TR2090 

eDTR2l00 

80TF2110 

60TR2120, 

BOTR2L30 

BDTF2140 

B0Tfl2150 

80TR2160 

BDTfi2170 

B0TR2180 

BDTR2190 

BOTP2200 

BDTR2210 

BDTR2220 

80TP2230 

aOT«2240 

6DTR22S0 

B0TR2260 

6DTRZ270 

B0TR2280 

flOTRZ290 

eDTR2300 

fiOTR2310 

BOTR23ZD 

BDTR2330 

60TR2340 

eOTR2350 

BOTR 2360 

B0Tfl2370 

B0TR2380 

BDTR 2 390 

60TR2*00 

eDTfl24tO 

B0TR2420 

B0TR2430 



80 Statistics — Distribution Functions 



Subroutine CDTR 

This subroutine computes P = P (x) = Prob: (X ^ x), 
where X is a random variable following the X2 dis- 
tribution with continuous parameter m. The value 
of X must be greater than or equal to zero and 0. 5 
^ m < 2 (10^) for computation to take place. D, the 
ordinate of the X 2 density at x, is also presented in 
the output. 

For X 2 0, P(x) may be written as: 

P(x) = / f (m,y)dy (1) 



where f(m,y) = y(-2)/2 e "^^/V (2-/^ r(f )) 



If e > 0, Tl can be expanded in the following mf inite 
series: 

z^ / z _gl, z^ Jl_ \ 
"^^ ""r(i+e)\^i+e" 2+e 2:{3+e) 3.'(4+e)**"j 

(2) 



where Z = — 



8. 



This series is used in the range 10"" < x ^ 10, and 
not more than 30 terms are necessary to ensure 
convergence within error bounds of 10" • 

For X > 10, 1-Tl is evaluated by the Euler- 
McLaurin formula up to third-derivative terms (see 
reference (2), equation 23.1.30). One finds: 



and D = f(m,x) 

To evaluate the integral, 9 = Y ~ % "^ ^^ ^^^^* 
defined where C ^1 denotes the largesfinteger 
less than or equal to ^. 6 is thus the fractional 
part of ^. 

Substituting this expression into the integral and 
performing the proper reductions, the following 
results are obtained. 



N 



1 - Tl = / h (u) du 




(3) 



where h (u) 



r(i+e) 

N N-1 



1__ 2u -(1 + 6)^,-1 ^-Nx/2u 
+ 6) W 



u e 



and / h(u)du = E h(u) + f ^W " ^ ^'(N) 



u=o 



If: 






then: 


< m< 2 








P (x) = Tl + T2 


2 ^ m<4 








P (x) = Tl 


m2 4 








P (x) = Tl - 2T3 


where: 










X 

Tl = / 



9 • 
y e 

1+9 
2 


-y/2 
r(i 


dy 
+ 6) 





T2 = f (2+2 9,x) 

T3 = E f (2i+2e ,x) 
i = 2 

T2 and T3 may be evaluated directly using logs and 
antilogs. 



If e = (W is an integer), Tl is easily evaluated 



as: 



+ — h'" (N) (Note: h' = h'" 
720 ^ ' ^- 



= at 0) 

In order to achieve accuracy consistent with that 
obtained by the method of equation (2), N = 26 is 
used in equation (3). 

If ^ X ^ 10"^, the approximation x = is made. 
P is set to 0; and D is set to lo'^, 0. 5, or 0, 
corresponding to m less than 2, equal to 2, or 
greater than 2 respectively. 

If m > 1000, Wilson and Hilferty's approximation 
is used. (X ^/m)-*-/^ is approximately normally 
distributed with mean 1 - 2/9m and variance 2/9m 
(see reference (2), equation 26.4. 14). K ms 1000 
and x > 2000, or m > 1000 and x >106, P is set to 1. 

Since Tl may have an error of about 10"", VflluSS 
of P(x) very near zero or one may be somewhat im- 
precise. To eliminate possible misinterpretation of 
results, if s P(x) s 10"^ or s 1-P(x) s 10"^, 
P(x) is set to or 1 respectively. 



Tl = 1 - e 



-x/2 



Statistics — Distribution Functions 81 



The X 2 distribution is a member of the gamma 
family of probability distributions. The general 
form, for distributions of this class is: 

X 

P (x) = / G(n,A, i/j; u) du 


where G(n,a, ^ ; u) = (u-a)""! e-("-a)/i/)/(it)^ T (n) ) 

This subroutine may, therefore, also be used to 
compute the probability integral from zero to x and 
the corresponding ordinate at x for any member of 
this gamma family by setting: 

X = 2(u-a) / il) and m = 2n 

Then P(x) will be the desired probability and 
2f(m,x)/^ will be the desired ordinate. 

For reference see: 

(1) K. E, Bargmann and S* P. Ghosh, Statistical 
Distribution Programs For a Computer Language. 
IBM Research Report RC-1094, 1963 

(2) M. Abramowitz and L A. Stegun, Handbook of 
Mathematical Functions. U. S. Department of 
Commerce, National Bureau of Standards Ap- 
plied Mathematics Series, 1966. 

C CDTF 10 

..CDTR 20 
COTR 30 
COTS '.O 
COTR 50 
COTR 60 
COTR 70 
; CDTR 80 
<cCOTfi 90 
CUTS 100 
GDIS lie 
CDTR 120 
CDTP 130 
CDTR UO 
CPTR 150 
CDTR 160 
COTR 170 
CDTR 180 
COTR 190 
CDTR 200 
CDTP 210 
COTR 220 
CDTR 2i0 
cdtf; 240 
COTR 250 
CDTR 260 
rOTR 270 
COTR 280 
CDTR 290 
CDTt 300 
CDTR 310 
CDTP 320 
COTP 330 
CDTR 3',0 
COTR 350 
COTF 360 
CDTR 370 
CDTR 3B0 
CDTR 390 
CDTR <iOO 
CDTR 410 
COTC 420 



lEST ^Cft 



tAlfcK 



'^UtJ'^C U1 INE COT = 

I^URPCSfc 

CCMPUTES P ( Kl = Pt [Idfl&l LI T Y THAI THf (• iNUUM UtP I adt E LI, 

DlbTrtlflUTED ACCORDING TO THfc CHi-SQUAkt 01STRI3UT[UN wlTH 
LEOKeeS OF FRttOCJH, IS LESS THAN OR eOUOL TU X. FIG, XI, T 

nPDINATE Of THE Ch1-S0UAF£ OENSITr fil X, IS ALSO CUMPUTcO. 



UESCfilPTIOh OF PARAMETERS 

X - INPUT SCALAR FOfi WHICH PlXl IS CCMPUItD. 

G - NUMBER OF DlGREES OF FREELlO'l CF THE CHl-SQUAKE 

DISTRIBUTION. G IS A CONTINUOUS PARAMETER. 
P - OUTPUT PfOefiBILlTY. 
D - OUTPUT DENSITY, 
I6R - RESULTANT EKMOR CODE 1-HEKE 

1£P= NO ERROR 

(ER=-1 AN INPUT PARAMETER (S INVALID. X IS I 

THAN 0.0, Gk G is less than C.5 OR GR. 
THAN 2«l0**(t5l. P ANJ D ARE SET TO 

IER=*1 INVALID OUTPUT. P IS LfcSS THAN ZtfiO i 

GREATER THAN UNE , UR SERIES FDR Tl I Si 
MATHEMATICAL DtSCRIPIIONt HAS FAILED 
CONVERGE. P IS SET TO 1.E75. 



SUBRDUTINcS ANO FUNCTION SUbPKCGRAMS KtQUUtD 
0LGA?1 
NOTR 

METHOD 

REFER TO H.e. BAfGMANN ANO S.P. Gh'jSh, STATISTIC^ 
DISTRIBUTION PROGRAMS FOR A COMPUTER LANGUAGE. 
ISM RESEARCH REPORT RC-109A, 1963. 



-CDTR 



30 



SueRQUTlNE coin X.G.P.D, lER J 

0OU6LE PRECISION KX ,OLXX, X2 . 0LX2 . GG, G2 , OL T 3 , THE T A , THP i , 
1GLG2,D0,T1 l.SER.CC.XI , F AC , TLOG , TERM , G TH , A2 , A . 6 . C. DT 2 . D I 3 . ThPI 

TEST FOR VALID INPUT DATA 

iFlG-( .5-l.E-5n 590,10.10 
3 If{G-2.E*5) 20.20,590 
3 IFIXI 590,30.30 

lEST FOR X NEAR 0.0 

} IFIX-l.E-81 *0,40,80 
) P=0.0 

lFIG-2.1 50,60,70 
) D=t.E75 

CC TO 610 
( 0=0.5 

GO TO 610 
> D=0-0 

GO TO 610 



CDTR 440 

fOTC 450 

CDTR 460 

CDTR 470 

CQTP 480 

CDTP 490 

COTR 500 

rorfi 510 

CDTR 520 
CDTR S30 
COTR 540 
CDTR 550 
CDTR 560 
COTR 570 
COIR 580 
CDTR 590 
COTR 500 
CDTR fclO 
COTR 620 
COTR 630 
CDTR 640 
CDTP 650 
COTR 660 



80 ir(X-l.E+6) 100,100,90 
90 D=0.0 
P- I .0 
GO TO 610 
C 
C SET PROGRAM PARAMETERS 

r 

100 XK=OBLE<X) 

OLXX=OLDGI XXI 
X2=XX/2, DO 
DLX2=0LOC(X21 
C&=061£(&1 
C2=GC/2.00 
C 

C COMPUTE ORDINATE 

C 

CALL DLGAM(G2.GLG2, IC-Kl 

00-I&2-I. 00 J«DLXX-X2-G2*. 693 147180^59945 3 -GLG2 
IF 100- 1. 66002) UO, 110,120 
110 IFIDD+I. 66002) 130,130,140 
120 0=1. E75 

GO TC 150 
130 D=0.0 

GO TO 150 
140 OD=UtXP(DO» 
D=SN&LIOD) 
C 

C TEST FOR G GREATER THAN 1000.0 

L TEST FOR X GWEATEk THAN 2000.0 

150 IF(G-10 00.) Ib0,l60,ie0 
160 lFlX-2000.) 190,190,170 
170 P-1,0 

GO TO 610 
180 A=DLCG(XX/GGI/3.D0 

A=OEXP(fll 

B^?. 00/(9. 00*GG) 

C=(A-1.00»3)/DS0RTIB1 

5C=SNGL(C ) 

CALL NDTR( SCP.OUMMYl 

Gf TO 490 

COMPUTE THETA 

1-90 K^ IDINTIGZI 

THETA=G2-0EL0AT(K1 

IF(THETA-l.O-a) 200,200,210 
20C THET A=O.DO 
210 THP|=THETA*1.D0 

SELECT METHOD OF COMPUTING Tl 

IFIIHETAI 230,230,220 
220 IFIKX-IG.OOI 260, 260, 320 

COMPUTE Tl FOR THETA EQUALS 0.0 

250 IF(X2-1. 68002) 250,240.^40 
240 Tl=1.0 

GO TO 400 
250 TU=I.U0-DEXP(-X2I 

T 1=SNGL1T11) 

GO TC 400 

COMPUTE Tl fOR THETA GSEATEF THAN 0.0 AND 
X LESS THAN OR EOUAL TO 10.0 



HO 1 + 1. DO J 1 



26C SER = X2*U -DO/THPl 
J = +l 

CC-OFLOAT( J) 
DO 270 IT1 = 3, 30 
XI=DFLGAT{IT1) 
CALL OLGAM(XI ,FAC. lOKt 
TLCG= XI*0LX2-FAC-01CG( XI ti^HETAl 
TERM=DEXP(T10G» 
TERM=OilGN( TERM.CC) 
SER=S£f ♦TCHM 

cc=-cc 

IF(DASS(T£RMl-l.D-9) 2 80. 2 70. 2 70 
270 CONTINUE 

GO TO 600 
280 IF ( SER 1 600,600.290 
290 CALL DLGAMITHPl.GTH, lUK) 

TL0G = IHETA*0LX2*0(.0G(S£R l-GTH 

IF(TL0G*1. 68002) 300,300,310 
300 TI=0.0 

GO TO 400 
310 Tll=DEXP(TLrG) 

TUSNGLITin 

GO TO 400 



320 A2=0.00 

DO 340 1=1.25 

XI=DFLDAT( I I 

CALL DLGAMI THPl.GTH, lOK) 

Tll=-(13.D0*XX)/Xl ♦IHPi*DLDG( 13.00«XX 

IF 1111*1-66002) 340,340. 3 30 
330 Tl 1 = DEXP{ Tin 

A2=A2*Tll 
^40 CONTINUE 

C=l.Ol28£051*ThETA/l5e,.uO-XX/312.00 

b=DA6S< A) 

C= -X2*THPl»DLX2tOLOG{B)-GTH-3,95124 371858142 7 

IF(C*l. 660021 370.370.350 
350 IF (A) 360,370,360 
360 C=-DEXP(C 1 

GO TO 390 
370 C=0.00 

CC TO 390 
380 c^oexpic) 

390 C=A2tC 

Tl Isl.DO-C 
Tl=SNGLm I) 

SELECT PROPER EXPRESSION FCP P 



GTH-DLPG) 



400 IF(G-2.) 4 20,410,410 
410 IF(C-4.) 450,460,460 



COMPUTE P FOR G GREATER THAN ZERO AND LESS THAN 2.0 



420 CALL OLGA«( THPI , GIN, IDKI 

0T2= THE IA*DLXX-X2- THPI '.69 314 71 80559945 3 



CDTR 670 
CDTF 660 
COrR 690 
COTR TOO 
COTi: 710 
COTR 720 
COTR 730 
CDTP 740 
COTR 750 
CDTR 760 
CDTP T70 
COTR 780 
COIR 790 
CDTP 800 
COTR 810 
CDTP 820 
COTC 830 
COTR 840 
COTR 850 
CDTF 860 
CDTR 870 
CDTR 880 
COTP 890 
CDTR 900 
CDTR 910 
COTR 920 
CDTR 930 
COTR 940 
COTP 950 
CDTR 960 
COTR 970 
CDTR 980 

COT« 990 

CDTR 1 000 
COTRIOIO 
coTRinpo 
CDTR1030 
CDTR104t> 
CDTRiOSO 
CDTR1060 
C0TP1070 
CDTR 1080 
C0TR1090 
COTRllOO 
COTRlllO 
CDTRU20 
CDTRllBO 
CDTP 1140 
C0TR1150 
CDTR1160 
C0TRI170 

coTouao 

COTRl 190 
COTRI2OO 
CDTC1210 
C0TR1220 
CDTP1230 
C0TR1240 
C0TB12S0 
CDTR1260 
CDTR1270 
CDTR12fiO 
CDTR1290 
CDTF1300 
C0TR1310 
CDTR1320 
roTt 1330 
C0TRl34fi 
COTR1350 
COIF 1360 
CDTR1370 
C0TR1380 
C0TP1390 
CDTRl4flO 
C0TR1410 
CDTfil420 
CDTR1430 
COTR 1440 
CDTS 1450 
CDTRi460 
C0TR14T0 
C0TR1480 
C0TRi490 
CDTR1500 
fOrfil510 
CDTR1520 
COTR153b 
CDTR1540 
C0TR1550 
C0IH1560 
C0TRi570 
CDTR1580 
CDTR1590 
CDTftl60C 
CDTR1610 
C0TR1620 
COIR1630 
CDTR1640 
CDTfil650 
C0TR1660 
CDTRi670 
C0TP1680 
CDTR1690 
CDTRITOO 
CDTF1710 
COTR1720 
CDTP1730 

corsi740 

CnTH1750 
C0TP1760 
CDT01770 
C0TR17B0 
CDTR1790 

C0TP1800 
CDTRieiO 
C0TR1B20 
CDTF 1830 
CDTR1840 
C0TR1850 
COTF I860 
CDr«ia70 

CDTRieeo 

CDTP189Q 
CDTRI900 
CDTR1910 
CDTR1920 
C0TR1930 
CDTR1940 



82 Statistics — Distribution Functions 



If (DT2*1 .68002) * 30, ^ 10 .^-tO 
".30 P=T1 



GC 



490 



Ui,0 0T? = D£KP(0T2) 
T2 = SNGH0T2t 
P=TI*T2+T2 
CO TO *90 

COMPUTE P FOR G GkEATER THAN OR EQUAL TO 2.0 
flNO LESS THAN *.0 



CrMPUTE P FOR 
AND LESS THAN 



bBEATfR THAN OR EUUAL TO A.O 
P EQUAL TO 1000.0 



-idCi DT3 = 0.00 

00 'teo 13 = 2, K 
THPl^DFLCAIlI 3)*IHET A 
CALL OLGAHITHPi.GTH.IOK) 
OLT3=THP1*OLX2-OLKX-X2-CTH 
IF(0LT3*l.fe8D02) <r60, 1B0, *. 70 

170 Df3=OT3»OEXP(DLT3l 

160 CONTINUE 

T3=SNGL(CT3) 
P=T1-T3-T3 

SET ERROR INDICATOR 

490 IFIPI 500,520,520 

500 !F(AeSIPl-I.E-Tl 510,510,600 

SIO P=D.O 

GO TO 610 
520 IFCl.-PI 530,550.650 
530 IFIA8Sn.-P)-l.e-71 510, 510,600 
510 P=l.O 

GO TO 610 
550 lF(P-l,E-8) 560,560,57tj 
5fc0 P=0,0 

GO Tn falO 
570 IF(( l.0-P)-l.E-8J 580,580.610 
5Hu P=l.O 

GC TO 610 
590 [ER=-i 

D = -t .£75 

P=-1.ET5 

GO TO 620 
600 IfP.= *l 

P= t.E7S 

00 TC 620 
610 ieR=o 
620 RETURN 

END 



C0Tfil950 

CDIft I960 

COTfi 1970 
rOTfil9BO 
CDrB1990 
CDTR2000 
C0TR2010 
C0rB2020 
COTH2030 
CDTR2010 
COIB3050 
COTR2060 
COTR207O 

coiR2aeo 

CDTR2090 
CDTP2100 
CDr(»2l 10 
C0TH2120 
C0TH2130 
C0TR2110 
COTR2150 
C0TH2160 
CDTP2170 
C0Tfi2iaQ 
CDTR2190 
CDTB2200 
C0TP2210 
CDrR2220 
CDTR223D 
CDTF2210 
CDTfi2250 
C0TR2260 
COTP22TO 
COTR2280 
CDTR2290 
COTf 2300 
COTft2310 
COTR2320 
COTF2330 
CDTR2310 
C0TR2350 
C0TF2360 
CDr«2370 
CDTR2380 
C0TK2390 
C0TR2100 
CDTfi2110 
CDTC2420 
COTR2l3n 
C0Tft2140 
€011^2150 
C0TR2160 
C0TR2170 
C0TC2^B0 



Subroutine NDTRI 

This subroutine computes x = p" (y) such that 
y = P(x) = Prob pC ^ x) where X is a random vari- 
able distributed normally with mean zero and 
variance one. 
That is, given P(x), the following is solved for x: 



P (x) = — / exp (-u2/2)du 
■J 277 -°° 

The following approximation* is used: 



w 



2.3 
- ^ a.w / X) b.w 



i = 



i = 



where: 



w = Vln (l/p2) (0 < p ^ . 5) 

ag = 2.515517 

aj = 0. 802853 

32 = 0.010328 

bi = 1.432788 

b2 = 0,189269 

bo = 0.001308 



(1) 



(2) 



If P(x) is greater than 0. 5, 1 - P(x) is used as p in 
(2) above, and the result of (1), x, is negated. 
The maximum error is 0. 00045; f(x) is also eal- 
culatedo 



'Co Hastings, Approximations for Digital Com- 
puters . Princeton University Press, Princeton, 
N.J. , 1955 

M. Abramowitz and L A. Stegun, Handbook of 
Mathematical Functions. Dover Publications, Inc., 
N. Y. , equation 26. 2. 23. 



Statistics — Distribution Functions 83 



t NTRI 10 

t NTRI 20 

C NT«I 30 

C £LEfiCLllh£ h£lkl NTRI 40 

t NTRI 90 

C fCPfCJE NTRr 40 
C CCfFlIES X ■ P»<*-n(*), TI-£ A«Gt«€M Ji SUCt- Tf*l V- PUl - NTftr 70 

C ll-E PRCeneiLlIY ll-AT 1l-€ F4^CCP< V*t(l«eLE Ut OlSTRieUTEC^ NTRI 80 

C *>CF*#iLVlC.ll, IS LESS TI-«K CR ECU4L 1C K. F(»), IhE NTRI to 

C CDCIKAIC CF T»-€ fcCRfAL CfhSITV. IT K. 15 ALSC CCffOTEO. NTRI 100 

^ NTRI 110 

C LS«C( MTRi iza 

C Cill NCIRKP.M.C.IER) NTRI 130 

C NTRI 140 

C CtSCFIFTICIt CF PHi*ft1H»S Nini t&O 

C F - fhFLT PRCe««ILITV. NTRI 160 
C X - CLirCI *RCL^€NI SLCt- T^*T P . Y - TMt PRCfl«eUIIt TM*T MRI I TO 
C L< THE R>KCG^ V«RI«eL£, I! LESS Tf-AN CR EOUAL TO X. NTOi ISO 

C C - CtlPLI CE^SITY, fOI. NTHJ 190 

C I£R - CLIFLT tRPCR CCC£ NTRI 200 

C - -1 IF F IS NOT Ih IHE IhTERHAL (0,1), IhCLLSIVE. NTRI 2L0 

C MC*,SSSSSE«7* th This C«SE NTRI 211 

C - C If IFCHE IS KC EPRCR. SEE REMARKS, eCLCH. NTPI 220 

C NTRI 230 

C F£P«fH5 MRI 2*0 

C f#kl*'0*' ERRCR IS O.COC^t. NTRI 250 

C If F - C. M IS SET ID -IK)«*74,. C IS SET TC C. NTRI 260 

C IF F > It M IS UJ TC (KM*?*. C IS SET TC C, NTRI Z70 

C NTRI 280 

C il.ei)CCTIh££ nt SiePftCGRII*'! RECUIREO NTRI 2-gO 

C hCht NTRI 300 

C M«I SIO 

C PtIFCC NTRI J20 

C eiStC Ch «PRRCl|fAIKhS Ih C. HASTINGS^ APPRCX |f<RT ICNS FCR NTRI 330 

C CiCIIAL CCr'RIJlERS. PKlKCEICh UMV. PRESS, PR1^CETL^, N.J., NTRI 140 

C 1S<*. <E£ €Ci<ATlCh 26.2.23. hAKCBCCK CF H«ThER«TICAL NTRI 3S0 
C fLhCTIChS* ReR'PChlU 4KC <TEOUh. CCVER PUEL I CATIONS. INC.. NTRI 360 

C ^Eh >C^R. NTRI 370 

C NTRI 380 

C NTRI 390 

C NTRI 400 

£LeFCLll^E hCTRKP.R.tt IE] NTRI 4t0 

C NTRI 420 

lE-C NTRI 430 

||<.SSS^SE*I4 NIRI 431 

C** NTRI 432 

IF(F)1.4,2 NTRI 440 

1 IE--I NTRI 450 

CC IC li NTRI 460 

; If (f-i.C17,5,l NTRI 470 

4 Ji— .^SSS*Se*T4 NTRI 480 

; l«C.C NTRI 490 

EC TC li NTRI 500 

C NTRI 9)0 

C NTHI 520 

7 C"f NTRI 530 

If IC-0.!)S.S.e NTRI 540 

t C-l.C-C NTRI 550 

f T3-«I.CCI1.C/(C*CIJ NTRI 960 

l«SC»IITj) NTRI 970 

X>1-(2.5 1S517*C.eC2ei3*T«0.ClC32a«I2)/(l.C*1.4327ae«I>O.ie4264*T2 NTRI 580 

1 *0.CCUCfl*T*12) NTRI 990 

If IP-C! IIO.IC.II NTRI 600 

IC »— H NTRI 610 

11 C-C.3SES4i3«EkFI-K*X/2.CI NTRI ^20 

ii RET(.R^ NTRI 630 

ERC NTRI 640 



84 Statistics— Distribution Functions 



Elementary Statistics and Miscellany 



Subroutine MOMEN 



This subroutine computes four moments for grouped 
data Fn , Fo, . . . , Fj^ on equal class intervals. The 
number of class intervals is computed as follows: 



n= (UBO„ - UBOJ/UBO 

where UBO = given lower bound 
UBO = given class interval 
UBO = given upper bound 

and the total frequency as follows: 
n 
T= E F^ 



(1) 



i=l 



(2) 



.th 



where F = frequency count in i interval, 
i 

Then, the following are computed. 



First moment (mean): 
n 



ANS = 



Sf. rUBOj 

i= 1 '- 



+ (i-0. 5) UBO 1 



(3) 



.th 

J moment: 



ANS. 



LI 

/ J F. rUBO^ + (i-0, 
i=l "^ L 



(4) 
5) UBO -ANS 



J T 

j= 2, 3, 4 



These moments are biased and not corrected for 
grouping. 









PCPE 10 








..PCPC 20 








HCHE 30 






«CeiiCClUE PCfEh 


«Cf^ +0 








«Cf»E 50 






FLFFC<C 


MCME 60 






K flM in It-E fiaSI fCLC I'CPEfcTS fCt> CBCUPiC C*T* Oh 


MCPE 70 






tKL#L CL«2£ IKIEHVALS. 


wcPE ao 

KC« 10 






ISiCE 


m;p£ 100 






C'Lt fCfCK (f ,l.eC.hCt>,*A<) 


«CH£ 110 
none 120 






CESCflfTlCh CF P4P^fE1Ef>S 


HCPE 130 






f - CBCCfCC t*r» (fUEtlthCItSI. tlVtN *5 « VECTCR Cf 


HCE 1*0 






LEhCIt: (l.eC<3l-LeCMIl/UflCI2> 


NCH£ 190 






liC - 3 CEIL VECICR. LECd) IS ICheft ^CUNC «hC LUCOl UPPER MCf>E 160 






CCtKC Ch CAT«. ueC<JI IS CLASS INTERVAL. KCTE THAT 


«« 170 






teC(3l fLST BE CPC«1ER Tl-Ah bICIll. 


MCttE IRQ 






fcCP - CfllCfc P<R*rtIE«, If HOP • U AhSdl • PEAK. IF 


MCHE 190 






KCP " 2. «NS(2I - SECCNO PCPEI^T. IF NCF - 3» AKSOI 


-NCME 200 






Tt-IRC PCfiEMT. IF hCP • A. A»iSlAt - FCLRT^ KCHEftl. 


HGM£ 210 






IF KCP ■ 5. ALL FCLO PC«€*TS *Rt FULEC Ih. 


«CPE 220 






AhS - CCIPLT VECTCtt Of LE^CTh S INK kt-ICH rCfENTS AHe PUT, 


. «€••€ 2 JO 
MCHE 2A0 






fl£P«FK^ 


PC« 250 






hClt 1»-AI !*-£ FlhST FC^'EM IS NCI CCNTI-AL ett Tht VAILC CF 


MCfiE 260 






Tt-E PEAK ITSELF. ThE PEAK IS ALkAVS CALCULATEC. HOHENTS 


MOH£ 270 






AfiE tIASIC AfrC NCT CCBRECTEC FCK e«C(JPIN6. 


HOME 280 
«Cf£ 210 






EiePCLTIKE! 4hC FLNCTICK SLEFPCGRAPS RfCLlREO 


POM£ 300 






hCf>C 


HCPE 310 
KCe 320 






PEIFCC 


MCNE )10 






PIfER IC P. C. KthCALL. Mt-E AOVAfCfO THECPY CF STATISTICS* 


tPCHE 3*0 






*.l, ♦-AfNEfi PLELlSt-INC CCfPAftV. l«««, CHAPTER 3. 


PCPE 150 

MCHE 360 

. .HC**E 370 






NOME 3*0 






SLERCllIAE PCPEh (F .CIC .KCF ,A^< 1 


HGME 390 






CIPEfSlCN Fll),LeC(II.AhS(lt 


MOVE 400 
«Cf€ *10 






CC ICC I-J.4 


PCHE *20 




ICC 


ANS(II-C.C 


PCE 430 






CALCILAIE UE MPBtR CF LLAiS INTERVALS 


MCPE 450 
MCME 460 






l>-(LeCI3)-tEC(lll/LeC(2)«0.* 


PCPE 4 70 
HCM£ 480 






CALCLLAU ICTAl FMECLENCV 


nCHE 410 
HOME SOO 






l-C.C 


WCME 510 






[C tic 1-1*A 


PCteE 520 


c 


lie 


l-IW(ll 


nCME 530 

MCHE 540 


t 


11! 
12C 

I3C 


ifim:p-:i 13C. uc» us 

fcCF-S 

JLPF"! 
CC TC l!C 
JLPF-2 


#»CME 550 
HOME 560 
«C«E 5T0 
r^CHE 580 
HCHE 540 
HCME 600 


c 




FIRST fLPtM 


MOME 610 
NOME 620 




15C 


CC UC I«l,fc 


MOPE 630 
HCHE 640 


t 


KC 


AfS(ii>Ahsii)-*Fiii*ueciii*iFi~c.si*uect2»i 

AfS(ll-A*SIl)/T 


new 650 
HOPE 660 
HCHE 670 


c 




^C TC i;«C.iCC.iSC,2(C,2C01, hCf 


MCME 690 
HOHE 610 


c 




SECCfC PCPEM 


HCHE 700 
HCHE 710 




iCC 


CC ilC I«1,K 
F !■ 1 


HCHE 720 
HCHE 7*0 


Q 


21C 


AI>Si2l«AI>5l2l«f {n*(LeO(il*(F I-C .5 l«LeC (2 l-AhS t 1 1 1 •*2 

«fSt2»-»hS(2l/l 

CC IC (i^CJiCK JLPF 


HCHE 740 
HCHE 750 
HCME 760 

HCHf 770 


c 




It-IPt ^C»'E^T 


HC«te 780 
HC^E 710 




JiC 


CC 2tC 1-1. f 
Fl'l 


HCHE dOO 
fCE aiQ 




<ec 


ifSi2l-»fcSl2Mf (n»(CeG(ll*(f I-C.5l«LeC(2l-AKSillM*3 

AhSt3l*<h:i3l/I 

EC IC (iCC.'IC). JUPF 


HCHE 820 
HCHE 930 
HCHE 340 
HCHE 850 


c 

c 




fCLRU PC^t^T 


HCHE 860 
HCffE 870 




3CC 


CC 3IC I-i,h 


HCHE 980 






Fi-i 


HCH£ 810 




31C 


/^SMI*AASl4l«F(II•<LeCUI«<f l--C.5MLflC(2l-A\Sllll«*A 


HCHE 100 






«».SMI«AfS(4)/T 


PCHC 110 




35C 


fElLHfc 


HCH£ 120 






Eft 


HC'-E 930 



Statistics — Elementary Statistics and Miscellany 85 



Subroutine TTEST 

This subroutine computes certain t-statistics on the 

means of populations under various hypotheses. 

The sample means of Aj, Ag A^^, and Bi, 

^2 BivfB are normally found by the following 

formulas: 



NA 

I 

1=1 






NB 



E". 



NA 



B = 



i=l 



NB 



(1) 



and the corresponding sample variances by: 

NA NB 



Z] (A. - A)2 



SA 



i=l 



NA - 1 



SB 



J2 (Bj 

i=l 



B)^ 



NB 



-(2) 



The quantities m and a^ stand respectively for pop- 
ulation mean and variance in the following hypotheses . 

Hypothesis: /i^ = A; A = a given value (Option 1) 

Let B = estimate of /Ug and set NA = 1. (A is stored 
in location A ). 

The subroutine computes: 
B - A 



ANS 

SB 

NDF = NB - 1 



yj NB (t-statistics) (3) 

(degrees of freedom) (4) 



Hypothesis: i"^ = Mg f CT^ = a^j (Option 2) 



The subroutine computes: 
B - A 1 



ANS=- 



/T 3 

VNA "*■ NI 



(t-statistics) 



NB 



NDF = NA + NB - 2 



(5) 



(6) 



(degrees of freedom) 



where S = 



/ (NA - 1) SA^ 

V NA + 



+ (NB - 1) SB^ 



NB 



(7) 



Hypothesis: M^ = Mg ( cr^ t^ a^ j(Option 3) 



The subroutine computes: 
B -a" 



ANS 



/ SA^ ^ SB^ 

V NA "*" NB 



(t-statistics) 



(8) 



NDF 



SA^ SB^ 
NA "^NB 




SB 



(9) 

-2 



(NA + l)+(^^^j/(NB + l) 
(degrees of freedom) 

Note: The program returns a rounded NDF, not a 
truncated NDF. 



is: 11 j^ - fig (no assumption on ct j(Option 4) 



Hypothesis 
The subroutine computes 
D 



ANS =- 



SD 

NDF = NB - 1 

where D = B - a" 



yfm 



(t-statistics) 

(degrees of 
freedom) 



SD = 



i=l 



(B. - A. - D)^ 
1 1 



NB - 1 



(10) 
(11) 

(12) 



(13) 



NA= NB 



SUBROUTINE nesr 



IND CErtTAlN T-irAnsriCS ON THE MEANS Of POPULAriONS, 



70 



CALL rTESI I A 



iNA,e,MatNOP>NbF.ANSl 



fiUP 



OtSCRiPJlOM Of PARAMETERS 

A - INPUr VECfQR OF LENGTH NA CONTAINING DATA. 

NA - NUHBER of OBSERVAnONS IK A. 
6 - IttCUJ VcCrOK OF LENliTM NB CONTAINING DATA. 
Ne - NUMBER OF Qi>StRVAT I JNS IN B. 

■ OPTIUNS FOR VARIOUS HypOTHtSES.. 

NaP=l THAT POPULATION MEAN Of 8 - GIVEN VALUE A. 

1 iET NA=i> 
Njp=^___ THAT POPULATION H£AN OF B - POPULATION MEAN 
OF A, GIVEN THAT THE VARIANCE Of 8 = THE 
VARIANCE OF A. 
NOP=j--_ THAT POPULATION MEAN Of 8 « POPULATION MEAN 
OF A, GIVEN THAT THE VARIANCE OF B IS NOT 
fcQOAJl TO THE VARIANCE OF A. 
NOP=<t--- THAT POPULATION MEAN Of B » POPULATION MEAN 



TIES 
.TTES 

rres 
Ties 

TTES 
ITES 
TTES 
TTES 
TTES 90 
TTES 100 
TTES 110 
TIES 120 
TTES 130 
TTES 140 
ITES ISO 
TTES 160 
TTES 170 
TTES 180 
TTES 190 
TTES 200 
TTES 210 
TTES 220 
TIES 230 
TTES 240 
TTES 250 
TTES 260 



A, GIVEN NO INFORMATION ABOUT VARIANCES OFTTES 2TC 



A aMU B. ( SET NA=Nfl» 
NLJF - OUTPUT VARIABLE CONTAINING DEGREES Of FREEJOM ASSOCI 

ATEO hlTH r-STATISTlC CALCULATEO. 
4NS - T-STATISTIC FOR GIVEN HYPOTHESIS. 



liA ANJ NU MUSI fit 
JPTION i. NA ANJ 

IF ■^a.' IS oiHfcR r. 

f-STATISnC wlLL I 

icT TO ZERO. 



Sfiifc CJll-GL PRCSi, 



GREATER THAN 1, ExCEPT THAT NA-1 IN 
a MUST ot The SAME IN OPTION t,. 
AN 1< 2. 3 OR 4, DEGREES OF FKtEOOM AND 
JT Be CALCULATED. NDF AND ANS w I LL 6E 



JUdPKjGKAMS KeyujRtj 



1^5-., CHA^'fER 5. 






I(£Sr (A.NA 

'< n,n(i) 



..'JJP.NJF.Ai^lS) 



In] tul UAi Ion 



TTES 280 
TTES 290 
TTES 300 
TTES 310 
TTES 320 
TTES 330 
TIES 340 
TTfcS 350 
TTES 360 
TTES 3 70 
ITES 36C 
TtES 39C 
ITES *00 
TTES 4i0 
Tres 42C 
TTES <,30 

ITES k-yC 
TIES 460 
.TTES -,70 
TIES ^80 
TTES 490 
TTES SOO 
TIES 510 
TTES 520 
TTES 530 
TTES 340 
TTtS 550 
TIES SoO 
TIES 510 
TTES >83 
TftS S90 
TTfcS oOO 



86 



Statistics— Elementary Statistics and Miscellany 



tALI,UL4Tc IMi: WtrtN Of 6 

lis BMtA^=O.C 

00 120 1*1«MJ 

PNb=NO 
(jhtAN^dMLAN/fNb 

IfChOP-'.) 12*, lUCt 20C 
l<;i IflHtJP-ll iCuf ljb» 125 

LALtULATt THE VAKlANCE Cf A 



13C 



OU no 1=1, NA 

iAi=^SA2*l A( I l-AMcAN 1*«2 

i.Ai = SA^/( FNA-1 -01 

LALLULATt THt WAKlANCfc Qf B 

135 SB2=0.0 

DO I'^O l=i.NB 
l^C SB;? = SB2»(tH I l-tJMcA^iI*•2 

Sb2=Sb2/IFNiJ-l.OI 

GO TJ ( 150, IfeC. WOI . NOP 

OPTICN i 

i5C ANS=((dM£AN-AMeAN)/SOKT(SB^II»SOKT(FNBI 
NDF=NB-l 
GU 10 2C0 

OPTION 2 

16C NDF=NA*N8-^ 
fNOF=NDf 

S=iQHTIC(FNA-1.01*iA2*(FNB-l.OI«SB2J/FMDf) 
ANS=UbKtAN-AHtAi*l/St*U.C/SURTU.C/FNA*l.D/fNBn 
GO TO 200 

OPTION 3 

17C ANS-(3MEAN-AMcANl/S«RT(iA2/FNA*S82/FNei 
Al={SA2/f^NA*SB2/FN6»»*2 
A2=(iA^/FNAl**2/<rNA*l.C 1 *( ^B^/FNb I '-S / ( FNB* I . J 

N0F=Ai/Ai-2.C*0.-J 
GO TO 2C0 

DPT I ON <h 

180 SO=0.0 

D=BM£AN-ttM£AN 

00 190 1=1. N6 
190 S0=SU*t6( I I-A( i)-OI ''^ 

SD=iURT(SO/(FNB-1.0)) 

ANS = (0/S01*SQt<TlFNt>) 

N[>F = NB-1 

^OC ktTURN 
tNO 



TIES 610 
TIES o2U 
TTtS *iO 
IFES 6*0 
TFtS 050 
TTES (>60 
TTCS 670 
TFCS 6ao 
TTES 69C 
TTES 70G 
irfeS 710 
IIES 720 
TTfcS 730 

nes 7-^0 
rrts 75C 

Fits 7&0 
Ties 770 
TTES 7«C 
TIES 790 
TT€S 8C0 
TTES SIC 
TTES 820 
TIES 630 
TTES 840 
TTES 850 
TT£5 a60 
TTES 870 
TIES sao 
TTES 890 
TTES 900 
TTES 910 
TTES 9 20 
TIES 930 
TTfcS 9*0 
TTES 950 
TTES 960 
TTES 970 
TTES 980 
TTES 990 
TIESIOOO 
TTESlOlO 
TTESI02C 
TTtSlO JO 
TTES10*0 
riESKSC 
TTtSlObO 
TTESlOTC 

TTESicac 

TTES1090 
TTtSllCO 
TTESlllC 
riES1120 
TTESUaO 
TTESU'.O 
TT6S1I5C 
TrESll60 
TTES1170 
TTES1180 
TTtSll90 
TTES1200 
TTES121C 
TTESi220 
TT£S1^30 
TTES1240 
TrESi250 



Subroutine BISER 

This subroutine computes a biserial coefficient of 
correlation between two continuous variables when 
one has been artificially dichotomized. The com- 
putational steps are as follows: 

1, Compute the mean of the continuously mea- 
sured variable. A; 



A = 



N 

E 

i=l 



N 



(1) 



wbere N = number of observations in the sample. 
2. Compute the standard deviation of the con- 
tinuously measured variable. A: 



s = 




(2) 



3. Obtain the following information for the di- 
chotomous variable, B: 

p = proportion of the cases in the higher group 
q = proportion of the cases in the lower group 
y = ordinate of the normal distribution curve 
at the point of division between p and q proportions 

4. Obtain Ap = mean of A values whose corre- 
sponding B values are in the hi^er group. 

5. Then, compute the biserial coefficient of cor- 
relation, r^, by the use of the following formula: 



'^b^ 



A - A 
P 



P 

y 



(3) 



6. The standard error of r, is estimated by the 
formula: 



pq 

y 



(4) 



y/lf 



For reference see: 

(1) J. P. Guilford, Fundamental Statistics in 
Psychology and Education. McGraw-Hill, New 
York, 1956, chapter 13. 

(2) J. W. Dunlop, "Note on Computation of Bi- 
serial Correlations in Item Evaluation", Psycho- 
metrika, 1936, I, pp. 51-60. 



Statistics — Elementary Statistics and Miscellany 87 









6ISE JO 


SJPnC.U 


UNt flISE 


** 


BISE 40 
RISE SO 


PURPf.S 






fllSf 60 


Tl. 


ffPuTI IhE aiSEPML CaRCfL^TrOM CJEFfiriFNI atlWEEN rWO Pise TO 


CCNriNUnuS VURUPLtS WMtN ONG Pf THE.'^ HAS RtfN A«riFICIALLY 6ISE «0 


UK, 


HLTf.'IIZtC 


' 


BISE 90 
BISF 100 


USAGE 






BISE 110 


f ti 


F !Sf ^ f 


Nt AtP.Hi ,a.\S.lF«l 


BISE l?0 
BISE 130 


OtSCklfTIlN -^1 


PARAf-tltfiS 


BISE 140 


N 


- f;<jfnLP 


CF IJESERVATIONS 


PISE 150 


t 


- INPUT 


VECTOR OF LENGTH N rONIAINING THE CGNTINUOUS 


BISE 160 




Vfl^IftflLE 


erse ito 


ti 


- l\PUl 


WECTOP CIF LfcNGTH N CONTAINING THE 1 CnrlT OMI Z£0 


Bise 180 




VA"! AflLE 


BISE 190 


HI 


- INPU' 


- NUMF'^IEAL CDCE 13 IM0IC4TE IhE HICmEC C ATEGORYBl SE 200 




Df THE 


DICHOtOMIZfcO VARlflBLc. ANV VALUE IN VECTOR Q 


BISE 210 




EOuat 


10 Oft GREATER THAN HI WILL BE CLASilFlEO INTO 


BISE ?Z0 




TH-f HIGHER CATEGCRY. 


BISE ?30 


iNS 


- 0(IT"L/T 


VECroo OF LENGTH fl CONTAINING THF FOLLOWING 


BISE 240 




ANSI 1) 


- MfAN OF VARIABLE A 


BISE 250 




A•i^^^) 


- STANDARD DEVIATION OF VARIA6LF A 


BISE 260 




ANS< 31 


- P^nPOHTION OF THT CASES IN THF HIGHER 


BISE 270 






CATEGORY OF VA*1£8LE 8 


8ISE 280 




AH SCI 


- P«CPafiTiriN OF THE CASES IN THE LOWER 


BISE 290 






CATEGORY OF VABIAPLE B 


eiSE 300 




ANSI SI 


- MEAN OF VARIABLE A EQH THOSE CAStS FALLING 


BISE 310 






INTO THE HIGHER CATEGORY OF VARIABLE B 


BISE 320 




ANSlt,) 


- MEAN OF VAOlftdLE A fC THOSE CASES FALLING 


BTSE 330 






INTO THE LOWCfi CATcGORV OF VARIABLE B 


BISE 340 




ANSI 71 


- BISERIAL CORRELATION COtFFlCIENT 


BISE 350 




A»jS(a) 


- STANDARD ERROR OF 9ISERIAL CORRELATION 


eiSE 360 






fOEFf ICIENT 


BISE 370 


lEfi 


- 1. If 


NO CASfiS ARE IN THE LOWER CATEGCRY OF VARIABLE 


BISE 380 




8. 




eise 390 




-I, IF 


ALL CASES ARE IN THE LOWER CATEGORY DF 


eiSE 400 




VARIABIE 8. 


BI5F 410 




0, OTHEPWISE. 


BISE 420 




IF lER 


IS NON-Z£t*Oi AN5( i ) -Iu»»75, 1-^,.,. ,6. 


eiSE 430 
BISE 440 


REwaPKS 






BISE 450 


TNR 


VALUES n 


THE 0KHOIOHIZE& VARIABLE, B, MUST SE IN 


BISE 460 


NUMt 


aiC FOfiM 


THEY CANNOR 6t SPtCIHED BY MEANS DF 


BISE 470 


ALP*' 


ABEIfC OP 


SPECIAL CHARACIERS. 


BISE 480 
BISE 4S-0 


suecour 


INE'^ AND 


FU^Crl'JN SUBPftOGPfiM^ "FOUIRED 


BISE 500 


fJOTftl 




BISE 510 








eiSE 520 


METHOD 






BISE 530 


REFER TO P. HORSr, 'P SYCHGLOG ICAL MEASUREMENT ANO 


BISE 540 


pReoicnoN'. 


P.','>~9b (WADSWO'TH. 1966). 


BISE 550 








8ISE 560 
BISE 570 



SUBROUTINE BISFR ( N , A , B .H I , aNS . I ER t 

DIMENSION AC 11 .B( 1 l,ANS( H 

COMPUTE WEAN AND STANDARO DEVIATION OF VARIABLE A 

IFR=0 

SUM=0.0 

SUM2-0.0 

on 10 i=i,N 

SUM=SUM*A(I ) 
10 SUM2=SUM2*A( I I^AI 1 ) 
FN=N 

ANS( H=SU*1/FN 

ANSI 2) =( SU12-ANSI lI»SUMI/( FN- 1,0) 
tNSI ;?)= S3PT(ANS(2I 1 

FIND PROPORTIONS OF CASES IN THf HIGHER AND LCVIfcR CAfEGORIE 

P = 0.0 

SUM=0.0 

SU*12=0.0 

or 30 r=i,N 

IFIFKII-HIt 20, 25, 25 
20 SUM2=SUM2*A( I I 

GO ID ^0 
25 P = P«-I.O 

SUM=SUMtAI I I 
30 confini;e 

ANS!4)=I.O 

ANSI 31=0.0 

Q=FN-P 

IF (PI 35,35,40 
35 lfR=-l 

GO TO 50 
40 ANS(5J=SUM/P 

IF (Q) 45,45,60 
45 IER=1 

ANS(4)=0.0 

ANSI 3) = I .0 
50 DO 55 1=5,8 
55 ANSnJ^l.ETS 

GO TO 65 
60 ANS(6l=SUM2/0 

P^P/FN 

Q=1.C>-P 

FIND OflOINATF OF THE NORMAL OISIRIbUTION CURVE AT THE POINT 
DIVISICM BcTWtEN SEGME.MS CGNTAINING P AND PHlIPORTIONS 

CALL NOTF I (0,X,Y,tR ) 

CPM'UTc THE atSERIAL COEFFICIENT OF COKRELATIGN 

«^((ANS151-AN-( L n/ AN SI 21 )"(Pfr) 

COMPUTE THf TFANDARO Ei'ROfi OF H 

ANSIS 1^1 Sr.''Tti'^ril/v-R^.ftj/sofir(FNJ 

STORE oesUlTS 

ANSI 31 =P 
ANS14)-2 
ANSI TI=fi 



BTSE 580 
BISE 590 
BISE 600 
BISE 610 
BISE 620 
BISE 630 
BISE 640 
BISE 650 
BISE 660 
BISE 670 
BISE 680 
6ISE 6<!0 
PISE 700 
BISE 710 
BISE 720 
BISE 7 30 
BISE 740 
BISE 750 
S BISE 760 
6ISE 770 
eiSF 7B0 
BISE 7'90 
BISE 600 

eise 810 

BISE 820 
SISE 830 
BISE 840 
BISE 850 
BISE 860 
BISE 870 
BISE 880 
BISe 690 
BISE 900 
BISE 910 
BISE 920 
BISE 930 
6ISE 940 
BISE 950 
BISE 960 
BISE 970 
BISE 9B0 
SrSE 990 
BISEIOOO 

Biseioio 

BISE1020 
BISE1030 
6ISE1040 
flISEl050 
DF BISE1060 
BISE1070 
BISElOflO 
aiSEI090 
BISEUOO 
BISEl 1 10 
BISEU20 
BISEl 130 
8rSEl|40 
BISEl 150 
BISEl 160 
BISEt ITO 
BISEUaO 
BISFU*JO 
BISE 1200 
BISEI210 
BI5E1220 
BISE1230 
BISE124a 
BISE I 2 50 
B1SEI260 



Subroutine PHI 

This subroutine computes a phi coefficient between 
two variables which are dichotomous. The compu- 
tational steps are as follows: 

1. Two dichotomous variables are summarized 
in a 2 X 2 table as shown below: 

Variable 1 



High Low 



Variable 2 



High 



Low 



A 


B 


C 


D 



A, B, C, and D stand for frequencies. 

2. Compute the phi coefficient by the formula: 



AD - BC 



VI 



A+B) (C+D) (A+C) (B+D) 



(1) 



3. Compute X as a fxmction of phi coefficient as 
follows: 



X^ =N</.^ 



(2) 



where N = number of observations. 

X 2, with one degree of freedom, may be tested 
at a required level of significance. If it is signifi- 
cant, the obtained phi coefficient is also significant. 

4. Compute the maximal phi coefficient that can 
be attainable in a given problem by the formula: 



max 




(3) 



where pj is the largest marginal proportion in a 
2x2 contingency table, and pj is the corresponding 
marginal proportion in the other variable. 
For reference see: 

(1) J. P. Guilford, Fundamental Statistics in 
Psychology and Education. McGraw-HUI, New 
York, 1956, chapter 13. 

(2) G. U. Yule, "On the Methods of Measuring 
the Association Between Two Attributes", Joxirnal 
of Royal Statistical Association, 1912, 75, pp. 
576-642. 



88 Statistics— Elementary Statistics and Miscellany 



SUS'inul INt 



C(i«PJTf THE Pt'l CUfFFlCieNt BFTwEFM T WCI VARIABLES WH T CH 

DICrinirMOOS. . 



.PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 



DESCRIPTION CF PARAMEFEPC 

N - MUHIf OF 0PSECV*T1UNS 

U - INPUT VECTOR OF LENGTH N CONTAINING THE FIRST OTCHOTO- 

HGUS VARIABLE 
V ' INPUT VECTOR OF LFNGTM hi CCNTAINING THE SECOND DICHOTO-PI 

MQU^ VAC I ABLE 
HU - INPUT NUM£filCflL CODE WHICH INOICATES THE HIGHER 

CATEGOPY OF iHt fIRST VflRIABLt. ANY CESERVATION IN 

wecrnp u which has a vauj.- foual to on gbeateo 

hILL BE CLASSIFIfD IN THE HIGHER CATEGORY. 
HV - INPUT HUMERKAL CODE FD« VECTOR V. SIMILAR TO HU 
P - PHI COEFflCIENT COMPUTED 
CH - CHl-SCUARE COHPUTfO AS A FUNCTION OF PHI COEFFICIENT 

(DEGREES OF FHEEOOM FOR CHI-SQUAfiE = IJ 
KP - COMPUTED VALUE Of THE MAXIMiL PHI COEFFICIENT THAT 

CAN 8c ATTAIhED IN THE P^OfiLEH 
IE - IF IF IS NON-£E^O* SOME CELL IN THE 2 BY 2 TABIE IS 

NULL. IF SO, P, CH, ANO XP ARE SET TO 10"*75. 



PHI 

PHI 

PHI 
PHI 

PHI 
PHI 

HAN HU PHI 
PHI 
PHI 
PHI 

PHI 

PHI 
PHI 

PHI 

PHI 

PHI 
PHI 
PHI 
PHI 



REMARKS 

VARIABLES U AND V MUST SE SPECIFIED NUMERIC. 

THE PHI COEFFICIENT IS A SPECIAL CASE OF THE 

PEARSON po.OOUCT-'^OMENT CORRELATION MHEN BOTH VAPIABLES ARE 

BINARY. 

SUeftPUriNES and fUNCTinN SUePRCGRftMS REOUIRED 

NONE 

METMCO 

REFER TO P. HORST, • PYSCHOLCG IC AL MEASUREMENT AND 
PREDICTION', P. 94 (HAOSWORTH, 1966). 



5UBRCUTINE PHI (N,U, V.HU.HV.P.CH.KP, IE) 

DIMENSION U( l),Vm 

CONSTRUCT A 2X2 CONTINGENCY TABLE 

IE = 
A=0.0 



P=0.0 




C = 0.0 




0=0.0 




DO 40 1=1,N 




IF(U( I l-HU) 10,25. 


,25 


10 IF(V(n-HV) 15,20, 


,20 


15 0=0+1.0 




GO TO 40 




20 e=6+i.o 




GO TO 40 




2 5 If(V(lI-HV( 30,. 3 5, 


,35 


30 C*C»1.0 




GO TO 40 




35 A=A»l.O 




40 CONTINUE 




IFUt 100,100,41 




41 IFIBl 100.100.42 




42 IFICI 100,100,43 




43 IF(D) 100,100,44 





COMPUTE THE PHI COEFFICIENT 

44 P=U*D-e«CI/ SQRT((A + B)«(r:«-0)»(A*CI*t6*0)l 

COMPUTE CHI-SOURE 

T=N 
CH=T«P*P 

COMPUTE THE MAXIMAL PHI COEFFICIENT 



■lA+O/T 
:(BtDI/T 
I A*6I /T 

:(C*OI/T 

P1-P2) 75, 45, 45 

P3-P4) 65, 50, 50 

PI-P3) 60, 55, 55 

SaBTI (P3/P4)» IP2/PI I I 

TO <35 

SORT! (P1/P21" IP4/P3t ) 

TO 95 

P1-P4J 70. 55, 55 

SQRTI lP2/Pn*IP3/P4H 

TO 95 

P3-P4) 90, flO. flO 

P2-P3I 60. 85, 85 

SQRTI (P<./P31*(Pl/P21 1 

ro 95 



IF( 
45 IF( 
50 IF! 



75 IF( 
80 IF! 



9C IF|P?-P4 

qS RETURN 
100 If=l 

P=1.E70 
CH=l.E75 
XP=1.ET5 
CO TO 95 
END 



70, B5, 



PHI 

PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
.PH! 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 

PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 



PHI 
PHI 
PHI 

PHI 

PHI 
PHI 



PHI 
PHI 
PHI 
PHI 
PH! 
PHI 
PHI 
PHI 

PHI 

PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 
PHI 



100 

ito 

120 
130 
140 

150 
160 
170 
180 
190 
200 
210 
220 
230 
240 
250 
260 
270 
290 
290 
300 
310 
320 
330 
340 
350 
360 
370 
380 
390 
400 
410 
420 
4 30 



470 
4^0 
490 
500 
510 
520 
530 
5 40 
550 
560 
5T0 
580 
590 
600 
610 
620 
630 
640 
650 
660 
670 
660 
690 
TOO 
710 
720 
730 
740 
750 
760 
770 
780 
790 
800 
610 
820 
S30 
840 
850 
660 
870 
860 
890 
900 
910 
920 
930 
940 
950 
960 
970 
980 
990 
1000 
1010 
10 20 
1030 
1040 
lOSO 
1060 
1070 
lORO 
1090 
1 100 
1 110 
1120 
lUQ 



Subroxitine POINT 

This subroutine computes a point-biserial correla- 
tion coefficient beUveen two variables, ^one binary 
(dichotomized) and one continuous. The computa- 
tional steps are as follows: 

1. Compute the mean of the continuously mea- 
sured variable, A: 



A = 



N 

E 

i=l 



A. 
1 



N 



(1) 



where N = number of observations in the sample. 
2. Compute the standard deviation of the con- 
tinuously measured variable. A: 



s = 




A 




N 



(2) 



N- 1 



3. Obtain the following information for the di- 
chotomous variable, B: 

Np = number of cases in the higher group 
Nq = niunber of eases in the lower group 

4. Obtain A- =mean of A values whose corre- 
sponding B values are in the higher group. 

5. Then, compute the point-biserial correla- 



tion, 



■■pb^ 



"pb = 



N 



N 



(3) 



6. Compute the t ratio used to test the hypoth- 
esis of zero correlation: 



t =r 



N- 2 



pb 



(4) 



1-r 



pb 



7, The degrees of freedom for the t ratio are 
obtained by: 



d.f. =N-2 



(5) 



For reference see: 

(1) J. P. Gmlford, Fimdamental Statistics in 
Psychology and Education. McGraw-Hill, New 
York, 1956, chapter 13. 



Statistics— Elementary Statistics and Miscellany 89 



(2) N, C. Perry and W, B. Michael, "The Re- 
liability of a Point-Biserial Coefficient of Correla- 
tion". Psychometrika. 1954, 16, pp. 313-325. 



SUBRCUriNE POINT 



POIN 
POIN 

SUPPOSE j°;j 

rn ccMPUie the pqint-piserial correlauon coefficieni poin 

SEIWEEN rt»0 VARIABLES, WHEN 0N£ OF THE VAfilAflCES IS A BINARrPQIN 
VARIABLE AMD ONE IS CONTINUIIUS. THIS IS A SPECIAL CASE OF POIN 
TMe PFARSnN PROOUCT-MOMENT COaPELAIION COEFFrCIENT. 



CALL POINT {N,A,8,HI .ANS.IERJ 



HI 



ANS 



POIN 100 

POIN no 

POIN 1?0 
POtN 130 
POLN 1*0 
POIN 150 
POIN 160 
POIN 170 
POIN ISO 
POIN 190 
POIN 200 
POIN 210 



DESCRIPTION OF PARAHETERS 

N - NUMBER CF OeSEHVAriQNS 

A - INPUT VECnP OF LENGTH N CC>iTAINING THE CONTINUauS 

VARIABLE 
9 ' INPUT veCTOP OF LENGTH N CONTAINING THE DICHOTOMOUS 
(BINARV) VARIABLE 

INPUT NUMERICAL CODE TP INDICATE THE HIGHER CATECHRV 
ANY VALUE Of TH*! fllMARY VARIABLE NOT L6?.< THAN HI HILLPOIN 220 
BE CLASSIFIED IN THE HIGHER Of THE Iwn CAT6G3niES. POIN ^^0 

OUTPUT VECTOR OF LENGTH 9 CONIAININC THE FOLLOWING 
RESULTS 

ANSIll- HEAN OF VARIABLE A 

ANS(?J- STANDARD DEVIATION OF VAflASLE A 

ANSI 3)- NU*!BER OF OBSERVATIONS IN THE HIGHER 

CATEGORV OF VAfilASLE 8 
ANSCJ- NUMBER OF CBSERVAIIONS IN THE LOWER 

CATECORV OF VARIABLE B 
ANS(5I- MEAN OF VARIABLE A FOR ONLY THOSE 

OBSERVATIONS IN THE HIGHER CATEGORY OF 
VARMBLt B 
ANS(6l- HEAN OF VARIABLE A FUR ONLY THOSE 

OBSe-JVATIONS IN THE LOWER CATEGORY OF 
VALUABLE B 
4f:S[7)- POINT-BISEFIAL CORftfLATION COEFFICIENT 
ANSIfll- T-TEST FOR THE SIGNIFICANCE OF THE 

DIFFEOtNCe BETWEEN THE MEANS OF VARIABLE 
FOR THE HIGHER AND LOWER CATEGORIES 
RESPECTIVELY. 
ANS(9I- DEGREES OF FREEDOM F0« THE r-TEST 
1. IF ALL ELEMENTS OF B ARE NOT LESS THAN HI. 
-1, IF ALL ELEMENTS OF a ARE LESS THAN HI. 
0. CTHERWISe. IF lER IS NON-ZERO, ANSITf, 1 = 5,. ..,9 
IS SET TO 10**75. 



lER- 



REMSCKS 



POIN 240 
POIN 250 
POIN 260 
POIN 270 
POIN 2B0 
POIN 290 
POIN 300 
POIN 310 
POIN 320 
POIN 330 
POIN 340 
POIN 350 
POIN 360 
POIN 370 
POIN 380 
POIN 390 
. POIN 400 
POIN 410 
POIN 420 
POIN 430 
POIN 440 
POIN 450 
POIN 460 
POIN 470 
POIN 480 
POIN 490 



THE SVM90LS USED TO lOENIFV THE VALUfS OF THF TWO CATEGOR lESPOl N 500 
OF VARIABLE B MUST 3E NUMERIC. ALPHABETIC Ci* SPECIAL POIN 510 

CHARACTERS CANNOT BE USED. 

THE T-TE<iTlANSI8) I IS A TEST 0^ WHETHEP THE POI NI-B I SEP I AL 
COtFflCIENT DIFFERS SIGNIFICANTLY FROM ZERO. 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

NONE 

METHOD 

REFER TO P. HORST, 'PSYCHOLOGICAL MEASUREMENT AND 
PREDICTION', P. 91 (WADSWORTH, 19661. 



SUBROUTINE POINT I N, A«B .HI , ANSt 1 ER ) 
DIMENSION A( 1), BID. ANSI II 

COMPLJTt MEAN ANO STANDARD DEVIATION OF VARIABLE A 

IER=D 
SUM=0.0 
SUH2=0.0 
DO 10 1=1,N 
SUM=5UM«ai I I 
10 SUM2 = SUM2*A( I )*A( I) 
FN=N 

ANSI 1I=5UM/1=N 

ANS(3)=lSUM2-ANSin«SUHI/(FN-1.0) 
ANS(21= SgRT(ANS12ll 

FIND NUMflERS OF CASES IN THE HIGHER ANO LOWER CATEGORI 

P=0.0 

SUM=0.0 

SUM2=0.0 

DO 30 I=I,N 

IF{6(!I-HII 20. 25, 25 
20 SUM2=SUM2*A( 1 ) 

no TO 30 
2 5 P=P*1.0 

SUM=SUM*ai I ) 
30 CONTINUE 

0=FN-P 

ANS(3I=P 

ANS(4I=P 

IF (PI ^S.iS.'.O 
35 IFR=-1 

GO TO 50 
40 4NS(5I=SUM/f 

IF (01 45, 45, ISO 
45 IER=1 
50 on 55 1=5,9 
15 ANSII 1=1. t75 

r.O TO 6=^ 
60 ANSI 61 =S!JM^CO 



COMPUTE 



HE POINT-BISERIAL CQH»:L'^T|^^^ 



R=(( ANSI 51-4%'SI 1 1 l/ANS( 21 )« S0RT{P/(1) 
ANSI T»=R 

COMPUTE T RATIO USED TO TEST THE HYPOTHESIS OF Jt^n COi 



COMPUTF OEGCFES OF FPEEDOM 
ANSI9I=Fn-? 



POIN 520 
POIN 530 
POIN 540 
POIN 550 
POIN 560 
POIN 570 
POIN 580 
POIN 590 
POIN 600 
POIN 610 
POIN 620 

POIN 630 

POIN 640 
POIN 650 
POIN 660 
POIN 670 
POIN 680 
POIN 690 
POIN 700 
POIN 710 
POIN 720 
POIN 730 
POIN 740 
POIN 750 
POIN 760 
POIN 770 
POIN 780 
POIN 790 
POIN 800 
POIN 810 
ES POIN 820 
POIN 830 
POIN 840 
POIN 850 
POIN 860 
POIN 870 
POIN dftO 
POIN B90 
POIN 900 
POIN 910 

POIN 920 

POIN 930 
POIN 940 
POIN -JSO 
POIN 960 
POIN 9 70 
POIN 990 
POIN 990 
POINIOOO 
POINIOIO 
P0IN1020 
P0IN1030 
P0IN1040 

priN;o50 

POIN1060 
POfNiO^O 

poiNtoeo 

POI Nl 090 
POINI 100 
POINlllO 
P0IN1I20 
POINI 130 
"tlATlONPOINl 140 
POINT 150 
P0INli60 
POINIWO 
POINI 180 
POINI 190 
POIN1200 
POIP^1210 
POIN1220 
P0IN1230 
P0IN1240 



Subroutine TETRA 

This subroutine computes a tetrachoric correlation 
coefficient between two veiriables where both of the 
variables have been reduced artifically to two cate- 
gories. The computational steps are as follows: 

1. Two dichotomous variables are summarized 
in a 2 X 2 table such as the one shown below. 

Variable 1 
High Low 



Variable 2 



High 
Low 



A 


B 


C 


D 



A, B, C, and D stand for frequencies. If any fre- 
quency is zero (0), the tetrachoric correlation will 
not be computed. 

2. Obtain the proportions of marginal totals: 
Pl=(A+C)/N (1) 
q^ = (B+D)/N (2) 
P2=(A+B)/N (3) 
q2=(C+D)/N (4) 

where N = number of observations. 

3. Obtain: 

y^ = ordinate of the normal distribution curve 

at the point of division between pj and q^ 

proportions 
y2 = same as y^ using p^ and q^ proportions 
z J = standard normal variable corresponding 

toyj 
Zg = standard normal variable corresponding 

toyg 

4. Then, compute the tetrachoric correlation 
coefficient by the use of the following formula: 



AD- BC 

AT 2 

^1^2^ 



"^t ^ ¥ ^1 S ^t 




^X 



(5) 



6z„ + 3 



')'f 



1_ / 6 
)40 \\ 



5040 
6 



4 2 

15z + 45z 



15 



(4 - ^'4 ^ 45z2 - 15)1.^^ 



90 



Statistics— Elementary Statistics and Miscellany 



Note : rt is found by the subroutine POLRT — 

Newton-Raphson method of approximation 
to the root of the above equation. 

5. For the purpose of testing rt = 0. 0, the stan- 
dard error is estimated by the formula: 



WHICH CUUt-Q ^ePUACE POLRT *AE PROO AND P 
JSE »40ULD "SeOUIoC HODIrlCiTION OT tETdA. 



(6) 



r 

6. In selecting the real root in [-1, 1] , if 
r^ = a + bi, and 

|b| s .5(10"^) I a I 



r^. is considered to be a real root. 



For reference see: 

a) J. P. Guilford, Fundamental Statistics in 
Psych ology and Education. McGraw-Hill, New York, 
1956, chapter 13. 

(2) W. P. Elderton, Frequency Curves and Cor- 
relation. 4th Edition. Cambridge University Press, 
1953, chapter 9. 



T£TR 
.TETR 



SU8P0UTINC TETSft 

PURPOSE 

COMPUTE A lETflACHORlC CORRELATION COEFFICIENT BElWtEK TMO 
VARIABLES WHERE DATA IN BOTH VARIABLES HAVE BEEN REDUCED 
ARTIFlCIALtY TO TWO CATEGORIES- 

USAGE 

CALL TETRA (N,U, V ,HU,HV. R. PS . 1 E I 



TETR 

TETR 

TETR 

TETR 

TETR 

TETR 

TETR 

TETR 

TETR 

TETR 

TETR 

DESCRIPTION Cf PARAMETERS I"" 

N - NUH6ER OF OBSERVATIONS *•="* 

U - INPUT VECTOR OF LENGTH N CONTAINING THE FIRST VARIABLE TETR 

REDUCED TO TWO CATEGORIES .„,.„. dllo 

V - INPUT VECTOR OF LENGTH K CONTAINING THE SECOND VARIABLETETR 

REDUCED TO TWO CATEGORIES TETR 

MU - INPUT NUMERICAL CODE INDICATING THE HIGHER CATEGORY OF TETR 

THE FIR*^T VARIABLE. IF ANY V^LUF OF VAC I ABLE U IS '■=''*' 

EQUAL TC OR GREATER THAN HL, IT WILL BE CLASSIFIED AS 

THE HIGHER CATEGORY. OTHERWISE AS THE LOWER CATEGORY. 

HV - SAME AS HU EXCEPT THAT I^V IS FOR THE SECOND VARIABLE. 

o - TETRACHORIC CORRELATION CPCPuTEO 

STANDAPO ERROB DF TETRACHORIC CORRELATION COMPUTED 
ERROR CODE 

- NO ERROR ,„ ,^,„ 

1 - UNABLE TO COMPUTE A TETRACHORIC CORRELATION DUE TO TETR 
THE FACT THAI iT LEAST ONE CELL SHOWS ?ERO FRE- 
QUENCY IN THE 2X2 CONTINGENCY TABLE CONSTRUCTED 
FROM INPUT DAIA. IH THIS CASE, R AND RS ARE SET 
TO 10**75. (SEE GUILFORD, 1956) 

2 - THE POOT SOLVER GIVES MULTIPLE BOCTS, CR NO fiOCTS, 
R, IN THE INTERVAL (-Itll INCLUSIVE. R AND RS ARE 
SET TO 10**T5. 

a - UNABLE TC CPMt^UTE A SAIISFACTORY VALUE CF TETRA- 
CHORIC CDftRELATIDN USING NE WTON-P PPHSON METHOD OF 
pppBOXIMiTlON TO THE ROOT OF THE EOUATIGN. R AND 
PS ARE SET TO XO»*T^. SEE SUBROUTIhE PDLRI ERROR 
f riOlCATORS. 

*. - HIGH ORDER COFiFFICRNT OF THE POLYNOMIAL IS ZEFO. 
SEf SUPt'OUTINE POLfiT (-PROC INDICATORS. 



RS ■ 



TETR 
TETR 
TETR 
TETR 
TETP 
TETR 
TETR 
TETR 



REMARKS 

VaLULS OF VltMBLES U AND V MUSI BE t«JMERICAL, AND 
ALPHIB'^TK ftNJ SPFCIAL CHASACTEPS MUST NOT 6f. USEO. 
FOR A DEPENDABLE RESULT FOR IcTfiACHORIC CORRELATION, 
ir IS RECOMMENDED THAT N BE AT LEAST 200 OR GRFATER. 



TETR 
TETR 
TETR 
TETR 

TETR 
TETR 
TETR 
TETR 
TETP 
TETR 
TETR 
TETR 
TETP 
TETR 
TETR 
lETR 
TETR 
TETR 
TETR 
TETR 
TETR 



SUBROUTINES ANT FUNCTION SUBPROGRAMS ^EOUlCEO JEJ^ 

PD^HI__THIS POLVNOMML HOOT ^OUTTNF WAS SELECTED BECAUSE OF TETR 
ITS SMJ11.L SrnHiGt REOUIREMENT. OTHER SSP ROUTINES TETR 



100 
110 
120 
130 

1^0 
150 
160 
ITO 

lao 

190 
200 
210 
220 

230 
2A0 

250 
260 

270 
280 
290 
300 
310 
320 
330 
3*0 
350 
360 
370 
180 
390 



4^0 
A50 
AbO 
*T0 
ABO 
490 
500 
510 
520 
5 30 
540 



METHOD 
REFER 
LOGY 
AND I 
ED.. 



THE |P TETO 550 

TETR 560 
TETR 570 
TETR 580 
P. GUILFnuo. 'FUNDAMENTAL STATISTICS IN PSYCHO- TETR 590 
AND PDUCATIJN'. MCGRAW-HILL. MEW YORK, 1956, CHAPTER 13TET9 600 
o. ELDERTON, 'FREQUENCY CURVES AND CORRELATION' <i-TH TETR 6l0 
AMB^IDCE UNIVERSITY PRESS, 1953, CHAPTEF 9. TET» 620 

> TETR 630 
TETR 640 



SUBROUTINE TETRA (N ,U. V.HU.HV.R.RSt I E I 

DIMENSION XCOFiai,COF(a).ROOIR(7),ROOTll7) 

DIMENSION U< ll<V(ll 

03UBLE PRECISION X 31 ,X3? , X312, X322 

CONSTRUCT A 2X2 CONTINGENCY TABLE 

A=0.0 

B=0.0 

C=0.0 

D=0.0 

DO 40 l = lTr! 

IF(U(ll-HUl 10, 25, 25 
IC IF(VII)-HVI 15, 20, 20 
15 0=0*1.0 

CD TO 40 
20 B=B*1.0 

GO TO 40 
25 1F(VCU-HVI 30, 35, 35 
30 C=C*1.0 

CO IG 40 
35 A*A*1.0 
40 CONTINUE 

TEST WHETHER ANY CELL IN THE COMTINGEWCY TABLE IS U^O. 
IF SC. RETURN TO THE CALLING ROUTINE WITH R=0.0 AND IE*1. 



IE=0 

IF(A) 60, *>0, 45 

45 IF<8) 60, 60, 50 

50 IF(C1 60, 60, 55 

55 IF(D» 60, 60, TO 
60 IE=1 

GO TO 66 

COMPUTE PI, 01. P2, 6N0 02 

70 FN=N 

Pl=( A*C>/FN 
01=l6tD)/FN 
P2=( AtBI /FN 
0?=(C+D)/FN 

FIND THE STANOAfiC NORMAL DEVIATES AT 01 AND 02, tUD THE 
OROINATES AT THOSE POINTS 

CALL NDTRI IQl , X I, Y 1 , FR 3 
CALL NDTRI (02,X2,Y2,ER J 

COMPUTE THE TETRACHORIC CORRELATION COEFFICIENT 

IFIXl) 76, 72, 76 
72 IFIX21 76, 74, 76 
74 P=0.O 

GO TO 90 
76 XC0F(l» = -HA*0-a*C»/IYl*Y2*FN»FNn 

XC0F(2M1.0 

XCOf (3t=Xl*X2/2.0 

XC0F(41=(XI*Xt-1.0l«( X2»X2- I. 01/6.0 

K3l'=DeLE(Xll 

X32=DBLeiX21 

K312=X31*«2 

X322=X32**2 

XCDF{5l=SNGL(X31*(X312-3.000)*X32«IX322-3.0DO>/24.0pOI 
XCOFl6l-SNGL{tK312MX3l2-6.0D01*3.0DOIMX322*(X322-6. 0001*3. 0001 

^XCOF(71=SNGL(X3l*IX312*(X3l2-10.QDOI*15.0OOI«X32*«X322*(X322-10.0 

I D0l*15.0D0)/72O.0DOI „„„. ^, , , „,,, 

XCOF161 = 5NGL(inX312-15.aOOI*X312*45.0Dai*X312-l5.0DOI*H(X322- 
1 i5.0DOI«X322*45.000l*X322-l'>.0OOI/5O4O.00Ot 

CALL POLRT ( KCOF ,COF. 7,R0nTR,R00TI , lERl 

J=0 

IFHERI TB, 7B, 64 

IFIABSIROOTHI)»-.5*ABS(RDOTRini*1.0F-6)79,T9,«J2 

79 B=ROnTft(I I 
IF(ABSIR>-1-C1B1,81,80 

80 o=l.E75 
GO TO 82 

81 J=J*l 

82 CONTINUE 
lF(J-l)B3.e8,33 

83 1E=2 

GO TO 66 

UNABLE TO COMPUTE R 

64 1E*IER 
86 P=!-0E75 

RS = R 

GO TC 100 
BE If (R- 1.0 E '5 1 90, 8 3, 83 

STANDARD ERBCR OF R=0.0 

9f> RS= S0RT(PI«P2*Q1*Q?'/<''1"^2* SQRTIFNII 



TETR 650 
TETR 660 
TETR 670 
TETR 680 
TETR 690 
TETR 700 
TtTP 710 
TETR 720 
TETR 730 
TETR T40 
TETR 750 
TETR 760 
TETR 770 
TETR 780 
TETR 790 
TETR 800 
TETR 810 
TETR 820 
TETR 630 
TETR 840 
TETR 850 
TETR 860 
TETR 870 
TETR 860 
TETR 890 
TETR 900 
TETR 910 
TETR 920 
TETR 930 
TETR 940 
TETR 950 
TETR 960 
TETP 970 
TETR 980 
TETR 990 
TETRIOOO 
lETfilOlO 
TETR1020 
TETR1030 
lETBlC^O 
TETR1050 
TETR1060 
TETRIOTO 
TETR1080 
TETR1090 
TETRllOO 
TETRIUO 
TETR1120 
TETP1130 
rETR1140 
TETP1150 
r£TRll60 
TETR1170 
TETRliaO 
TETP 1 190 
TETR1200 
TETR1210 
TETR1220 
TFTR1230 
TETR1240 
TETP1250 
TETR1260 
TETR1270 
TETP1280 
TETR1290 
rETR1300 
TETfll310 
TETP1320 
TETR1330 
TFTR1340 
TETR1350 
TETfil360 
TETRISTO 

TErRi3eo 

TETR1390 

TETR1400 
TETR1410 

TETR1420 
TETR1430 

TETR1440 
TETR1450 

TETR1460 
TETR1470 
TETR1480 
TETP 1490 
TETRI500 
TETRISIO 
TETR1520 
TETR1530 
TETO1540 
TETR1550 
TETR1560 
TETR1570 
TET':i580 
TETHl 590 
TETH1600 
TET«1610 
TETR1620 
fETRI630 
IETP1640 
TETR165Q 
TETR1660 
TeTPl6T0 



Statistics — Elementary Statistics and Miscellany 91 



Subroutine SRATE 

This subroutine computes the survival rates qt 
subjects alive n periods after diagnosis or treat- 
ment. The siurvival rate for each period is com- 
puted successively for each of K periods where K 
is specified and K s n. An example of the input to 
this subroutine is presented in Table 2. 

Table 2. Example of Input to Subroutine SRATE 



2. Proportion dying during period: 



D. 
^i E. 



3. Proportion surviving during period: 



P. = 1 
1 



Q, 



(2) 



(3) 



Periods 

after 
diagnosis 


Alive at 
beginning 
of period 


Died 
during 
period 


Lost 
during 
period 


Withdrawn 

alive during 

period 


(i) 


(Li) 


(Di) 


(Ui) 


(Wj) 


1 


130 


40 


4 


10 


2 


76 


6 


2 


8 


3 


60 


2 


1 


5 


4 


52 


1 





4 


5 


47 








47 



The input information includes: 

« Periods after diagnosis. This column shows 
the time period elapsed from the date of 
diagnosis or treatment. A period may be any 
time interval. 

Alive at beginning of period. The first entry 
in this column indicates the initial number of 
subjects; in Table 2, Lj =130. Each entry 
thereafter is obtained by subtracting from the 
preceding number of subjects the total of those 
who are no longer in the program; in Table 2, 



^1 - (Dj + Ui+W^) = 



130 



- (40 + 4 + 10) = 76. 

Died during period. This column indicates the 
number of subjects that died during the period. 

« Lost during period. This column indicates 
the number of subjects whose survival status 
became unknown during the period. 

« Withdrawn alive during period. This column 
indicates the number of living subjects with- 
drawn from the study during the period. 

For the value of i = 1, 2, . . . , K, the subroutine 
computes the following information: 

1. Effective number exposed to risk of dying 
during period: 



E. = L. - 
1 1 



(U. + 
1 



W.)/2 



(1) 



92 Statistics— Elementary Statistics and Miscellany 



4. i*" period survival rate: 



R. = n P. 



5. Standard error of survival rate: 



(4) 



'.-.yE 



Q. 



D. 



(5) 



j=l 



For reference see: S, J. Cutler and F. Ederer, 
"Maximum Utilization of the Life Table Method in 
Analyzing Survival", Journal of Chronic Diseases . 
December, 1958. pp 699-712. 



SuePOlJTINH SPftTE 

PURPOSE 

13 COMPUff THF PRffQRTIlDN OF SUPJECIS SURVIVING, IME 
SUtWlVAL RATts Af«o XHT. ST4N0Ar,0 Efi«QRS fQH SIKCESSIVELY 
•'tOUCtO TIMf PERIODS. THE SURVIVAL RATE 15 ClWPUtEO FOR 
EACH tlf K PPHIODS, WHEXt K IS A CONSIANT TO flf SPECIFIED 
IS LfSS THAN OR EOUAL 10 N (MHtRt N = TOTAL NUMBER OF 
PERlGil^J . 



SRAIt (N.KtX.IE] 



SRAT 
.SRAF 
SRAT 



SRAI *0 

SRAT SO 

SRAT 60 

SRAT 70 

SRAT 60 

SRAT 90 

NDSRAT 100 

SRAT 110 

SI»AT i?0 

SRAT 130 

S«AT UO 

SRAT 150 

SRAT 160 

SRAT 170 



OESCeiPTIOIV Of PAfiA«eTE«S 

N - IMF Ti-'TAL hlUMBfcR OF PERIODS AFTER TREATMEM OR DIAGNOS 1 SSRAT ISO 

K - THL SPECTFIEO PERIOD UP TO WHICH SURVIVAL RATES ARE TO SRAT 190 

BE CALCULATED SRAT 200 

X - AN INPUT AND OUTPUT HATR I K (N X SJ CONTAIMNG THE SRAT ^10 

FOLLOWING INFORMATION SRAT 220 

FOR INPUT — STORED IN THE N ROk'S OF EACH COLUHN SRAT 230 

COL I - WIHBER rf SUBJECTS ALIVE AT THE PEGINNING OF SRAT 240 

PERIOD SRAT 250 

cm 2 - NUMBEK OF SUBJECTS WHICH 0IE1 DURING THE SRAT 260 

PfcfilOO SRAT 270 

COL 3 - NUMBER OF SUBJECTS LOST TO FTLinw-UP DURING SRAT 280 

THE PERIOD SRAT 290 

COL ■- - NUMPE5 OF SUBJECTS WITHDRAWN AtlVE DURING THESRAT 300 

PEKIOO SRAT JIO 

FOR OUTPUT — STORED IN THE FIRST R HOWS OF EACH SRAT 320 

COLUMN SRAT 3J0 



COL 
Ci]|. 
COL 
C0(. 

COL 
I. IF K 



EFFECTIVE NUMBFO EXPOSED TO THE F I SK OF OriNGSRAT 3*0 



. - PROPORTION WHO DIED DURING IHF PERIOD 
' - PRUPORTION WHO SURVIVED DURING THE PERIOD 
1 - SUflVIAL RATE 

t ~ STANDARD ERROR OF THE SURVIVAL RATE 
IS NOT IN THE CLOSED INTERVAL (O.NI. 



2. IF THE NUMBER OF SUBJECTS ALIVE AT THE BEGINNING 
CF PFRinO I IS LESS THAN THE SUM Of THOSE WHICH OIEO, 
HERE LOST, OR MERE WITHDRAWN DURING PERIOD I (I>1,.., 

3, ir TME (JUMflfS Of SUBJECTS WHKH DIED, HERE LOST, OR 
WERE WITHDRAWN IN PERIOD I IS NOT EQUAL TO THE NUMBER 
ALlVf AT IHE BEGINNING OF PERIOD I LESS THE NUMBER 
ALIVE AT THE flEGINNING OF PERIOD I * I n«l,,..N-lJ 



SRAT 350 
SRAT 360 
SRAT 370 
SRAT 390 
SRAT 390 
SRAT 400 
SRAT 410 
N) SRAT 420 



SRAT 430 
SRAT 440 
SRAT 450 
SRAT 4b0 
SRAT 470 
SRAT 
SRAT 



REMARKS 

IF THE SUBJECTS IN A GIVEN GROUP ARE ALL DIAGNOSED OR 

TREATED AT THE SAME TIME, THE CONSTANT K MAT SE SET EQUAL TOSRAT 500 

SUBJECTS IN A GIVEN GOUP ENTER THE STUOT AT SRAT 510 

CAN BE NO GREATER THAN N-I. SRAT 520 

SUBROUTINFS AMD FUNCIIPN SUBPROGRAMS REQUIRED SRAT 540 

^0N£ SPAT 550 

METHOD j^^j jjg 

REFER TO S. J. CUTLER AND F. EDERER 'HAXIMUM UTILIZATION Of SRAT 580 

'*"= ..CE TABLE METHOD IN ANALVZINC SURVIVAL', JOURNAL OF SRAT 590 

SRAT 600 



VARYING TIMES 



THE LIFE 



CHHO'^IC niSEASFS. DECEMeER, 1958. PP 699-712. 



SUBROUrtN€ SRdTE (r^.K.X.IEt 
DIMENSION XII) 

INin ALIZATION flNO fRRD^J CHECKING 
IE=0 

00 1 IiNP<,,NP9 

XdlsO.O 

IF (K) ?,?,3 

IE=l 

GO TO '*^ 

IFIK-NI <.«<-. 2 

00 9 I=I,N 

NPg^NP'.tN 

NPl=hP9*N 

rftINT(Xn»-X(NP^)-X(NP«l-XlNPll*.Olll 5*6,6 

IE=2 

tr TO ^.S 

IFU-M 7,9,9 

IF {INT(X|1 + 1)-X(I l+XtNPAl + XlNP^I + XlNPl }«'.01)t 6,9, B 

1E = 3 

GO 10 45 
CONTINUE 
Ll-0 
L2=Ll+N 
L3=L?*N 
L4=L3*N 
L5=L**N 
L6=L5+N 
L7=L6*N 
L8=L7*N 
L9=L8*N 
LD=L2 
LE=L5 
LQ = L6 
SUM^O.O 



SRAT 610 

.SRAT 620 

SR*T 630 

SBJT 6A0 

&RAI 690 

SRAT 660 

SRAT 670 

SRAT 6S0 

SRAT 690 

SRAT 700 

SRAT 710 

SRAT 720 

SRAT 730 

SRAT 740 

SRAT 750 

SRAT 760 

SRAT 770 

SRAT 790 

SRAT 790 

SRAT SOO 

SRAT BIO 

SRAT S20 

SRAT 630 

SRAT 640 

SRAT B50 

SRAT 660 

SRAT 670 

SRAT 860 

SRAT 690 

SRAT 900 

SRAT 910 

SRAT 920 

SRAT 930 

SRAT 940 

SRAT 950 

SRAT 960 

SRAT 970 

SRAT 960 

SRAT 990 
SRAT 1000 
SRATIOIO 
SRAT1020 
SRAT1030 



DO 40 1=1, K 

COMPUTE fFFECTIve NUHBER EXPOSED TO RISK OF DYING 

Ll=Ll*l 
L3=L3+1 
L4=L4*1 

K(L5) = K(Ln-(X(L3l*K(L4n/2.0 

COHPUTE PROPORTION OF DYING 

L2=L2*1 
L6=t6+l 

XIL6I=X(L2I/X1L5I 

COMPUTE PROPORTION OF SURVIVING 



CCMPUTE SURVIVAL RATE 

L8=18*1 

IF (I-ll 20» 20, 25 
20 X(LC)'X1L7) 

GO TO 30 
25 XILei*X(Le-I l*X(L7) 

COMPUTE STANDARD ERROR OF SURVIVAL RATE 

30 L9=L9*l 

SUM=SUH*X(L6)/(K(L5)-X{L2IJ 
40 X(L9) = XH.6l*SQRri SUM) 



45 RETURN 

END 



SRATt04O 
SRAT1050 
SRAT 1060 
SRAT1070 
SRATIOSO 
5RAT1090 
SRATllOO 
SRATlllO 
SRAT1120 
SRATi 130 
SRAT 1140 
SRATI 150 
SRATI 160 
5HATU70 
SRATIiaO 
SRATL190 
SRAT1200 
SRAT1210 
SRATI220 
SRAT1230 
5RAT1240 
SRAT 12 50 
SRAT1260 
SRAT1270 
SRAT12a0 
SRAT 1 290 
SRATHOO 
S«AT13tO 
SRAT1320 
SRAT1330 
SRAT1340 
SRATI 350 
SRATI360 
SRAT1370 
5RAT1380 
SRAT1390 
SRAT1400 
SRAT1410 



Statistics — Elementary Statistics and Miscellany 93 



MATHEMATICS 



Matrices: Storage 



Subroutine RCPY 



Subroutine MCPY 



SUBROJTiNt MCPV 



CALL MCPy (A,R,N, 



MS) 



D£iCkIPnCN OF PAkAMEFERS 
A - NAME Of INPUT MAIRJX 
R - NAWe OF OUTPUT MATRIK 
H - NUHQiR OF ROWS IN A OR K 
n - NUMfitS OF COLUMNS IN A Ck (< 

MS - JNt OIGII NUMBER FOR STJ^AGt Hl.Dc OF MaTRU A (AND Hi 
C - GtNERAL 

1 - SVMMcTBIC 

2 - DIAGONAL 

REMARKS 
MONt 

SUBSCUT INLS AND FUNCT [ON SUfaPKCGi*AMS REUUI Rt D 



M£ THQJ 

EACH cLcMCNT OF MATRIX A IS MJVfcU TO THc CORRcSPJNDI KG 
cLEMcNT Of- MATRIX R 



SUosaur INt MCPr ( A.ft ,\, M 
[MHENSICN A( H,R( 1) 

CuM.>LirL Vt-CrOK LENT.! 

CALL LJCIN.M, n .f^.M.MS ) 

CGCV MArn,IX 

o:j 1 1= u IT 
Ril l = A( II 
rttlURN 



MCFV 


IC 


«CPV 


po 


MCPr 


30 


MCPV 


'.U 


MCPV 


50 


HCPY 


6C 


MCPY 


TO 


MCPV 


flC 


MCPT 


9C 


MCPY 


lat; 


MCPV 


1 IC 


MCPY 


^^^) 


MCPY 


liD 


MCPV 


K.T 


MCPV 


IbC 


MCPy 


IhO 


MCPy 


170 


MCPY 


ISO 


MCPY 


I9f 


MCPV 


?G0 


MCPV 


die 


MCPV 


220 


MCPY 


?iC 


MCPV 


Z'*': 


HCPV 


ZbO 


MCPV 


?bO 


MCPV 


Z70 


MCPV 


^bU 


MCPY 


/-iJ 


MCPV 


)CS 


MCFY 


iin 


MCPV 


i23 


MCPV 


ii- 


MCPV 


^^.o 


MCPV 


3t.C 


MCPY 


i60 


MCPV 


17.- 


MCPV 


J3L 


MLPV 


s-*: 


MfPY 


<.:c 


MlPV 


*flC 


MCPY 


'.^C 


MfPY 


'.l,- 


MCPY 


^i-C 



SUSROUriNt RCPY 

PU-iPOSE 

COPY SPEClFltJ ROW OF A MATRIX INTO A VECTOR 

USAuE 

CALL RCPY lA.LiR.NfM.HS) 

OcSCRIPTlUN JF PARAMETERS 
4 - NAME OF INPUT MATRIX 
L - R01 UP A TO Bfc MOVEO TO R 
•<. - NAME JF JUTPUT VECIJi* OF LEN&TH M 
N - rtUNdER OR ROWS IN A 
M - NUMiicR OF COLUMNS IN A 
MS - ONE DIGIT NUMBER FOR STORAGE MODE OF MATRIX A 

- GENERAL 

1 - SYMMETRIC 
2-01 AGONAL 

htMARKS 



MtTHOO 

cLcMfcrtfj Jf ROK L ARc MOVED TO C JRRESPONi) I NC POSITIONS 
Jh WCCIOS R 



SUBAuoriNE kCPV{A,L ,R,N.M,M3I 
iJIMtNSlLN A( n.RIl) 

^6 i J = 1 . M 

L Jl-aT c ELcHl^T for any M«rrtIX STJRaCfc MODE 
lALL LolIL. J,i-J,N,M,MS) 

riiT fok icRJ eLl:^LNT IN OIA>iU^Al MATRIX 
lULJi t , -: , 1 

lOVf tLc'^c'*! TO R 
1 *.( Jl =A{LJ 1 

3 CL-irUL 



RCPY 10 
, .RCPY 20 
RCPY JO 
ftCPY 40 
RCPY 50 
RCPY 60 
RCPV 70 
RCPY 80 
RCPY 90 
RCPY 100 
RCPY 110 
RCPY 120 
RCPY 130 
RCPY 140 
RCPY 150 
RCPY 160 
RCPY 170 
RCPV 130 
RCPY 190 
RCPY 200 
RCPV 210 
RCPV 220 
RCPV 230 
RCPY 240 
RCPV 250 
RCPV ^60 
RCPV 270 
RCPV 280 
RCPY 290 
RCPY 300 
RCPV 3lO 
RCPY 320 
-RCPY i30 
RCPY 340 
RCPY 350 
RCPV 360 
RCPY 370 
RCPY 380 
RCPY 39C 
RCPV AOC 
RCPV 410 
RCPY 42C 
RCPY ^30 
RCPV 440 
RCPV 4St 
RCPY <.&0 
RCPY 47C 
RCPY 480 
RCPY 493 
RCPV 500 
RCPV 510 
RCPY 520 
RCPY 530 
RCPV 54; 
RCPY 550 



94 Mathematics — Matricesi Storage 



Subroutine CCPY 



Subroutine DC PY 



SUBROUTINE CCPV 

PURPOSE 

COPY SPECIFIED COLUMN Gf A MATRIX INTQ A VECTOR 

USAGE 

CALL CCPy(A.L.R.N,H,MSI 

OtSCRlPTION OF PARAMtTEftS 
A - NAME OF INPUT MATRIX 
L - COLUMN OF A TO B£ MOVEO TO ft 

« - NAME OF uurPur vEcrafl of lemgih h 

N - NUMBER OR ROUS IN A 

M - NUMBER Of COLUMNS IN A 

MS - ONE UlGlr NUMSER FOR STORAGE MQOE OF MATRIX A 

3 - GENERAL 

1 - SYMMcTRIC 

2-01 AGONAL 



SUBRUuriNtS ANU FUNCTION SUftPRUOKAMS RtflUIREO 

LOC 

HE I MOO 

ELEMENTS 0*^ COLUMN L ARE MOVED TO CORRESPONOI NO POSITIONS 
OF VECTOR R 



suertouriNfc lcpy ( a,l ,r,n.p4,ms) 
I^tHtNSION A(I) ,R( 1) 

00 3 I = l,N 

LOCATE ELEMfNT FOR ANY MATRIX STORAGE MGDE 
CALL LOCi l,L, IL. N.M.MS) 

TcST FOR lERO ELEMENT IN OIAGJNAL MATRIX 
IFJ IL ) I, 2,1 

MOVE ELEMtNT TO R 

1 Rl I J = fll U) 
GO TO 3 

2 «l 11=0.0 

3 CONTINUE 
RETURN 
CNU 



5C 



ICC 



CCPY 
...CCPY 
CCPY 
CCPY 
CCPY 
CCPY 
CCPV 
CCPY 
CCPV 
CCPV 
CCPY 110 
CCPY 120 
CCPY IJC 
CCPY KO 
CCPY 150 
CCPY 160 
CCPY IJQ 

CCPY lao 

CCPY 190 
CCPY iOC 
CCPY ilO 
CCPY 220 
CCPY ZiO 
CCPV 24C 
CCPY 25C 
CCPY 2fa0 
CCPY 270 
CCPY 280 
CCPY 290 
CCPV SQO 
CCPY ilO 
CCPY i2C 
..CCPV iiO 
CCPY 3*C 
CCPY iiC 
CCPV 360 
CCPY 370 
CCPV 39C 
CCPY 39C 
CCPY <tCC 
CCPV -.iC 
CCPY <.20 
CCPY ■*30 
CCPV '.'.0 
CCPY 450 
CCPY 46C 

CCPY ".70 

CCPV 480 

CCPY 490 

CCPV 5CC 

CCPY 510 

CCPY 520 

CCPV 53C 

CCPY 540 

CCPY 55t 



SUSROUriNE UCPY 

PURPOSE 

COPY DIAGONAL ELEMENTS Of A MATRIX IllTO A VECTOR 

USAGE 

CALL OCPY (AiRtN.nSI 

DESCRIPTION OF PARAMETERS 
A - NAME Of INPUT MATRIX 
R - NAME OF OUTPUT VECTOR OF LENGTH N 
N - NUMSER OF ROWS AND COLUMNS IN HAHtlX A 
MS - ONE DIGIT NUMBER FOR STORAGE HODE OF MATRIX A 

- GENERAL 

1 - SYMMETRIC 
2-01 AGONAL 

REMARKS 

INPUT MATRIX MUST BE A SQUARE MATRIX 

suasouriNES and function suaprograhs required 

LOC 



ELEMENTS ON DIAGONAL DF MATRIX ARE MOVED TO CORRESPONOING 
POSITIONS OF VECTOR R 



SUBROUTINt OCPYI A,R,N,MSJ 
CIMENSICN A( tl.RIl) 

DO 3 J=1,N 

LOCATE DIAGONAL ELE«EM f^R ANY MATRIX STORAGE MODE 
CALL LJCI J.J. IJiN.N.MS ; 

MOVE OIAGUNAL ELEMENT TG VECTOR rt 

3 RI J)=AI IJI 

RETURN 
END 



20 



70 



OCPY 
. ..DCPY 
OCPY 
OCPV 
OCPY 
OCPY 
OCPV 
OCPY 
OCPY 
OCPY 100 
DCPY 110 
DCpv 120 
OCPY 130 

OCPV 140 
OCpY 150 
OCPY 160 
OCPV 170 

OCPV lao 

OCPY 190 

OCPV 200 
OCPY 210 
OCPY 220 
OCPY 230 
OCPY 2*0 
OCPY 250 
OCPY 260 
OCPY 270 
OCPY 280 
OCPY 29C 
OCPY 300 
..OCPY 310 
OCPV 320 
DCPY 330 
OCPV 340 
OCPY 350 
OCPY 360 
OCPY 370 
OCPY 380 
DCPY 390 
DCPY 400 
OCPY 410 
OCPY 420 
OCPV -^30 
OCPY 440 
OCPY 450 
OCPV 460 



Mathematics— Matrices: Storage 95 



Subroutine XCPY 



Subroutine MSTR 



subHuuriNt KC'^r 



USAGE 

CALL )(CPY(A,'*,L,K»NRiMK,NA,MA,lS) 

DtSCRIPTlON Of fARAMfcTERS 

A - NAMt 3F INPUT MAI-«1X 

R - NAMe iJF QUIPJI MATRIX 

L - HCW of A WHERt FUST tLcMrMf OF •< CAN BE FDUND 

< - COLUMN UF A WHEKc flRST CLE^tNT OF « CAN at FOuNO 

NR - NUMoLR OF ROUS TC dfc CUPIEO INTO R 

MR - NJM6tR CJF COLUMNS Td b£ C'JPIfcD IHW K 

NA - NUMatR JF ROWS IN A 

MA - NUMBER Of COLUMNS IN A 

MS - UNt DIGIT NUM6£R FOR SUSAGL hODt OF MATRIX A 

- GfcNtRAL 

1 - SVMMtTRIC 

Z - DIAGONAL 



MArXIX k CANNUT bt IN THE SAMt LOCAflUN AS MATRU A 

MATRIX R IS ALWAYS A otNLRAL ,tA TR [ X 

SUdfiGUIINeS ANiJ FUNCIIUN SUbPROGkaMS RfcOUIREU 

loc 

METHOD 

»A[R|X R IS FGKMfcC 6V LJPYING A PORtlON OP MATRIX A- THIS 

IS DONE BV tXTRAtriNG NR ROWS ANO MR COLUMNS Of MATRIX A, 

jTakting with ellhent at row l, column K 



SUBRJUT IHt XCPrlA,k,L,fv,NR,HR,NA,MA.MSl 

DIMENSION A( L),RI I) 

INIT 1ALIZ£ 

IR = 

L2=L*NK-J. 

K2=K*HR-1 

DO 5 J=K,K2 
DO 5 I=L,L2 
IK- IR+I 
R{ Ift)=C.O 



iKAGt MLiOe 



LOCATt tLtHifNI FOR ANY MATRIX 
CALL LOCI I.J.IAtNAtMA.MS) 

TtST FOR iERiJ ELEMENT IN OIAGUNAL MATRIX 

IFIIAI 'i.b.'. 

4 H(1RI=A(IA) 

5 CONTiNUE 
RETURN 

END 



XCPY 


10 


XCPY 


£0 


XCPY 


>0 


XCPY 


'•C 


XCPY 


^J 


XCPY 


60 


XCPY 


7C 


XCPY 


30 


XCPY 


90 


XCPY 


ICC 


XCPY 


lie 


XCPY 


l^-J 


XCPY 


IJO 


XCPY 


I4b 


XCPY 


\^d 


XCPY 


Ifc-J 


XCPY 


1 70 


XCPY 


16C 


XCPY 


19C 


XCPY 


2C0 


XCPY 


?10 


XCPY 


Z2U 


XCPY 


?JC 


XCPY 


2^: 


XCPY 


2 5C 


XCPY 


2»C 


XCPY 


£(C 


XCPY 


^a-c 


XCPY 


?90 


XCPY 


■iOO 


XCPY 


no 


XCPY 


i/"J 


XCPY 


no 


XCPY 


i40 


XCPY 


liO 


XCPY 


J6C 


XCPY 


370 


XCPY 


ibv 


XCPY 


39C 


XCPY 


UCO 


XCPY 


■tiC 


XCPY 


'.t;C 


XCPY 


".^n 


XCPY 


'.'.0 


XCPY 


"i^C 


XCPY 


UoC. 


XCPY 


kJO 


XCPY 


-.80 


XCPY 


<,90 


XCPY 


SOO 


XCPY 


5 10 


XCPY 


h/0 


XCPY 


•iiC 


XCPY 


S^iC 


XCPY 


5&C 


XCPY 


ibO 


XCPY 


^7C 


XCPY 


580 


XCPY 


•>w 


XCPY 


iOO 


XCPY 


6l(J 


XCPY 


O.'C 


XCPY 


ftlO 


XCPV 


64tJ 



SUBROUTINE NSTR 

PURPOSE 

CHANGE STORAGE NODE OF A MATRIX 

USAGE 

CAl-L NSrRUiR*N,HSA,NSRl 

OESCRIPTION OF PARANETERS 
A - NAMe OF INPUT MATRIX 
R - NAME OF OUTPUT MATRIX 

N - NUMBER OF ROWS AND COLUMNS IN A ANO R 
HSA - ONE OIGIT NUMBER FOR STqRAGE MODE OF MATRIX A 

- GENERAL 

1 - SrNNETRlC 

2 ~ 01 AGONAL 

HSR - SANE AS mSa EXCEPT f=OR MATRIX R 

REMARKS 

MATRIX R CANNOT BE IN THE SAME LOCATION AS MATRIX A 
MATRIX A MUST BE A SQUARE MATRIX 

SUBROUTINES ANO FUNCTION SUBPRuGRAMS REQUIRED 
LOC 

METHOO 

MATRIX A IS RESTRUCTURED TO FORM MATRIX R. 
MSA HSR 
C MATRIX A IS MOVED TO MATRIX R 

C 1 THE UPPER TRIANGLE ELEMENTS OF A GENERAL MATRIX 
ARE USED TO FOAM A SYMMETRIC MATRIX 

2 THE DIAGONAL ELEMENTS OF A GENERAL MATRIX ARE USED 

TO FORH A DIAGONAL HATREX 

1 A SYHMEtrIC MATRIX IS EXPANDEO TO FORM A GENERAL 

MATRIX 
1 1 MATRIX A IS MOVED TO MATRIX R 

1 2 THE DIAGONAL ELEMENTS OF A SVH«4£TRIC MATRIX ARE 

USEU TO FORM A DIAGONAL MATRIX 

2 C A DIAGONAL MATRIX IS EXPANOLO 8Y INStKTING HCSStNG 

ZERO ELEMENTS TO FORH A GENERAL MATRIX 
Z I A DIAGONAL MATRIX IS EXPANDED BT INSERTING MISSING 

ZERO ELEMENTS TO FORM A SYMMETRIC MATRIX 
2 2 MATRIX A IS MOVED TO MATRIX R 



SUaROUriN£ MSTRI A,RtNiMSA,HSRI 
DIMENSION A( l),RI 1) 

DO 20 I-l.N 
DO 20 J-1,N 

IF R IS GENERAL, FORM ELEMENT 

IFlMSR) 5,10.5 

IF IN LOWER TRIANGLE OF SYMMETRIC OR DIAGONAL R, BYPASS 

IFII-J) 10,iC,20 
I CALL LOCI l,J,IR,N,N.MSAl 

IF IN UPPER ANO OFF DIAGONAL OF jlAGONAL R, BYPASS 

IF( IRI 20.20,1^ 

OTHERWISE. FORM R(I,J) 

R(1K)=0.0 

CALL LOC(IiJ.IA,N,N,HSAI 

IF THERE IS NO A(I.J), LEAVE RU, Jt AT CO 

IF( lAI 20,20.15 
R(IR1=A(IAI 

CONTINUE 

KETUKM 

END 



10 



40 



70 
SO 
90 



MSTR 
.MSTR 
MSTR 
HSTR 
MSTR 
MSTR 
MSTR 
MSTR 
MSTR 
HSTR 100 
MSTR 110 
HSTR 120 
MSTR 130 
MSTR 1^0 
HSTR ISO 
MSTR 160 
HSTR 170 
MSTR 160 
MSTR 190 
HSTR 200 
MSTR 210 
MSTR 220 
MSTR 230 
MSTR ZW 
MSTR 250 
HSTR 260 
HSTR 270 

MSTft zao 

HSTR 290 
HSTR 300 
MSTR 310 
HSTR 320 
MSTR 330 
MSTR 340 
MSTR 350 
MSTR 360 
MSTR 370 
MSTR 380 
MSTR 390 
MSTR A^OO 
MSTR *10 
HSTR <.20 
MSTR 430 
MSTR 440 
HSTR 450 
MSTR 460 
MSTR 470 
.MSTR 460 
MSTH 490 
MSTR 5O0 
MSTR 510 
HSTR 520 
HSTR ^30 
HSTR 540 
HSTR 550 
HSTR 560 
HSTR 570 
MSTR 580 
HSTR 590 
MSTR 600 
HSTR 610 
HSTR 620 
HSTR 630 
HSTR 640 
HSTR 650 
MSTR 660 
HSTR 670 
MSTR 6ao 
HSTR 690 
MSTR TOO 
HSTR 710 
MSTR 720 
MSTR T3C 
HSTR 740 
MSTR 750 
HSTR 760 
MSTR 770 
MSTR 780 
MSTR 790 
HSTR 800 



96 Mathematics — Matrices: Storage 



Subroutine LOG 



Subroutine CONVT 



SUBROUriNE LOC 

puRPOse 

COMPUTE A VECTOR SUaSCRIPT fOR AN EttMENT IN A MATRIX OF 
SPEClFiEO STORAGE NODE 

USAGE 

CAtL LOC U.J.IR.N.M.MSI 

DESCRIPTION OF PARAMETERS 

I - ROM NUMBER OF ELEMEMT 

J - COLUMN NUH6ER OF ELEMENT 

IR - RESULTANT VECTOR SUBSCRIPT 

H - NUMBER OF ROWS IN HATRU 

M - NUMBER OF COLUMNS IN MATRIX 

HS - ONE DIGIT NUMBER FOR STORAGE MODE Of MATRIX 

- GENERAL 

1 - SYMMETRIC 

2 - DIAGONAL 

REMARKS 
NONE 



LOC 
..LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 

LOC 
LOC 
LOC 
LOC 
LOC 
LOC 



toe 

110 
L20 

L30 
I'tC 
ISO 
160 
170 
160 
190 
200 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

NONE 



METMOD 

MS=0 



LOC 210 

LOC 220 

LOC 230 

LOC 240 

LOC 2 50 

LOC 260 



SUBSCRIPT IS COMPUTED FOR A MATrIx UITH N*M ELEMENTS 
IN STORAGE (GENERAL NAntlX) 

subscript is computed for a matrix miih n*(n«^ll/2 in 
storage (upi>er triangle of svhhetric matrix}. if 
Element is in loner triangular portion, subscript is 
corresponding element in upper triangle, 
subscript is computed for a matrix uith n elements 

IN STORAGE IOIAGOnAl ELEMENTS OF DIAGONAL MATRIX). 
If ELEMENT IS NOT UN 01 AGUNAL I AND TMERefORE NOT IN 
STORAGEJ. IR IS SET rO ZERO. 



LOC 
LOC 
XOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 
LOC 



270 
280 
290 
300 
310 
320 
330 
3*0 
350 
360 
3 TO 
380 
390 
400 
410 



SUBROUTINE LOCH, J, IK, N.M, MSI 

IX=1 

JX=J 

lf(MS-l( 10,20,30 
) IRX=N*( JX-ll+IX 

GU TO J6 
I iF(IX-JX» 22.24.24 
: IRX«IX*-IJX*JX-JXI/2 

GO TO 36 

IRX = JK+nX«{X-IX)/2 

GO TO 36 
I 1RX=0 

IFdX-JXl 36.32.36 
: IRX-U 

IR^IRX 

RETURN 

END 



LOC 4S0 
LOC 460 

LOC 470 



LOC 
LOC 
LOC 



480 
490 
SCO 



LOC 510 

LOC 520 

LOC 530 

LOC i>40 

LOC 550 

LOC 560 

LOC 5 70 

LOC 580 

LOC 590 

LOC 600 



C SUBROUTINE CONVT 

C 

C PURPOSE 

C CONVERT NUM6£«S FROM SINGLE PRtCISIOH TO OQuBLE PRECISION 

C OR FROM OOUBLE PREClSIJN TO SINGLE PRECISION. '"'^''^^^°'* 

C USAGE 

C CALL CONVT (N ,M, MOOt , S.O.MS ' 

C OESCRIPTION OF PARAMETERS 

C N - NUHd£R Of ROMS IN MATRICES S AND 0. 

C M - NUMBER OF COLUMNS IN MATRICES S AnO O. 

C MOOE - CQOE INDICATING ITPE OF COhVERSION 

C 1 - FROM SINGLE PRECISION TO DOUBLE PRfcClSIQN 

C Z - FROM DUUBLE PRECISION TO SINGLE PRtCISION 

C S - IF MO0E=l. THIS MATRIX CONTa|»S SINGLE PRECISION 

C NUMBERS AS INPUT. IF MOOE -2, IT CONTAINS SINGLE 

t- PRECISION NUMBERS AS OUTPUT. THE SIZE OF MATRIX s 

^ ISN6YM* 

C D - If HOOE-l, THIS MIRIx CONTAINS UOUBLE PHeClSlON 

C NUmEllS AS OUTPUT. If WlDt.J, IT CONTAIIdS oouatE 

^ M£CISION KUneWS AS INPUT. IKE SUE Of (UIRIX IS 

C HS - ONE DIGIT NUHSEA FDK STORAGE NODE OF HATRix 

C - GENERAL 

C 1 - SrHMETRIC 

t 2 - DIAGONAL 

C 

C REMARKS 

C NATRIX CANNOT BE IN THE SANE LOCATION AS NATRIX S. 

C ;"*" ".""" " OEFINEO ar A DOUBLE PRECISION STAIENENT IN CONV 340 

C THE CALLING PROGRAN. Jgjjj 35J 

CONV 360 
CONV 370 
CONV 380 

HOO """' "" 

ACCOHUING TO THE TYPE Of CONVERSION INOICATEO IN NODE, THIS CONV 410 
SueRQUTINE COPIES NUH6ERS fRON HATRIX S TO HATRIX D OR FROM CONV 420 



CUNV 


to 


CONV 


30 


COhv 


40 


CONV 


50 


CONV 


60 


CONV 


70 


CONV 


«r 


CONV 


90 


CONV 


100 


CONV 


lie 


CONV 


120 


CONV 


130 


CONV 


140 


CONV 


150 


CONV 


16C 


CONV 


170 


CONV 


160 


CONV 


190 


CONV 


200 


CONV 


210 


CONV 


??o 


CONV 


230 


CONV 


240 


CONV 


2S0 


CONV 


260 


CONV 


270 


CONV 


280 


CONV 


290 


CONV 


300 


CONV 


110 


CONV 


320 


CONV 


330 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 



MATRIX TO MATRIX S. 



SUBRQuriNE CONVT <N ,H. MOOE. S.D.MS 1 
DIMENSION S(lt(D< 1) 

DOUBLE PRECISION D 

FINO STORAGE MODE OF MATRIX AND NUMBER OF DATA POINTS 

IFIMS-I) 2. 4. 6 
2 NM-N*N 

GO TO B 
<* NM>UN«n«NJ/2 

GO TO 8 
i NM-N 

TEST TrPE OF CONVERSION 

) IF(N00E-1I lOt 10. 20 

SINGLE PRECISION TO OOUSLE PRECISION 

I 00 15 L-L.NH 
■ 0(L}>S(L) 
CO TO 30 



DOUBLE PRECISION TO SINGLE PRECISION 



00 25 L-I.NH 
S(LI>OILJ 



RETURN 
ENO 



CONV 4 30 
CONV 440 
..CONV 45G 
CONV 460 
CONV 4 70 
CONV 480 
CONV 490 
CONV 500 
CONV 510 
CONV 520 
CONV 5 30 
CONV 540 
CONV 550 
CONV 560 
CONV 570 
CONV 580 
CONV 590 
CONV 600 
CONV 610 
CONV 620 
CONV 630 
CONV 640 
CONV 650 
CONV 660 
CONV 6 70 
CONV 680 
CONV 690 
CONV TtlO 
CONV 710 
CONV 720 
CONV 730 
CONV 740 
CONV 750 
C(MV 760 



Mathematics— Matrices: Storage 97 



Subroutine ARRAY 



Matrices: Operations 
Subroutine GMADD 



SUBROUTINE ARRAY 

PUKPOSe 

CDNVfcRT DATA ARRAY FROH SINGLE TO 00U6LE OIHENSIUN OR VICE 
VcftSA, THIS SUBROUTINE IS USCD TO LINK THE USER PROGRAM 
WHICH HAS DOUBLE DIHENSION AA-tAvS AND THE SSP SUBROUTINES 
rfHlCH OPERATfc OH ARRAYS Of OAIA IN A VtCTOR FASHION. 



USAGE 

CALL ARRAY tNOOE< T 



J,NtH,S)0) 



DESCRIPTION OF PARAHETERS 

rtOOE - CODE INDICATING TYPE 0»^ CONVERSION 

1 - FROM SINGLE TO QOUSLE DIHENSION 

2 - fROH DOUBLE TO SINGLE DIMENSION 
1 - NU18ER Of AOfS IN ACTUAL DATA HATRIX 
J - NUhBER of COLUMNS IN ACTUAL DATA HATAI X 
N - NUMBER Of ROMS SPECIFIED FOR THE MATRIX D IN 

DIMENSION STATEMENT 

H - NUMBER OF COLUHMS SPECIFIED FOR THE HATRIX D IN 

DIMENSION STATEHENT 

S - IF MOOE-I. TNIS VECTOR IS INPUT WHICH CONTAINS THE 

ELEMENTS OF A DATA HATRIX Of SIZE I BY J. COLUMN I 
Of DATA MATRIX FOLLOWS COLUMN 1. ETC. IF MOOE'Zt 
THIS VECTOR IS OUTPUT REPRESENTING A DATA MATRIX 01 
SIZE I BY J CONTAINING ITS COLUMNS CONSECUTIVELY. 
TH£ LENGTH OF 5 IS IJ» WHERE IJ>I«J. 

- IF M00e»l. THIS MATRIX OF SUE N BY M IS UUTPUT, 

CONTAINING A DATA HATRIX OF SIZE I BY J IN THE FIRST ARRA 
I ROWS ANO J COLUMNS. IF H00E>2i THIS N BY M MATRIX ARRA 
IS INPUT CONTAINING A OATA MATRIX Of SIZE I BY 
THE FIRST 1 ROWS AND J CULUHNS. 



ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 

ARRA 

ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 



REMARKS 
VECTOR 



ARRA 

ARRA 
ARRA 
ARRA 
ARRA 
ARRA 
ARRA 



CAN BE IN THE SAME LOCATION AS HATRIX 0. VECTOR 
IS REFERRED AS A MATRIX IN OTHER SSP ROUTINES, SINCE U 
CONTAINS A DATA HATRIX. 
THIS SUBROUTINE CONVERTS ONLY GENERAL DATA MATRICES (STORAGEARRA 
MODE OF 01. A*^"* 

ARRA 

SUBROUTINES ANO FUNCTION SUBROUTINES REQUIRED *«RA 

NONE *'^«* 

ARRA 



100 
110 
120 
130 
140 
150 
160 
ITO 
180 
190 
200 
210 
220 
2 30 
2*0 
250 
260 
270 
280 
290 
300 
910 
320 
330 
340 
350 
360 
370 
380 
390 
400 
410 
420 



HETHOO 



REFER TO THE DISCUSSION ON VARIABLE DATA SUE IN THE SECHONARRA 
OEsCrISInG OVERALC rules for USAGE IN THIS MANUAL. AARA 

ARRA 
ARRA 



460 
ARRA 470 
480 
490 
500 
510 



SUBROUTINE ARRAY INOOEt I , J tN.H, StOI 
OIHENSION SI II, D( I) 

Nl«N-l 

TEST TYPE OF CONVERSION 

IF(M«ie-ll lOOi 100, 120 

CONVERT FROM SINGLE TO DOUBLE OIHENSION 

IDO IJ*I«J-»1 

NM-N*J+1 

00 110 K-L,J 

NM-HH-NI 

DO no L-l*I 

MM-NH-l 
ILO O(NHI-SIIJ) 
GO TO 140 

CONVERT FROM DOUBLE TO SINGLE DIMENSION 

120 IJ-0 

NN-0 

00 130 K-l.J 

00 12S L-ltl 

IJ-Ij*l 

NH-Nli»l 
125 SMJt-OINMI 
130 NH-NH*'Nl 

140 RETURN 

END 



ARRA 520 
ARRA 530 
ARRA 540 
ARRA 550 
ARRA 560 
ARRA 570 
ARRA 580 
ARRA 590 
ARRA 600 
ARRA 610 
ARRA 620 
ARRA 630 
ARRA 640 
ARRA 650 
ARRA 660 
ARRA 6T0 
ARRA 680 
ARRA 690 
ARRA 700 
ARRA 710 
ARRA 720 
ARRA 730 
ARRA 740 
ARRA 750 
ARRA 760 
ARRA 7T0 
ARRA 780 
ARRA 790 
ARRA 800 
ARRA a 10 
ARRA 820 
ARRA 830 
ARRA 840 
AARA a SO 
ARRA 860 



SUBROUTINE GHAOO 

PURPOSE 

AOO TWO GENERAL MATRICES TO FORM RESULTAWr GENERAL MATRIX 

USAGE 

CALL GMAODI A, S.R,N,H] 

DESCRIPTION OF PARAMETERS 

A - NAME OF FIRST INPUT HATRIX 

d - NAMb UF StCUNO INPUT HATRIX 

R - NAME OF OUIPUI MAiaiX 

N - NUMBER OF ROMS IN A.B<R 

M - NUHBcR OF COLUMNS IN A.B.R 

ALL MAfRICeS MUSI BE STORED AS GENERAL MATRICES 

SUBROUTINES AMD FUNCTION SUBPROGRAMS REOUIREO 
NONE 



SUBROUTlNt GMAOOIA, B,R,N,M) 
OIMFNSION Al 1).B( 1) ,R( 11 

CALCULATE NUMBER OF ELEMENTS 

NM=N»M 

AOO HATKICES 

00 10 1 = UNM 
to R(l l^Al II«SI I 1 

RETURN 
END 



GMAO 


10 


GMAO 


20 


GHAO 


30 


CHAD 


40 


GMAO 


50 


GMAD 


60 


CHAD 


70 


GMAO 


80 


GHAO 


90 


GMAO 


100 


CHAD 


lie 


GMAO 


120 


GHAO 


130 


GMAO 


140 


GMAO 


lUO 


CHAD 


160 


CHAD 


170 


GMAO 


lac 


GMAO 


19C 


GHAO 


200 


GMAO 


2IC 


GMAO 


??0 


GMAO 


210 


GMAO 


240 


GHAO 


P'iO 


GMAO 


260 


GMAD 


270 


• GMAO 


^60 


GMAO 


790 


GMAO 


300 


GMAO 


JIO 


GMAO 


320 


GMAO 


330 


GMAO 


i4n 


GMAO 


350 


GMAlJ 


360 


GMAO 


3 70 


GMAO 


380 


GMAO 


390 


tMAO 


40C 


GMAO 


410 


GMAD 


'.20 



98 Mathematics — Matrices: Operations 



Subroutine GMSUB 



Subroutine GMPRD 



SJ6RL)UTIN£ GMSUb 

PJRPOSc 

SJJTKACr OME GcNEKAL MATRIX FROM ANOTHER TO FORM RtSULTANT 
MATRIX 



CALL liMSUdt A. a.R.N.M) 
UfcSCKlPTIUN UF PAAAKcTEKS 

A - NAME Of FIRST INPOT MATftiX 

d - hAME JF SfcCOMJ INPUT MATRIX 

R - NAME Or OUTPUT MATRIX 

N - NUHubK Qf ROWS IN A.BtR 

.^ - NUM6E;< Of COLUMNS IH A.d.R 

REMARKS 

ALL MATRICES liJil Bf SrOttEO Ai GENERAL MATRICtS 

SUBROUTINES AND FUNCTION SUriPKUSRAMS RfcyUIREO 

NONE 

MbTHOO 

MAfKIX B tLtMENTS ARE SUBTRACTEO FROM CORRESPONDING MATRIX 
ELEMENTS 



SUBROUTINE GHSUBf A,8,R,N.M) 
DiMENSICN A( l),tl( 1) .Rl 11 

CALCULATE NUMBER OF ElEmEnTS 

NN=N*M 

SUBTRACT MATftlCtS 



10 



60 



GO 10 I = I , NH 
»l 1 J =Al 11-31 I J 

RETURN 
ENO 



GMSU 
. . CHSU 
GHSU 
GMSU 
GMSU 
GMSU 
GMSU 70 
GMSU 8C 
GMSU 9C 
GMSU 100 

ghsu no 

GMSU 120 
GISU 130 
GHSU 140 
GMSU 150 
GHSU 160 
GMSU 170 
GMSU ISO 
GMSU 190 
GMSU 200 
GMSU 210 
GMSU 220 
GMSU 2 30 
GMSU 2*C 
GMSU 250 
GMSU 260 

AGMSU 2 70 
GHSU 280 
GMSU 290 

.GMSU 300 
GMSU 3ia 
GMSU 320 
GMSU 330 
GmSU 340 
GMSU 35C 
GHSU 360 
GMSU 370 
GMSU 380 
GMSU 390 
GHSU 400 
GHSU 410 
GHSU 420 
GMSU 430 
GMSU 440 



GMPR 10 

.GMPR 20 



SUBROUTINE GMPftO 

PURPOSE 

MULTlPLr IWG GcNCRAL HAtHICES TO FORM A RESULTANT GENfRAL 
MATRIX 

USAGE 

CALL GMPRD<A,B,R,N.H,L] 

OcSCRIPTlON Or PAAAMtTERS 

A - NAME OF FIRST INPUT MATRIX 

8 - NAMe Of SECOND INPUT MATRIX 

R - NAHfe OF OUTPUT MATRIX 

K - NUMBER OF ROWS IN A 

M - NUMBER OF COLUMNS iN A ANO ROWS IN B 

L - nuhser of columns in B 



30 



60 



GMPR 
gmph 

GHPR 
GHPR 
GHPR 
GHPR 
GHPR 90 
GHPR 100 
GMPR 110 
GMPR 120 

GMPR 130 

GHPR 140 
GHPR ISO 
GMPR 160 
GHPR 170 
GMPR 180 
GHPR l90 
GHPA 200 
GMPR 210 
GMPR 220 
GMPR 230 
GMPR 240 



Rt^HARKS 

ALL MATRICES MUST SE STOrteC AS GENERAL MATRICES 
MATRIX R CANNOT BE IN THE SAME LOCATION AS MATRIX A 
MATRIX R CANNOT BE IN THE SANE LOCATION AS MATRIX 6 

NUM8CR Of COLUMNS OF MATRIX A MUST BE EOUAL TO NUMBER Of RCWGmPR 250 
OF MATRIX e GMPR 260 

Ghp* 2 70 

SUBROUTINES AnD FUNCTION SUBPROGRAMS REQUIRED GMPR 280 

NONE GMPR 290 

GMPR 300 

•'ETMOO GMPR 310 

THE M Br L MATRIX b IS PREHULTI PL lED BY THE N BV M HATRlX A GMPR 320 

ANO THE RESUI.T IS STORED IN THE N 8V L MATRIX R. GMPR 330 

GMPR 340 

GHPR 350 

GMPR 360 
GHPR 370 
GHPR 380 
GHPR 39C 
GMPR 40O 
GHPR 410 
GMPR 420 
GMPR 430 
GHPR 440 
GHPR 4 SO 
GMPR 460 
GMPR 470 
GHPR 4B0 
GMPR 490 
GMPR 500 
GMPR 510 
GMPR 520 
GMPR 530 
GMPR 540 



SUBROUTINE GMPftOI A, e*R. N,M.L I 
DIMENSION A( lltBI II .R( 1) 

I«"0 

IK--M 

00 10 K=1,L 

lK=iK+M 

00 10 J=l.N 

Ift=IR*l 

JI=J-N 

I6=IK 

«tlR)-0 

00 10 I'l.M 

JI=Jl4-N 

18=19+1 

R( IRJ^KdRI+AIJU^BUB) 

RETURN 
ENO 



Mathematics — Matrices: Operations 99 



Subroutine GMTRA 



Subroutine GTPRD 



GMTR 



10 



30 



SUtiROUriNg GMTRA 



USAGE 

CALL GMTRA( A> R,N,M} 

OfcSCRlPriON OF PARAftfcTERS 

A - NAME Of MATRIX TO BE TRANSPOSEO 

R - MAME Of RESULTANT NArftlX 

N - NUMBfcR OF ROWS OF A ANO COLUMNS OF R 

n - NUMBER Of COLUMNS OF A AND ROWS OF R 

REMARKS 

MATRIX R CANNOT Bt IN THE SAME LOCATION AS MATRIX A 
HATRICtS A ANO ft MUST 6E STORED AS GENERAL MATRICES 

SUBROUriNES AND FUNCTION SUepBOGRAMS REQUIRED 
NONE 



SUBROUTINE GMTRAf A. R< N.M) 
DIMENSION A( t),R( L) 

IR=0 

00 lO I=1,N 
iJ=I-N 
DO 10 J=1.M 
IJ=IJ*N 
IR=IR+1 
10 Rl IRl'AdJ) 
RETURN 
END 



.GMTR 
GMTR 

GMTR *C 

GMTR 50 

GMTR 60 

GMTR 70 

GMTR 6C 

GMTR 90 

GMTR 100 

GMTR 110 

GMTR IZO 

GmTR 130 

GHTR 140 

GMTR 150 

GmTR UO 

GMTR 170 

GMTR ISO 

GMIR 190 

GMTR 200 

GMTR 2LD 

GMTR 220 

GMTR 230 

GMTR Z'tO 

GMTR 250 

GmTR 260 

GMTR 270 

.GMTR 260 

GMTR 290 

GMTR 300 

GMTR 310 

GMTR 320 

GMTR 3 30 

GMTR 3*0 

GMTR 350 

GMTR 360 

GMTR 370 

GMTr 360 

GMTR 390 

GMTR 40C 

GMIR 410 



THE TRANSPOSE O^ ANOTHER 



suaROuriNE arpRa 

PURPOSE 

PREMULTIPLV A GENERAL MATRIX 
GENERAL MATRIX 

USAGE 

CALL GTPRU( A, S.R.N.M.L) 

DESCRIPTION Of PARAMETERS 

A - NAHti OF FIRST INPUT MATRIX 

6 - NAME Qf StCOND INPUT MATRIX 

R - NAME Of OUTPUT MATRIX 

N ~ NUMdtR CF ROWS IN A ANO it 

M - NUMBER Or CJLUMNS IN A ANi) kOtaS IN R 

L - NUMSbR LF CULUMNS IN b ANO R 

REMARKS 

MATRIX R CANNOT BE IN THE SAME LOCATION AS MATRIX A 
MATRIX R CANNOT BE IN THE SAME LOCATION AS MAFRU 6 
ALL HATKICES MUST 8E STQkEJ AS GENERAL MATRICES 

SUBROUTINES AI4D FUNCTION SU6PRCGRAMS REguiRLD 

NCNE 

McThCO 

MATRIX TrtANSPUSc Of A IS .^U T ACTUALLV CALCULATED. INSTEAD. 
ELfeHENTS OF MATRIX A ARE TAKEN COLuMNjISt RAIHER THAn 
ROl««(ISc FOR POSTMULTl PLICATION 6Y MATRIX a. 



SUbftOUriN^ GTPkOI Af B.R'N.H.L) 
OIMENSICN A( im( 1) ,R| 11 

IR = 
IK = -N 

DO tC K=l,L 
IJ = 
IK=:n.*N 
DO IC J=l,M 
iB^IK 
JR=IR»1 
«( l«t = 
DO iC l=l,N 
1J= 1J*1 
IB= Ifltl 
10 RURi = R( MItAI IJl «□! Id) 
RETURN 
END 



GTPR 
.GTPH 

GTPH 
GTPR 

GTPR 
GTPR 
GTPR 



TO 



GTPR 80 

GTPR 90 

GTPR ICO 

GTPR ilO 

GTPR 1^0 

GTPk 13C 

GTPR 142 

GTPR 150 

GTPH 160 

GTPR 170 

GTPR 180 

GTP.* iqc 

GTPR 2CC 
GTpB ^10 
GTPR 220 
GTPR ZiO 
GTPR 2AG 
GTPR 250 
GTPH ZtC 
GTPR 270 
CrPR 280 
GTPR ^-50 
GTPR 3CC 
GiPK 3Kj 
GTPR 52C 
GTPR 330 
.GTPR 3<,0 
GTPR 350 
CTPk 36C 
GTPR 370 



GTP 



3ElO 



GTPR 390 

GTPR 400 

GTPR 410 

GTPR *t20 

GTPR 430 

GTPR -.^C 

GTPR 450 
GTPR 460 
GTPR 470 
GTPH 480 
GTPR 49C 
GTPR aOO 
GTPR 510 
GTPR SZO 
GTPR 530 



100 Mathematics — Matrices: Operations 



Subroutine MADD 



Subroutine MSUB 



SUBROUTINE MAJU 



PUKPiJSc 

MiO TMO MATRICES tLtHENT dY ELEMthf TU fO«H RfcSULfANr 



50 



•JSAGt 

CALL MAOOlA 



.RtN.i 



»Sbi 



t>tSCKlPIIUh Of PARArttT£RS 

A - fiAHt Of INPUT MATRIX 
d - NAME JF (NPUT MATklK 
R - NAMt 3F OUTPUT MATRIX 

■■4 - H-JtHatH OP AOnS IN AtdfR 

1^ - NLIHdtit OF COLUMNS iN A.iJ.R 

MSA - uNt tlllilT NU«6£R FOR STJRAoE WOOE Uf HATAU A 
Q - GENcKAL 

1 - SirWitTRlC 

2 - 0IAG0r4AL 

HiU - SAME AS MSA EXCEPT fCR MuTRlX U 



SUBROuTINfcS MO FUNCTION $UBPKtlG«AMS REQUIRcO 

LUC 

METHOD 

STUKAGE rtQJt uF iJUTPUT MATAIX li FIRST OCTEhMIwcO. AOUIT 
UF COkkESPUNJING fcLEHtNTS IS THlN PtRFORMEO. 
THE FOLLOWING TABL£ SHUwS THE STORAGfc MODE UF TH£ OUTPUT 
rtATkU FOR AtL COMdlNArlONS OF iNPul MATRICES 



GeNERAL 

C£NfcRAL 

GENERAL 

SyMMcTfttC 

SVHHdTKlC 

SCHMETRIC 

DI AGUNAC 

01 AGONAL 

DIAGONAL 



GENERAL 

SYMMETRIC 

DIAGONAL 

GlwCRAL 

SYMMETftIC 

OIAGUNAL 

GENfcRAL 

SYMMETRIC 

DIAGONAL 



«tNE«AL 

GcNcRAL 

CtNEt<AL 

t;tNERAL 

SVHMETRJC 

SfMHETRlC 

GtNtRAL 

SYMMETRIC 

DIAGONAL 



SUbRUUT INE MAOOI Aid ,R, M.M, MSA.MStJ) 
DIMENSION AlK.ei 11. «I 1) 

L-ETtHMINe Srj^AGE MQOt OF JUTPUT MATRIX 

lF[MiA-MSd) 7, b, I 
b CALL LUC1N.M,NM.N.M,HSA) 

GU TO IOC 
7 MrcST=MSA*M5a 

MSR=0 

IflMTfcSn 20.20.10 
C MSR=1 

D |F(MTcST-2l 35,35, 3d 
Li MSR=2 

LOCATE tLEMENTS AND PtkFORN ADDITION 

i) 00 90 J = l,M 

00 90 I=1,N 

CALL LJC( I* J. IJRtN,M,MSRI 

IF{IJR] ^C^O.^iO 
) CALL LOCU,J.IJA,N,M,MSA} 

AEL-C.O 

IF( IJAl 53,60,50 
} AEL=A( IJA) 
) CALL LaC< It J. IJB.N.n.MSBI 

BfeL=0.0 

IFIUei TO. 60.70 
) BtL^BI IJBl 
) R(J JRI-AEL+BEL 
'. CONTINUE 

RETURN 

AUD MATRICES FOR OTHER CASES 

I 00 ilO I-L.NH 
I R( I )=A( II *6l II 
RETURN 

END 



NADO 
.MAUU 
MALO 
HAC-0 
MADO 
MAOD 
HAOO 
HAi;0 
MAtO 93 
MADO 100 
MAOD lie 
MAOD UC 
MAUi) 130 
MADO UO 

HAuii 15a 

HAl/0 loC 
MADO 170 
MADO 1 60 
MADO 190 
MALD 2CC- 
HAOO 210 
MADO 220 
MAOD 2 30 
MAOO 2«C 
MADD 250 
MADO ^60 
MAtD ^70 
MACJ 28C 
MADO 29C 
HADO 30C 
MAOO J 10 
lON MAUD 320 
MADO 3 30 
MAUO 3-10 
MAOD 350 
MAOO 36C 
MAOO 37C 
HADO 380 
MACD 390 
MACO 4UC 
MAOO 410 
HAOO 42C 



MADO 4<>0 
MAOO 450 
MADU 460 
..MADO 4 70 
MAtO 4 60 
MAOO 490 
MADO SCO 
MAOO 51G 
MAOO •>20 
MAOD )>C 
MAOO 540 
MACO 5 SO 
HADO 560 
MAOO 570 
MAOD SUG 
NADU 590 
MAOO &C0 
MADO 6L0 
MAOO 620 
MAOD 6JC 
MADO 640 
NADD 650 
MAOO 660 
MAOD 6 70 
HAOO 660 
MADD 69C 
HALO 700 
MAOO 710 
MADO 720 
HAOO 730 
HAOO 740 
HADO 750 
HADO 760 
HAOO 770 
HAOO 780 
HAOO 790 
HAOO 600 
MAOO BIO 
HAOO 620 
HADD 83o 
HaOO 840 
MAOD 850 
HAOO 860 
HADO 870 



SUBROUTINE HSUB 

PURPOSE 

SUBTRACT rXO HATftlCES ELEHENT BY ELEMENT TO FQRH RESUt-TANT 
HATRIX 



80 



USAGE 

CALL HSU8(A,B 



RtN|H,M$A,HSei 



DESCRIPTION OF PARAMETERS 
A - NAME OF INPUT MATRIX 

A ~ NAME OF INPUT HATRIX 

R - NAME Of OUTPUT HATftlX 

N - NUMBER OF ROWS IN A.e.R 

H - hUMBER OF COLUMNS IN A.B.R 

MSA - One OICIT number for storage mode of MATRIX A 

- GENERAL 

1 - SVMHETAIC 

2 - DIAGONAL 

MSB ~ SaHE aS MSA EXCEPT FOR MATRIX B 



SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
LOC 

HETHOO 

STRUCTURE Of OUTPUT MATRIX IS FIRST OETERHINdO. SUBTRACTION 
OF MATRIX A ELEMENTS FROM CORftfcSPUNOING HATRIX A ELEMENTS 

i^ Then perfurheo. 

THE FOLLOWING TABLE SHOWS THE STORAGE MODE OF THE OUTPUT 
MATRIX FOR ALL COH81NATI0NS UF INPUT MATRICES 



GENERAL 

GENERAL 

GENERAL 

SYMMETRIC 

SYMH£TRIC 

SYMMETRIC 

DI AGONAL 

DIAGONAL 

01 AGUNAL 



GENERAL 

SirHMETRIC 

DIAGONAL 

GENERAL 

SYMHETftIC 

DIAGONAL 

GENERAL 

SYMHETRlC 

OIAGUNAL 



GENERAL 

GENERAL 

GENERAL 

GENERAL 

SYMMETRIC 

SYMMETRIC 

GENERAL 

SYMrlETRIC 

DIAGONAL 



SUbROUTlNt HSUBU.U.R.N.H.HSA.NSiil 
OIHENSION A( 1) ,dl 1) ,R( II 

DETERMINE STORAGE MODE OF OUTPUT MATRIX 

iFIMSA-MSbl 7,5. 1 
S CALL i.OCIN.nt.\H,.^,H.HSAt 

GO rU ICO 
7 HT£Sr=MSA«NSa 

HSR>0 

IFIMTESTI ^0,20, IC 
C HSR-1 
IF(MTEST-2) 35,33,30 

HSR-2 

LOCATE ElEHENTS ANO PfcRfOKH SUBTRACTION 

5 00 90 J^i.H 

DO 9C I>ltN 

CALL LOCI i.J. IJK.N, M.MSK) 

Iff UKI 40,9C,40 
3 CALL LUC( 1. Ji IJA.N. M,HSAI 

A6L"C.O 

IF( (JAI ^.60, 50 
} AEL'AI IJAl 
"t Call luCI I , j. ijs. n. h,hsbi 

5£c=0.0 

lEI Uci 70, hO, JQ 
' bEL-o( Ijai 
; Rtl Jkl=A£L-rt£L 

1 CUNTINJE 
RETURN 

SUBTRACT MATKICeS FOR OTHER CASES 

t DU lie l=l,NM 
I Mil 1-AI I t-bi I) 

RETURN 



MSUB 

HSUB 

MSUB 

HSUB 

HSUB 

HSUB 

HSUB 

HSUB 

HSUB 

MSUB 100 

MSUB ILO 

MSUB 120 

MSUB 130 

HSUB 140 

HSUS L50 

HSUB 160 
MSUB 170 

HSUB lao 
HSU8 19C 
HSUB 200 
MSUB 210 
MSUB 220 
MSUB 2 30 
HSUB 240 
MSUB 250 
HSUB 260 
HSUB 270 
HSUB 280 
HSUB 290 
HSUB 300 
HSUB 310 
HSUB i20 
HSUa 330 
HSUB 340 
MSUB 350 
HSUe 360 
MSUB 370 
MSUB 380 
MSUB 39C 
MSUe 400 
MSUB 410 
HSUB 420 
HSUB 4 30 
MSUB 440 
MSUB 450 
MSUb 460 
MSUa 470 
..MSU8 4d0 
MSUb 490 
MSUd 500 
HSUB ilO 
HSUd ■>20 
MSUB 530 
MSUB 54C 
MSUb 550 
MSUB 56'] 
HSUB 5 70 
HSUB 5SC 
HSUd 190 
MSUa bZl' 
MSUd 610 
MSU8 620 
MSua 630 

MSUb 34C 

HSUB o5C 
MSUB 660 
MSUB 670 
MSUB 6^0 
MSUt) 69? 
MSUb 700 
MSUb TIO 
MSUB 720 
MSUb 730 
MSUB 740 
MSUb /5'J 
MSu8 760 
MSUB 770 
MSUB 76C 
HSUd 7 JO 
HSUB SCO 
HSUB e 10 
HSUB d20 
MSUB diC 
MSUa i]40 
HSUd 95C 
HSUb BbO 
MSUB a70 
MSUB 880 



Mathematics — Matrices: Operations 101 



Subroutine MPRD 



Subroutine MTRA 



20 



SUtiKOJrihb HPHD 



PURPQSt 

MULTIPLY TWO HATRICES TO fORH A RfSULlANr MATRIX 



CALL HPK0{A,e.R.N.M.NSA.i1SB.Li 
iJESCtilPTION Of PAftAMtltRS 

A - NAMfc Of fiftsr Input matrix 
d - name uc sfccONO iNPur matrix 
R ' NAME Of Output matru 

N - NUMBtR OF ROWS [N A AtiO A 

M - NUMfttR Of COLUMNS I^ A AND ROWS IN A 

MSA - ONE JIGJT NUMoER ("33 STORAGE HQOE OF MATRIX A 

- (iEN£RAL 

1 - SYMMEiflIc 

2 - OlAGOAtAL 

MSB - SAMt AS MSA EXCCPT FUR MATRIX B 
L - MJHBcR Jl= COLUMNS IN d ANO R 

REMARKS 

MATRIX R LAAINUT Bt IM IH€ SAMt LOCATION AS HATKIC£$ A OR 
l4UrtBcK UF COLUMNS Ot^ MATRIX A MUST BE tOUAL TO NUMBER OF 
OF MATRU e 

SUdKGUTINES ANO FUNCTION SUBPROGRAMS ftEQUIR£D 
IQC 

MtTHOO 

THE M ay L MATRIX 6 IS PREMUL Tl PLIED BY THE N BY M MATRIX 
ANJ THE RfcSULT IS STQREi) IN THE N BY L MATRIX R. THIS IS 
ROW INTO COLJHN PKOOUCT. 

IHt FOLLOMiNG TABLE SHOWS THE STORAGE MODE OF THE OUTPUT 
MATRIX FOR ALL COMBINATIONS OF INPUT HATRiCcS 



GENERAL 

GENERAL 

&tN£RAL 

SYMMETRIC 

SYMMETRIC 

SYMMETRIC 

DIAGONAL 

DIAGONAL 

DIAGONAL 



3£NERAL 
SYMMETRIC 

DIAGONAL 

GENERAL 

SYMMETRIC 

DIAGONAL 

GENERAL 

SYMM£TR1C 

DIAGONAL 



GENERAL 
CtNERAi. 
GENcRAL 
GENERAL 
GENERAL 
GENERAL 
GENERAL 
GENERAL 
DIAGONAL 



SPECIAL CASE FOR DIAGONAL BY OIAGJNAL 

MS«MSA»10+MSB 

IFIHS-22> 30.10.30 
I 00 ^0 I'itN 
I R(I l-A{ U*U( I) 

RETURN 

ALL OTHER CASES 

I IR=L 

OO 90 R-l.L 

DO 90 J-I.N 

RIIR>=0 

00 so I-l.H 

IFIMSI 40.60.40 
I CALL LOClJ.I.IA.N.H.nSAI 

CALL LOCI I.K.IB.M.L .HSei 

IFIIA) 50.80.50 
I IFIIB) 70*00.70 
I tA-H*{ l-ll+J 

ie>H*llt-lMI 
I RURI>R( IK)*AI|A1«SIIB1 
I CONTINUE 

RETURN 

END 



MPKD 
, . . . MPKO 

HPRO 10 
MPRD *0 
MPRD 50 
MPRO 60 
MPRO TC 
MPRO 83 
MPRO 90 
HPRD 100 
MPRO 110 
MPMO t2C 
MPRO 130 
MPRO 1*0 
MPRD 150 
MPRD 160 
MPRO 170 
MPRO IHC 
MPRO 190 
MPRO ZCO 
HPRD 210 
MPRO 220 
MPRO 2 30 
MPRO 240 
MPftO 250 

e HPRO Z6C 

RUHHPRO 27C 
MPRO 2B0 
HPRt) 29C 
MPRD JOO 
MPRD 310 
MPRD 320 
MPRO 330 
MPRD 34G 
MPRO 350 
MPRD 360 
MPRO i70 
HPRO i80 
HPRO 390 
MPRO *00 
MPRD 410 
MPRO 420 
MPRO -tJO 
HPRD 440 
MPRO *50 
MPRO 460 
MPRO 470 
MPRO 480 
MPRO 490 
.MPRO 500 
MPRO 510 
MPRO 520 
MPRO 530 
MPKO 540 
MPRO 550 
HPRO 56C 
MPRO 5 70 
MPRO 5d0 
NP«0 590 
HPRO 600 
MPRO 610 
MPRO 620 
HPRO 630 
MPRO 640 
MPRO 650 
HPRO 669 
HPRO 6 70 
HPRO 6 60 
MPRD 690 
MPRD 700 
HPRD 710 
MPRD 720 
HPRD 7 30 
MPRO 740 
MPRO 750 
MPRO 760 
MPRD 7 70 
HPRO 7S0 
MPRO 790 

MPRO a 00 
MPRO a to 



SUBROUTINE MTRA 

PURPOSE 

TRANSPOSE A MATRIX 

USAGE 

CALL HTRAIA.R.N.M.NS) 

DESCRIPTION OF PARAMETERS 

A - NAME OF MATRIX TO o£ TRANSPOSED 

R - NAME OF OUTPUT MATRIX 

N - NUHSER OF ROWS OF A ANO COLUMNS OF R 

H - NUMe£R OF COLUMNS OF A AnO ROUS OF R 

MS - ONE DIGIT NUMBER FOR STORAGE MOOt OF MATRIX A (ANO R) 

- GENERAL 

1 - SYMMETRIC 

2 - DIAGONAL 

REMARKS 

MATRIX R CANNOT BE IN THE SAME LOCATION AS MATRIX A 

SUBKOuriNES ANO fUNCTION SUBPKQGAANS REOUIREO 
MCPY 

McTriOO 

TRANSPOSE N 6r H MATRIX A TO foRH M 6y N MATRIX R BY MOVING 
EACH ROW OF A INTO THE CORRESPONDING COLUMN OF ft. IF MATRIX 
A IS SYMMETRIC OR DIAGONAL. MATRIX R 1$ THE SAME AS A. 



50 



flO 



SUBROUTINE MTRAIA.R.N.H.HSI 
OIMENSICN AdI.RUl 

IF MS IS 1 OR 2, CUPY A 

IF(M5) IC.20.10 
) CALL HCPY( A.R.N.N.MS) 
RETURN 

TRANSPOSE GENERAL MATRIX 

I 1H = 

00 30 Ul.N 

IJ=I-N 

00 30 J=1,M 

1 J=IJ*N 

IR=IR*1 

Rl Irtl^Al IJI 

RETURN 

tNO 



MTRA 
.MTRA 
HTRA 
MTRA 
MTRA 
HTRA 
HTRA 
HTRA 
HTRA 
MTRA 100 
HTRA 110 
MTRA 120 
MTRA 130 
MTRA 140 
HTRA 150 
HTRA 160 
HTRA 170 
HTRA lao 
MTRA 190 
MTRA ZOO 
HTRA 210 
HTRA 220 
HTRA 23D 
MTRA 240 
HTRA 250 
HTRA 260 
HTRA 2 70 
MTRA 280 
MTRA 290 
MTra 300 
MTRA 310 
HTRA 320 
.HTRA 330 
HTRA 340 
MTRA 350 
HTRA 360 
HTRA 370 
MTRA 3S0 
MTRA 390 
MTRA 40C 
MTRA 410 
MTRA 420 
MTRA 430 
MTRA 440 
MTRA 450 
MtHA 460 
HTRA 470 
MTRA 480 
MTRA 490 
HTRA 500 
MTRA 510 
MTRA 52C 
MTRA 530 
MTRA 5*0 



102 Mathematics — Matrices: Operations 



Subroutine TPRD 



Subroutine MATA 



sueROuriNE tpro 

PURPOSE 

TRANSPOSE A MATRIX AND POSTHULTIPLY SV ANOTHER TO FORM 
A R6SULTANT MATRIX 



DESCRIPTION OF PARAMETERS 

A - NAME OF FIRST INPUT HATRIX 

a - MAHE OF SECOND INPUT MATRIX 

R - NAHC OF OUTPUT HATRIX 

N - NUMBER OF ROWS IN * AND B 

H - NUH8ER OF COLUMNS IN A ANO ROMS IN R 

KSA - ONE DIGIT NUMBER FOR STORAGE NODE OF MATRIX A 

- GCNERAL 

1 - SVNNETRIC 

2 - DIAGONAL 

MSB - SAME AS MSA EXCEPT FOR MATRIX B 
L - NUNBER OF COLUNNS IN 8 ANO R 



20 



90 



SO 



IS NOT ACTUALLY CALCULATED. INSTEAD* 
ARE TAKEN COLUHNHlSE RATHER THAN 
CATION eV HATRIX 8. 

SHOWS THE STORAGE MODE OF THE OUTPUT 
NATIONS OF INPUT MATRICES 



SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
LOG 



METHOD 

MATRIX TRANSPOSE OF 
ELEMENTS IN MATRIX A 
ROWWISE FOR HULTIPL 
THE FOLLOWING TABLE 
MATRIX FOR ALL COMBU 
A 
GENERAL 
GENERAL 
GENERAL 
SVHHETRIC 
SYMMETRIC 
SVNNETRIC 
01 AGONAL 
01 AGONAL 
DI AGONAL 



GENERAL 

SYMMETRIC 

PI AGONAL 

GENERAL 

SYMMETRIC 

DIAGONAL 

GENERAL 

SYMMETRIC 

DIAGONAL 



GENERAL 
GENERAL 
GENERAL 
GENERAL 
GENERAL 
GENERAL 
GENERAL 
GENERAL 
DIAGONAL 



SUBROUTINE TPROf A.B.R.N.M,MSA.MSB.L I 
DIMENSION AUIfBI I) .R( t) 

SPECIAL CASE FOR DIAGONAL BY DIAGONAL 

HS-NSA*10*MS6 

IFINS-22) 30,10,30 
10 00 20 l>l*N 
20 R(II-A<II*ein 

RETURN 

MULTIPLY TRANSPOSE OF A BY fi 

30 IR-l 

00 90 K-I.L 

00 90 J>L.M 

RIIRt-0.0 

DO to I-L,N 

IFIMSI 40,60,40 
40 CALL LOCII,J,tA,N.N,MSAI 

CALL LaCU,K,IB,N.L*MSBI 

IFIIAI 90,80,50 
50 IFdBI 70,80,70 
60 IA-N*IJ-1)*I 

iB-N*(K-ll*I 
70 R<IR1-R<IR)«A{ IA)*B(IBt 
80 CONTINUE 
90 IR-IR*I 

RETURN 

END 



TPRO 

.TPRD 
TPRO 
TPRO 
TPRO 
TPRO 
TPRO 
TPRO 
TPRO 
TPRO too 
TPRD 110 
TPRO I 20 
TPRD 130 
rPRO 140 
TPRO ISO 
TPRD 160 
TPRO ITO 
TPRO lao 
TPRD 190 
TPRO 200 
TPRO 210 
TPRO 220 
TPRO 230 
TPRO 240 
TPRD 250 
TPRO 260 
TPRO 2 70 
TPRO 260 
TPRO 290 
TPRO 300 
TPRD 310 
TPRO 320 
TPRO 330 
TPRO 340 
TPRO 350 
TPRD 360 
TPRO 370 
TPRO 380 
TPRO 390 
TPRO 400 
TPRO 410 
TPRO 420 
TPRO 430 
TPRO *40 
TPRD 450 
TPRO 460 
TPRO 470 
TPRO 480 

.TPRO 490 
TPRO 500 
TPRO 510 
TPRO 520 
TPRO 530 
TPRO 540 
TPRD 550 
TPRO 560 
TPRO 570 
TPRO 580 
TPRO 590 
TPRO 600 
TPRO 610 
TPRO 620 
TPRD 630 
TPRD 640 
TPRO 650 
TPRD 660 
TPRO 670 
TPRD 680 
TPRO 690 
TPRD 700 

TPRO no 

TPRO 720 
TPRD 7 39 
TPRO 740 
TPRO 750 
TPRO 760 
TPRO 770 
TPRO 780 
TPRO 790 

TPRO eoo 



SUBROUTINE NATA 

PURPOSE 

PAENULTIPLV A MATRIX BY ITS TRANSPOSE TO FORN A 
SYMMETRIC MATRIX 

USAGE 

CALL HATAtA,R,N,H,HSI 

DESCRIPTION OF PARAMETERS 
A - NAME OF INPUT HATRIX 
R - NAME OF OUTPUT MATRIX 
N - NUMBER OF ROWS IN A 
H - NUNBER OF COLUMNS IN A, ALSO NUMBER OF ROUS ANO 

NUNBER OF COLUMNS OF R. 
MS - ONE DIGIT NUMBER FOR STORAGE nOK OF MATRIX A 

- GENERAL 

1 - SYMNETRIC 

2 - DIAGONAL 

REMARKS 

MATRIX R CANNOT BE IN THE SAME LOCATION AS MATRIX A 
HATRIX R IS ALWAYS A SYMMETRIC HATRIX WITH A STORAGE MODE" 

SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
LOC 

METHOD 

CALCULATION OF (A TRANSPOSE At RESULTS IN A SYMMETRIC MATRI 
REGARDLESS OF THE STORAGE MODE OF THE INPUT MATRIX. THE 
ELEMENTS OF MATRIX A ARE NOT CHANGED. 



SUBROUTINE NATAt A.ft ,N. H,MS ) 
DIMENSION AUI,R(1) 

DO 60 K=t,H 

XX=(K*fC-K>/2 

DO 60 J^l.M 

IF< J-K) 10,10.60 
I iR=J+KX 

R{ IRI-0 

DO 60 l*l,N 

IFIHS) 20,^,20 
I CALL LOC( I.J. lA.N, H.MS) 

CALL LOC( I.K.ie.N.H.MS) 

IFdAI 30,60,30 

IFdSI 50,60,50 

IA=N«(J-lt*I 

IB-N«(K-IJ*I 

R<IR} = R(tR|4-A( 1AI*A(IB> 

CONTINUE 

RETURN 

END 



HATA 
MATA 
MATA 
MATA 
MATA 
NATA 
MATA 
MATA 
MATA 
HATA 
MATA 
NATA 
HATA 
MATA 
HATA 
MATA 
MATA 
HATA 
NATA 
MAT* 
MATA 
MATA 
HATA 
HATA 
MATA 
HATA 
MATA 
MATA 
HATA 
MATA 
HATA 

XHATA 
HATA 
MATA 
MATA 

.MATA 
MATA 
HATA 
MATA 
HATA 
MATA 
NATA 
MATA 
HATA 
MATA 
HATA 
HATA 
MATA 
NATA 
HATA 
HATA 
HATA 
HATA 
HATA 
HATA 
MATA 
MATA 
HATA 



100 
110 
120 
130 
140 

L50 

160 
170 
180 
190 
200 
210 
220 
2 30 
240 
250 
260 
270 
280 
290 
300 
310 
320 
330 
340 
350 
360 
370 
380 
390 
400 
410 
420 
430 
440 
450 
460 
470 
480 
490 
500 
519 
520 
530 
540 
550 
560 
570 
580 



Mathematics—Matrices: Operations 103 



Subroutine SADD 



Subroutine SSUB 



SUBKUUTlht SADL 

PUR past 

AOJ A SCALAR 10 EACH tLEMENT Of A MATRIX 10 fORH A 

MATRIX 

USACE 

CALL SAUDI A. C .R. N,H,Ms| 

LitSCRlPIlON UF PARAMiTcRS 
A - hAML OF INPJT HATKIX 
C - SCALAR 

k - NAME jF OUTPUT MATRIX 
N - NUMotft OF ROWS IN MATRIX A AND R 
M - NUM6ER OF COLUMNS IN MATRIX A AND R 
MS - UNt DIGIT NUMBER FOR STOkACE MODE JF MrtfRlX A 
C - OtNERAL 
1 - SYMMETRIC 

i - oiagomal 

Rl; MARKS 
NlJNE 

SU&ROUTiNES AND rUNCTIOh SU&PROGRAMS RfcOUlREO 
LOC 

M£THOO 

SCAL*R IS AUjEO TO EACH ELEMENT Of MATRIX 



SUBROUTINE SAOOt A.L.R.N.M.rtS) 
iJIMENSICN A( n,«< II 

COMPUTE VtCrOR LENGTH, IT 

CALL L0C1N,M,IT ,N,M,MS t 

AOO SCALAR 

OO i ]=I.IT 
R( I ; = A( I i*-c 

RETURN 
END 



SAUO IC 

. ^ SADO 2C 

SACD 30 
SAC-O ^.O 
SADO 50 
SADO 6C 
RESULTANTSADD 70 
SADO ac 
SAOO 9C 
SAtJD IOC 
SAOD 1 IC 
5ADD lifC 
SAOO liO 
SAOO X'tO 
SAOO 15C 
SAOO 16C 
SACD 17C 
SACO IHC 
(AND R} SAOO i9C 
SmLO iCC 
iAOO £1C 

SAOO ^^c 

SADD mC 

SAOO 24C 

SAOD ;?: 

SACD 2t>C 
SAOO 270 

SAOO zee 

SADD 290 
SAOO iCC 
SAOO 31C 
SAOO 32C 

SAOO 330 

SACD 3«.C 
SAOD 3 5C 
SADD 3t)0 
SAOD 37C 
SADD iSC 
SAOD 390 
SADO <fCC 
SAOO *flC 
SADO (,^Z 
SADO •'iO 
SAOO A^C 
SAOO AiC 
SAOO 46C 
SAOO *.70 



SUBROUTINE SSUB 

PURPOic 

SUBTRACT A SCALAR FROM E^CH tLfcM£Sr Of A MATRIX TO fORM A 
RESULTANT MATRIX 

JSAGE 

CALL SSUaf AtC 'RtN.M.MS) 

DESCRIPTION Cf ^ARAMETtRS 
A - NAMfc OF INPUT MATRIX 
C - SCALAR 

R - NAMc OF UUIPUT MATRIX 
N - NUMOtR Of RO-S IN MATRIX A AND R 
M - NUMBER OF COLUMNS IN MATRIX A ANO R 
MS - ONE OIGir NUMBER FOR STORAGE MCOE OF MftTfllX A (ANO Rl 

- General 

1 - SlfMMETRIC 
Z - Ul AGONAL 

REMARKS 
NONE 

SUBROUTINES And function SUBPROGRAMS REUUIAEO 
LOC 

methoo 

SCALAR IS SUBTRACIEO FROM EACH £ACM ELEMENT OF MATRIX 



SUBROUTINE SSUBI A, C.R.N, M.MS) 
DIMENSION AlUtRI 1) 

COMPUTE VECTOR LENGTH, IT 

CALL LaC(M,H, IT.N.H.MS) 

SUeTRACT SCALAR 

00 i I'l.IT 
Rm=A( l)-C 
RETURN 
END 



SSU8 

.SSUB 

SSUB 


IC 
2C 
JC 


SSU6 


4r 


SSUB 


5C 


SSUB 


bC 


SSUb 


IC. 


SSUB 


BC 


ssue 


9C- 


SSUB 


I on 


SSUB 


110 


SSUB 


liO 


SSUB 


I 30 


SSUB 


uc 


S5U8 


150 


SSUB 


160 


SSUB 


1/0 


SSUB 


IB'J 


SSUB 


I9C 


SSUB 


/oc 


SiUS 


?ic 


ssue 


??? 


SSUB 


240 


SSUB 


^40 


S5U6 


250 


SSUB 


260 


SSUB 


->70 


SSUB 


280 


SSUB 


2SC 


SSUB 


300 


SSUB 


31C 


SSUB 


3 AT 


.SSUB 


330 


SSUB 


StO 


SSUB 


350 


SSUB 


360 


SSUB 


3 70 


SSUB 


380 


SSU6 


390 


SSUB 


'.00 


SSUB 


4rlO 


SSUB 


MQ 


SSUB 


*3C 


SSUB 


*<-C 


SSUB 


-.iO 


SSUB 


460 


SSUB 


470 



104 Mathematics — Matrices: Operations 



Subroutine SMPY 



Subroutine SDIV 



HOLXlPtt cACH ELEMENT OF A MATRIX flV A SCALAR JU FORM A 
RESULTAhT MATRIX 



OtSCRiPTION Jf fAHAMtrthS 
A - NAMt UP INfUT MATRIX 
C - SCALAK 

R - NAME Cf c*UTPUT MATRIX 
N - NUHatiH Jt <U*ii IN HATRIX L AND R 
(1 - NL'HOi:R Ot" CULUHNb IN MATRIX A AMD K 

MS - cue oi';ir numcii^h fum storage Moot of hatkix a iahd (<} 

- GtNtkAL 

1 - SYMMcTftlC 

2 - DIAGONAL 



REMARKS 



SUBROUTINES A.NO FU»iClION 5.U0PRJGRAMS RtiiiilRtO 
LQC 



SUSAOUT INt SHP¥(A.C|R.NiH,MS} 
ulMtMSiCf^ A[ 1) f R( IJ 

CuMPure VECTUk LENGTH, IF 

CALL L3C{N,M, U,,\i,M,MS» 

MULT [pLY ev SCALAR 

oa 1 1=1, IF 

K( I )=A( [1*C 

RETURN 
LHu 



SMPY 


IC 


. SMPY 


20 


SMf-Y 


io 


SMCY 


4c 


SMPY 


^c 


SMPY 


60 


SMPY 


TC 


iMPV 


Hf 


SMPY 


90 


SMPY 


ICC 


SMPY 


uc 


SMPY 


wc 


SMPY 


1 jC 


SMPY 


un 


SMPY 


1;.: 


Sm^y 


IbC 


SMPY 


17!J 


SMPY 


IrtC 


SMPY 


l'*L- 


SMPY 


2LZ 


SMPY 


2Lr. 


SMPY 


22c 


SMPY 


/K 


SMPY 


i^C 


SMPY 


ii'jC 


SMPY 


/C<L 


SMPY 


pt:, 


SMPY 


■/■d'^ 


LMPY 


^90 


SMPY 


jc: 


SMPY 


ilC 


SMPY 


iZ'^ 


SMPY 


3>C 


SMPY 


3 40 


SMPY 


J^C 


SMPY 


^bO 


SMPY 


37C 


SMPY 


3 60 


SMPY 


i<iC 


SMPY 


4C0 


SMPY 


'.li 


SMPY 


42: 


SMPT 


'.J'J 


SMPY 


'^'.C 


SMPr 


*5C 


SMPY 


460 


SMPY 


A ?0 



SUBROUTINE SOIV 

PURPOSE 

DIVIDE EACH ELtMENT Of A MATRIX UY A SCALAR TO FORM A 
RESULTANT MATRIX 



OESCRIPFION OF PARAMETERS 
A - NAME Of INPUT MATRIX 
C - SCALAR 

R " NAME OF OUTPUT MATRIX 
N - NUMtltK OF ROMS JN MATRIX A AND R 
M - NUM6ER OF COLUMN:. iN MATRIX A AN0 R 
MS - ONE LIGIT NUMBER FUR STORAGE MODE OF MATRIX A ( ANu R) 

- GENERAL 

1 - SYMMETRIC 

2 - DIAGONAL 

REMARKS 

IF SCALAR IS ZERO. DIVISION IS PERFOAHEO ONLY OrcE 10 CAUSE 
FLOAFINO POINT QVERFLUM CONDITION 

SUBROUriNtS AND FUNCTION SUbPROGRAHS REOuIREO 
LOC 



SUBROUTINE SOIV(A*C>R. N.M.MS) 
L-lMcNSION A( II,R( II 

COMPUTE VecTuR LENGTH, IT 

CALL LOCI N.M, ir,N.M,M3) 

OH/IDfc BY SCALAR llf SCALAR IS Z£RU, OIVIOE ONLY ONCE) 

IFIC) 2,1.2 

1 IF>1 

2 00 3 1 = 1. IT 

3 kH I = 4( Il/C 
RETURN 

tNO 



SDIV 10 
.SOIV 20 
SDIV 30 
SDIV ^0 
SOIV 50 
SOIV 60 
SDIV 70 
SOIV bO 
SDIV -SO 
SDIV 100 
SUIV UO 
SDIV i^O 

soiv lao 

SDiV UO 

StJlV l!)0 

SDIV 160 

SiJiV 170 

SDIV 180 

SDIV 190 

SDIV iroij 

SOIV 210 
SuIV 220 
SOIV HQ 
SDIV 21^0 
SUIV 2^0 
SDIV ^6C 
SOIV 270 
SOIV 2d0 
SDIV 2'*2 
SDIV >00 
SOIV lie 
SOIV 320 
SOIV 3iCi 
SOIV 3'tO 
SDIV 3iO 
SJIV ifcC 
SOIV i7C 

SOIV 'JJ3'^ 

Si. IV 3''C 
iOIV tt/O 



^«.C' 



SDIV 

SDIV '.bO 

SOIV '.'.0 

sl>i V 4 ro 

SOIV i.-iO 

SOIV <*■•,'-, 

SDIV i.CC- 



Mathematics — Matrices: Operations 105 



Subroutine SCLA 



Subroutine DCLA 



.fc ?>L( A /U 



bUtfKlWjrlNt SCI A 

PUKPOSt 

:>Ll LACK LLtHtNT (If A HATHIX LOUAL Td A GIVtN SCALAH 

USAt;t 

CALL SCLA (A,C,N,M,HSI 

UtSCKIPTIIJN af PAKAMtlCkS 

A - NAMfc M iNPUr HAIKU 

C - SCALAK 

N - NUHULK U¥ KdWS IN HAThIX A 

N - NUMUtK Uf CULUMNS IN MAfHIX A 

MS ' IINL Jlull NUHULH hUK STUKAtiL MUUL UF HATKIX A 

- (^tNtKAL 

1 - SYNMfcTKIC 
2-01 AGUNaL 



SUBKUUriNtS AND FUNCTIUN SUBPKUGriAHS REQUIREO 
LUC 



SUBRUUTINE SCL Al A.C.M. H. MS ) 
OintNSiON Afll 

COMPUIt VtCrOR LtNGIH, If 

CALL LUCIN.H, ir. N.M.MS) 

RtPLACt BY SCALAR 

00 i 1=1. IT 
1 Al D-C 
KETURfl 
END 



SCI A It} 



SCI A 


ti. 


SCLA 


M 


^LL A 


•»C 


SCLA 


ino 


SCI A 


1 10 


SCLA 


I/O 


SCLA 


1 )0 


SCLA 


1-^0 


SCI A 


l',G 


SCLA 


IhO 


SCLA 


1 to 


SCiA 


IHO 


SCLA 


IVC 


SCLA 


<;ou 


SCI A 


.-IC 


SCLA 


^^0 


SCLA 


/iO 


SCLA 


/AO 


SCLA 


/'>0 


SCLA 


/tfO 


SCIA 


^ro 


SCLA 


^bo 


SCLA 


^■^^c 


SCLA 


100 


.SCLA 


110 


SCLA 


i/0 


SCLA 


no 


SCLA 


i<.0 


SCLA 


i'>0 


StLA 


160 


SCLA 


iro 


SCLA 


IHO 


SCLA 


JVO 


SCLA 


^00 


SCLA 


Air> 


SCIA 


'.^0 


SCLA 


AiO 


SCLA 


J. 40 


SCLA 


<.50 



SUBROUriNI: UCLA 

PURPUSt 

SkT t:ACH UlAGtMAL tLLMLNT UF A HAfRIX LtlUAL rO A VCAlAft 

USAGE 

CALL OCLA UiC.h.HSI 

UbSCRIPTIUN OF PAMAMLILkS 
A - NANt Jf= INPUT HATHIX 
C - SCALAR 

N - hUHULR UF HCIWS ANU COLUMNS IH MATRIX A 
NS - ONt DIGIT NUtBcK FUR SlURA&t HUDt Qf HATRlX A 

- GeNLRAL 

1 - SVHHLTRIC 

2 - DIAGONAL 

RLMARKS 

IN^JT MATRIM MUST BL A SUUARL MATRIX 

SUBRUUriNtS AND FUNCTIUN SUUPKUGAAMS REtiUlHt;0 
LUC 

MLTHUO 

tACM tLtMtNT ON 01 AGUNAC Of MATRIX IS RCPLACIO flV SCALAR C 



DO i I - 1 , N 

LUC Ml ul A;;uNAt tLtMbNT FOR ANV 

CALL LUCI 1. It IU,N,N,MS) 

KtPLACb tlAOUNAL (.LtMlNIS 

&( lUI'C 
ktlUkN 
ENU 



•IRIX STORAGE MUOt 



UC4 A 10 
.OCLA /O 
UCLA 10 
OCLA 4,0 
UCL A ^0 
UCLA 60 
UCLA ia 
UCLA 80 
OCL A 90 
OCLA 100 
UCLA 110 
OCLA l<fQ 
OCLA no 
UCLA ISO 
UCLA IbO 
OCLA 140 
OCLA 1 to 
OCLA lao 
OCLA 190 
UCLA 200 
OCLA 210 
UCLA 2 20 
OCLA :fio 
UCLA 2^0 
UCLA 2S0 
UCLA 260 
UCLA 2/0 
UCLA 2tl0 
OCLA 2ho 
.UCIA }00 

ociA no 

UCLA 120 
UCLA no 
OCLA it,0 
OCLA ISO 
UCIA JbO 
UCLA iro 
UCLA J«0 
OCLA )<<0 
UCLA iiOO 
UCLA 410 
OCLA HJO 



OCl A 



30 



106 Mathematics — Matrices: Operations 



Subroutine RADD 



Subroutine CADD 



C SUMOUTINE HAOD 

C 

C PURPOSE 

C AOO ROW Of ONE HATRIX TO flOM 0^ ANOTHER MATRIX 

C 

C USAGE 

C CALL RAJO(A<IRAtRtIR(t«r«tH,M$,LI 

C 

C 0£SCHIPnCN Of PARAHETfRS 

C A - NAiie Of INPUT HATHU 

C IRA - ROM IN MATRIX A TO HE AOJtO TO ROW IRR OF NATRlX R 

C R - NAME JF UUTPUT MATRIX 

C IHA - ROW IN MATRIX. R WHERE SJtiMATION IS DEVELOPED 

C N - NOMdER OF ROWS IN A 

C M - NUMdER Of COLUMNS IN A ANO R 

C MS • ONE OISIT NUMBER fOR STORAGE MOOE OF MATRIX A 

C - GENERAL 

C 1 - SyNNETRIC 

C Z - DIAGONAL 

C L - NUH8ER Of ROWS IN R 

C 

C REMARKS 

C MATRIX R MJST 8£ A GENERAL MATRIX 

C MATRIX R CANNOT BE IN THE SAME LOCATION AS HATRIX A UNLESS 

C A IS GENERAL 

C 

C SUSRQUriNES AND FUNCTION SUBPROGRAMS REQUIRCO 

C LOC 

C 

C METHOD 

C EACH ELEMENT OF ROw iRA Of MAfRU A IS AOOEO TO 

C CORRESPONOINS ELEMENT Of KOW IRR OF MATRIX R 



SUBROUTINE RAOO( A, IRA.R. IRR«NtM«MS.L} 
DIMENSION A( 1)* Rl II 

IR'UR-L 
00 2 J-l.M 
IR*IR+L 

LOCATE INPJT ELEMENT FOR ANY HATXIX STDRAGE MOUE 
CALL LOCnRA«J.IA.NtH,HS) 

TEST fOR ZERO ELEMENT IN DIAGONAL HATRIX 
If (lA) 1.2.1 

AOO Elements 

1 RIIR)«A(lA}^AllAt 

2 CONTINUE 
RETURN 
END 



20 



RAOO 

.RADD 
RAOO 
RADD 
RAOO 
RAOO 60 
RAOO TO 
RADD BO 
RAOO 90 
RADD too 
RAOO 110 
RAOO 120 
RAUO 130 
RADO 1^0 
RAOO ISO 
RAOO 160 
RADO I TO 
RADO IBO 
RAOO 190 
RAOO 200 
RAOO 210 
RAOO 220 
RADD 230 
RADD 240 
RAOO 2 SO 
RAOO 260 
RAOO 270 
RAOO 280 
RAOO 290 
RAOO 300 
RADO 310 
RAOO 320 
RAOO 330 
RAOO 340 
RADD 350 
RAOD 360 

.RADD 370 
RAOD 380 
RADD 390 
RAOD 400 
RAOO 410 
RAOO 420 
RAOO 430 
RAOO 440 
RADO 450 
RADO 460 
RAOO 470 
RAOO 4ao 

RADO 490 
RAOO SOO 
RADO 510 
RAOO 520 
RADD 530 
RADO 540 
RADO SSO 
RAOD 560 

RADO sro 

RADO 5B0 
RAOO S90 



SUBROUTINE CADO 

PURPOSE 

ADD COLUMN OF ONE MATRIX TO COLUMN OF ANOTHER MATRIX 

USAGE 

CALL CAOOIA,[CAtR«ICRiN.N.MS*L) 

DESCRIPTION OF PARAMETERS 

A - NAME OF INPUT MATRIX 

ICA - COLUMN IN MATRIX A TO BE ADDED TO COLUMN ICR OF R 

H - NAME Of OurPur MATRIX 

ICR - COLUMN IN HATRIX K WHERE SUHHATION IS OEVELOPEO 

N - NUMBER Of ROWS IN A AND R 

H - NUMBER OF COLUMNS IN A 

MS - ONE DIGIT NUMBER FOR STORAGE NODE OF MATRIX A 

- GENERAL 

1 - SYMMETRIC 

2 - DIAGONAL 

L - NUMBER OF COLUMNS IN R 

REMARKS 

MATRIX R MUST BE A GENERAL MATRIX 

MATRIX R CANNJT BE IN THE SAME LOCATION AS MATRIX A UNLESS 

A IS GENERAL 

SUSROUflNES AND FUNCTION SUSPROGRAMS REttUIREO 
LOC 

METHOD 

EACH ELEMENT OF COLUMN ICA OF MATRIX A IS AOOEO TO 
CORRESPONDING ELEMENT Of COLUMN ICR SF MATRIX R 



SUBROUTINE CAOOI Af ICA.R. ICR.N,H,MS«LI 
DIMENSION Alii. RID 

IR*N«<1Cr-1) 
DO 2 I>1*N 
IR-IR«L 

LOCATE INPUT ELEMENr FOR ANY mAFRIX STORAGE MODE 
CALL LOC(I«ICA(IAtN,M,MSI 

TEST FOR 2ER0 ELEMENT IN DIAGONAL MATRU 
IFI lA) 1.2.1 

ADO ELEMENTS 

1 R(IRl«R(IXI»A(lAl 

2 CONTINUE 

RETURN 
END 



20 



50 



SO 



CADO 
..CADO 
CADO 
CADO 
CADD 
CADO 
CADD 
CADO 
CAOO 
CADO 100 
CAOO 110 
CAOO IZO 
CAOO 130 
CADO 140 
CAOO ISO 

CAOO 160 
CADO I TO 
CAOO ISO 
CAOO 190 
CADO 200 
CAOO 210 
CAOO 220 
CADD 230 
CADO 240 
CAOO 250 
CADO 260 
CADO 270 
CAOO 2S0 
CADD 290 
CADO 300 
CAOO 310 
CADO 320 
CAOO 330 
CAOO 340 
CM>0 350 
CAOO 360 
.CAOO 370 
CADO 380 
CAOO 390 
CAOO 400 
CAOO 410 
CADO 420 
CaOO 430 
CAOO 440 
CADO 450 
CADD 460 
CADO 470 
CAOO 480 
CAOO 490 
CADO SOO 
CAOO 510 
CAOO 520 
CAOO 530 
CAOO 540 
CADO 550 
CAOO S6Q 
CAOO 570 
CAOO 580 
CAOO 590 



Mathematics — Matrices: Operations 107 



Subroutine SRMA 



Subroutine SCMA 



A SCALAR AND ADD TO ANOTHeR ROW 



sueftouriNE sama 

PURPOSE 

NULTlPLV ROW OF MATRIX BY 
OF THE SANE MATRIX 

USAGE 

CALL SKHAU.C.N.N,LA,LB» 

CJESCAIPTION OF PARAMETERS 
A - NAME Of MATRIX 
C - SCALAR 

h - NUMSER OF ROUS IN A 
H - NUMBER Qf COLUMNS IN A 
LA - ROW IN A TO 6t MULTIPLIED 6V SCALAR 
^a ~ Row IN A TO WHICH PRODUCT IS ADDED 

IF IS SPECIFIED, PROOOCT REPLACES ELEMENTS IN ROW LA 



REMARKS 
MATRIX 



A MUST S£ A GENERAL KATRIX 



SUeROUTlN£S AND FUNCTION SUBPROGRAMS REQUIRED 

NONE 

MErHOO 

EACH ELEMENT OF RQV LA IS MULTIPLIED 8Y SCALAR C AND THE 
PRODUCT IS ADDED TO THC CORRESPONOINS ELEMENT OF ROW LB. 
ROM LA REMAINS UNAFFECTED SV THE OPERATION. 

IF PARAMETER LB CONTAINS ZERO. MULTIPLICATION BY THE SCALAR 
IS PERFORMED AND THE PRQOUCT RcPLACES ELEMENTS in ROW LA. 



SUBROUTINt SitMAU.CtNtMfLA.LS) 
OIMENSION A( 1} 

LAJ=LA-N 
LBJ«La-N 
00 3 J=1,M 

LJCATf cLEMtNT IN BOTH ROWS 



C^eCK Lfl FOR ZERO 

IFILd} 1,2,1 

IF NOT, MULTIPLT BY CONSTANT AND AOO TO OTHER ROW 

A(LtiJI = A(LAJ)«C«'A(Lajl 
GO TO i 

OTHERWISE, MULTIPLY ROW BY CONSTANT 

AILAJI=AiLAJ)«C 

CONTINUE 

RETURN 

END 



SRMA 10 
. SRMA 20 
SRMA 30 
SRMA 40 
SRMA SO 
SRHA 60 
SRMA TO 
SRMA BO 
SRNA 90 
SRMA LOO 
SRNA 110 
SRMA 120 
SRMA 130 
SRMA 140 
SRHA ISO 
SRMA 160 
SRHA 170 
SRMA ISO 
SRMA 190 
SANA 200 
SRMA 210 
SRMA 220 
SRHA 230 
SRMA 240 
SRHA 250 
SRHA 260 
SRMA 2 TO 
SRNA 280 
SRMA 290 
SRMA 300 
SRMA 31C 
SRHA 320 
SRMA 330 
SRNA 3*0 
..SRHA 350 
SRMA 3&0 
SRHA 370 
SRHA 380 
SRHA 390 
SRMA 400 
SRMA 410 
SRMA 420 
SRHA 430 
SRHA 440 
SRHA 450 
SRNA 460 
SRMA 4T0 
SRMA 480 
SRNA 490 
SANA 500 
SRMA SlO 
SRMA S20 
SRMA 5 30 
SRHA 540 
SRHA 550 
SRHA 560 
SRHA STO 
SRMA 560 
SRMA 590 
SRNA 600 
SRHA 610 
SRMA 620 
SRHA 630 



SUBROUTINE SCHA 

PURPOSE 

MULTIPLY COLUMN OF MATRIX BY A SCALAR AND AOO TO ANOTHER 
COLUMN OF THC same MATRIX 

USAGE 

CALL SCHAI A,C,N,LA,LS) 

OeSCRIPTION Of PARAHETEBS 
A - NAHE Of MATRIX 
C - SCALAR 

N - NUMBER OF ROWS IN A 

LA - COLUMN IN A TO BE MULTIPLIED BY SCALAR 
LB - COLUMN IN A TO WHICH PROOUCT IS AOOEO 

IF Is SPECIFIED, PRODUCT REPLACES ELEMENTS IN LA 

REMARKS 

MATRIX A MUST Bt^ A GENERAL MATRIX 



MET MOO 

EACH ELEMENT OF COLUMN LA IS MULTIPLIED BY SCALAR C AND THE 
PRODUCT IS ADDED TO THE CORRESPONDING ELEMENT OF COLUMN L8. 
COLUMN LA REMAINS UNAFFECTED BY THE OPERATION. 
IF PARAMETcR LB CONTAINS ZERO, MULTIPLICATION BY THE SCalAR 
IS PERFDrtHEO AND THE PRODUCT REPLACES ELEMENTS IN LA. 



SUBROUTINE SCMAl A.CN.LA.LBI 
DIMENSION A( 1) 

LOCATE STARTING POINT OF dOTH COLUMNS 

lLA=N*(LA-i| 
1LB = N»CL6-U 

UO 3 1=1, N 

lLA=ILAtl 

ILB=ILB+1 

CHECK LB FOR ZERO 

IF(L6) 1,2,1 

IF NOT MULTIPLY BY CONSTANT ANO AOU TO SECOND COLUMN 

1 A(H_B|=A( 1LAI*C*4(IL6I 
GO TO 3 

OTHERWISt, MULTIPLY COLUMN BY CONiTANT 

Z A(ILA)=A( ILAI*C 
3 CONTINUE 
RETURN 



10 



70 



SCHA 

.SCMA 
SCMA 
SCMA 

SCMA 
SCHA 
SCHA 
SCMA 

SCHA 90 
SCMA 100 
SCHA 110 
SCMA 120 
SCHA 130 
SCMA 140 
SCHA ISO 
SCHA 160 
SCma 170 
SCHA ISO 
SCMA 190 
SCHA 200 
SCHA 210 
SCMA 220 
SCHA 2JtO 
SCHA 240 
SCHA 250 
SCHA 260 
SCHA 270 
SCMA 280 
SCHA 290 
SCHA 300 
iSCMA 310 
SCHA 320 
SCMA 3 30 
.SCHA 340 
SCMA 350 
SCHA 360 
SCHA 370 
SCHA 380 
SCMA 390 
SCHA 40C 
SCHA 410 
SCMA *2C 
SCMA 430 
SCHA 44C 
SCMA 4»0 
SCHA 4e>0 
SCMA 4 70 
SCMA 480 
SCMA 490 
SCMA 500 
SCMA 510 
SCMA 520 
SCMA 530 
SCMA 54G 
SCMA 550 
SCMA 5&0 
SCMA 5TC 
SCHA 5S0 

SCMA 590 
SCKA 600 
SCMA 610 
SCHA 620 



108 Mathematics— Matrices: Operations 



Subroutine RINT 



Subroutine CINT 



ThO rows of a HAIitlK 



I. LA, LB t 



OtSCKlPTlJ'J OF PA«AM£T£RS 
A - NAME iJF MATRIX 

N - NUMbtR JF ROWS IN 4 

M - NUMdcK Of COLUMNS IN A 

LA - ROW TfJ BE INrEftCHANGEO UllH kOH LB 

IE - ROW T3 dt IMTERCHANCeO WUH ROH LA 

REMARKS 

MArftlX A HJSr B£ A GENtKAL MAIrtlX 

SLiB^lOUI INLS AND fjNCIION SUBPROGRAMS HtOUIReo 
NtlNE 

MerriOo 

EACH £LE^E«r OF ROW LA IS INrCRCHANGEO WITH CtHtReSPONOINC 
ELtrttNT OF ROW L8 



SUSRClUriNL RINT{A,N,H,1.A,LBI 
DIMENSION A( 1) 

LAJ=LA-N 
LBJ=LB-N 
DO i J=Itr1 

LOCATE ELEMENTS IN BOTH ROWS 



iNTckCHANOe ELEMENTS 

SAVE^AI LAJ] 
A(LAJ) = A(L6J) 
3 A(LBJI=SAVE 
RETURN 

tfJO 



90 



..RINT 20 
RINT 30 
RINT «0 
RINT 50 
RINr 
RINT 
RINT 
RINT 
RINT 100 
RINT 110 
HINT 120 
RINT 130 
RINT L40 
RINT 150 
RINT 160 
R{Nr 170 
RlNT ISO 
RINT 190 
RINT 200 
RJNT 210 
RINT 220 
RINT 230 
RINT 240 
RINT 290 
RINT 260 
RINT 270 
RINT 280 
..RINT 290 
RINT 300 
RINT 310 
RINT 320 
RINT 330 
RINT 340 
RlNT 390 
RINT 360 
RINT 370 
RINT 380 
RINT 390 
RINT 400 
RINT 410 
RINT 420 
RINT 430 
RINT 440 
RINT 450 
RINT 460 
RINT 4T0 
RINT 4B0 
RiNT 440 



SUSROUTINe CiNT 

PURPOSE 

INTERCHANGe TMO COLUMNS OF A MATRIX 

USAGE 

CALL CINT(A,N,LA.LB) 

DESCRIPTION Of PARAMETERS 
A - NAME OF MATRIX 
N - NUMBER Of ROUS IN A 

CA - COLUMN TO Bt INTCRCHANCEO KiTH COLUMN tB 
LB - COLUMN to S£ INTERCHANGED WITH COLUMN LA 

REMARKS 

MATRIX A MUST BS A GENERAL MATRIX 

SUeROUTINbS AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EACH ELEMENT OF COLUMN LA IS INTERCHANGED WITH 
ELEMENT OF COLUMN LB 



30 



60 



90 



SUBROUTINE ClNTIAiNtLAtLB) 
DIMENSION Ad) 

LOCATE STARTING POINT OF BOTH COLUMNS 

ILA-N*(LA-1I 
lLB=N*(La-l} 

OQ 3 Ul,N 

1LA-ILA«1 

ILfl^Ue+l 

INTERCHANGE ELEMENTS 

SAVE=A(ILA) 
A(ILAI = A( ILBI 
3 A(1LB)=SAV£ 
RETURN 
END 



^ CINT 

i CINT 

CINT 
CINT 
CINT 
CINT 
CINT 
CINT 
CINT 
CINT 100 
CINT 110 
CINT 120 
CINT 130 
CINT 140 
CINT 150 

CINT 1«0 

CINT 170 
CINT 180 
CINT 190 
CINT 200 
CINT 210 
CINT 220 
CINT 230 
CINT 240 
CORRESPONOINGcINT 250 
CINT 260 
CINT 270 

CINT 280 

CINT 290 
CINT 300 
CINT 310 
CINT 320 
CINT 330 
CINT 340 
CINT 350 
CINT 36C 
CINT 370 
CINT 380 
CINT 390 
CINT 400 
CINT 410 
CINT *20 
CINT 430 
CINT 440 
CINT <,50 
CINT 46C 
CINT 470 
CINT 480 



Mathematics — Matrices: Operations 109 



Subroutine RSUM 



Subroutine CSUM 



SUBKOUTINE RSUM 

PURPOSE 

SUN ELEMENrS Of EACH ROW TO FORM COLUftN VECrOH 

UiAQt 

CALL ASUN (AiR.N.M.nSI 

OcSCRlPTlON Of= rARAMErERS 
A - NAME OF INPUT MATRIX 
(t - lUMe OF VECrOR OF LENGTH H 
N - NUNBfcR OF ROUS IN A 
M - NUHBER OF COLUMNS IN A 
MS - 0N€ DIGIT NUM8ER fOA SrORAGfc MODE Of NATftU A 

- GENERAL 

1 - SYMMETRIC 

2 - DIAGONAL 

REMARKS 

VECTOR R CANNOT tt IN THE SAME LOCATION *S MATRIX A 
UNLESS A IS GENERAL 

SUBROUTINES *N0 FUNCTION SUSPROGRAMS REQUIRED 
LOC 

METHOD 

ELEMENTS ARE SUMMED ACROSS EACH ROW |NtO A CORRESPONOINC 
ELEMENT OF OUTPUT COLUMN VECTOR ft 



20 



$0 



SUaROUTINC R$UN(A«RfN«MiMSJ 
DIMENSION AdI.Rd) 

00 3 I-1«N 

CLEAR OUTPUT LOCATION 
Rdl-O.O 
00 ) J-l,M 

LOCATE ELEMENT FOR ANY MATRIX STORAGE MODE 
CALL LOC(I.J*IJ.N<M«MS> 

TEST FOR 2£R0 ELEMENT IN DIAGONAL MATRIX 
IfdJJ 2»3«2 

ACCUNULATE IN OUTPUT VECTOR 

iJ5iJJL-R*l»***l4J 
i CONTINUE 
RETURN 

END 



RSUM 
..RSUM 
RSUM 
RSUM 
RSUM 
RSUM 60 
RSUM 70 
RSUM 80 
RSUM 90 
RSUM too 

RSUM no 

RSUM L20 
RSUM 130 
RSUM L40 
RSUM ISO 
RSUM 1*0 
RSOH 110 
RSUM 180 
RSUM 190 
RSUM 200 
RSUM 210 
RSUM 220 
RSUM 2i0 
RSUM 24^0 
RSUM 250 
RSUM 260 
RSUM 270 
RSUM 280 
RSUM 290 
RSUM 300 
RSUM 310 
RSUM 320 
..RSUM 330 
RSUM 340 
RSUM 3$0 
RSUM 3A0 

RSUM aro 

RSUM 380 
RSUM 390 
RSUM 40C 
RSUM 410 
RSUM 420 
RSUM 430 
RSUM 4.^ 
RSUM 450 
RSUM 460 
RSUM 4 70 
RSUM 460 
RSUM 490 
RSUM 500 
RSUM $10 
RSUM 520 
RSUM 530 
RSUM S40 
RSUM $S0 
RSUM 560 
RSUM 570 
RSUM 580 
RSUM 540 



suaituuriNE csjH 

PURPOSE 

aUM ELEMENTS OF EACH COLUMN jO FORM ROU VECTOR 

USAGE 

CALL CSUMl A,R,NtM(HSI 

DESCRIPTION OF PARAMETERS 
A ~ NAME OF INPUT MATRIX 
ft - NAME (Jf VECTOR OF LENGTH M 
N ' MJM8EK OF ROWS IN A 
H - NjMa£R OF COLUMNS IN A 
MS - ONE DIGIT NUMBER FOR STOftAGE MOOE OF MATRIX A 

- GENERAL 

1 - SYMMETRIC 
2-01 AGONAL 

REMARKS 

VECTOR R CANNOT BE IN THE SAME LOCATION AS MATRIX A 
UNLESS A IS GENERAL 

SUdftOUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
LOC 

METHOD 

i:Lt:MeNrS ARE SUMMED DOWN EACH COLUMN INTO A CORRESPONDING 
ELEMENT OF OUTPUT ROU VECTOR R 



SUaROUriNE CSUMUtR(N*M.MS) 
DIMENSION Atll .Rf 1) 

DO 3 J'l.H 

CLEAft OUTPUT LOCATION 
RIJI-0.0 
DO 3 I-l.N 

LOCATE ELEMENT FOR ANY MATRIX STORAGE MODE 
CALL LDC(I.J.1J.N.M»MS| 

TEST For zero element in diagonal MATRIX 
IFIIJI 2(3f2 

ACCUnjLATE IN OUTPUT VECTOR 

2 R1J1-RIJ|«-AI IJI 
9 CONTINUE 

RETURN 

END 



30 
40 



60 



90 



CSUM 

...CSUM 

CSUH 

CSUM 

CSUM 

CSUM 

CSUM 

CSUM 

CSUM 

CSUM 100 

CSUM 110 

CSUM 120 

CSUM 130 

CSuM IM 

CSUM ISO 

CSUM 160 

CSUM 170 

CSUM 180 

CSUM 190 

CSUM 200 

CSUM 210 

CSUM 220 

CSUM 2)0 

C&UM 240 

CSUM 250 

CSUM 260 

CSUM 270 

CSUM 2S0 

CSUM 290 

CSUM 300 

CSUM 310 

CSUM 320 

..CSUM 330 

CSUM 340 

CSUM 350 

CSUM 360 

CSUM 370 

CSUM 380 

CSUM 390 

CSUM 400 

CSUM 410 

CSUM 420 

CSUM 430 

CSUM 440 

CSUM 450 

CSUM 460 

CSUM 470 

CSUM 480 

CSUM 490 

CSUM 500 

CSUM 510 

CSUM 520 

CSUM 530 

CSlM 540 

CSUM 550 

CSUM 560 

CSUM 570 

CSUM 580 

CSUM 590 



110 Mathematics — Matrices: Operations 



Subroutine RTAB 

The function of this subroutine is graphically dis- 
played by Figure 7 (see description under ''Method" 
in the program listing) . 



Matrix A 



3<iB C 



Vector B 



6(1) 



— — — RdWJ — — — 



Matrix R 



L+1 



S(J) 



Vector S 



S(L+1) 



Figure 7. Row tabulation 



!i.CliC(.III>.t mn 



KELuie Bcks [f > H<is|> ic FC«» < sinnnr r<liiix 






MfSrft.n.f < 



CESCriFiick cf ftntrtjtn 

» ~ t,tH Cf IkCLl HAIRI* 

t - »iH Cf IkFLI VfCIO Cf ICNCIf k COKIMkC «t» 
• - »"l Cf CCIPCI IHI«H CCflUlklKG S<."B««» CF lOli 0*T«. 
II IS IMIIALLf SCT IC iCHC BIT IH« SceHCLTlNE. 

► : i;"[tS'cf'ic'i; r")" " '"■"' '** ""'■-« «^"" 

► - fcLI-etB Cf CCLLfhS Ih « «hC ft 
1 - I.LI>eER CF aCteS I*. It 

^S - Cfct CICII hereto fCP STCR«C€ l-CCI Gf r>«Ifl[X A 
CEkEKAL 



1 






P IS «lk«yS A GCfEVil HlTftlK 



StP«ClliM5 ifcC flfcCflCN StePRCCRA^S RECCIBEC 
ICC 
FfCC 

l-tT^CC 

•ChS CF C*T* U f*TRU J AR£ lABULlUC a«£EC Cfc Tt-£ KEY 



ftlAtJ 10 
.«T*6 20 
RTAe 10 

RTia 40 

RTAR 30 

ATAfl 60 

RTAb 70 

ATAe 80 

AlAe 9C 

HrAa 100 

RTAe 110 

fir«B 120 
KfAd 130 
ftTAe 140 
RTAS 150 
RTA8 160 
KTAB 170 
ftfAO IflO 
RTAB 190 
BTAB 200 
RTAe JIO 
RTAe 220 
RTAB 230 
fllAB 240 
RTAB 250 
RTAB 260 
RTAa 2T0 
RTAB 2S0 
RTAe 290 
RTA8 100 
RTAB 310 
RTAd 120 
RTAe 330 
RTAS 340 



CCfcTAINEC Ih VECTOR «. I^E FLOAIIKG PClKT Kl.t'eER \H Sill If RTAS 350 
TRLfcCAieC TC fCR*- J. IH n^ RCh CF A |$ *ODEC IC THE JIH RTAB 360 
RCh Cf R Eief»efcT e» CLEHC^I A^O CfcC is ADOEO IC S(JI. IF J RTAB 3T0 
li ftCT etThCEK C«t AHC I, C^E IS AOCEC ID SIHl. THIS RTAd 380 

fRCCiCLRC IS REFEAIEC fCR CvER) £tE#EM l^ VECTOR B. RTAB 390 

IfCh CC^RLEIICfc. Il-E CUIPLT KATRlA R CC#iTAII.S « SUfMARV CF RTAB *00 
?5^<Vc " S^CiFlEC eir VECTCB «. EACH ELEKEM Ih VECTCR S RTAB 410 
CCfcTAIAS t COCM Cf Thf kLr-BER Cf RCkS Of A l.5€C TC FCRM TPERTAB 420 
CCRRESfthCUC RCh CF R. EiE^-EKT S<L«1I CCMAIUS A COufcT OF RTAB 430 
Tl-E fttrEER CF RCkS Cf A fcCT UCLliCEC ill R AS A RESULT CF J RTAS 440 
etIAfi LESS It-Afc C^£ CR GREATER T^A^ 



SLEfCLIUE flACIA.e.f .S.f.^.^S.Ll 

clr'E^slCA A(it.efii.aiii«$(u 



CLEAR CUIRLT AREAS 



IT.r.L.Cl 



CAll ICCir* 
EC IC 1R-1.I1 
f>IIRJ-C.C 

cc jc i:-i.L 

SflSI-C.C 
SU411-C.C 

cc (C l-l.fc 

ICSI FCR If-C KEY CtlSIOC Tt-E RAKGC 

jA-riii 

If (JR-ll SC.4C.3C 
IF IJR-L) 4C.4C.5C 



ACC PCh Cf A TC RCh Cf R AfcC 1 TC CCLM 

CALL RACC |A, |,R,J|i,ti,f>.|>S*LI 

S(J(I«SIJRI«1.C 

EC TC CC 

S(L*II>!<141)4|.C 
CCAIIhLE 

RETCRA 
(AC 



RTAS 450 
RT*:; 460 
.RTAB 470 
RTAfi 4B0 
RIAB 4'30 
RTAB 500 
RTAB 510 
RTAB 520 
RTAB 530 
RTAB 540 
RTAB 550 
RTAB S60 
RTAB 570 
RTAS 580 
RTAB 590 
RIA6 600 
RTAB 610 
RTAB 620 
RTAS 630 
RTAB 640 
RTAB 690 
RTAB 660 
RTAB 670 
RTAS 6S0 
RTAS 690 
RTAB 700 
RTAB 710 
RTA8 720 
RTAB 730 
RTAB 740 
ATAfl 750 
RTAS 760 
RTAB 770 

RTAB reo 

RTAB 790 



Mathematics—Matrices: Operations 111 



Subroutine CTAB 



Subroutine RSRT 



The function of this subroutine is graphically dis- 
played by Figure 8 (see description under "Method" 
in the program listing) . 



i 


M 


I [ Matrix A 



column J 
L \/ 







Matrix R 





B(l) 



S(J) S(L+1) 
J i 



M 
Vector B 



L+1 
Vector S 



Figure 8. Column tabulation 



stefCLiihE cue 



lfl> IC fQHf « SOfHAP> MATRIX 

tescunic* cf n»«nte«s 

t - XAME Cf IKPLT PAIRIX 

t - »»|il Cf UPLI VECIO CF LenGtf !■ CCMllNlkC K£» 
B - A^Pt Cf CCTPUT fi«1>(lx CCMAIMM; Siif'C'flT CF CCtUMN 0Ar«.CTA6 
il IS IMtlALLY SE1 TC 2EffC ev THIS SLflfCL T 1 NC . 

s - ^»^^ CF clipli vecice cF lEkCiF l»i ccmaimkg ccu^TS 

^ - NtCeFH Cf NChS IN A A^C « 

^ - ^tP€Ell CF CCLCNS If A 

I - HLfeeH CF CCLLfkS Ik » 

► 5 - CKE CIGIl M.^ilEf FLF SICfiAGE ^CCE CF ^AlfllX A 

C - CEKEBAL 

1 - iYffElflC 

2 - CI'CCNAL 



FiFfAFBS 

f/IFlX 



H IS AlhAVS A CEhEFAL BAIRIX 







CTAO 


30 


CTAH 


40 


CT*6 


SO 


CT*8 


60 


CT»B 


TO 


CT4B 


10 


CI*B 


90 


CTAB 


100 


CT*B 


no 


CTAB 


i^O 


CTAa 


130 


CTAB 


140 


CTAB 


150 


CT*e 


160 


CTAB 


170 


CTAB 


lao 


CTAfl 


191 


CTAB 


?an 


CTAd 


210 


CTAH 


?M 


CT46 


?»0 


CTAB 


?40 


CTAB 


?sn 


CTAB 


260 


CTAB 


2 70 


CTAB 


?«0 


CTAB 


^90 


CTAB 


300 


CTAB 


310 


CTAB 


J 20 


CTAe 


530 


CTAB 


340 



^LtlRCLTUtS >hC f^.^CIIC^ SiefUCGHAI-S KtCLlKtC 

LCC 

t/tc 

^■£T^ct 

CCLLPhS CF CAT/ it. fAIFl* A ARE lAEt-LATEC flAStC CK Th£ KEV 

CCMAIdeC IN VfCTCH », Tt-L fLCAHKC PCINI NC^eES IN BUI IS CTAB 3SQ 

IfLUCAICC IC fCPf J. 1^■^ lit- cCtO*^ Cf * is «CC(C TO IK£ JTHCTAB 360 

CdLKK CF f/TtllX AKC Cht IS ICOEC IC S(J). IF THE V'LtE Ct-CTAB 3r0 

J li NCT eE1hfC^ I ANC It C^E IS ACCEC TC SIL«i) CTAB 380 

LFCh CCfFlfllCh. Tt-E CCIFlT fATrilx U CChTAIhE A SUHMARV CF CTAd 390 

CClLCh CAT* A< iPiClflU t» WECICH E. EACF ElEfEfcT U VECTOBCTAB 400 

* CC^TAJ^S A CCCNT CF TfC MjfB£« CF CCLUHhS CF A tStO TC CTAB ^10 

FCVC C. ELffEftT SIL*l) CCOTAIhS T»-E Mj^'eCfl OF CLLUHNS CF A CTAA 420 
fCI UCLCCEC I*, f) AS A Ht^LLT CF J BEIKG lESS THAN ONE CK 
CfC/lE^ IFAA L. 



SCEiiCCTJKE CTAE(A,e,t),S.K,F',f<.ll 

cir'EfSUf Aii}.eiit,Dui,s(ji 

CLEAfi CtlFLT «fiEA< 

CAil LCClN.l. IT.h.L.CI 
CC K l<:>I.IT 
. «(lt))-C.C 
CC 2C l£-liL 
;il5l-C.C 
SU«1I-£.C 

CC tC ■■l.f' 

IE<I fCf) Th£ KEt CLIflUE Tt^t PA\6E 

Jfl'eill 

IF IJ«-li 5Ct4Ct3C 

If UP-t » 4C,«C,5C 

<CC CCtCh Cf A IC CCiUCN CF fi AKC I IC CCLM 



CALl CACC («< ltaiJR.h.l'.''S.LI 

S1Jf))«S(J|l)*l.C 

CC IC fC 

S(L*l)<5(i4ll*l.C 
CCfllflE 

FETLttf 
(Al 



CTAB 430 

CTAB 440 

CTAB 450 

..CTAS 460 

CTAB 470 

CTArt 480 

CTAe 490 

CTAQ 500 

CTAB 510 

ciae 520 

CTAB 510 
CTAB 540 
CTAB 550 
CTAB 560 
CTAB 570 
CTAB 580 
CTAB 590 
CTAB 600 
cm 610 
CTAH 620 
CTAH 6)0 
CTAB 640 
CTAB 650 
CTAa 660 
CTAti 670 
CTAtJ 690 
CTAB 690 
CTAB 700 
CTAfl 710 
CTAB 720 
CTAO 7 30 
CIAB 740 
CTAB 750 
CTAB 760 
CTAB 770 
CIAB 7(*0 



SUtS-^CUTINE kSRT 

^G<tT AQwS CJf A MATRIX 

USA^fc 

CALL kSRr(A.6,R,N,M,MSI 

Jt5c«IPTI0N UF PAftAHCTCRS 

A - NAHc OF I.NPUI MAIrtlX 10 oE SORTED 

d - NAME QF IN.>UT VECI3X MHICrl L-QhTAINS SORTING KEf 

R - NAME CF SOKTEL OuTPjT MATRIX 

N - NuMfldft OF ROWS IN A Ai^jO R AND LENGTH OF B 

.1 - iNUMtJ^R df COLUMNS IN A ANl; R 

MS - QUE JIGII NUMBtR FOR STJ-tA&fc MODE OF MATRIX A 

- General 
i - svmmeiric 
2 - diagonal 

RcMARKS 

HATRU R CANiViUr BE IM THE SA^^E LOCATION AS MATRIX A 

^iATRIX R IS ALMAYS A GENERAL KATRIX 

1^ MUST Bt GREATER THAN ONE. 

SUfcRCjTlf^ES ANO FUNCTIUN SUBPROGRAMS REQUIRED 
LCi. 

METriOO 

RO*iS OF INPUT MATRIX A ARt SORfEO 10 FORM OUTPUT MATRIX R. 
THE SukTtO RJM SEQUENCt IS OETERMINED BY THE VALUES OF 
::LfcMENTS IN COLUMN VECTOR 6. THE LOWEST VALUED ELEMENT IN 
B WILL CAUiE THE CCRft ESPONOING ROW OF A TO BE PLACED IN THI 
FIRST ROW OF R. THE HIGHEST VALUED tLEHENT OF 6 WILL CAUSE 
The CORRESPONDING ROW Of" A TO BE PLACED IN THE LAST ROW OF 
R. IF DUPLICATE VALUES EXIST IN Si THE CORRCSPONi}! NG ROWS 
OF A ARE MOVEO TO R IN THE SAME ORDER AS IN A. 



SUBikOUTlNE RSRTI A,B,R,N,M,MSI 
LtlMENilON Al 1 I , S( II tRI U 

MUVE SORTING KEY VtCTUR TO FIRST COLUMN OF OUTPUT MATRIX 
AND BUILD ORIGINAL SEQUENCE LIST IN SfcCONQ COLUMN 

DO IJ 1=1, N 

R< I i = ii n 

I2=ItN 
; R( 121= I 

SORT ELEMENTS IN SORTING KEY VECTOR (URIGIMAL StdUENCE LIST 
IS REStaUENCEG ACCORDINGLY) 

L = N*l 
; ISORr=0 

L = L-1 

DO 40 I=2,L 

IF1R( I )-Rt I-l( ) 30, 4C,4C 
: I SORT = 1 

RSAV£=R(1I 

R(l )=R1 I-U 

R(l-ll=RSAVt 

12=ItN 

SAV£R=R( I2J 

R(I2)=R( 12-1) 

t<( 12-lJ^SAVER 

CONTINUE 

IF( ISORTJ 2C,5D,2C 

MOVE ROWS FROM MATRIX A TJ MATRIX R (NUMBER IN SECOND COLUMN 
Of A REPRESENTS ROW NUMBER OF MAIRIX A TO BE "OVEOi 

DO 8-3 1=1tN 

GET ROW NUMBEK in MATRIX A 

12=I*N 
IN=R(I2I 

IR=1-N 

DO bJ J=ltM 

LOCATE ELEMENT IN OUTPUT MATRIX 
[R^IRtN 

LJCATc EttMcNT IN INPUT MATRIX 
^ALL LOCI IN.J.IA.N.M.MSI 

TcST rOR ^cRO cLEMENT IN OUGCNAl MATRIX 
IF( lAl 60, 7C,oC 

MJVc iiLEMtNT 10 OUTPUT MATRIX 

kl IRl^dl lAt 

GO TJ 30 
R( IRI=0 

CUNTfNJt 

kETURN 

END 



50 



RSRT 
..RSRT 
RSRT 
RSRT 
RSRT 
RSRT 
RSRT 
KSRT 80 
RSRT 90 
RSRT IOC 
RSRT 110 
RSRT 120 
RSRT 130 
RSRT 140 
RSRT 150 
R^RT 16C 
RSRT 17C 
RSRT 180 
«SRT 190 
RSRT 2G0 
RSRT 210 
RSRT 220 
RSRT 230 
RSRT 240 
RSRT 250 
RSRT 260 
RSRT 270 
KSRT ^80 
RSRT 290 
RSRT 300 

RSRT :io 

RSRT 320 

RSRT 330 

RSRT 340 

RSRT 350 

RSRT 360 

RSRT 3 70 

RSRT iSO 

RSRT 390 

RSRT 400 

,RSRT ".lO 

RSRT 420 

RSRT 430 

RSRT 440 

RSRT 450 

RSRT 460 

RSRT 470 

RSRT 480 

RSRT -vgo 
rSrT soo 
RSRT 510 
RSRT 520 
RSRT 530 
RSRT 540 
RSRT 550 
ftSRT 560 
RSRT 570 
RSRT 560 
RSRT 590 
RSRT 600 
RSRT 610 
RSRT 620 
RSRT 6 30 
RSRT 640 
RSRT 650 
RSRT 660 
RSRT 670 
RSRT 680 
RSRT 69C 
rSrT 700 
RSRT 710 
RSRT 720 
RSrT 730 
RSRT 740 
RSRT 750 
RSRT 760 
RSRT 77C 
RSRT 780 
R.SBT 790 
RSRT 8C0 

RSRT eio 

RSRT 820 
RSRT 830 
RSRT 840 
RSRT 850 
RSRT a6C 
RSRT 870 
RSRT B80 
RSRT 990 
RSRT 900 
RSRT 91C 
RSRT 920 
RSRT 930 
RSRT 94C 
RSRT 950 
RSRT 960 
RSRT 970 
RSRT 9tJ0 
RSRT 99C 
RSRTlOQO 
kSRTlCiO 
KSkTlC2C 
RSRT1030 
RSRT1C4C 
RSRtl(,50 



112 Mathematics — Matrices: Operations 



Subroutine CSRT 



Subroutine RCUT 



10 



iUoRCjriNE CiKT 



PJkfOSC 

SOKT CULUMMS OF 



HATKIX 



CJciCKlPriCN CF *'ARAMtT£kS 

A - f.AMt U^ INPUT MATHlx TO bt SCft TtO 

J - NAKfc oF INPUT VEtTjfl WHICH caNTAJf^S iURTING Kd V 

A - ^AKE Of SUHItO IJUfPJT MATRIX 

N - r*JHdLR Of «OHS IN A ANO k 

M - NUMUER Uf COLUMNS IN A AN.; R ANO Lt:NCTH CIF B 

MS - out OIOIT hUMBtK FOR STOKAGfc MOOE Of HATRIX A 

- G£Nfc«AL 

1 - SYMMETRIC 
2-01 AGuNAL 

KLHaRkS 

MATRIX R CANNJT BE IN THE SAME: LOCATIUh AS KATMlX A 

MATRIX t< IS ALWAYS A GENERAL MATRIX 

M MJST Bt GREATER THAN ONt . 

SUBRLuriNFS ANO FUNCTION SUBPROGRAMS REQUIRED 
LOC 
CCPY 



CSRT 
..CSRI 
CSRT 
CSRT 
CSRT 
CSRT 

CSRI 70 
CSRT 80 
CSRT 90 
CSRT ICC 
CSRT 110 
CSRT 12P 
CSRT HO 
CSRT 140 
CSRT ISO 
CSRT 160 
CSRI 170 
CSRT 180 
CSRT 190 
CSRT 200 
CSRT 210 
CSRT 220 
CSRT 230 
CSRT 2*0 
CSRT 250 
CSRT 260 
CSrT 270 
CSRT 280 
CSRT 290 
CSRT 300 
CSRF 31C 

MfcTHCC CSRT 32C 

CCLUMNS UF Input matrix a are sorted to form output matrix CSRT 33C 
R. THE SOKTEO column SEQUENCE IS OETERMINiD BY THE VALUES Of CSRT 34C 
ELEMENTS IN ROW VECTOR 6. THE LOWEST VALUED ELEMENT IN CSRT 350 

B WILL CAUSE THE CORRLSPONOINC COLUMN Of A TO S£ PLACED IN CSRT 360 
THE FIRST COLUMN Op R. THE HIGMfcST VALUED CLEMENT OF 6 WILL CSRT 370 
CAUSE THt CORRESPONOING ROM OF A TO BE PLACED IN THE LAST CSRT 380 
COLUMN OF R. IF DUPLICATE VALUES EXIST IN B, THE CSRT 390 

CORfteSPONJlNG CULUHNS Of A ARE MOVED ID R IN THE SAME ORDER CSRT 40C 
AS IN A. CSRT 41C 

CSRT 420 
..CSRI 430 
CSRT 4*0 
CSRT 450 
CSRT 460 
CSRT 470 
CSRT 48U 
CSRT 490 
CSRT 500 
CSrT 510 
CSRT 520 
CSRT 530 
CSRT 540 
CSRT 550 
CSRT S60 
CSRT 5T0 
CSRT 560 
CSRT 590 
CSRT 600 
CSRT 610 
CSRT 620 
CSRT 630 
CSRT 640 
CSRT 650 
CSRT 660 
CSRT 670 
CSRT 680 
CSRT 690 
CSrT 700 

CSRT no 

CSRT 720 
CSRT 730 
CSRT 740 
CSRT 75C 
CSRT 760 
CSRT 770 
CSRT 760 
CSRT 790 

CSRT aco 

CSRT aio 
CSRT 820 
CSRT 830 
CSRT 840 
CSRT 850 
CSRT 860 
CSRI 870 
CSRT 680 
CSRT 890 
CSRT 900 
CSRT 910 
CSRT 920 
CSRI 930 
CSRT 940 
CSRT 950 
CSRT 960 
CSRT 97C 



SUakUuIlNc CSfir(A,6,ft,N,M,MSI 
DlMtN^ICN A( l],a( U ,R( 1 ) 

MLiVE SURIING Ktr VECTOR TO FIRST ROW OF OUTPUT MATRIX 
«Nl) build original SfcOUtNCE LIST IN SECOND ROW 

lK=i 

DO IC J^l.M 
ft(lK)^b( J I 
R( IK«i 1=J 



SORT ELEMENTS IN SORTING KEV VECTOR (ORIGINAL SEQUENCE LIST 
IS RtSfcyUENCeO ACCOROINGLVt 

L=M+1 
r ISORI=0 

L = L-l 

IP=l 

IQ=N+l 

DU 50 J=2,L 

iF(R{ Iy]-r{( IP) I 3C,4C,4C 

I SORT = I 

RSAVt=R(IO) 

Rll JI-R(IP» 

a( IPI=^SAVE 

SAVER=«( U*ll 

ftt Iw»l)=Rl IP»l) 

RCPtU^SAVER 

lP=IptN 

lU-I J*N 
I CONTINUE 

iFl liO^TI 20.oi.,JC 

MOVE CJLUHNS FrJm MATRIX A TO MATRIX R (NUMBER IN SECCND ROW 
OF R -ttPRtSENTS COLUMN NUfOER OF MATRIX A TO BE MOVED) 

10^ -N 

CO TC J=1..M 

10= lU+N 

GET CL.LUMN NUMBER IN MATRIX A 

I2=IJ*^ 
IN=R( 121 

M^Vt COLUMN 

IR-I J+1 

CALL CCPVU,1N.R( IK J.N.r.MSl 

CONI li\Jt 

HcTJRn 



bJoRLUriNE KCdl 

Pj^PCSt 

PARIITIUN A .4ATRIX oETMttN SPdCIFIfeO ROwS TO FORM TWO 
RESULTANT MATRICES 

USft>i£ 

CALL RCJT ( a.L.Rt S.N.^I.ISI 

UtiCRIPIlUN JF PAKAMETcRS 
A - NANc Of INPUT MAT.*U 

L - COn Jf A ABOVE WHICH PAKTIflONlNG TAKES PLACE 
K - NAMt OF MATRIX TO dc FORMdJ FROM UPPER PORTION Of - 
S - NAMc OF MATRIX Tu d£ FJRMcO FfiUH LOWER PORTION QF , 

a - iHUMdcR ue «QwS IN * 

M - NUMdtA u>= Columns In a 

MS - UMt JloIT KtUMSER fOA STJ^^AGfc MODE CF MATRIX A 

- CENE-tAL 

1 - SYMMETRIC 

2 - DIAGDNtl 

RcMAfiKS 

MATRIX H CAN.40T ai IN ^AME LOCATION AS HATRIX A 

MATRIX s Cannot be in same looaiion as matrix a 

HATKIX R CANNOT BE IK SAME LCCAriON AS MATRIX S 
MATkIX a ANC MATRIX S ARE ALWAYS G£N£kAL MATRICCS 

SUJttOUTlNfcS ANO fUNCFIJN SUIl.PRCGR AMS H£QUIR£D 



NcTnL,U 

ELEMtNTS OF MATRIX A AdJVE ROW L ARE MQVEu TG FORM MATRIX 
JF L-1 ROWS ANJ M COLUMNS. tLtMENIS OF MATRIX A IN ROW L 
ANU B£LO*« ARE MU^itO fC FORM NATkIX S OF N-L*l ROWS AND M 
COLUMNS 



SUoKUUlli^E KLJI < A|L ,R,S.N| M,i 
JlMtMilLN A( 1 (,R| II ,S( U 



I s = i; 

DO 7C J=1.M 
uO 70 l-l.N 

FIND LOCAIION IN OUTPUT MATRIX ANJ SET TO ^ERO 

IF( 1-L » tClCU 
', IS=ii»l 

SI isi^a .c 

CO TJ ic 
1R=M*1 

Kt 1HI = J.j 

LuCAIt cLEHtNf Fu.4 ANY MATkIX STJ<AG£ HDDfc 
CALL ..oCt 1, J.IJ.N.'i.MSl 

Ttsr FJK zt^j elcment in jiaGunal matrix 

IFIIJI <.],70i4i 

UtTER.IINt -HETHcR AfauVc U? BcLJW L 

IFU-L) aCSO.SC 
^l 1S1-A(|J| 

JJ TJ 7C 

.r( IR}^d( I J) 

CUNTi MJt 

■(tTURN 
tNO 



RCUT IC 
. .RCUI 20 
RCUT 30 
HCUT 40 
RCUT 50 
RCUT 60 
KCUT 7C 
RCUr 8C 
RCUT 90 
RCUT iCO 
RCUT 110 
RCUT 120 
RCUT 130 
RCUT 140 
RCUT 150 
RCUT 160 
RCUT iTC 
RCUT I8U 
RCUT 190 
RCUT 20c 
RCUT ?1C 
RCUT 220 
RCUT 2 30 
RCUT 240 
RCUT 250 
RCUT 2 60 
RCUT 2 70 
RCUT 2B0 
RCUT 290 
RCUT 300 
RCUT 310 
RCUT 320 
RCUT 330 
RCUT 34O 
t RCUT 350 
RCUT 360 
RCUT i70 
RCUT 380 
RCUT 390 
..RCUT 4C0 
RCUT 410 
RCUT 1*20 
RCUT 430 
RCUT 440 
RCUT 450 
RCUT 460 
RCUT 470 
RCUT 4B0 
RCUT 490 
RCUT 500 
RCUT 5iC 
RCUT 520 
RCUT 530 
RCUI 54C 
RCUT 55C 
RCUT 560 
RCUT 570 
RCUT 580 
RCUT 590 
RCUI oCO 
RCUT 610 
KCuT 620 
RCUT «i30 
RCUT 640 
RCUT 650 
RCUT 660 
RCUT 6 70 
RCUT 680 
RCUT 690 
RCUT TOO 
RCUT 710 
RCUT 720 
RCUT 730 
RCUT T-tO 
RCUT 750 



Mathematics — Matrices: Operations 113 



Subroutine CCUT 



Subroutine RTIE 






SlIWcEN SPcClFlfcO CUI.UMN5 T(j FORM TWO 



jr (A, L. R.S.N. 



,nsi 



Kl^TlO'^ Jf I'A'^AMeitKS 

- Nttrtc Jr INPUT f1AT-(IX 

- COLtJ.<M Jf A rU IHE LErT OF HHfCH PA^T 1 1 lONI Nj lARfc 
PLACE 

- NaMc Ur SATSIX rO lie fORM£J FROM LtFf PO^^TION OF A 

- IM4.1C a*" '4ATRU TU tJE FOkM^O FftOM RIGHT PORTION OF 

- '♦JHOCS Ur HUwS IN A 

- A.lJM5->» Jf COLUMNS I.M A 

S - ONE Jl.iir NU?1dtS FOK SrjKflGE MOPE OF MAfrtU A 
C - k^t-McRAL 

i - SYMrtEFRIt, 
^ - Ui AGONAL 



MAr*tU 
.lATRlX 

lOC 



CANNOT Be IN SAME L0C4I10N AS MATRIX A 

wANNJT BE IN SAHE LOCAriCN AS MATRIX A 

CAMNOT BE l^ SAMe cOCXTION AS HAIftlX S 

A.O MATRIX S ABt ALilAl^i GtNtRAL MAMlCci 

AHJ FJNCFIUN SUBPROGRAMS RtOOIREO 



cLtMcM i Or MATRIX 
F^.«M MAIRIX R OF N 

MATRIX A IH COlUM\ 
MATKIX S JF N RGhS 



CCUT 
.CCuT 
CCUT 
CCUT 
CCUI 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 

CCuT 
CCUT 
CCUT 
CCUI 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 

ccur 
CCUT 

ccur 

CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 

ccur 

CCUI 
CCUT 



OiMENWC.'j a< u,Ri n .^( 1 1 

JU 7J J = i.>v 



uurt'uf matrj X 



ScT TO ZErtO 



iF(j-L) 2J,i:,i: 

SI ISIO.O 
&C TJ 3C 
21. IR=I«*1 

LUCAlt LLLMcNI FOR ANY MATRIX SIJsASE huiJE 

j; I.JLL LJCt I.J,IJ.r4..>1.M5) 

reSr rOft lc<0 ti-tMcNT IN OIAJOiMAC MATRIX 

1F( IJI ^C. 70. -.0 

iJcIc-^MIJc HHcIHcR RIGHT J-* L£FF Jr L 

•tC IflJ-Ll aJiiC.JD 
aC b( 1 SI = A( IJ t 

iu IJ T; 
&C ^( IR) = A( IJ t 

RtTURN 



A TJ THE LEFT OF COLUMN L ARE HOVtO TO 

ROMS A.MO L-i COLUMNS. ELtMENTS OF 

L A^O TO \Hc RIGHT Of L ARE MOVED TO FORMCCUT 

AND M-L«l COLUMNS. CCUT 

CCUT 

, CCUT 

CCUT 
CCUT 
CCUT 
CCUI 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CcUT 
CCUI 
CCUI 
CCuT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUI 
CCuT 
CCUT 
CCUT 
CCUI 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUT 
CCUI 
CCUI 
CCUT 
CCUT 
CCuI 

ccur 

CCUI 



no 

1*C 

I 50 
L&O 
170 

Lao 

l-SO 
200 

no 
zzo 

a-to 

250 
260 
270 
zao 

290 
300 
310 
j20 
330 
340 
350 
360 
370 
380 
390 
AOO 
*10 



*90 
500 
510 
5 20 
530 
54C 
550 
563 
570 
580 
59C 
600 
6I0 
620 
630 
640 
650 
bbO 
blC 
680 
690 
700 
TIO 
720 
7 30 
740 
750 
760 



RUr<<»USE 

AOJUIN J^C .HAIftlCES H I f H SAMfc l-OLUMN OlMgNSlON TJ FORM ONE 
^£SJLTANI HATRix (SEE METHJDt 



JSAiE 

LAlL Hllt I a.6.R.N.M.HSA,MS 



. ) 



Oes.;«IPTluN QP r'AKAIEIERi 

A ' NAME Jr FIRST (NPUl MATRIX 

J - NAME OF icCUNO INPUT MATRU 

•< - NAMc OF OUTPUT rtAlKlX 

N - NUHBcR Df RJwS ts A 

•1 - NUMtJtR Of COLUMNS IN AtB.K 

.ISA - ;;Nt JIjIT NUMbtR FOR STORAGt MQOt OF MATRIX A 

J - GENERAL 

I - SrMMETRlC 

2-01 AGONAL 
*4Sd - SAMt AS MSA tXCtPI FOR MATRIX B 
L - NUMbtK UF ROWS IN 6 

REMoRitS 

MATRIX H CANNUI bE IN THE SAME LOCATION AS MATRICES A 0" 8 

MATRIX R IS ALWAYS A GENcRAL MAIMIK 

-iAlRlx A MJST HAVE THE SAMt NUMflER OF COCUt.NS AS MATRIX B 

SJEitOullNES ANu FUNCTION SUoPRCGraMS RECUIREO 
LOC 

HtlHOO 

MAT-'IX 6 IS ATT4CHE0 TJ THE flUTTJM OF MATRIX A . 

THE RESULTANT MATRIX R CONTAINS N«L HOw$ ANU m COLUMNS' 



bUSROUIlNE RTlt:4A,a,R,h,M,M^A.MSB.LI 
UlMENSlUn4 ul i I , d( 1 1 .R< 1 ) 

NN^N 
iR = 
NX= NN 
MSX-MSA 
00 9 J^ 1, M 
00 8 11=1.2 
UU 7 I = i , NN 
iR=IRtl 
R( 1R1=T .0 

LOCATE fcLcMcNT f JK ANY MATRIX SIJRAGE MOOt 
I.ALL L-JCl I, J, IJ.NN, M.MSXt 

ItSI FOR Z^AL iILEMEM IN DIAGONAL MATRIX 
IFII J) 2,7,2 

MJVc CLEMENT IG MATRIX R 

uU IJ( J. 4), I 1 

R(lR)=4(lJl 



cfii Aajvh 



RfcicI FJR NtHT COlJ^N 



RTIE 


30 


RTIE 


40 


RTIE 


SO 


RTIE 


60 


RTIE 


70 


RTIE 


RO 


RTIE 


90 


RTIE 


100 


RTIE 


ilO 


RTIE 


120 


RTIE 


1)0 


RTU 


140 


«ne 


150 


RTIE 


Lb'j 


RTU 


I7n 


RTIE 


180 


RTIE 


190 


RTIE 


20 S 


RTIE 


210 


RTIE 


220 


RTIE 


2)0 


RTIE 


2*0 


RTIE 


250 


RTIE 


26r 


RTie 


270 


RTIE 


2ao 


RTIE 


290 


RTIE 


30C 


RTIE 


(10 


RTIE 


320 


RTIE 


330 


RTIE 


340 


RTIE 


350 


RTIE 


360 


RT[£ 


170 


.RTIE 
RTIE 


jao 

390 


ftiie 


4C0 


RTIE 


410 


Rllt 


4 20 


RTIE 


4 30 


RTIE 


440 


RTIE 


430 


RTIE 


4h0 


RTIE 


4/0 


RUE 


4eo 


RTIE 


490 


RTIE 


^UU 


RTie 


510 


RTlE 


520 


RTIE 


5 3U 


RTIE 


b4D 


RTIE 


550 


RTIE 


560 


RTIE 


570 


RTif 


580 


RTIE 


590 


RTIE 


600 


RTI£ 


610 


RTIE 


6 20 


RTIE 


630 


RTIE 


?.4fl 


RTIE 


650 


RUE 


6o0 


RTIE 


670 


RUE 


680 


RUE 


690 


RTIE 


roc 


ATlt 


710 


RTIt 


7?0 


RTIE 


nc 


RTIE 


740 


RTIt 


7^^ 


RTIE 


r60 


RTIE 


7 70 


RTIE 


7d0 


RTIt 


790 



114 Mathematics — Matrices: Operations 



Subroutine CTIE 



Subroutines MPRC and DMPRC 



ADJOIN rwu HAlRlCt^i .(irH SAHb ROM OIHENSIUN Hi FUftM 0N£ 
KcSULTAMT AAJRU (SLt leTKOOl 



JALL CTlEU,atR|N,H,MSA,MSfltLJ 

L^LSCf<If>riUN OF PARjlMtrtRS 

4 - NAMt OF fIRST INPUT MATRIX 

a - NAMt OF SECJND INPJT MATrtlX 

K - NAHf OF JUTPUT HATKIX 

H - NUMBtK OF ROHS l\i AttltR 

M - NUMBEft UF COLUMNS IN A 

^SA - UNb DIGIT NUHdtR FQA STjKAGt: HOL)£ OF MATRIX A 

- GtNtRAl 

i - Sy«HtTRIC 

2 - OlAGUNAL 
MS6 - SA«t Ai MSA tXCfT FOR iH*TRIX B 
L - NjMfltR Of COLUMNS IN a 

KcMARKS 

MATKIX R CANNUr 6t IN THt SAtIt LOCATION AS MATRICES A OA B 

MATRIX R IS AtMAYS A GENERAL MATRIX 

MATRIX A MJST HAVE THE SANe NUHd£R UF ROWi AS MATRIX B 

SUbAOUriNEi AND fUNCHON SliBPfiOGRAMS REQUIRED 
LCC 

METHCO 

MAIKIX 6 IS ATTACHED TO THt RIJHT OF MATRIX A . 

THt RESULTANT MATRIX R CONTAINS N ROWS AND N*L COLUMNS 



SUuHQUr IN£ cric(A,d,H|N.n.HSA,MSB.L) 
DlMENSIJ>'< Adl.BIU (Rl It 

MM=M 

1R=0 

«Sx=Mja 

OO 6 JJ=1.2 

00 5 J=^1.MH 

00 > l=i.N 

Ik=Ik*l 

R(lRJ-0.0 

LUt-ATE tLcMtNT FOR ANY MATRIX STJ^AGt M006 
CALL L.JCI I. Jf 1 JiNtMM.MSXI 

TcSr FOR ^tKC tLEMtNT IN DIAGONAL MATRIX 
IFIIJI 2,'>,2 

MiJWt: tLEMSMF TG MATRIX R 

^ GO 10(3,'.), JJ 
3 R(IR»=A<IJJ 

GO TO 5 
t, R(iit l = d< IJ] 
5 CUNTINUE 



Rf^cAT AHOVt FOR MATRIX B 



M$X=MSd 
MM=L 
6 CONTINUE 
RETURN 
tNO 



CTIE 
.CTIE 
CTIE 
CTIE 
CTIE 
CTJE 



60 



CTIE TO 
CTIE 60 
CTIE 90 
CTIE 100 
CTIE 110 
CTU 120 
CTlE 130 
CTlE 140 
CTIE ISO 
CTI£ 160 
CriE 170 
CTIE ISO 
CriE 190 

criE 200 

CTIE ^10 
CriE 220 
CTIE 230 
CTIE 2<tO 
CTIE 250 
CTU 260 
CTlfc 270 
CTIE 260 
CTIt 290 
CTIE 300 
CTlE 310 
CTIE 320 
CTIE 330 
CTIE 340 
CTIE 350 
CTIE 360 
CTIE 370 
.CTiE 360 
CTIE 390 
CTIE 400 
CTIE 410 
CTIE *20 
CTIE 430 
CTIE 440 
CTlE *50 
CTIE 4oO 
CTIE 4T0 
CTJE 480 
CTIE 490 
CTIE 500 
CTIE !>10 
CTie 520 
CTIE 5 30 
CTIE 540 
CTIt 550 
CTIE 560 
CTIE 570 
CTIE 560 
CTIE 590 
Cri£ 600 
CTIE 610 
CTIE 6 20 
C7IE 630 
CTIE 640 
CTIE 650 
CTIE 660 
CTIE 670 
CTIE 680 
CUE 690 
CTlE 700 
CTIE 710 
CTIE 720 
CTIE 730 
CTIE 740 



These subroutines permute the rows or columns of 
a given m by n matrix A according to a transposition 
vector ITRA= (ti, , , . , ts) or its inverse. (See the 
general discussion tmder "Permutations" for defini- 
tions and notation. ) 

1. Mathematical background 

Permuting the rows or columns of A according to the 
transposition vector ITRA means applying the per- 
mutation (1, ti), . . . , (s,tg) to the rows or columns of 



A, while permuting according to ITRA'-' means ap- 
plying the permutation (s, ts), - 



2. Programming considerations 



-1 
(1, ti). 



If the columns of A are to be permuted, the input 
parameter IROCO must be nonzero, and s = n; if the 
rows are to be permuted, IROCO must be zero, and 
s= m. Similarly, if the input parameter INV is non- 
zero, the rows or columns of A are permuted ac- 
cording to ITRA; while if INV is zero, the rows or 
columns of A are permuted according to ITRA-1. 

If m and n are not both positive, or if ITRA is 
not a transposition vector on S = { 1, , . , , s} , tiie 
subroutines are prematurely terminated and the er- 
ror parameter lER is set to -1 or 1, respectively. 
If there is no error, lER is set to zero. 

The matrix A is assuhied to be stored column- 
wise, and the permutation of the rows or columns 
of A is performed in s steps. At the i*^ step, if the 
permutation is according to ITRA-1, rows or col- 
umns i and sj are interchanged; if the permutation 
is according to ITRA, rows or oolumns s - i+ 1 and 
*s " i+ 1 ^^® interchanged. 









MPRC 


10 








..HPRC 


20 








MPRC 


30 


SUBOOUTINE 


Hppr. 


MPRC 


40 








MPRC 


50 


PURPOSE 






MPRC 


60 


TO P 


ERMUT^ THE ROWS OR COLUMNS OF A GIVEN MATRIX ACCORDING 


MPRC 


TO 


^n t 


, 1IVSN TRANSPOSITION VECTDR Of ITS INVECSF. (SEE THE 


MPRC 


60 


DISCUSSION ON PERMUTATIONS FOR DEFINITIONS AND NOTATION.) 


MPRC 


90 








MPRC 


100 


USAGE 






MPRC 


110 


CALL 


MPRC( A,H.N,ITftA. INV, IROCO, I EPI 


MPRC 


120 








MPRC 


130 


OESCRIPTION Of PARAMETERS 


MPRC 


I'.O 


A 


- 


'".IVeN M dV N MATRIX AND RESULTING PeP»UT£D MATRIX 


MPRC 


150 


M 


- 


NUMtiER OF ROWS OF A 


MPRC 


160 


N 


- 


NUM'iER OF COLUMNS OF A 


MPRC 


170 


ITRA 


- 


OIVEN TRANSPOSITION VtCTDR (OIMENSIDN M IF ROMS ARE MPRC 


ISO 






PtftHlJTFD, N IF COLUMNS ARE PERMUTEOI 


MPRC 


190 


INV 


- 


INPUT PARAMETER 


HPRC 


'00 






IKV NON-ZFnO - PEFMUTF ACCORDING TO ITRA 


MPRC 


210 






INV = - PERMUTfc ACCOOOING TO ITRA INVERSE 


HPRC 


220 


fROC 


T - 


fNPjr FAtmnR 


nm Z30 






MCCO N0N-2Er;c - PFtMOIE TNC COLUMNS nF A 


MPRC 


240 






IROCC = - PFPMUTE THE PP«S OF t 


rtPBC 


250 


lEC 


- 


"ESULTING EKXOP PARAMETER 


MPRC 


?60 






IFP = -I - M AND N ARE NOT BOTH POSITIVE 


MPRC 


270 






IcR = - NO ERROR 


MPRC 


280 






IPR = t - ITRA IS -iJOT A TRANSPOSITION VECTOR ON 


MPRC 


290 






1,...,M IF POMS ARE PcRMUTCO, 1,...,N 


MPRC 


300 






If COLUMNS ARE PERMUTED 


MPRC 
MPRC 


310 
320 


RE.MSRKS 






MPRC 


330 


tl) 


IF 


irB=-l THEi-E IS NO C0.4 ^UT ATION. 


H?RC 


340 


(^> 


IF 


ICR= 1. THEN COMPUTATION HAS OEEN UNSUCCFSSfUL DUE 


MPRC 


350 




TO 


csaoa, BUT TMf hATHIX a WILL «FLFCT THt ROW OR 


MPRC 


360 




CPLU-i^ IMTflCHANGtS PtHrn^Mfo 6EP0RE THt ECROR WAS 


MPRC 


37U 




OEIFCTTtO. 


MPPC 


380 


(3) 


IMF 


MITCIX ^ IS ASSUMED TO fic STORED COLUMNwrSE. 


MPRC 


390 



Mathematics — Matrices: Operations 115 



NJNF 

McTHOO 

THE BOwi OR COLUMNS ARE PERHJTCn tLEMENTWjSE, ! NTfcRCHANG ING 
ROW OR COLUMN I «ND I THAd J , . . . ,1f)W VR C0LU1N K AND ITfcAlKt 
IN THAT nCDCC If INV = 1, *N0 OTHEOMtSt^ I MTEF rHANGI NG B0« O" 
COLUrtN K AN.1 ITftAIiC l,...i*(OW OR CCLUMfi 1 AND ITAAILI, UHERE 
K IS « C1« N DEPENDING OH WMETHEn UL PERMUTE BOWS OR COLUMNS. 



suaaouTiNt HpRC(A,w,N.irit4, inu.iroco, r e«) 



DIMENSION 1( I) ,II5a( n 

TESf Of OIMpNSlONS 
tF(M)14. U, ] 
If (Nl U, ]',,?. 

DEfEHMlNE WHICH ARE TO BE PERNUfED-THE ROWS OR THE . OLUMWS 
IFIIBOCOIS,'..; 



L=M 

LL*N 
GO in 5 

INITIALIZE FCP ROW INTERCHANGES 

KHH=H 
L = N 



LL = 



ITIflLWE LC'CP OVE" 4LL POWS OS COLUMNS 



TEST fllR INVERSE OPERATION 
IF(INV}6. 7,6 
IA = LL 
ID=-1 

DO 12 I=1,LL 
K=rTRAII Al 

IF(K )13, 13, 10 
IF(LL-KJ 13,10,10 



PEOFORN ROW 0" COLUMN INTERCHANGE 
DO 11 J=l,L 
SAVe = A( ID 
A(U1 = A(KI 
fl(KI=SAV£ 
K<K*HHM 
IL=IL+MMM 



NORMAL EKIT 
IER=0 
RETURN 

£^ROR RETUftN IM CASE ITRA IS NOT 4 TRANSPOSI TCOh VECTOR 
IER=1 
RETURN 

ERROR RETURN IN CASE OF ILLEGAL DIMENSIONS 
lER^-1 
RETURN 
END 



MPRC 400 

MPRC <ilO 

MPRC ^120 

MPRC A 30 

MPRC 440 

MPRC 450 

MPRC 460 

MPRC 4 70 

MPRC 480 

MPRC 4*90 

MPRC 500 

.HPRC 510 

HPRC 520 

HPRC 530 

MPRC 540 

MPRC 550 

MPRC 560 

NPRC 570 

MPRC 580 

HPRC 5<)0 

HPRC 600 

MPRC 610 

HPRC 620 

MPRC 630 

MPRC 640 

MPRC 550 

MPRC 660 

MPRC 6 TO 

MPRC 680 

MPRC 690 

MPRC TOO 

HPRC 710 

HPRC 720 

MPRC 730 

HPRC 740 

HPRC T50 

HPRC 760 

HPRC 7 70 

MPRC 780 

NPRC 790 

HPRC eoo 

HPRC 810 
HPRC (120 
HPRC 830 
MPRC 840 
HPRC 850 
HPRC 860 
HPRC B70 
HPRC 8B0 
HPRC 890 
MPRC 900 
MPRC 910 
HPRC 920 
MPRC 930 
HPRC 940 
HPRC 950 
HPRC 960 
HPRC 970 
MPRC 980 
MPRC 990 
MPRC I 000 
HPRCIOIO 
HPRC 1020 
HPRC1030 
HPRC 1040 
MPRC L 050 
HPRC1060 
MPRC 1 070 
HPRCIOBO 
MPRC 1 090 
MPRCttOO 
MPRCUIO 
HPRC 11 20 
HPRC It 30 
MPRC1140 
MPRC 11 50 
MPRC1160 
MPRC1170 
MPRC1180 



M£THOO 

THE POHS OR COLUMNS ARE PERMUTED CLEHGNTWISE. INTERCHANGING 
ROW OR COLUHN I AND I TRA( 1 1 , . . . .ROW OR CIKUHN K AND ITRAfK) 
IN THAT OR0£R If INV=0, AND OTHERWISE INTtRCMANGING ROM OP 
COLUMN K ANO I TRA ( K I , . . . , RUW OR COLUMN I AND lTRAIL>f WHERC 
K IS H OR N OEPENOING ON WHETHER WE PERMUTE ROWS OR COLUMNS 



SUBROUTINE DHPRC ( A ,H ,N . ITRA, INV, IROCO, I£R) 



TEST OF DIMENSIONS 
IFIHt 14,14,1 
1 IFINH4,14,2 



INITIALIZE FOR COLUMN INTERCHANGES 

3 MM"H 
MMH=-1 
L = H 
LL=N 

GO TO 5 

INITIALIZE FOR ROW INTERCHANGES 

4 MH = 1 
MHH=H 
L = N 
LL=H 

INITIALIZE LOOP OVER ALL ROWS OR COLUMNS 

5 IA = 1 
10=1 



TEST FOR INWEPSE OPERATION 
IF 1 1NV)6, 7,6 

6 IA=LL 
IO = -l 

7 00 12 1=1, LL 
K=ITRA( lAt 

8 1FIK.H3, 13,10 

9 IF(LL-KU3,10,iO 



OR COLUMN INTERCHANGE 



INITIALIZE ROl 

10 IL-IA*MM 

K=K*MM 

PERFORM ROW OR COLUHN INTERCHANGE 
DO U J=1,L 
SAVE'AI IL I 
At 1L) = AIK) 
A{K|35AVE 
K=K*MMM 

11 IL=IL+HMH 

ADDRESS NEXT INTERCHANGE STEP 

12 IA=IAtID 

NORMAL EXIT 
IER=0 
RETURN 

ERROR RETURN IN CASE ITRA IS NOT A ICANSPOSI T ION VECTOR 

13 IER=1 
RETURN 

ERROR RETURN IN CASE OF ILLEGAL DIMENSIONS 

14 IER=-1 
RETURN 
END 



OMPR 420 
OMPR 430 
OHPR 440 
OMPR 450 
OMPR 460 
OMPR 470 
OHPR 460 
DHPR 490 

■DMPR 500 
OMPR 510 

.OMPR 520 
OHPR 530 
DMPR 540 
OMPR 550 
DMPR 560 
OMPR 570 
OMPR 580 
DMPR 590 
DHPP 600 
OHPR 610 
OMPR 620 
DHPR 630 
OMPR 640 
DMPR 650 
OHPft 660 
OHPR 670 
DMPR 680 
OHPR 690 
OHPR 700 
OMPR 710 
OMPR 720 
OHPR 730 
DMPR 740 
DMPR 750 
DHPR 760 
OMPR 770 

OMPR reo 

DHPR 790 

OMPR 800 

OHPR 810 
DHPR 920 
DMPR 830 
OMPR 840 
OMPR 850 
DHPR 860 
DMPR 870 
DMPR 880 
DHPR 690 
OMPR 900 
DMPR 910 
DHPR 920 
DHPR 930 
OMPR 940 
OHPR 950 
DHPR 960 
DHPR 970 
OHPF 960 
OMPR 990 
DMPR 1000 
OMPFIOIO 
OHPR 1020 
OMPRL03O 
OHPR 1040 
DHPR1050 
0MPR1060 
DMPR 1070 
OHPR 1080 
DMPR 1090 
DHPR 11 00 
DMPRlllO 
0MPR1I20 
OMPR 11 30 
OHPR 1140 
OMPR II 50 
OMPR 1160 
OHPRllTO 
OHPRllSO 
DHPP 1190 
DMPR 1 ZOO 



SUflROUTINE DMPRC 

PURPOSE 

TO PERMUTE THE ROWS OR COLUMNS OF A GIVEN MATRIX ACCORDING 
TO A GIVEN TRANSPOSITION VECTOR OR ITS INVERSE- (SEE THE 
DISCUSSION ON PERMUTATIONS FOR DtFINITIONS AND NOTATION,) 



IX AND RESULT ING 



IF POWS APE 



PEFMUTE flCCORDING TO ITRA 
PcRHUTE ACCORDING TO ITRA INVERSE 



DESCRIPTION OF PARAMETERS 

A - GIVfcN DOUBLE PBECISICN 

PERMUTED MATRIX 
M - NUM9ER OF ROWS GF A 

N - NUMBER Cf COLUMNS OF A 

ITRA - GIVEN Tf ANSPUSITION VECTOf lOIHENSION 

PERHUTED, N IF COLUHNS ARE PERHUTEDl 
INV - INPUT PARAHETER 

INV NON-ZERO - 

INV = - 

IfiOCO - INPUT PARAHfreR- 

IBQCO NON-ZERO - PERMUTE THE COLUMNS OF A 

IROCO = - PERHUTE THE ROWS OF A 

lER - RESULTING ERROR PARAMETER 

lER - -1 - « ANO N APE NOT BOTH POSITIVE 

1£R = - NO ERROR 

lER = 1 - ITRA IS NOT A TRANSPOSITION VtCTOR ON 

l....,M IF ROUS APE PEfMUTEO. 1. ,N 

If COLUMNS ARE PERMUTED 



IF IcR--i THERE IS NO COMPUTATION. 

IF ieR= 1, THEN COMPUTATION HAS BEEN UNSUCCESSFUL DUE 

TO ERROR, BUT THE MATRIX A WILL REFLECT THE ROW OR 

COLUMN INTERCHANGES PERFORMED BEFORE THE ERROR WAS 

DETECTED. 

THE MATRIX A IS ASSUMED TO BE STORED COLUMNWISE. 



DHPF. 10 
DMPR 20 
DHPR 30 
DHPR 40 
OHPR 50 
DHPR 60 
OMPf TO 
OMPR 80 
DMPR 90 
DMPF 100 
DMPR 110 
DMPR 120 

DMPR 130 

OMPR 140 
DMPR 150 
DHPt- 160 
OHPR 170 
DHPR ISO 
DMPF 190 
DMPR 200 
OMPR 210 
DMPh 220 
DMPR 230 
DMPR 2^0 
DHPP 250 
DMPR 260 
DHPR 270 
OMPR 280 
DMPR 290 
DHPR 300 
OMPR 310 
DMPR 320 
OMPR 330 
DMPR 340 
OMPR 350 
DMPR 360 
OMPR 370 
DMPR 360 
DMPR 390 
DMPR 400 
DMPR 410 



116 Mathematics — Matrices: Operations 



Subroutine MFUN 



Subroutine RECP 



SUe»<OUTINc MfUN 

APPLY A fUW;nON TO EACH ELcM£f«f CF A HATRIX TO FOKH A 
itbSULTANT MATHlX 

USA^t 

CALL MfUN ( A.F.R.Ntflf HSI 

AN External itAJtHeur must PRtCcOt call srAT6M£Ni in order 

ro lutNJ tFY ^ARAHtrtR F AS Trie NAhE OF A FUNCTION 

l)tSCRI?riON OF PARAMEieKS 
A - HAHt QF INPUT MATRIX 

F - NArtt OF FQjtTRAN-fUftNISHcU OR UStR FUNCTION SJdPRQGRAM 
K - NAME Qf OUTPUT HATflU 
N - NUMUcR OF ROWS IN MATRIX A AnO R 
M - NUMdER OF COLUMNS IN MATrIx A ANO ft 

MS - ONE uIlilT NUMSER FOR STORAGE MOoE OF MATRIX A UNO Rl 
>C - GcM£RAL 
i - SYMHETKIC 
^ - 01 AGONAL 

KEMARKS 

PRECISION IS DEPENOENT UPON PRECISION OF FUNCTION USED 

SUSROUTUlS ANO fUNCTION SUBPROGRAMS KtU'JIREi) 
LDC 

McTHCO 

FONCriO.^ F IS APPLIdO T3 EACH cLEMENT Of MATRIX A 
TC fUK« MATRIX ft 



IQ 



SC 



COMPUTE VICTOR LENGTH, II 

CALL lOlIN.M. ir .NtM.MSt 

dUlLO .lATftlX R fOR ANV STJRAGc MJOt 

UO 5 1= 1,IT 
ft( I )=F( A( i I ) 
RETURN 
tNU 



NfUN 
.MFUN 
MfUN 
HFUN 
MFUN 
MFUN 
HFUN 
MFUN 80 
MfUN 90 
HfUN LOO 
HFUN 110 
HFUN UO 
MFUN 130 
HfUN 140 
HFUN 15C 
HFUN 160 
HFUN 170 
HFUN ISO 
MfUN 190 
MFUN 200 
HfUN 210 
HFUN 220 
MFUN 230 
HfUN 240 
MFUN iiO 
HFUN 2bC 
HFUN 270 
HFUN 2B0 
MFUN 290 
HfUN 3U0 
MFUN 310 
MFUN 12C 
HFUN 3 3C 
HFON 340 
HfUN 350 
,MfUN 360 
MFUN JTO 
MFUN i60 
HFUN 390 
HFUN 400 
HFUN 413 
HFUN 420 
HFUN 4J0 
HFUN 440 
MFUN 4 5L' 
MFUN 46 C 
HFUN 4rc 
HFuN 480 
HFUN 490 
MFUN 500 





• «•..- J 


...KCLP 2U 
RcCP iO 


rj(.(.l iu''J ki:CP 




RECP 4C 
RECP 50 


r'JK^ilSL 




kcCP 60 


CAlCUlATL -UClPftUCAL OF A,i tLcPlfcNT. dHlS IS 


A FUriTRAN 


RCCP 70 


rUNCriUlX i'JII-KOyRAil WHICH HAY at UitO AS AN 


ARGU'ltNT BY 


RECP «0 


.UuKuuriNL y.(-uN. 




fiecp 90 

HECP 100 


JSaje 




RECP 110 


^lCP(£J 




RCCP lilD 
RECP 130 


JciL«lPr(uN J(- PARAMbTtflS 




RECP 140 


t - MATRr* fLtMENT 




RECP 160 


KfMARK j 




RECP 170 


•<fClPKCi.aL Kjf Z£^lJ IS TAKcN ID «c l.Ct75 




RECP IdO 
REcP ISO 


iUa.<CjH?4tS «tO FUNCTION liUSPRUORAMS KtOUIRfcO 




RECP 200 


iMCNt 




RECP 210 
RECP 220 


MtlHOJ 




RECP 230 


<tCI»>XOCAL LF ELEMtNT t IS PLACfcO IN «ECP 




RtCP 240 

RECP 2S0 

...RECP 260 



FUNCriUN RLCPI dl 

QiG=i.je7s 

TEST LLtrtENT FOR icfiU 

iF(e ) i.*;. I 

IF .HUN-ltRQ, CALCULATE RtClPRULAL 

1 RECP=l.D/E 
RE TURN 

If 2lRu, ScT €QJAL to li'jFINirY 

2 r£CP = 3IGn( diLi.Lt 
RETURN 

END 



RECP 2 70 
RECP 280 
RECP 290 
RECP 300 
RECP JlO 
RECP 320 
RECP 330 
RECP 340 
RfcCP 350 
RECP 36C 
RECP 370 
RECP 380 
RfcCP 390 
RECP 400 
RECP 410 
RECP 420 
RECP 430 
RECP 440 
RECP 450 



Mathematics— Matrices: Operations 117 



MATHEMATICS 

Matrices: Inversion, Systems of Linear Equations 
and Related Topics 

Subroutine MINV 



PJkF>JSL 



CALL HlNVJd.MjUrL.HJ 

Jt'SCKJI-T lUN Jf PA«AMtrc«S 

A - iNt'OT *^A[Rlx, Dtir,<UYtU l.i CUMPUTATIUN AHO RcPLACfcO BY 
h^ciUL fAWr InlVLRSt . 

■M - CI«Ock JF MATklX A 

J - RtSUi-rAhir DETtRrHINANr 

L - wUKK ViiCrUR L)l- LtNuIH N 

M - WJKK VtCrOR Of LtNGTH N 



;^ATkIX A HJST fa£ A GcNtRAL MAf-^IX 



FUNCI IiJN suap« 



AHS HEOUIRtU 



FHiE SIANUA^O GAdiS-JOKJAN METMUIj IS UStU. THt DtTESMlNANT 
iS ALSO CALCJLATtU. A J£TtKMI.NANT UF ZtRO INUICATE^ THAI 
THc MATfiU IS S1NGULA«. 



IF A JGUSLE PKLClSiON VCRSIUN Qf THIS ROUTINE IS UtSIRfcO, THE 
L l.'^ CULJHN I bHOULU BE KLMJVEO FROM THE DOUBUt PRtClSION 
STAltMLNT WHICH FaLLQWS. 

UuUbLc PRtClSION A. 0, tilGA,Mlii.y 

THt L -lUSr ALSO tit KtHJVEJ FRUH UJUbLE PRtCISIUN STATcMtNTS 
APPtAKlNG IN OTHcR ROUTINES USED IN CONJUNCTION Ml TH THIS 
RJUr lN6. 

THt OUUiJLt PKtClSiUN VcRSItJN OF TH 1 5 SUBitOUtINt MUST ALSO 
CUNTAlN OOUriLE PRECISIOM FORTRAN FUNCTIONS. ABS IN STATEMENI 
10 MUST UL CHANoEO To UAdS. 



StAi<LH FOR LAKGtSr fcLcMLNT 

0=1.0 

00 no k^Un 
NH=^hK+N 
L(K»=K 
M(Kl=K 
K,K=NKtH 
blGA^Al i^iCl 
DO 20 J=«..N 
1Z=N#IJ-IJ 

oa 20 i=K,N 
[J=U*I 

iFI AbStolGAl- AbblAdJJM lb, 20, 20 
I 61GA^A( iJ) 
L(«(l= I 
M(Kl=J 
CONTINJc 

iNTbSCHANGE ROWi 

J=H<) 

IF( J-K.J 3i, it),2b 

> Kl=K-N 

00 10 1=1, N 
M = KI*fli 
HOL J=-4(K I ( 
JI=KI-K*J 
AtKI )^4( Jl ) 
AIJIl --HtlLL! 

INT £Ki,HArtGt LULJMNS 



JI=^JPtJ 
HOlJ=-AIJn] 

A( JKI^A(J I 1 

a{ ji I =hijllj 

jIViJb lOlJM.j Ai MINUS PlVuI 
CJNThI ■iCJ IN tJ IJA) 



VALUE Uf PIVOT ELEHtNT IS 



lF(dI^^( 't^.'.c, ^ 


■f 


^-c .: 




r<fclURf>. 




no t>:> 1=1, J, 




ifii-<i ici-i.'j: 




iK-^NKtl 




rtHO- il I.<l/(-dI, 


;a) 


cONTMJt 




Ktl,Jc= 1A(.<1< 




'J J 5 J I =l,.\i 




1K^I^<.I 




-lOLJ^Al IM 




1 j^ I- ; 





.MlNV 20 
M](-4W 30 

MINV ■^O 

MlNV SO 

MiNV 60 

MINV 70 

HINV UO 

MINV 90 

MINV 100 

HIMV 110 

MINV 12J 

MINV iiC 

MINV lifC' 

MINU ISO 

niNV 160 

MINV 170 

HINV 180 

MINV 19C 

MINV 200 

HINV 210 
MINV 220 
MfNV 230 
MINV 2'.0 
MINV 250 
MINV 21,0 
MINV ^70 
MINV 2B0 
MINV 290 
NINV 300 

.MINV 3LC 
MINV 320 
MINV 330 
MINV i^'O 
MINV 350 

.MINV 360 
MINV 370 
MINV 380 
MINV 390 
MINV '.00 
MiNv 410 
MINV 420 
MINV 430 
MINV ^-tO 
MINV 450 
MINV 4bO 
HINV 47C 
MINV 460 
MINV 490 
HINV 500 
MINV 510 
..MINV 520 
HINV 5 30 
MINV 540 
HINV 550 
HINV 560 
MINV 570 
MINV 580 
HINV 590 
HiNV &00 
MINV 610 
HINV 620 
HINV 630 
MINV 640 
MINV 650 
MINV 660 
MI»JV 570 
MINV 680 
MINV 690 
MINV 700 
MINV 71C 
MINV 720 
MINV 73q 
MlhV 740 
HINV 750 
MINV 760 
MINV 770 
MINV 7ttO 
MINV 790 
MINV 800 
MINV BIO 
HINV 820 
MINV 8 30 
MINV S'.O 
MINV B50 
MINV 360 
MINV 870 

MINV aao 

MINV a-JC 
MlNV 900 

MINV 910 

HINV 920 

HINV 930 

MINV 9*.0 

MINV 450 

MINV 950 

MINV 970 

MINV 980 

MINV 99C 

m;nviooo 
minviuic 

MINV1C20 
MINVlOiQ 
MlNVl040 
HINViOSO 

MINVlOaO 
HiNV1070 
M1NV1C90 
MINV1J9J 
HINVlIOd 
MINVil 10 
MINVUZ3 
MlNvll iO 
MINVI140 
MINVI 150 



00 65 J=l.N 

IJ=IJ».^ 

|F( I-XI oO.6j.6J 

IF(J-K| 02,65, o2 

AJ=IJ-I *K 

A I 1JMHCLJ«AIKJ 1 tA( IJ) 

CONTINJt 



01 l/IJc 



<.y*i 



PI VfJT 



KJ=K-M 

00 75 J=I.N 

KJ = KJ*-i| 

1F( J-<I 70, Ta, 7J 

AIKjJ-AlKJI/tllGA 

CUNT li^Jt 

PiiOjUCT OF PIVOTS 



KtPLA^^ PIVJI tJf RtClP.<DCiL 



FI^iL rtOrt AND CJlUMN interchange 



10: 


^M^-I1 








IF iKI 1!)J. l^' 


0, I 1 


J 3 


1C5 


I=L(M 








1FI1-<I 120, 


120, 


. lOB 


1 Jt 


jy=M*( .<'i) 








jR-i^*( i-n 








00 lie J=l,IM 








jK= JJ* J 








hclo= ai Jt.) 








jl-JRt J 








Al JK (^-A< J] 1 






lie 


AlJII ^HOLj 






i^". 


J=M( K) 








ii-t---<) icj,; 


IJJ, 


li!r> 


125 


<^I=^-^i 

■oO 13- 1= l.p\ 

HLlLJ = Ai -CI ) 
J1=K1 -<'J 

a(KI1^-A[ Jl 1 






13-: 


^(JII --■^0,.Q 







MINVli60 
MINVa70 

MINVlldO 

MINVI190 
HINV1200 
MINV1210 
HI NVl 220 
MINV1230 
MINV1240 
HINV1250 
Ml NVl 260 
MINV1270 
MINV1290 
MINVJ290 
HINVI300 
MlNVL3i0 
MINVU20 
HINV13iC 
HINVU40 
MINVI350 
MINVI)60 
MINVi370 
MlNV136a 
NIhV1390 
NINV1400 
MINV1410 
MINVI420 
MINVI430 

HINVl't'.O 

HINV1450 
MINV1460 
MINV147D 
MlNVi480 
MINV1490 
MINVi500 
MINVISIO 
MIKVi520 
MINV1530 
MINV1540 
MINV1550 
MINV1560 
MlNVi57C 
MINVlSdO 
MINV159C 
MiNVlbOO 
MlNVI6iO 
MINV1620 
ri|NV16>C 
MiNVio40 
MINVlopy 
MINVI06O 
MINVI673 
MlNVloB? 



118 Mathematics — Linear Equations 



Subroutines SINV and DSINV 

These subroutines invert a given symmetric positive 
definite matrix, using factorization by subroutines 
MFSD and DMFSD. 

1. Mathematical background 

Given an n by n symmetric positive definite matrix 
A, an upper triangular matrix R= (rji) exists such 
that 

T 
A = R R 



.-1 



-1/R-1\T 



Then A"^ = R"^(R"-^) ^. The elements rji^ of R" 

are computed using the following recursive 

formulas: 

k _ 

r"., = -d/r..) ( Z r. F , ) 
ik 11 . , im mk 

m=i+ 1 



r., = 1/r.. 
ik 11 



^ik= ' 



i<k 

i=k 
i>k 



2. Programming considerations 

The given symmetric positive definite matrix A is 
stored columnwise in compressed form, that is, 
only the upper triangular part in ^(^"*'-'^) successive 
storage locations. 

Subroutine MFSD (DMFSD), which is called 
internally, returns the elements rj^ (i ^ k) of the 
upper triai^ular matrix R in the storage locations 
of A. The inverse (upper) triangular matrix R"-*^ 
and at last the resultant upper triangular part of the 
inverse matrix A~^ are calculated and stored col- 
mnnwise in the same storage locations. 

If any calculated radicand rj^ (k = 1, 2, 3, . , . , N) 
is not positive, further calculation is bypassed, and 
the error parameter lER is set to -1. This means 
that matrix A is not positive definite, possibly due 
to roundoff errors. lER is also set to -1 if the in- 
put parameter N is less than one. 

Let all radicands be positive, and let r\^ be the 
first radicand which is no longergreater than the 
internal tolerance TOL = |EPS . a^kj . The sub- 
routine gives the warning lER = k-1; however, 
calculation is continued. The warning indicates fliat 
there may be loss of significance at factorization 
step k due to loss of significant digits in the cal- 
culation of rj^. 



SU'S'SOUTINE SINV 

PURPOSE 

INVE«T A GIVCN SYMMETRIC POSlTIVg OCFINITE HftTRtX ^ 

USACF 

CALL SINVt A,N,EPSi lER) 

DESCRIPTION OF PARAMETERS 

A - UPPER TPIANGULAP PART OF TM{ GIVEN SYMMETRIC 

POSITIVE 0£FINITe N BY N COCFFICIEKT MATRIX. 
OH RETURN A CONTAINS THE RESULTANT UPPER 
TRIANGULAR MATRIX. 
H - THE NUMBER OF RCWS (COLUMNSI IN GIVEh MATRIX. 

EPS - AN INPUT CONSTANT WHICH IS USED AS RELATIVE 

TOLERANCE FOR TEST ON LOSS OF SIGNIFICANCE. 
lER - RtSULTIMG ERROft PARAMETER C6OEO AS FOtLOUS 

ieR=0 - NO ERROR 

[ER=~l - NO RESULT BECAUSE Qf WRONG INPUT PARAME- 
TER N OR BECAUSE SOhE RAOTCANO IS NON- 
POSITIVE (MATRIX A IS HHT POSITIVE 
DEFINITE, POSSIBLY DUE TO LnsS OF SIGNI- 
FICANCE) 
lER^K - WARNING WHICH INDICATES LOSS OF SIGNIFI- 
CANCE. THE RAOICANO FORHEO AT FACTORIZA- 
TION STEP K^I WAS STILL POSITIVE BUT NO 
LONGER GREATER THAN ABSIEPS^AIKf LtKt II I. 

REMARKS 

THE UPPER TRIANGULAR PART OF GIVEN MATRIX IS ASSUMED TO BE 
STORED CQLUMNWISe IN N*(N*ll/2 SUCCESSIVE STOPAGE LOCATIONS 
IN THE SAME STORAGE LOCATIONS THE RESULTING UPPER TRIANGU- 
LAR MATRIX IS STORED COLUMNWISE TOO. 

THE PROCEDURE GIVES RESULTS IF N IS CHEATER THAN ANO ALL 
CALCULATED RAOICANOS ARE POSITIVE. 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
MFSO 



SINV 

• SINV 
SINV 
SINV 
SINV 
SINV 



60 



SUBROUTINE S INVI A.N,£PS 1 1 ERi 



DIMENSION A| 1) 

OOUBLE PRECISION DIN.MORK 



FACTORUE GIVEN MATRIX 

A = TRAMSPQSEITI • T 
CALL MFSOI A,N,EPS,IERI 
IFIIERl -StI, 1 

INVERT UPPER TRIANGULA* MATRIX T 

PREPARE INVERSION-LOOP 
IPIV>N*(N«^l)/2 
INO-^IPIV 



BY MtANS OF SUeROUTINE MFSD 



c 




INITIALIZE INVERSION-LOOP 
DO 6 I-I,N 

01N=t.00/0BLe(A( IPIVK 
A(IPIV)=DIN 
MIN'^N 
KEN0=I-1 
LANFsN-KENO 
IFIKENO) 5.5*2 




2 


J-IND 


c 






c 




INITIALIZE POM-LOOP 
DO 4 K-l,KEND 
HORK=O.DO 
MIN=MIN-1 
LHOR^IPIV 
LVER=J 


c 






c 




START INNER LOOP 
00 3 L=LANF,MIN 
LVEP»LVEP+l 
LHOR=LHOR+L 




3 


WORK*HaRK«-DeL£(A(LVER)*A(LH0Rn 


c 




END OF INNER LOOP 


c 




AU)=-WORK«OIN 




. 4 


J-J-MIN 


c 
c 




END OF ROH-COOP 


5 


IPIV-IPIV-MIN 




6 


1ND=IN0-1 


c 
c 
c 




END OF INVERSION-LOOP 




CALCULATE INVEHSEIAI 8Y MEANS Of INVERSE(T) 


c 




INVERSEIA) = 1NVPRSE(TI * TRANSPOSE ( INVERSE ( TJI 


c 




INITIALIZE MULTIPLICATION-LOOP 
DO fl l=l,N 
IPIV=IPIV+I 
J=IPIV 


c 






c 




INITIflLI^'E BOW-LOOP 
DO 8 K=I,N 
WORK =0.00 

LHOR=J 


c 






c 


r 


START INNER LCOP 
00 7 L=K,N 
t.VER=LHO«>.»K-I 

WORK=MORK»DBLE(AILHDRI*A(LVER) I 
LHOR=lHDR*L 


c 




tNO Cf INNER LOOP 


c 




A(J1.W0RK 




6 


J = J*K 


c 
c 




END OF ROW- AND MUL TIPL ICAnON-LOOP 


1 


RETURN 






END 



SIMV TO 
SINV 80 
SINV 90 
SINV IDO 
SINV tlO 
SINV 120 
SINV 130 
SINV 140 
SINV 150 
SINV 160 
SINV 170 
SINV 180 
SINV IQO 
SINV 200 
SINV 210 
SINV 220 
SINV 230 
SINV 240 
SINV 2S0 
SINV 260 
SINV 2T0 
SINV ZBO 
SINV 290 
SINV 300 
SINV 310 
SINV 320 
SINV 330 
.SINV 340 
SINV »0 
SINV 360 
SINV 370 
SINV 380 
SINV 390 
SINV 400 
SINV 410 
SINV 420 
SINV 4}0 
.SINV 440 
SINV 450 
.SINV 460 
SINV 470 
SINV 480 
SINV 490 
SINV 500 
SINV 5L0 
SINV 520 
SINV 530 
SINV 540 
SINV 550 
SINV 560 
SINV 570 
SINV 580 
SINV 590 
SINV 600 
SINV 610 
SINV 620 
SINV 630 
SINV 640 
SINV 650 
SINV 660 
SINV 670 
SINV 680 
SINV 690 
SINV TOO 
SINV 710 
SINV 720 
SINV 730 
SINV 740 
SINV 750 
SINV 760 
SINV T70 
SINV 780 
SINV 790 
SINV BOO 
SINV 810 
SINV 820 
SINV 830 
SINV 840 
SINV 850 
SINV 860 
SINV 870 
SINV 8B0 
SINV 890 
SINV 900 
SINV 910 
SINV 920 
SINV 930 
SINV 940 
SINV 950 
SINV 960 
SINV 970 
SINV 980 
SINV 990 
SINVIOOO 
SINVIOIO 
SINVI020 
SINV1030 
SINV1040 
SINVIOSO 
SINV1060 
SINV1070 
SINVI080 
SINV 1090 
SINVllOO 
SINVlllO 
SINV1I20 

simno 

SINV1140 
SINV1150 
S1NVL160 
SINVlI7a 

SINVllBO 
SINV1190 
SINV1200 



Mathematics— Linear Equations 119 



SUBROUTINe OSINV 

PURPOSE 

INveoT A GIVEN SYMMETRIC POSITIVE OEflNITE MATRIX , 

USAGE 

CALL OSINVI A.N.EPSt lEK) 

OESCRIPTrON OF PARAMETERS 

A - OOUIJLE PRECISION UPPER TRIANGULAR PART OF GIVEN 

SYMMETRfC PnsiTIVE DEFINITE N BY N COEFFICIENT 
MATRIX. 

ON ReTUHN A CONTAINS THE RESULTANT UPPER 
TRIANGULAR MATRIX IN DOUBLE PRECISION. 
N - THE NUM8ER OF ROWS (COLUMNS! IN GIVEN MATRIX. 

EPS - SINGLE PRECISION INPUT CONSTANT WHICH IS USED 

AS RELATIVE TOLERANCE FOR TEST ON LOSS OF 
SIGNIFICANCE. 
lER - RESULTING ERROR PARAMETER CODED AS FOLLOWS 

rF«=0 - NO €R«OR 

l-^R--! - NO RESULT BECAUSE OF WRONG INPUT PARAME- 
TER N OR BECAUSE SOME RAOICAND IS NQN- 
PDSITfVE (MATRIX A IS NOT POSUIve 
DEFINITE, POSSIBLY DUE TO LOSS OF SIGNI- 
FICANCE) 
UR = K - WARNING WHICH INDICATES LOSS OF SIGNIFI- 
CANCE. THE RADICANO FORMED AT FACTORIZA- 
TION STEP Ktl HAS STILL PCSITIVE BUT NO 
LONGER GREATER THAN AfiS( EPS* A (Ki- 1 ,K + l I I . 

REMARKS 

THE UPP£fl TRIANGULAR PART OF GIVEN MATRIX IS ASSUMED TO BE 
STORED COLUMNWISE IN N*(N*n/Z SUCCESSIVE STORAGE LOCATIONS 
IN THE SAME STORAGE LOCATIDKS THE RESULTING UPPER TRIANGU- 
LAR MATRIX IS STORED COLUMNWISE TOO. 

THE PROCEDURE GIVES RESULTS IF N IS GREATER THAN AND ALL 
CALCULATED BAOICANDS ARE POSITIVE. 



METHOD 

SOLUTION IS DONE USING FACTORIZATION BY SUBRDUTUE DMFSD, 



SUBROUTINE DSINV(A,N,EP5. lEB I 



FACrORIZE GIVEN MATRIX flV MEANS OF SUBRCUTINE DMFSD 

A = TRANSPOSEir I • T 
CALL D«FSO(A,N,EPS,IER) 
IF( lER) <), I. I 

INVERT UPPER TRIANGULAR MATRIX T 
PREPARE INVERSION-LOOP 

1 IPIV=N«(N+U/2 
IND=IPIV 

INITIALIZE INVERSION-LOOP 
DO 6 I^l.N 
DIN=1.D0/A( IPIV) 
A(IPIV)=OIN 
MIN=N 
KENO=I-l 
LANF=N-KEND 
IFIKEND} 5»5.Z 

2 J-INO 

INITIALIZE ROW-LOOP 
00 A K=l,KENO 
WORK=0.00 
MIN=MIN-1 
LHOR=IPIV 
LVER=J 

START INNER LOOP 
DO 3 L=LANF,MIN 
LVeR=LVER*l 

lhor=l-hor*l 

3 WCRK=NORK#A(LVERI*A{LHOR| 

END QF INNER LOOP 

A( JI--WORK»OIN 
* J=J-MIN 

END OF ROW-LOOP 

5 IPIV-IPIV-MIN 

6 IND=INO-l 

END OF INVERSION-LOOP 

CALCULATE INV£RSE(A| BY MESNS OF INVERSEIT) 
INVERSEiA) = INVERSFITl * TRANSPOSE ( INVERSE 1 I I I 
INITIALIZE MULTIPLICATtON-LOOP 

00 8 l=l,N 

IP1V=IPIV*I 

J-IPIV 

INI T I ALIZE RCn-l OOP 
00 8 K = I ,N 

WCII:k=O.DO 
L-^OR^J 

STAST INKER LTOP 
DO 7 L=K.N 
lVEa=LHOR»'<-I 
WORK=t.ORK*fl ( I HOR MA (L VE*^) 

7 LHOR=LHOR+L 

END Cf INNER LOOP 

A( ji =W0RK 

8 J=J*K 

FNC r>f A3H-- AND MUL I IPL 1 CA T I ON-L G^P 



RETURN 
END 



OSIN 10 
-OS IN 20 
OSIN 30 
OSIN 40 
OSIN 50 
OSIN 60 
OSIN TO 
OSIN to 
DSIN 90 
OSIN 100 
OSIN 110 
OSIN 120 
OSIN 130 
OSIN 140 
DSIN 190 
OSIN 160 
DSIN 170 
DSIN IdO 
OSIN 190 
OSIN 200 
DSIN 210 
OSIN 220 
DSIN 2)0 
DSIN 240 
DSIN 250 
OSIN 260 
DSIN 270 
OSIN 260 
OSIN 290 
OSIN 300 
DSIN 310 
OSIN 3 20 
DSIN 330 
OSIN 340 
DSIN 350 
■DSIN 360 
OSIN 370 
DSIN 380 
DSIN 390 
DSIN 400 
OSIN 410 
DSIN 420 
DSIN 430 
DSIN 440 
DSIN 450 
DSIN 460 
DSIN 470 
. .DSIN 480 
OSIN 490 
OSIN 500 
OSIN 510 
DSIN 520 
DSIN 530 
OSIN 540 
DSIN 550 
OSIN 560 
OSIN 5 70 
OSIN 580 
OSIN 590 
DSIN 600 
DSIN 610 
OSIN 6Z0 
DSIN 630 
DSIN 640 
DSIN 650 
OSIN 660 
OSIN 670 
OSIN 680 
OSIN 690 
DSIN 700 
DSIN 710 
OSIN 720 
OSIN 730 
OSIN 740 
DSIN 750 
OSIN 760 
DSIN 770 
DSIf« 780 
OSIN 790 
DSIN 900 
DSIN 610 
DSIN 820 
DSIN 8 30 
DSIN 640 
OSIN 850 
OSIN 660 
OSIN 670 
OSIN 880 
DSIN 690 
OSIN 900 
DSIN 910 
OSIN 920 
DSIN 930 
OSIN 940 
DSIN 950 
OSIN 960 
DSIN 970 
OSIN 980 
DSIN 990 
DSINIOOO 
DSINIOLO 
OSINIOZO 
DSIN1030 
OSIN1040 
DSIN1050 
0SIN1060 
DSINI070 

osiNioao 

DSIN1090 

osiNino 

DSINlllO 
0SINI120 

DUN1130 

0$!N1140 
DSIN1150 
DSIN1I60 
OSINllTO 
DSINUSO 
DSINI 190 
0SIN1200 
DSIN1210 
DSIN1220 



Subroutine SIMQ 



SJd-<OjriNE ji.-io 



JbTAiN SOLJIiUN OF A Scf Of SIMULlANtOUS LINEAR cQUATIONS, 



CALL S IM;3(A,dtN,KS) 

UtSCKIPTIUN Or" PARAMtlc^S 

A - HATKIX UF COcFFICIdNIi SIJt<tiJ COLUMNWlSC. THc SE ARE 

JtSTRUYEJ IN THE C J.HPJTATI UN . THE SIZE OF MATRIX A IS 

N BY H. 
J - VdCTJR L.F URlGlr^AL CJNSTA.JTS (LENGTH Nl . TrttSt ARE 

kE?L4Cci) OY I^INAL SOLUTION VALUES. VECIUR X. 
J - WdMdaK OF tUUATIONS ANO VARIABLES. N MUSI 6E .GT, ONE. 
-^S - rjJTPU'- DIGIT 

fan A NORKAL I^OLUTIUN 

1 FOR A SINGULAR ScT OF EgUAIIONS 

HcHaRKS 

MAIRU A MUST BE GL.NtRAL. 

l^ MATklK IS SINGULAR , SGLUTIUN VALUES Aftt MEANINGLESS. 
A\ ALTtRNATlVd SOLUTION HAY 8t UBIAlNtO 6Y USING MATRIX 
INVb-^SlGN (MINVt ANJ MATRIX PttOUUCT (GMPRO). 

SJoROUTINES AND FUNCTIJN SU8PRUGAAHS REQUIRED 



'iETHUJ QF SOLUTION IS tjr ELIMINATION USING LARGEST PIVOTAL 



SIMQ 10 
. S I MQ ?0 
SI MO )C 
SIHd 40 
SIMQ 50 
SIMU 6 
SIMO 70 
SIMQ 80 
SIMQ 9C 
SIHU 100 
SIMQ lie 
SIMQ 120 
SIMU 130 
SIMQ l<r0 
SIMQ 150 
SiMQ 160 
SIMQ 17C 
SIMQ ISO 
SI HO 190 
SIMQ 200 
SIMQ 210 
SlMy 220 
SIMQ 230 
SIMQ 240 
SIMQ 250 
SiMU 2bO 
SIMQ 270 
SIMQ 2B0 
SIMO 290 
SIMQ 300 
SIMQ 310 
SIMQ 320 
SIMQ 330 
SlMQ 340 



JIVISjR. EACH SrAi,E OF ELlHlNATlUN CONSISTS OF INTERCHANGINGS IMQ 350 



WHEN NECESSARY TO AV3I0 DIVISION ©Y UxO OR SHALL 
ELEMENTS. 

THE FORWARJ SOLUTION TJ OBTAI,^ VARIABLE N IS UJNE iN 
^ STAGES. THE BACK SOLUTION FQ,* iHt OTHER VARIABLES IS 
CALCULATcO 8Y SUCCESiWE SUd S fl I UT I ONS . FINAL SOLUTION 
VALJcS ARE OtVELOPEC IN V£CrGR A, WITH VARIABLE I IN B(l)> 

VAKlABLd 2 IN &12) VARIABLE N IN diNI. 

IF NU PIVOT CAN dt FOUNJ EXC££JlNG A TOLERANCE OF 0.0, 

IHt MATRIX IS CONSIDERED SINGULAR AND KS IS SEl TO 1. THIS 

TjLtRANCc CAH Be MOOIFIEO BY REPLACING THE FIRST STATEMENT. 



SUBROUTINE SIHJIA.d, 
OIMtNSfUN Ad). 31 LI 

FO^irfA'^J SOLUTION 

I Ol = J . 3 

KS=0 

JJ=-N 

00 o5 J^l.N 

JY=J*1 

JJ=JJ*N*1 



SEARCH FOR MAXIMUM COEFFICIENT IN COLUMN 

IJ-IT*I 

If (A6S(oluAI-ABS(AI IJ}) 1 20.30,30 
2C cllGA = A( IJ) 

I MAX = I 
3C CONTINUE 

lEST FJR PIVOT LESS THAN TOLERANCE ISlNGULAR HATRIX) 

IFIAiJil BiGAl-TULJ 35,35.40 
35 XS=1 
RETJKN 

INTtRCHANjt ROWS If NECESSARY 

40 U = JtN»lj-2) 
II=lrtAX-J 
DO 5J A=J.N 
I1=I1+N 
I2=Ii*iT 
SAVE=AI II] 
All n = A<I2l 
A(I2t=SAVE 

uIVlOE EQUaTIJN oY LEAOINJ CDfcfflCIENT 

5C A( I 11=AI 1 U/BloA 
SAVE=d( IHAXI 
fl( IMAXI^Bl J) 
BlJl=SAV£/6IGA 



ELlMINAIc 



XT VARIABLE 



If ( J-N( 


53,70,55 




55 1QS=N*(J-1) 




JO 65 1 


X=JY,N 




IXJ=I JS 


♦ IX 




IT=J-U 






00 6C J 


XijV.N 




IXJX = .1J» 


(JX-1)*IX 




JJX=IXJ 


K*II 




6C AdXJXI 


^A(UJXt-lA( IXJ)«AIJJXM 


65 B(lAl-o 


IIX)-(ctlJI 


*A(IXJ)I 


BACK 


SULUTlUN 




7C ^Y-N-| 






IT-N*N 






DU 6'. j! 


■l.NV 




IA=iT-J 






IH=N-J 






IC = N 






DO 30 K= 


i-> J 




Ell3i-'H 16l-a( lAI- 


'ddCI 


lA=la-i4 






lu IC=IC-i 






RETURN 






ttiO 







SIMQ 363 
SIMQ 370 
SIMQ 360 
SIMQ 390 
SIMO 400 
SIMQ 410 
SIMQ 420 
SIMQ 430 
SIHQ 440 
SIMQ 450 
SIMQ 460 
...SIHQ 470 
SIMQ 480 
SIMQ 490 
SIMQ 500 
SIMQ 510 
SIMQ 520 
SIMQ 530 
SlMg 540 
SiMQ S50 
SIMQ 560 
SIMQ 570 
SIHQ 580 
SIMQ 590 
SIHQ 600 
SIHQ 610 
SIMQ 620 
SIMQ 630 
SIHQ 640 
SIMQ 650 
SIMQ 660 
SIMQ 670 
SIMQ 6S0 
SIHQ 690 
SIHQ 700 
SIMQ 713 
SIMQ 720 
SIMQ 730 
SIMQ 740 
SIMQ 750 
SIHQ 760 
SIMO 770 
SIMQ 780 
SIMQ 790 
SIHQ 800 
SIMQ 810 
SIMQ 820 
SIMO 830 
SlNQ 840 
SIMQ 650 
SIHQ 660 
SIMQ 8 73 
SIMQ 880 
SIMO B90 
SIHQ 900 
SIMO 910 
SIHQ 920 
SiMQ 9 30 
SIMQ 940 
SIHQ 950 
SIMQ 960 
SIMQ 970 
SIMQ 98: 
SIHQ 990 
SIMQIOOO 
SIMQIOIO 
SIMO1020 
SIMQ1330 
SIHQ1040 
SIHQIOSO 
SIMQ1060 
SIHQIOTO 

iimm 

SIMQI040 
SIMQllOO 
SIMQlUO 
SIMQ1120 
SIM01i30 
SINQ1140 
SIMQ1150 
SIMgil60 
SIMQllZO 
SIMQLIBO 
SIHQU9C 
S1MQI2C0 
S1HQI210 
SIM01220 



120 Mathematics — Linear Equations 



Subroutines GELG and DGELG 

These subroutines solve a system of general simul- 
taneous linear equations by Gauss elimination. Con- 
sider the system of general simultaneous linear 
equations: 

A * X = R (1) 



Now transform the elements of pivot rows in ma- 
trices A and R by multiplying with 1/p, and the other 
elements by adding -a^j times the new first rows of 
these two matrices to the other v rows, thus gettir^: 



11 



+ ^^(1 =2, 3, ..., m) 



(4) 



with an m by m coefficient matrix A and an m by n 
right-hand side matrix R both stored columnwise. 
Solution is done by means of Gauss elimination with 
complete pivoting. If matrix R is the identity ma- 
trix, solution X is the inverse of matrix A. The 
solution X is generated in matrix R. Thus, the 
computation of the solution requires no additional 
storage requirements. 

Explicitly, the given system (1) is of the form: 



11 



12 



a a 

21 22 




2m 



11 



21 



12 



22 



In' 



2n 



a a ... a 
ml m2 mm, 



rr,, r,„ r, \ 

11 12 ln\ 



r r . . . r 
21 22 2n 



r , r „ ... r 
I ml m2 mn 



X X „ ... X , 

ml m2 mn/ 



(2) 



The first step is to search the whole matrix A for 
the element of greatest absolute value , say aij , 
and to select it as first pivot (p = aij) . With 
aij, generate the internal absolute tolerance for 
testing loss of significance in the following way: 



tol = I a 



ij 



with a given relative tolerance e . 

Suppose that pivot ay is equal to a^^ • K it is not, 
interchange the first rows of matrices A and R with 
the i*^, and the first column of matrix A with the j^^, 
and save column interchange information by storing 
the difference (j-1) of pivot column index j and step 
counter k = 1 [^interchanging column 1 with column j 
means interchai^ng of variables Xjj with Xi- (1=1, 
2,...,n)]. 



.(1) 



= + 



11 



11 


- p ^^ 


A, U, 


(1) 

vl 


= %1 - \\ 


■4? 


(1) 

i'l 


= \l - \l • 


'S' 



, n) 




(5) 


(1= 2, 3, .. 
v= 2, 3, .. 


.. m; 
., m) 


(G) 


(1 =1,2,. 
v= 2, 3, ., 


., n; 
.. m) 


(7) 



If column interchange information is saved in the 
first position of the main diagonal, the result of the 
first step is the two matrices: 



/0-l)aj2 ^3 ••• ^m 



,(1) 



a<l> a(^) 
22 23 



^32 ^33 



2m 



3m 



a(l>aW...aW 
m2 m3 mm 



and 



rW = 



11 12 



21 22 



■ • r, 



In 

(1) 
2n 



ml m2 * * ■ mn 



Now repeat this procedure m-2 times , starting at 
each step with the matrix A^*^) of the step before 



Mathematics — Linear Equations 121 



without first k rows and first k columns, and the ma- 
trix r'*^' without first k rows. The total result after 
m-l steps is the matrices: 



-1) a<'> a<^> 



ao-2) ai^j 

^2 ' 23 



rm-1) 







(J3-3) 



. . a 



Im 

2 m 

(3) 
3m 



and 



"m ' ' 



R 



(m-l) 



r 


12 


r<^> 


/ r(2) 


,(2) 
22 


• • • '^2n 


r(3) 
31 

1 


32 


• • • '^3n 


\r<-) 
\ml 


m2 


• « • 1 

mn 



Now work backward and set: 



(m) (m-l) (m-l) (m) „ , 1 

1^ n , = I" 1,-a^ n • I* , (1=1,2,. .,n) 
m-1,1 m-1,1 m-l,m m,l ^ • 



(m) ^ (m-2) _ (m-2) (m) 

m-2,1 m-2,1 m-2, m-l' m-1,1 



M . ^(m) 

m-2,m m,l ^ ' 



''l,! - "^11 ^2 ''21 ^13 ""31 



(1) (m) „ 
4m- ^ml (l=1.2.....n) 



(8) 



After each step of back substitution, rows of solution 
matrix X = r("^) have to be back-interchanged ac- 
cording to interchange information in the correspond- 
ing main diagonal element of matrix a('^~^'; in order 
to get the correct sequence of right-hand side column 
elements r'^) corresponding to the sequence of left- 
hand side column elements ap'. 

The only case in which the above procedure can 
fail to give a solution occurs when at any step all ele- 
ments of the rest-matrix of A^ ) become zero, and 
no pivot element can be found. In this ease the pro- 
cedure is bypassed, and the error message ier = -1 
is given. Actually, because of rounding errors , a 
further check of the absolute values of pivot elements 
is performed by the procedure. If at elimination 
step k this absolute value becomes less than tol (see 
equation 3), it is likely that matrix A is singular too. 
But as this is not necessarily the case, and as this 
test depends highly on the choice of the relative 
tolerance c"*" , the procedure gives only the warning 
ier = k-1, indicating that there is a possible loss of 
significance in the results computed by the algo- 
rithm . In case of a well scaled matrix A and an 
appropriate choice of the relative tolerance, warning 
ier = k-1 may be interpreted to mean that matrix A 
has the rank k-1. If there is only one equation to 
solve (m= 1) , the test on loss of significance is sup- 
pressed. 



+For subroutine GELG, a relative tolerance f 
between 10"^ and 10""^ is suggested; and for sub- 
routine DGELG, between 10"^"* and 10"^®. 
-H-For example, e = 10"^ and warning ier = 3 mean 
that there is a possible loss of about five or more 
significant digits in the initial values of elimina- 
tion step 4, and that matrix A seems to have the 
rank 3. 







.gelg ^0 
GcLG iD 


aJOKOJl Irjt 


:-i.L<^ 


ocLO -.C 


t-jKt-'Jit 




*,tLt. 6C 


ru >ULVt 


4 ucNt-tAL SrSrS.'i Of ilrtJLTANgUlJS L1NE4R cUUATIOnS 




jiii^f 




GEL J ■*!: 


i-iLC .^lL 


iH.<,A,n,l\,^PS, [cf<l 


ocLG 10': 


Jcat,'v|»'nON 


i)r »Art^MtrcKS 


i-icLO 1^0 


.{ 


lilt M 5* M HAr<i< JF KIjHT HAnJ slJti. IJESrRJrtL, 


j^c-Li; li'i 




.)!'< ficlO-iU < CU.glAlMi InL iuLuTlLN „(- TH^ cwUAIIGNS 


-ucLL. 1*0 


A 


rnc 'I ^Y « Cll^FfUlc«J ;4-r«lK. lUcil^Ul^tO) 


vfcLO IrJL 


■^ 


r-it f*jA6ct If -^JUATlONS JS IML bVSUH. 


^lLO leC 


N 


iHt MU.IJtK Uf .*iv,nT rlA.Su a I Dc V,.CT:;kS. 


ucL^ 1?: 


cPi 


AN l\>'Of CJfVSTa.^T WrilCH li USci; Aa -KELAIlVc. 


Cti.-J liC 




1:)LtAA/4Cc r^'rt r£sr ON tGib. Uf SI i^Hl t- I CA,V_ t- 


o;lj hj 


I i:K 


K^a.lLTIMj ixACA >>AKAI^^li.fi CCOcU *S FUi.Li)«i 


ulLG iJC 




l.;l%:i - \u LKr^JK. 


utLu tlV 




[cK^-t - \0 .*!:iULT JcoAUSE OF M i_tiS IHA.* I Urt 


CcLJ 22C 




PIVOI LLtrtLi^r AT ANY fctlJtiNAriJM JfcP 


OcLo JiJ 




tJUAL TJ C, 


i^eiG j<.c 




.'U = A - ^A'<!ilfi^ JQC ]J mSlQlt ICS^ Of UCMfl' 


UU Jij 




C-thCt |;NJJC.ITlJ at tLlMIMATl^N iTc»> K*i, 






'*ii-'<; P;VJ? ^L-WlM .v«i LlSS HAN cH 


otLb jv: 




..JU«L rj Ir<c iNlLnNAL nJtc-iA.'^Ci; tit's TI «t $ 






i»jSjLur.;LV ^-.KtAltST cLcMcf.f Oi" .lATKIX A. 




^ie.'i ir-.i-i 




uCLG jK 


JN.'Ol l^-»l 


■liLci -i .,N J .\ A-^u. Ai;„.4LlJ 1;. rtt iIt.K;J ,UL^MN-ISt 


oct« >^; 


1 .\ -l-.K .<<_ 


i.-. r1<"1 Mji-OfiJlrfL il^jXAGt LUCAriJh-i, u.^ KcflJRN 


ucLij JIC 


joL^I ],;a, 


M.vrniA rN |j ^••^^,c cjtjMh^iit tCl. 




IH. r'-lj'.t: 


JjAf olVti ..LnULfj Ir li,L hJMi.H OF .jj-.rin,\i iH IS 


ucLu «:)"■ 


J IN - 4 1 ciN r 


u\ .; it,. ,-;v.r .LLi-i^pXili aT AtL ^Hil^iH-.JN irf"! 


•j c Ll. ' 1 " 


ItN^ ^ii l-L 


<.--! ^^,.:^; ^.. -:j.,_vL.< .^akjUNo u-<=^ - 1. ^ivC\ - 


U 1. L u J 7 ,■ 


i.^.-lv.At .> 


CJiiilLL- L..iS Jr ^I...If ICANCt. IN ..lie u^ A WuLL 




)',~LI„ Sj 


^l* - A,\,. A'V,<jJ,^,iT.. rn.e.^ANi;i. c^^. i^.v^^ liAV dE 


..,:Lo ?T. 


1 iHt (.iNt-.NL t 
■ 1 U .U T .u 


L.J TrtAt Kjr,i« A ,-,.,i fHc KA^^ ";. .\o wj.,.,ino l> 


.icir, -,.: 



122 Mathematics — Linear Equations 



Nj U^ ^^uii-ELIHIfum-N -I7h 



4IjiT L^_<1^:.■l^ l.H A^UK 



I t>IV>Td 

AU I li ^IVJT tL::Mt»tT. I>IW CJUAINS THt *dSCILJTS vALJc Of A(II. 



Lsr-1 

iF(*»IV-lL,4.l6tt>. ? 

j = n-ii/H 



of PIVOT fcLfcHEi^I 



PIVOT rflW REyJcTIO'^ iiNJ KCf l.'ifckCHA.^O 

f B=f lVl»RlLLt 
t^(Ll-T J 



1^ ttlllNATION I;. 
IFtit-HlS, 16, In 

LtNC^LiT*"*-* 

I I-J'-* 

UJ i 1 L-LST.Lc\(J 

AIL1-&4LL) 

rd'Pivi«»(i.Li 

alll'Ta 



IK KiGHT HAND jJOE « 



I^Ti 



pwur *'j» RfcOocriu\ i^ hwt^ia 



ftftiJ hcxi PIVJ! 4 



iLcrtt-Jl ^fcJJi-Ii 
five. 

J'O 

03 i3 ll^LST.ttNJ 

Pivi--^(iii 

lST«i[*h 

i-L-i-J 

A(Lt«^AUt**'IVi*'*(LL J 

Tb=«La<AUtl 

If «Tt-PIWI 15, Ib.i- 

PIV"ld 

1>L 

(.UNI IKIJC 

LL*L»J 

l.i.T-L3.I*M 

L.aLi UF Ltl^l^AIiilN Li-kJF 



tfACK SjBiT IlL-T ICV A.'»0 i^ACH lNItt^CnA^j£ 
1 Flh-U *::,;.;, 1 ■J 

LS»-«*1 

DO .;! l-i.« 

I1=LST-1 

iSr=liT-tST 

i.-AILI'-.'j 

lU 4.1 J-il.N1..^ 

tu*>tl J> 

Kt JI=klKl 

i 1 AlKl-To 
4^ KtTUK'X 



cknUK <ETU(tt> 
kCIURN 



JtL'i ^7C 



itLG 



■ii-Li 39C 



ucL(. 


/i>- 


-tlli 




C£Li; 


7 2G 


.icLo 


7i? 


^eLi; 


/to 


u = I.C 


T^J 


wrLi 


T6C 


0£t.^ 




«ci.O 




GfeLG 


r9: 


j£Li 


3, J 


CtLG 




M^L-^ 








GELGl^ir 
(.ElGlCaC 

ge;lo:od: 

UELC.'iC 

GELC.ll--' 
GLLulii: 

uELGll->C 
uftCU J.. 

iiCLGil^C 
;*tLOtl=C 
iicLGll*. 

JcLGl^c; 
GcLOiii: 

GcLGliaC 
GtlGi.-: 

«ELGJ3'.: 

GELGUTC 

GctGim 
JELGll-:- 

jclgui:' 
(jtLGi-.^: 

liELGltJC 

i,El.Gl-.<.C 
GcLGU^C 

uElglho;' 

JtLGi.-.K 
JtlGUdC 

celguv: 

G^lGI^^C 
GELCl3>C 

GELG155C 
JELCl^s: 
GELGiiTC 
uELulsiC 
GELG159: 
GcLGls.: 
.i€(.Gl;>i: 
CEl-Glo^C 
GclGIoj:; 
./cLGIo— : 



^UbKOuTlhE iJ^tLG 

PgKPQSf 

XO ^JLVE A GtlVcAAt. SrSI£M OF :)lHU4.T*hfcUUS LINEAK tUlJATlOMS. 

USAGE 

CA«.t. L>GEt.G(f<t A,H,h, cPSt IcAl 

OcbCklPTIGh lie PAAAHETtRS 

A - OJUdLE P<vEClSIJr< H &Y r« (ill>HT HANU SiOt MATAIx 

liJt^lriuVcb)) . 'JH licTUKN K LUNIAIUS THt SuLUTIuhS 
L,F IHc tJJATIOi-ii. 
A - JJLIi.Lt PktClilUN « 6* »- CUtfFlCltKT HAI.<1X 

rjLirROVtCj. 
M - Trit MJrtbtK 0^ EtjJATlG.xS ih fHt SYSIE*-. 

1. - Wtc NUJ.tLrt OF «iGh7 tiAfiu MOt VfCTLkj. 

tPS - ilfijLt Pf.tLISIUN INPUT CLhSTANT WHIkH li USED AS 

KtLATlVt rjLt«Ai4tt H* rtST ON LOSS UF 
ilGNlf ICANLt. 
lEA - AcSJLTING ERhuK PAMMf^ETtl^ CObtU AS fOLtJuS 

lEK'C ~ NO tK«(m, 

|t« = ^l - Uu RCSUtT atCfcUSt Of « LtiS TnA#. 1 OR 
P;i/uT ELtMfcNT AT AMV EllMlfailOK STEP 
tijUAt TO Ci 
Itft.K - tiAhiiING uui. IiJ POJ-SIBLE tCSs CF StGNlFI- 
CAHc {"tOICArtO Al fcLIHlNATtOh SrtP K*l, 
hhERE PIVCT EiEHEhl HAS ttS^ triAN bfl 
E<.U<'L r^ TMc INIfcklUL TOLtKANCE EP& TIMCS 
AtKSL'LUTELr u<<EA|esi ELCMtNT Jr HATRIA A. 

mE.hark» 

1M>UT MATRICES it AhJ A A>(c ASSii^El^ TC ik. STCREJ -uLUMMi^tSc 
IN n*»i IsESP. n«H SUCCESSDTE SIJAAt^E UrCATIONS. C"! AtTURN 
SOLJTICN KATftU R IS SfCREu CULU^hrilSf TOa. 

The PKCCcOjHe gives HiSuLTS IF \Hk ?«UNiE*t ur tvUATIuNS M IS 
Gt>EATl.r4 THAN ANO P I VJT cLEiHc-^TS AT ALL ELlHINAriOh STEPS 
AAc DIFFc^icNT F^OK 0. rlJ«Ev£;t «^4N|fiG IE4-II, - IF JIVEN - 
IKJICAftS ^DialiJLE LOSS JF SliNlF ICA^itc. iK CAit OF * MEIL 
iLALEJ ^AlnU A AhO APPRiOPftlAT^ TGLtRANCE EPS. IcK'K Hav Sc 
|NTERPx£TEJ THAT f<ATRlK A HAS THc AA*tK ii.. Nu MAANIhu IS 

'jlv€N IM Case f^'i^. 

SUEAOJir^ES AMJ FJj«CTIJ^ SJlPitOGi<AiHS •tECfUIRcO 



rc 



»*ETriCJ 

SCLJTICN IS JUNE bT ^tftNS 
Ct^PLc'e PWoTlNO. 



Of JAJaS-ELIMINATt^N rtlTH 



SUttftJuT Uc 



ELS(R. A,f4.,\.tPS.l£ill 



L'lnEhSIu^ AlIl.xUI 

t,0i;3Lfc PrtEClSI^N li, A,PIw,Td,rJL.Pl¥l 

SEaACH FCK G'tcATcST cCc^ENT iH lAIAM t 
i lER'C 
PIV-C.OC 

JJ 3 L'l.H'l 

T&*JAbS(AIL) I 

Irlfo-PIVt 3.3,^ 
2 PIVTd 

I'L 
i ..JNTlNJE 

TuL-cfi'PI V 

A(I» IS PIV-I rLC.-tiMf. PIW i.J.<TA|Ni iHc AflSOLOTc VALJd OF All). 



LSl-l 

iJO 1 7 it = i»H 

TEST u.^ Sl.-iuJLAAiTf 

IFtPI V)<3,^3,4 
•i iff itR) 7. 3, I 
5 |FlPlV-TdLl6,6, 7 
o it«-A-l 
7 Pitfl-l.uC/Al 1 I 

JsII-lt/M 

i>|-J*.'*-fC 

I*K IS HO-.-l»L)t<, j*t( CJlUKM-I^JcA J- PUCT cLtHc'.T 

PIVUT hC'i' ^l^jCfi:.!^ t,!*0 ■i'Jt, I.<4TEALHA\uc IN KIGht HAND SIJc R 
(,0 6 L«K, «'<,•■ 
LL-CU 

ra = P|WMA(LLl 
^UCl = RlL) 
3 -IL l-TS 

IS ELlHlhATIJN T^RIlKATEtJ 

CJLJHfD INTfcRCHANuC IN l4Ar:<IK A 
<i LtNO-LiT'M-K 
IFI Jll^,l^,t j 
l<. 1I-J"K 

i>Q 11 L>LST.LE\J 

To-AILI 

LL>C*I 1 

A(Ll-A(L. I 

It iittlCTa 

AjM INTtHCHurui^t A^KJ PIVOT kG« REDUCTION IN MATRIX A 

12 iO U L'iiUnn,H 

LL»L»I 

IB'PIVl 'AlLLl 
«.(LLI-Aai 
U A(4.l-T5 

SAV£ CJEUNM INTERCHANGE 1NF0A<1A T lOh 
AUSTI-J 

ELEMENT RtDoCTlJj A«.0 N€«T PIVGT SEAACM 

PIV'O.JO 

LST-iST+l 

J«C 

OC 16 I l-LSTtLcKJ 

P1VI--AI 111 

isr-ii*N 



OcLG 
StLG 
UELG 
Cfct G 
CcLG 
bfc'LG 

uelg 

OcLG BO 

OElG 90 

OtLG ICC 

OcLG 110 

DELG I2C 

UcLG 13: 

UElG I'.O 

UCLG Ibc 

OELG ;^c 

DcLG 17; 
JtLC icC 
UlLO 1 /C 
CtLG iCt 
UELG 2iC 
OtLG 4;2C 
OfcLG 2 3C 

JELC e-vc 

DtLG <*C 
OElw 2S0 
CtLG ^Tj 
OtLG ^fcC 

JELG 14::' 

OELG 3.: 
OtLG 31C 
JELG 3^: 
OcLG 3)C 
U£LG Si: 
JELG 3^: 
iJtCS iaO 
J£LG j7J 
OtLG 3d: 
OcLG 392 
DctC *C0 
3«LG *iC 
DELG oJO 
OELG «iC 
DcLG ^4: 
DELG *5C 
OcLG ••oCi 
OELG (>rc 
OELG *a; 
OELG *iC 
OtLG iCZ 
DclG SIC 
0=LG 32C 
..UELG 53J 
OELG 5*C 
OELG 55: 
L^cLG 3&V 
i/cL- 57J 
OELG as: 
OtcG 5«: 
OtLG s-:-: 

DcLG Si} 
JcCG o^C 
OELG »)': 

OcLG 3<t: 
OcLG t»3; 
OELG ti&: 
OELG S70 
OcLG 6i} 
OcLG 19: 
OELG 7:3 
OELG 7i: 
0=lC 72: 
OtLG 73; 
CcLH 7'*.' 
OclG 7SJ 
wELG To3 
OtLG 77? 
3cLG Td: 
DELG 7)C 
3ELC iCI 
JcLG di: 



■jELi; 



B^: 



DtLG ij: 

uELG d^: 

OcLG ii7 
OElG db^ 
OELG d7C 
GELS 3!)D 
OELG i9: 
OcL:* 90G 
DctG 913 
OELG 92C 
OELG 930 
OEt-G 94': 
OELG 930 
OEi-G 9^C 
OcLG 970 
DELG •'3C 
UELG 99C 
OfLG12:r 
JcLGiClC 
OtcGlOiO 

DtLCi-:3': 
OELGi:*: 

OcLGi:50 
JElGICoC 
DeLGU73 
OcLGICSJ 
0ELC139C 
OcLGUC^ 
OELGlllC 
OcLGll^C 

bELGUoC 
DELG1IS3 
OELCildC 
L)cLG117C 
OcLGliaC 
DEL SI 190 
JELGL^CC 
OCLG1217 
OELC122C 
OELCl.^30 

OELCliSC 
CELGU60 
OELGl^rC 
OELGL^eO 
DEtC129C 



Mathematics — Linear Equations 123 



LL'fJ 

it rv(i.Ll-R(ti.l*f=lVI*'<( L) 
IT LSl-l.Sr*rt 



4t if (y-ll i"3.£*!,t-. 

L-o 2i 1 = ^.1 

i i«Lir-i 

I6=W( Jl 

i.u ^. K-I>T,*<r(,rt 

2l Tb=Tc-AUI*^(LLl 
^=J♦^. 

il 4IKI=Ti 



£> ItH'-l 

tJtQ 



UcLC.tii. 






JcLGl 
OdLii 



>7, 
L.cLGli.>0 

DtL015LC 
CtLGI6<:0 

ticLOio^: 



Subroutine RSLMC 

This subroutine computes an approximate solution 
to a system of linear equations when the coefficient 
matrix has been factored into a product of two tri- 
angular matrices. 

1. Mathematical background 

Consider a system of linear equations 

Ax = b (1) 

having a nonsingular coefficient matrix A. There 
exists a permutation P such that PA = LU, where 
L is lower triangular with unit diagonal, and U is 
upper triangular. Putting c = Pb we see that (1) is 
equivalent to the system 



Ux = y 
Ly = c 



(2) 



Let x^ be a trial solution of the given system. It 
can be improved by means of the iterative process 



r(P) 
Ad<P) 



(P) 



= b - Ax 



= x<P) . d<P^ 



(3) 



where the correction vector d is computed using 
L and U as in (2) . 

If A is not too ill-conditioned, this process will 
give a satisfactory solution, provided that r(P', the 
residual vector, is computed with sufficient 
accuracy. 

2. Programming considerations 

This routine may be used to solve a nonsingular 
system of linear equations whose coefficient matrix 
has been factored by means of subroutine FACTR. 

Let € > be a relative precision parameter 
(input to RSLMC). In the following discussion we 
use the notation ilxll =E |xj| . The process (3) 
is applied to the system (1) starting with x(°) = 0, 
and is stopped when one of the following situations 
occurs: 

a, iEn= 0. The components of the correction 

vector d^P' satisfy the inequalities 



(P) 



s c 



(P) 



i = l,2, n. (4) 



Then x = x is returned as the solution. 



124 Mathematics — Linear Equations 



b. Assume that p > 1, for some i the inequality 
(4) fails and 

1 



.(k) 



,(P) 



2 
2 



> 1 



.(k-l) 



,{P-1) 



k = 1,2,>, 



.p-1 



Then: 



lER^lif Ild^>ll -e ||x<^>|| . 

IER = 2if \\M\>^ II x^P^li . 

c. IER = 3. II d^-^^ II ^Ylld^^^ll . In this case 
the trial solution is too far from the exact solution 
and the process cannot converge. In general this 
happens when A is badly ill-conditioned. 
lER = 4. U is singular, 
in all cases x = x^^) is returned. 
Note : To obtain accuracy in the computation of 
the residual vector, each component is computed in 
double-precision arithmetic. 

For reference see: 
(1) H. J. Bowdler, R. S. Martin, G. Peters and 
J. H. Wilkinson, "Solution of Real and Complex 
Systems of Linear Equations", Numerische 
Matheraatik, vol. 8, no. 3, 1966. 



(2) 



J«H, Wilkinson, The Algebraic Eigenvalue 
Problem. Clarendon Press, Oxford, 1965. 



iUftP.OUflNf «SL»(C 



SCCJTIOM OF A ^VST€« Cf lINftr^ COU'TIOM Bl-S 






,Af ,9,r.r<,ff'<(i,ifF.u,v,'ep| 






DCSCCIPTIGN OF PkPtf»€Tf9^ 
« INPUT MATRIX 

Af *PftAV ff TMC F*CTO«IZ*TIOH CF ThC rfflGISAL «*TRIM 

fl tlGMT HAhO SIO€ V«TCR 

V VeC"JP CONTAINING TM€ 5Q;.UTIC« ON rttUfN 

N 0PC6« OF THE SirSTE** 

fI'=LAT|VE ^PtCISCCN INCrCATCWIBtOOIfftC IVPUTJ 
fo-jpB INtlCATn" 

• IF FIICM rO^PQIttKT CF I HftTS Thf PtfCISir.N I 

•I IF ONLV The HW^ Or X METS TUS buECUION 

-2 IF THE PRECISION IN T**i KCHW CF THC CO'4PUTtO «U«< 230 

SOlUTICN li tOhSa rHA\ £PSI P^L" 2J1 

»J I* THE SOLUTION ObTAlNtO HAS hO ••CAtilNC *" »H. »U* ^'i.f 

-* IF i OIAGCSAL T£^"! 3F Th6 li#Pe« TPfANGUtAP «St»" iJ") 

FACTOR 1^ tESC ' «SL« 2^J 

if?e OF Trtt floSI DIMf'^SirN AiSIGKEP :r friE Afr^AT A iSlK ?70 

rN IHf CALLING PPCGPA*! -HeN TI-.E MAT. I It I". IN DCU^LE «SL« ^^J-i 

Sj3^'"6IPTeO OAT* STOFA^.e «»GOf. M'fc WMFK THE «ATmX ASt" ^'5') 



IS IN SSP VtCTOO SIOfiAGt "OOt . 

WijarING stcpa';e veCTOS 

CT-'ekSION CF V •'uST BE SP^tft^ thAN 

y^J."".- HHifi af^LTATIONS OF ^OMS r* 

STOHEO 

OrM<-NSION CF PfP NUSI jE GCCATeR r>'AN C« E3UAL fP N 



Cf EGUAl TC N 
THE HATFIir APE 



■SLH 
ASL" 
»SL« 
• SL»' 



THE M«Tt-U or IMF SVSIf« WAT t)E 
FACTi IN TMt Aa^AV *f <»'I0« T? 
IME trV" rilANGUl.A"! fACTOP "^IJi 
FPSI IS M';ntf|£0 WHEN !tF-2 

JUet-QiJT !•«€<; ASd fUNCTICfc SjePAC&ft*' 
N0N5 



A TPi,.L ';cL'jri* :s Fi-tsr CL.f-'iiito. 

C»LCUt.4T!rc FRC* ^FS'Ok<«l VECT^IdS. 



«Ef £«£«IC^< 

J- H. WILKINSON - 1-4f *LG€ttPt-ir 
ClAaESOl* PRESS JXF"":, 19*5. 
5. *»'=T£P:, AVO J. -1. wIlRINt?'.. 
'Of'»ltK i.VST*»«5 :iF LI'.Eic ccj — 
VCL. e, ^-"1. 5, U*6, :i7-23«.. 



FACTCaWcO 

«r«V TO TMI3 iUfi'lUTtNE 
ftArfC AN UMT ;iA5n-j»i_. 



PSL-^ J": 

THE SUO.HOUTINS^SLK m 



TMft. c^e-ecncNs a«e 



PSl" *.?T 
tSL« -JO 

«St 
tSl 



•St" 430 



• SIP" 



*»5 



"St" 50J 
PSLM ^1) 
asc 5?i 

■ Sf S33 



SUnPC*JTI»E PSLJ«C C;,Af,a,x,- ,f p^i.irs 
OlffENSlOS A<tl.Ar=fl|.P.ftl.Xlll,Vlti,3: 
DOUStE P=?CISrC*: 3» 



(rlGE^IVALUc PRC?Lc»< - 
-. J. SCNDLEP. P. S. PAftTIN 
♦S-rtUlir** IF PcAL ANO 

:;*is', »u»'FRis':»-c mathc*!atm,rsli 

•SI" 5^0 

•St-N S*.! 

A St" 5 TO 

A Si" «?0 

lA.v.PEai pst* 500 

Mil =st» -Sl-^ 

ASlf 613 



INITIAL liATir-. 

DO-0. 
ICP-0 
IfE'O 
on 10 i>i.> 

Vll 1-6(1 > 
10 Illl-O. 
in irf-iTf*i 

iME PtR«uTAriON< OF aou^ ut A $m aoplicd td v 

00 10 1-1. N 
^-PEflll 

IF I«>l >2f) )0.?9 
>*> OI-VIKI 
Vmi'VII I 

vm-f>i 

30 CONTI>4UF 



TPIANCULAk SYSTEM 



SOLUTION 0= THE LOWCI' 
on 50 1"2,*4 

INI-I-l 

D»-V(II 

It(-I 

00 40 R-l , I-*! 

0P-D»-1,C0«4F< m**-**! 
40 IK.IK*IA 
^0 V( I l-OP 

soL'nnr tf Tne uppet- T^iAN&uLAa s»stf«« 

iriAFIUII ^ii.*»4.*,F. 
t»*. lEP-4 

GO TP a? 
58 W(M|.i>P/Af U< I 

DC- 70 I-?.'* 

IHI-N-I* 1 

INF-I«).l 

OP = VI I-^l) 

U") INI- lMft*lMl 

r| = AFt :»r I 

00 f,-i ir.ISf ,«« 



u 



*0 r.P»PP-!.0')*eFl IK)»V(FI 
70 W( IHll-CiP/:^! 



t/l-f;l*a8'.(v( I I I 

02.02*!cS(Xi I I I 

IF CAS3IV(ril-FPSl*A8S()({ril» 60,80, TS 
75 KL^-I 
tie CUSIIN'ff 

IF Utf Il40.»'2,fc*> 
^2 PFTOAN 

as IF tirf.-ii\M),'»n,^i 

JTfdJTIJNS •'•£ <TO">rrj wfM TH? 
IMA'* rULF CF T"E ON? OF Tm^ FQH 



»=< OF »rt€ ro' 







-7 


IF (OO-2.*31ll20.S.0,»0 


RStN 


10 


JO 


00 « 1«I,N 


■ Std 


20 


#5 


I'd l-KUI.VI II 


•«.N 


W 




00 110 I'l.N 


• StM 


*0 




CP-9II) 


• StN 


=>0 




11-1 


• S4N 


60 




DO 100 r-l.N 


PSt" 


*0 




DP.uP-i.u'j*A(;iti*xui 


«$l" 


a.-} 


lOG 


l — IMIA 


■ SL« 


90 


llO 


VI II .OP 


■ StM 


!0f> 




00«OI 


fSLN 


11'; 




GO TO 20 


RSLN 


120 


l?'5 


IFIITE-ilMI. 140,125 


IISLN 


I'O 


12S 


IF (01-EP;I»3?l!27,l2r,no 


ASLP 


140 


I?7 


ie»-t 


«Sl» 


I SI 




PETUFN 


AStN 


160 


150 


IEa-2 


• Sl»< 


170 




E»Si«Ll/;j2 


HSLN 


MO 




PETUR^ 


• StN 


190 


MG 


ICP-) 


PSt" 


itO 




PETUPN 


RSLf 


211 




END 



■ Si" 610 
FSlP *40 

^SIN 6S0 
PSL" fe*.-) 
PSl** 6 70 

«*iip h^n 

• SLf %■»') 
»Stt» 701 
• V • 713 

• SIN in 

• Sl*« 74'* 

• Si* 710 
6St»» 7*') 
•St*" 77-> 

• U* T10 
«SlN 7^0 
•iL" 1'*0 

• 1L« ^n 

• St" i!?'* 
PSLH »Hf( 

• SL" *i'.a 

SStit >!*.'> 

■ SLN ^t>, 

■ SLH ••'') 
'SIN U'.fi 
*SLN VI 
PSl- ',?-, 
PSL'* *.--) 
PSL" ')'.'» 
SSL*" ',-.'- 
RSL" ',/.0 

• Sf '."J 

P',l»' «,=10 

B'A«I ')'>'J 

A SI fit/ 1-: 

t ',L"JOi'. 
CSl M1(,4T 

P'Afl JVJ 
Pti*;'.'-'^, 

P'.Lfl'J'-v 

f'.Lf: ': = ', 

• SlKl'.'.O 

BSl-! I',-: 
P'-Lf^l M *. 
^'.L-^J \/': 
'-SL-U;. 
P'A^l !••? 

Fifi I'-'. 
p'iLPi !',•; 



li'.lMI I<.^ 
i- 'A •;;"('( 

1« >L N 1 2 ?0 
PSl»'li'^0 
PSLPl J4n 
■ SITUS') 
[ PSL*[^*,,> 

• 'jLNI ?I0 

• St'«l2'rj 

tSLNI Jl i 

'SI"; in 

»SL"l =, ' 1 

fit*! 3i'< 
".fl i'O 
•SL-l ISO 
a'.LPl ^',T 
fr :l • 1 J 7 J 
PU-I 5>'. 
t >|. - 1 J ', 

• SL<'t4lO 
A IlL • 1 *. 1 'J 

• 'A P 1 4 "", 

• SI*!**.'- 
■ SL-I^iO 
ftSl.«'l4',0 

RSt*)'^? 

• Sl'14-.- 
PSL-IS'". 



Mathematics — Linear Equations 125 



Subroutine FACTR 

This subroutine determines a decomposition of a 
real nonsingular matrix as a product of a lower tri- 
angular matrix with unit diagonal and an upper tri- 
angular matrix, 

1. Mathematical background 

Let A be a real nonsingular matrix of order n. In 
general, A can be factored into a product of the 
form A = L U, where L is lower triangular with unit 
diagonal and U is upper triangular. 

The elements of L and U may be computed recur- 
sively as follows: 

p-1 



a. = a. - 
ip ip 


2. 

k=l 


ik kp 


i=p, p+1, . 


. ,n 


1. = 5. / 
ip ip/ 


/i 
PP 




i=p,p+l,. . 


• ,n 


u = a 
PP PP 











P-1 



.rE 



u.=a.- > 1 , u, . j=p+l,p+2, ... ,n 
PJ P] L^ Pk k] 
k=l 



Using these formulas for p= 1,2, . . . ,n,the 
decomposition can be carried out in n stages. 



p-1 

% = %-Z) 'ik\p i=P.P+l.---.n 
k=l 

Each term a'^ replaces the corresponding term 
of A in storage. 

b. Equilibrated partial pivoting. 

Let m be the smallest row subscript such that 



(1/Np) 



mp 



= max 
i^p 



(1/N.) 



IP 



If a.jjjp = 0, the error message lER = 3 is given 
and further calculations are bypassed. If a ^0, 
the m'''^ and p*'" rows of A are interchanged, 
PER(p) is moved to PER(m), and the number m is 
stored in PER(p). Thus the first p positions of 
PER contain the information on the permutations 
needed so far in the form of a transposition vector. 

c. Computation of the p**^ column of L. 



1. = a. /a 
ip ip PP 



i=p+l,p+2, .. .,n 



These terms of L replace the corresponding 
terms of A in storage. The diagonal terms of L, 
which are all equal to 1, are not stored. 

d. Computation of the p*" row of U 



u = a 
PP PP 



2. Programming considerations 

Even if A is nonsingular and well-conditioned, the 
above process can fail when a leading principal 
submatrix of A is singular; furthermore, the pro- 
cess is numerically unstable whenever a leading 
principal submatrix is ill-conditioned. 

In order to avoid these inconveniences, a tech- 
nique of partial pivoting combined with an equili- 
bration of the matrix has been built into the 
algorithm. 

Initially, the maximum norm of each row vector 
is computed; 



p-1 



N 



J 



PJ 



p=l,2,, 



If any Np = 0, the error parameter lEH is set io 
3 and further calculations are bypassed. Other- 
wise the reciprocals l/N^ are computed and stored 
in the vector PER. 

Then, assuming that the first p-1 columns of L 

and p-1 rows of U have been computed, the p*" 

stage of the factorization process is: 

a. Computation of the a. . 

ip 



u = a - 7 1 u 
PJ pj JLu pk kj 



j=p+l,...,n 



k=l 



These terms replace the corresponding terms 
of A. 

Note : Double-precision arithmetic is used to 
compute the inner products needed in steps (1) and 

(4). 

For reference see: 

(1) H.J. Bowdler, R. S. Martin, G. Peters, and 
J. H. Wilkinson, "Solution of Real and Complex 
Systems of Linear Equations", Numerische 
Mathematik, vol. 8, no. 3, 1966. 

(2) J. n. Willdnson, Tfie Algebraic Eigenvalue 
Problem. Clarendon Press, Oxford, 1965. 



126 Mathematics — Linear Equations 



SlERCCIl^E FJCm 



FCrH 

.FCTR 

fCT« 
fCTB 
FCTR 

FLSKit FCTR 

F«CICI<l2«TICh CF IH£ ft^fl^H A IMC * PRCDLCI Cf A IfWER FCTR 

J/f>GLL«M l<i1fllK I AhZ MK tfPtO IHIA^CULAR fJIPlJi O. L M4SFCTH 



L»n CliGCKiL kt-ICF IS IkCI SICREC. 



LSiCE 

C'lL F«CTHU.P(R«h.U.|f«| 



CeSCi^lFIUh CF PtftPttEKS 

* p»m\* t 

ftf QKt ClfE^SIONAL #RB«Y hHERE PES^'L F»T IC^* CF RChS Cf 

1»^£ fAIRlX ARC SICREC 
CIPtfcSlCIt Cf fED PLS1 eE CVEATffi TFAh CR EQUAL TC M 

^ CRCCR CF 1F£ PATf)I> A 

U SIZE CF It-E fIftSI C1*'ENSI0(> ASSIGKEG 1C TH£ AR<IAT A 

Ih The CALil»iG PRCCRAM khft. ■»•£ fATRI« IS IK ilCUBLE 
SteSCBIPIEC OAl* S1CRACE PCOE. lA-K. %f.fh T^E fAIRIX fCTA 220 
IS I*. SSP WECICW SKRACE PCCE. FCTR 230 

1£# ERRCf) IfCICAICP kFIC^ IS 2E«C IF Tt-ERE IS hC ERftCR 

the IS Tt^REE IF IKE FRgCECLRE FAILS. 



FCTR « 

FCTR 100 

FCTR 110 

fCT« liO 

fCTH HO 

FCTR 1*0 

fCTd ISO 

FCTR 160 

FCTR I/O 

fCTR 180 

FCTR in 

FCTR 200 

FCTft 210 



flH(H 



fCTH 2« 
FCTR 250 
FCTR 260 
fCTR 270 
Ati: REPLACED CY ThE lAIAhGULAR FACTOR$FCTR 280 

FCTR 290 
IhC FLKCIICh SLEfHCCRARS KECCIREC FCTR iOO 

fCTA 310 
FCTft 320 
fCTR 930 
FCTR 3*0 
fCTR 350 
FCTR 360 
FCTR 170 
FCTR J80 
FCTR 390 
FCTR *00 



t-i CRIClhAL *'«TNU, 



SiefCltUES 

PEIFCC 

£tCCESSIVE CCfFLTATICh CF 
CCffESfChCUC RChS CF L. 



[^E CCLL^KS CF L AlkC ThE 



FEFEREttCES 

J. f. hILKlKSCK - ThE AlCEGRAIC EIGEKVALUE PRCGLEC - 
CLIfCACCK PRESS, C^fCRC* ISE5. h. J. BCIiOLEfl, R. $. NARTIN 
G. FEIERS. AhC J. I-. kllLKI^SCh - •SCLL1ICK CF REAL A^C 
CCPfLEf SVSIEPS Cf LIhEAR ECtATIChSS htPEKISCHE PATHEPAT IK.FCTR *10 
VCl. «* KC. 3. 19tC. P. ^17-23*. FCTR *20 

FCTR *30 

FCTR 4*0 

FCTR *50 
FC1R 460 
FCTR *70 
FCTR *80 
FCTR *90 
FCTR 500 
FCTR 510 
FCTR 520 
FCTR 510 
FCTR 5*0 
FCTR 550 
FCTR 560 
FCTR 570 
FCTR 5«0 
FCTR 590 
FCTR 600 
FCTR 610 
FCTR 620 
FCTR 610 
FCTR 6*0 
fCTR 650 
fCTR 660 
FCTA 670 
FCTR 6a0 
FCTR 690 
FCTR 700 
fCTR 710 
fCTR 720 
FCTR 7)0 
FCTR 7*0 
FCTR 750 
FCTft 760 
FCTR 770 
FCTR 780 
FCTR 790 

fCTR noo 

fCTR 810 
FCTR 820 
FCTR 830 
FCTR S*0 
fCTR 850 
FCTR 860 
FCTR 870 
FCTR 880 
FCTR 890 
FCTR 900 
FCTR 910 
FCTR 920 
FCTR 930 
fCTR 940 
FCTR 950 
FCTR 460 
FCTR 970 
FCTR 980 
FCTR 990 
FCTR I 000 
FCTRIOIO 
FCTR 1020 
FCTR1030 
FCTR10*0 
FCTR1050 
fCTRlOfcO 
fCTRl070 
fCTRlOBO 
fCTR1090 
FCTRllOO 
FCIRlllO 
FCIftll20 

fcrmiio 

fCTRIl*0 
fCTR1150 
FCTf<1160 
FCTHU70 
FCTRUaO 
^CTHU90 
FCTR1200 
FCTR1210 
FCTR 1220 
FCTR 1230 
FCTR1240 
FCTR1250 
FCTftU60 
FCTR1270 



<Le(-CL1U£ F^CTPfA.FER.k.lJ.ItRI 

CIPEASUlk AUl.PERllI 

CCLElE FHECISICK CP 
C 

C CCfFLWIlCK Cf bEIGt-IS FCP ECl, IL IGR AT ICh 

C 

CC 2C I-l.fk 

»«c. 

CC IC j-i.h 

IF lAESIAlUIJ-f IIO.IC; 

t >-'es(AUjii 

IC 1J-IJ4IA 

IF (»} lie. lie. 2C 
2C fERlil-l./X 

IC-C 

CC ICC 1*1. h 

IPl-1-1 

IFl-Kl 

IFIVC1>I 

«-c. 

c 

C CCPFLUIICf. Cf M-l ITh CCLLPh CF L 

C 

CC !C t'ltk 
Kl-lOP 
CF-A Ul 1 

IF (I-ll UC,*C,25 
25 KJ-R 

CC 3C J-l.lPl 
IJ>IC«J 

CF-Cf-1.CC«A(|(J)«A( IJ) 
3C *J*KJ<1A 
AIKM'CF 
C 

C SE'FCF FCR ECCfLIERATEO PIVCT 

C 

4C If (X-t/£S(CFl«FER(|(|l45,5C,5C 
*5 IFIhCI-M 

>«C<£SUf)*PER(K) 
tC CCMI^LE 

IF (X )liC.llC.55 
C 

C PERPLIATICK CF AChS IF RECLIRtC 

C 

;; IE (1FIK1-I) IK, 70.57 
■7 «(1-IF1VC1 
Ij-t 

CC ec j>i.h 

V-AIIJI 
A(|J)*I lit II 

<lt(l}-> 

Kl>|il*i/ 

tC IJ-U*I< 

FEf;(IFUCT)*PE«iU) 
7C EEp-I I)-1FIVC1 

IF <I-M J2.1CC.1CC 
ii IJ-1C*1 

f'ii |J 1 

: CCPI-LlAIiCh CF Ui IIF hih CF L 

KC>IC*IA 
CC SC K>Ifl.h 
li|-IC*n 
flKl t>A (K I l/f 
IF II- I IJ IC,«C. };: 
7i IJ-I 

KI««C*I 
CF>iUl) 

CC ec j-i.i*'! 

•■J-KC^J 

Cf >CF-1.CC*A( IJMAInj) 
ec IJ<1J*I/ 
AUII-CF 
SC «C-CC*JA 
ICC IC-IC<Ii 
IEH-C 
t'EILfi^ 
IK IER>; 

the 



Subroutines MFGR and DMFGR 

The followii^ calculations are performed for a 
general rectangular matrix: 

1. Determine rank and linearly independent rows 
and columns of a given matrix. 

2. Express a submatrix of maximal rank as 
product of triangular factors. 

3. Express nonbasic rows in terms of basic ones. 

4. Express basic variables in terms of free ones. 

1. Theoretical backgr ound 

Calculation (1) is most critical. It is not claimed 
that MFGR will give the correct rank in all cases, 
due to the intrinsic difficulty caused by performing 
calculations with a finite number of digits. 

The rank is determined using the standard 
Gaussian elimination technique with complete piv- 
oting. This implies that the rows and columns of 
the given m by n matrix A are interchanged at each 
elimination step if necessary. The interchange 

information is recorded in two integer permutation 
vectors IROW and ICOL: 



The i 



th ( row ) of the interchanged matrix 
( column f corresponds 



nROW(I)th row 
° ® UCOL(I)th column 



in the original 
matrix A. 



Initially IROW(J) = J and ICOL(J) = J. 

The notation A^ is used for the interchanged 
matrix implied at the i*'^ elimination step.t 

a. First elimination step 

Let ajk be the absolutely greatest element of matrix 
A, which is found first in a columnwise scan. The 
internal tolerance TOL is set equal to |EPS 



a. 



jkl 



If I aj[f| ^ TOL, further calculation is bypassed. 
Otherwise rows 1 and j ana columns i and k of matrix 
A are interchanged, giving A^ . The same inter- 
changes must be applied to IROW, interpreted as 
column vector, and to ICOL, interpreted as row 
vector. 



a1 is uniquely expressed as product L^ 
by imposing the following conditions: 



Dl • Ul 



(I) U is the n by n identity matrix except for the 
first row. 



-I- 
Superscripts do not mean powers. They merely 

indicate the number of the elimination step at 

which the result is obtained. 



Mathematics — Linear Equations 127 



(II) L is the m by m identity matrix except for the 
first column. The first diagonal element has 

a value of one. 

(III) D-'- is an m by n matrix with first diagonal ele- 
ment equal to one, while all remaining ele- 
ments of the first row and column are equal 

to zero. 

Partitioning of matrices A-*^, L-*-, D-*-, U leads to: 



r- 


^^ 


k 


22 / 


or explicitly: 


1 


1 


4. 


-<. 


4i 


= 4 




11 



22 



= l; 



u. 



21 12 



+ D 



1 

22 



This means: 

(I) The elements of the first row of U are 



11 



^1' ^2 



1 11 

\2' ■••' ^n = ^n 



(II) The elements of the first column of L are 



i = 1' 4 = 4Ai"--'Ci 



1 / 1 
V/^ii 



Note that it is possible to record all nontrivial 
entries of L-*-, D-*-, U-'- in the storage locations oc- 
cupied by the original A, storing only: 




b. Second elimination step 
,1 j^ 2 



Let d. , > be the absolutely largest element of 

D . If I d . ^ TOL, D„„ is interpreted as beine 
22 ik I - 22 



'22' " I jk 
the zero matrix. 



If D is not zero in the above sense, it may be 



decomposed analogously. In the compact scheme. 




rows 2 and j and columns 2 and k are interchanged, 
obtaining : 




The same interchanges must be performed with 
IROW (interpreted as colunm vector), with ICOL 
(interpreted as row vector), and with A^ giving re- 



sult A' 



2. 




U 



12 



(III) The elements of submatrix Di, of D^ are 



d., = a., - 1.. 
ik ik il 



i = 2, .... m 
k = 2, . . . , n 



Ik 



Ik ik 



11 



Capital letters are used as notation for ma- 
trices or vectors throughout. means zero 
matrix, I means identity matrix; dimensions 
are implied by compatibility. 



Now D may be expressed uniquely as the product 
of the form LDU, imposing conditions I, II, HI. 
The result is: 



D, 




22 



It is easily seen that A^ = L^ D^ U^, 
1 0> 

with: L" = I 1 " 1 




128 Mathematics — Linear Equations 



D 








J D„ 



1 2 2 
^1 ^2 ^13 

u U 
22 23 



Neglecting the small elements in D this may 

be written more compactly as: 



^'"= (lr) ("'U«) 



with: L 




0- • -0 
1 



r2 



where 




<"12' Ul3> 



LR = <L^+i,l' Vl,2 Vl,r^ 



c. Final result of elimination process 

2 
At the next elimination step D is factorized, and so 

r 
on. Now assume that finally D , , equals zero 

r+1, r+l 

in the sense that all its elements are absolutely less 

than TOL. This means that A has the rank r, and 

the end result is the factorization A^" = L^* D^ U^": 




r2 



L" L 

r+l, 1 r+l, 2 



r+l, r 




U 



UR 



11 


12 





2 
"22 


6 






lr 



rr 



K.rn\ 



u 



2. r+l 



Kr+l/ 



L is of dimension r by r and unit lower triangular. 
U is of dimension r by r and upper triangular. 
LR is of dimension m - r by r; if the given matrix A 
is row regular (that is, m = r), LR is absent in the 
final factorization. 

UR is of dimension r by n-r; if the given matrix A is 
column regular (that is, n = r), UR is absent in the 
final factorization. 

d. Further calculations performed 

The problem of matrix factorization arises in connec- 
tion with the solution of systems of equations AX=R. 
Three different cases must be distinguished: 

(1) r = m = n 

A is nonsingular, and AX=R has a uniquely 
determined solution. 

(2) r < m 

A is not row regular; solutions of AX = R 
exist only if the linear combinations among 
the rows of A are also valid among the rows 
of R. 



Mathematics — Linear Equations 129 



(3) r<n 

A is not column regular; AX = fi has 
nontrivial solutions. 
The cases (2) and (3) may occur combined.' 

The solution, if it exists, is uniquely determined 
if r = n; otherwise it contains n - r free parameters. 
It is quite natural to ask for the linear combinations 
among the rows of given matrix A and for the linear 
forms expressing basic variables in terms of free 
ones. Therefore, instead of LR and UR, matrices 
C and H are returned, containing linear combina- 
tions and homogeneous solutions respectively. 

Observe carefully that the calculated factorization 
belongs to the interchanged matrix A^. Therefore 
A^X^ = R^ is dealt with instead of AX = R, where 

{fr} is obtained from Q using the (J^Q^^^'j^th} 

element of < > as 'j ^th/ element of 

X^ 
R^ 



N 



1 = 1 n 

J = 1,. • • , m 



r r ,^^l\ f\ 

Let X , R be partitioned into | I and j 




Then: 



/l \ (U, UR) /xA ^ /rA 



or explicitly: 



L • U • X + L • UR • X = R 
LR • U • X^ + LR • UR • X = R 



Since L and U are nonsingular, this implies 
-1 



X^=U 

L-% 



LR 



L-1 • R - U"l • UR • X 

. = R- 



For the convenience of the user, LR is replaced 
by LR • L"-*^ = C; UR is replaced by -\J~^ UR = H, 
while L and U remain untouched. Consistency 
requires that R2 = CRj^, and homogeneous 
solutions are given by X^ = HXg. In case of a con- 
sistent system of equations A"^ X^ = R^, the general 



solution is X = 



ft) 



with X = U'''" l'''' R +HX 

X J. ^ 



while the values of the free variables contained in 
X2 may be chosen arbitrarily. 

2. Format of Results 

Subroutine MFGR returns matrices L, U, C, H, D 
in the storage area originally occupied by the input 
matrix A in the compact scheme shown in Figure 9, 



-IRANK- 



M 



V 

Z 



\. u 

L \v 


H 


C 


D 



Figure 9. Format scheme (MFGR) 



3. Numerical examples 



GO' 



a. Let A = ( , ^ ], EPS = 1.0E-7 

Subroutine MFGR returns as results: 

L = (1), U = (5), C = (0. 2), H = (-1. 0) 

combined in the compact scheme: 

/s.O - 1.0 \ /u I h\ 
^0.2 0.6E-7J \C I D/ 

IRANK = 1 
ICOL =(1,2) 
mow =(1,2) 

The value 0.6E-7 is obtained instead of the correct 
value 0, due to roundoff errors. 

This example shows that a proper choice of EPS 
is somewhat greater than 10"", if d is the number of 
significant digits in the representation of floating 
point numbers. 

With EPS = 0, MFGR would give the incorrect 
value of 2 for the rank. The choice EPS = may 
well result in an incorrect value less than the correct 
rank, as shown by the following. 

If the element a^o is slightly decreased, resulting 
in a matrix A of correct rank equal to 2, then sub- 
routine MFGR gives an incorrect value of 1 for the 

rank with any choice ol the relative tolerance EF6, 

even with EPS = 0. 



b. Let A 




EPS = l.OE-7 



130 Mathematics — Linear Equations 



Subroutine MFGR returns as results: 



combined in the compact scheme: 



^10 

L =1 0.2 1 

1 0.6 -0.3333330 1 



5 13 -0.48E-7 -0.9399992 

12-2 -0.2499999 -0.2500009 
,0.6 0.2 1.6 -0.2499999 0.7499991 



U 



'5 


3 


1 > 





2.4 


0.8 








0. 6666664 



/I 0\ 

\l q) 



IRANK 
ICOL 

mow 



(JJ.) 



= (4,2,3,1,5) 
= (2, 3, 1) 



combined in the compact scheme: 



Homogeneous solution of A • X = 



( 


f5 3 

0.2 2.4 
0.6 -0.3333330 
1 
Vl 


1 > 

0.8 

0. 6666664 



/ 


IRANK 
ICOL 

mow 


= 3 

= (3.2,1) 

= (1,3,4,2,5) 






x^ = -0.48E-7 • X 
4 1 



0.9999992 • x 



X = -0.2499999 • x, - 0.2500009 • x 
2 1 5 

X = -0.2499999 • x + 0.7499991 • x 
o 1 5 

X and X may be chosen arbitrarily. 



U 



fa a a 
24 22 23 

^4 ^32 ""33 

a a a 
14 12 13 




Linear dependencies among rows: 

row (2) = 1 • row (1) + • row (3) + • row (4) 
row (5) = 1 ■ row (1) + ■ row (3) + • row (4) 



'a a a 

13 12 11 



L • U 



33 



c . Let A = 



32 



31 



a a a 

43 42 41 




, EPS = 1.0E-7 






■jKLlJtlNt -■,FC« 

111 Jwl'tK-lln.c rfAhK Ai^ 

(31 tXP^^j> ■■(ors-aASlC IJHi li* ri«MS Of a^ijC uNi 



•-ALL li-Jrtt A. '4.?<.EPS, IftwiA, I now, ICCLl 

A - jl>/t:H MAIkU -ITH H ,(J1,S ANJ h cJLUMN^. 



tPS 

Kll 



- .VJV.itR jf HOWS Jf f^AJAlK A- 

- ;.JrtJti* Uf CClu^i^S iF .iAT.tlA A. 

- iLMVALJt f .>•, (t-iJ AfrtCTtC Sr xGUNl-l!*:^ ^^^St. 

- KtSJLIAM ^tHK uf JUc*. MATRIX. 

- I^rcGcK VtLtUK Jr Ql-H>i:vSlUN ."l CO^lAlNIl^, Tht 
SjfiCrtiaiS Lf oAiK. TiJ-i Ih Iftb-dl ,.. . ,lnC».( i(<fi\i. 

iJojtHlPIS ~.h J«ilt. :JLJMf4S IN 1.01(1) U*^ TC 
iCliLliRAKiC ] . 



..MfGk ^C 

MFt-ft JO 

MF&R ■.; 

MfOft 5C 

rtfC*< ijO 

■IF Ok l3'- 

i^FC-R loJ 

HfiiR 170 

rtfOK lb:: 

J'FLR lie 

«FOk ^IJ 

MFOk .^i.: 






-Its 



LcFI HiNj rKlAN^ULAft FAoI^a IS NLRHAlWcl; i 
JlAjJ'^rtL Cof«TA]ft,<, iLL uiVti iNUi ALLCWiiVi; Ij 
iDrf>,IAGo\ AL (>A-JT. 



: I That 



Subroutine MFGR returns as results: 



L = 



H = 




-0.48E-7 

-0.2499999 

-0.2499999 



U = 




-0.9999992\ 

-0.2500009 1 

0. 7499991/ 



^- IS US£J fb-i LJL.JcAtlL.-* 
- '.i VfeN "(Arfil A. 



^ A-ICftS 



C HtlHOJ 

L ..Auvil^iJ cL l:ilNATIG.\ TtCrt 

C Jf frtc f-d.UiULA.* FALTuki 

C -i.MP..tIc CH/^TING IS DJILT IfJ. 

C [M ,-»3t JF A Si;^uI;la« -^aTrix j,4l» ihe T-^Iaj^u 

c JF 4 iJJ'^■^fKU J'' maIhm •o.hk ah kcHlHt.^, 

C The -(t«4lNj.4G P4!(rS Or THi ^EiJlTANT MaTRM ^U- riE 

i: J-.^=»Jd.\C((:> Or KL»i A.wu THt SoLUTIGN UF TH-i h j +j j t iil JdS 



SucKUJf P,c Ir Jt;(6,M,N,cPS. M4f*C, lAb^, I CUD 

uHci^jluNfcU L.'JMHV VAftlAoLcS 
L/iHcNili.J 4UI,I^UW^lJ,JCJLl II 

Tfcil Or iPiCiFIEj i.I.'^thSI.^NS 
IFIMJ.^,^, I 

£ lH*.rtl< = -I 

►■tlU'^f; \^ LAse OF FLri^AL l'*MJ-<S 



MFjri J). 






MFCK Ji7 

HfGk ^^^. 

MFCS I): 

HFG« j^: 

MFCt. 3-:^ 

HFC-* 5;: 
MfGt 330 
1FCR 59': 
MFCk 6OC 
HFG'' blC 



Mathematics— Linear Equations 131 



slaacm FiKsr Pivor cLtHt^^r 

00 o J= L.J 
UO ■» 1 ' I . ■* 

JJ=JJ»l 

H<JLj:A( JJI 
IC = J 

jj 7 I- L. i 

INirULUc cLirtl.-JAnON LUJP 



■J IhlA.^n= .H^NK* 1 



JJ=in-l At-HK 

i'J U(j 11 J^l .<AMK .N«l, M 
i=J*JJ 

A( JJ=flf It 

iH^Ml ]>vA.<lrv) = JJ 

l«It"K»,MANG^ ■-■JLJ.iNS If NLCcSJrtKV 
li JJ= ( IL- [-(Ai'K l»H 



Al 1)=jAV- 



If |.i,i»i (■-..■ J.^^ 

i«.A,sf )km cjfir,ti\'T so9M*.rfl;x anj itARcH Ntxr Pivor 

is JJ=LL 

iAve=pi V 
JJ=JJ*1 

Itil i:j-i LAiT C:,1_>J*1N 
IF< I^A.JK-N» 1 ', 1--. !■' 
17 11= JJ 

U = i i ♦ . 
.MM= 1 I -L 
«( U )=A1 1 I t-HOLi;*A(rtM) 

iF-(Aas(;.( iin-Aji(»ivin'r,i9. u 

16 PIV = AI Ul 
IC=I 

icf UJ MATRIX tX^K^SSl^G 'i.'J'l JtP^.i JcNC IE S 
2: 1F( IRANK-il j,2i,^l 
21 IR = i_L 

Jj=Jotl 
«f1^ JJ 
iC= IR 

HULJ = r1 JLO*A(nfHl •«( 11,1 
lL=lC-l 

2t CUrtTjNJc 

fLbf rjR CJlOMN HtJUL«HlTV 
^b |F(N-i'<AN<) j, J,^, 

iLf IIH- MATKlX CRI>A£SSING rfA S I C tf4«lAfaLiS IN TcBrlS GF Ffti: 

PArtA.ltTtKS (HJIuGchcdUS SOlUTUN). 
^6 IR=LL 

jU jO J = i,UANK 

JJ=lk 
LL=1 
HULJ=C . 

27 11=11-1 

■ Fill )^V, 29,29 
^« H0LD=H0LJ-A) JJl "AiLL) 



nfOk 


ojO 


HFG^ 


o'.O 


HFG»^ 


J"iC 


MFGK 


of>C 


MFOk 


67: 


MFGR 


6du 


MFO« 


s-JC 


MFGrl 


70 i 


MFOn 


/ t.J 


HFl.<* 


'/C 


MFtH 


7r 


HFG^ 


7'.C 



MF&K 


7 jC 


HfGA 


74-- 


MFGr^ 


dOO 


MFOK 


iV- 


MfGx 


6^ 'J 


Mi'Gk 


J JC 


MFCf* 


avv 


MrG« 


f--)^ 


MFCK 


It.- 


Mf G-( 


dfi.- 


MFGK 


a^C 


MFbK 


ij-*',' 


MFCft 


■jc; 


MFGrf 


•HO 


«r[,K 


^i.'- 


HFGR 


V )C- 


MFL-K 


vtC 



•trGKK'. '. 

IFGKI- IC 
MFCRl jJC- 
MFGf*l^ *'- 
MFGkl'.-^i", 



Xfi 



«1'.' 



,iF&Ki:d; 


MFG'<i„'JC 


MFG«U-C 


MFGhl ilC 


^f-GillL-LL 


MFG^lijC 


HrGKil'.'; 


.1FGt<i lt>3 


.-1FG;<iU.- 


MfGrvliT'. 



MrGi^UVf 
Mt^O-tl^CL 
MFG'l! .:ii- 
MFG^U<iL 
MFoKU )■-' 
><FCK12'*: 
MFGKl<;'JC 
hFO-(Uo- 
MFGfil^'C 
MFGkU'jO 
MFGKli-*'- 
MfGKLl j;c 

KfGhiii; 

MFUKl J^C 
MFO'^lijC 
■^FGKIJ^C 
MFG-ill50 
MFG«lioO 
SFGKli/C 
MFG"ilj^' 
MFG-^IJO' 
MFCrtKC'" 



mf: 



«U2.j 



rtFG^l'- 



f.FGhl'.^C 

MFGftUdL 
MFGfii*.4C 
rtFGRlbO'. 
MFGKltii: 
f',FGt*l3 20 

t^FGfclj'fk. 

MFGRl5oO 
1FGAlb7: 
■iFoKi^d. 
MFGiii^'JC 
MFGRlti':C' 
MFGrtlolD 
MFGfilfe2C 
MFGRlbiC 
MfGMli.'.C 
^lfGrtlt.;iC 
Mf G«lfafiC 
KFG«l67U 
MFGrilb^C 
HFGMloyC 
SFGR170C 

mfokuk 

.■4fGR17^0 
MFClfiC 
IFlvKI ^-rO 
MFGRi750 
1FG«1 fbJ 
MFGH17 7C 
MFGt*17D0 
MFGR17V0 
MFGRU^O 
MFGRUIO 
«1FGHla20 
MFGKldaC 
MFGRld'tO 

HFGftlii60 
MFGR1O70 
HFGRlaea 
MFGRlttflO 

MfGKlSCC 
rtFGRI910 



LI. = L L - 1 

COTU 27 

A(Li.l = 1H0*.U-A(LLI »/A( JJ I 

lh=IR-l 

RETUKN 

tND 



MFGR193C 

rtFGKl<)4D 
MFGRl-JSC 

HFOK1960 

MFGRl<i7C 
MFbRl9oO 



Fur a GUfci^ t1 tJV N MfttKIX IHC rOlLUWlNi C ALCUlATI UAiS 

AUc ffcKFUkHtJ 

11) DeTcRHINE AANK AHo L1Ni:ARLV 1 rtJcP tn(L«t NT RlJMii ANG 

I.ULUMNS I bAilSI. 

( ■>! FALTOKlZc A :>UbHATAlX uF -IaaImmL KAMK. 

IjI tXPKcS^ .^j\-hA^lC '(a<JS iM TERNS Uf BASIL UhtS. 

(-.1 c«Pkcj:> dAili. VARIASLcS li4 tckrtS OF f«Et JNti. 



GALl J1r^K( A.HtN.FPSt IRAt4<i IAJh, ICJL) 
.iAtHlX 



Ra^s 



LiL^HTIi;.- ur PAflAHETiiWS 

;. - iJUJuLt PRLCISidN GIV 

AND N COLUHhS. 

1j:4 XlilUKN A CONTAINS T.ic TRIANGULAR FACTORS 

JF A SLiijMATRU OF HAXIMAL RANK. 
.^ - NU.1i>iR Jf Ki,WS OF MAThlA A. 

N - AiUMa::^ OF LULlW.^S uf HaIKiX A. 

LPi - »lNij.Li: PKfcGlilUi* TCSTVALUC HiH. ZtRO AFFctTti 

;iJUNJuFF NOISE- 
1K«.<^ - RLiSJLr^NT KAf^K JF GUiN MAIKlH. 
IKUh - INTlGcR VtC[Ut< jF DI^^t^SlCJN M CJNTAIMNj TMi 

iJjSCKlPTS Jf BASIC kUWS IN I *0W ( 1 ) , . . . , I kOh ( I RANK 
iGiIi. - iNTtGtK VLCTUX UF ulHENllU*^ N CUhiTAl ^^l NG TMt 

iUL.Si.hlHIb OF BASIC COLUMNS IN ICOHU jf TO 

ICijL ( iHrtNK t . 

fMt Ltr-r Urt.'Jj iKliiNGULiH rAGTj^v ib NLiKMALIZcJ SjCH THAT 
frit alAjuNAL U;.»lAl.^4i 4LL ONci IrtUi ALLU-ING Tj STOHc ONLY 
rH._ SU3i>l ^•j'j'iAL PAHT- 

Jo.-<GjTI.ML-> ANO FJNGTIUN SOdPKoG'<«rtS RtUJI«ca 



l)MGH 10 

•JMGH ^0 

DMCR 3C 

OMGK *.€ 

UMGR 50 

t>MG^ 6C 

JM«K 7C 

uMijR eo 

JMCR 9C 

UrtGk i:c 

OMGR lie 

OMGH UC 

JrtGR 131- 

OMGK l<.0 

OMoR 15C 

OHGR 100 

iJHGft 1 7C 

uHGR IdC 

0>Mjh WG 

tMGB .'JC 

iJNGR ^IG 

iJMGK ^^C 

■JM&K 2 3C 

»JMt,K J*.? 

0*1 UK i'tiD 

fMGH ^60 

OrtGK ^?C 



UMGR 


>i: 


JflGk 


333 


D«G« 


Ji-O 


J^CR 


3e: 


urtGK 


jfi'- 


JMG^ 


i'j 


[JMGS 


330 


UMGK 


JSu 



.itlHLj 

GAJJSiAN ;;Ll>1lNAU^N rcCHlJltUc I i UStU FOR CAlC^lATIuN 

JF He TRlANGJLA'i FAtr,,'*^ uf 'i oIVL'N MATRIX. 

„UilPLtTi: »>lVJTi.^l, IS ctUUT IN, 

IN i.AS£ JF A ilNGULAii rtAT-<lX JNlY IH£ TRIAMCUlAH riCIOrtS 

JF A Su-j^AT^lK Jf >^AA1'4AL kAUK ARt. KtfAlNtU. 

IhL KuHaI;41,'«G t-AHTS Ul- Trie fttiJLT^NT MAIklX iJltft iMt 

J^PL.iJL.MCItiS UF RUMS tnJ THc iULUirGN Of THE HGrtJoENt {JUS 

iAlHlX c-jjAflUN A*K=C. 



SOoKOUT l.\_ iJHFG.<I Ai .1, N, EPi. I HANK, l<*Jii, (Cui 1 

JIM^NilJ.'^tu Ul(rt,1Y i/AKlMtLcS 
JlMon<Slw,\ A( 1 I.IKUJ t II tICULI II 
uuUdLl Pr<cLl:-IJ^4 A,t>IV.MQLl3,SAVE 

Ti-sr ur ^'■LCirict- oiulvsIjNS 

iF(rt)£t.J,l 
1 Ir(.«)^,J.'t 



JMGK *20 



(NiTIALUc GJLJi'*"! INUtX VcC TJft 
StARCH rltjST JJVJT tLcHcNT 
•. JRAlM^ = ■:, 



Ju o J:=i,;'l 

ICoLl Jl =J 

JJ=JJ*l 

r^OLiJ^AI JJ( 

in JAoSlFlVJ-DAtiSlrtJLJl )5,o,6 
t. PIV-=HGLD 

1^=1 

IC = J 

c OJNriNJE 

h^irULlZE Kji. INGtx WcCTJR 
uLi / i = l,M 

; iRUM{ 1 I -[ 

>tr uP iMIcAN-iL TCLt*<ANl,t 
ruL^u^il ci>s*SNGLI t'lVJ ) 

lNlTlALl<:t ELlMliUriCN lCJP 
NM=-iJ*.1 
Uu 19 iNCJL = NiN1,f4 

TtSr rui* FEASltJlLlTY GF PIVJ7 
a iF(A(>Sl:>.«ui.( PIV I l-TGLI 2C,<fC,9 

I.^IchCHjnGE KUWS if Nt^-cSSARr 

1F( JJ|12,1^,1C 
iC i>u 11 J = lh.HHK,Nli,H 



J*JJ 



SAVl=A1JI 
A( JJ=A( II 

11 *u; = S4Vt 

UPwATt K(j- iNJtX VtCTiin 
JJ^IRCrfdKl 
lrtJ«( IRI = 1«0.^( IRAM) 
lRo«( ISA^K)=JJ 

INTcAi-HAUyc GULJINj IF NcCtSSARY 
l^ JJ=( 1C-IRAN^1*N 



u-iGK 


•.3c 


D«b.^ 


-.-vc 


Jr4GK 


4^U 


UHCR 


•.oO 


GN„R 


'i?.-' 


0«GR 


•.oU 


UHGR 


-•^■; 


uMGK 


5:3 


JMGrf 


alJ 


. .OMGk 


52j 


D.'iGK 


^ji: 


OMGk 


■>4C 


UMGR 


_>5C 


0,1 GR 


56: 


GMGR 


3 70 


UMGR 


ad-j 


L>HGR 


!>93 


JKGK 


6CC 


DMGR 


olG 


OMG« 


o<;: 


J«&« 


ojO 


OMGR 


n^O 


JHGH 


os; 


ONGH 


o6* 


OHlfP 


ot; 


OMGfl 


toSC 


OHGk 


69C 


OMGR 


7GG 


OnQR 


710 


GMGK 


72C 


ijWGR 


730 


OrtGR 


7fcC 


U«GK 


/50 


OMGR 


76C 


t;MUR 


77G 


DMGK 


730 


i;MGR 


79C 


DHOh 


acc 


OMGR 


oi: 


i;mG-< 


b*;.: 


JMGR 


aac 


JMGK 


•s'.C 


UftGR 


S50 


O.HGK 


6o0 


DMGR 


d70 


OMGR 


f^dO 


jMGR 


9 40 


LiMGK 


iJO 


UMGR 


9 13 


JMGK 


9i;J 


UMGR 


9i: 


DMCi 


940 


JMv,R 


i5C 


UMGR 


■ibQ 


LfMuR 


J70 


CHCH 


9cC 


U,>10R 


99C 


GMGKi 


:oc 


JMG-^l 


JIC 


0MG«1 


-tO 


JMGRl. 


: 5C 


UMGRli 


j40 


D«GRi: 


350 


OMCKlCfeO 


OHGHl: 


>7C 


UMGRi: 


:-sG 


DMi,Ri; 


;9o 


ONGhllCC 


J'lGRlUO 


OMGRIUC 


t>Hv,RU 


ij 


ijmgku*.; 


1JMGRI15D 


OMGR 1 1 


&v 



132 Mathematics — Linear Equations 



LiL l^t J=l,M 
l=lt<»JJ 
SAV£=A(KKI 
A(KK)=A( 1 I 
ltK«tCK-i 
I<. A) I)=SAVc 

Ji^JATt COLJM.V l.iOtX VtCrOK 
JJ=ICJHit.3 
|CUL( IC)':lCui_( I RANK I 

lb RK"IKAniK*l 

TwAivSrO^H vJ.*Kfc\T SUoMarHEX AN^ ScAftCH NEXT PIVOT 
16 JJ=lL 

t/U 111 J-.\((,t« 

ri6i.J=i( JjJ/>AW£ 
A( jJl =Ma^ 

rtir e.M last cjLJdN 

IFl tk-NK-M 17, If, li 
IV J]=Jj 

CD 19, I =\K,\ 
1 1 = 1 I 'rt 

J-( I 1 f = .l) II J-Hul. J'Al M^t 

IF ( jAojUI nil-^^o5{t=iV»H9.l5.ia 

13 PIi/ = iM I I) 

tC = I 

1^ t-i^riNJi 

j^r Jr^ .1AT.<M c<^S£SSlNC- ajW i;fcPtNJENC]tS 

^C It-l l'<i^^-lJ3,I;t-.;l 

^l JH=LL 

u,U ^t J=^»l -i^i-^K 

ll=J-l 



JJ=JJ*1 
r r_ = i rt 

>.J ^^ L^l. Jl 

HL,'L^-NJLj*a(rtrf) *A(i C» 

iC= u-t 

Jh CJNTlNJt 

TcSr fun CUL^HN Kt&JLAKlTY 

ici -P .-IjIkJX iiX|JRtii.I.\b ^AbU Va^lADLtS iN rfc'Hb OF rkEt 

25 IR-Ll 





1.U JJ 


= 1. 


-(AjMK. 




Jt. 2^ 


-K< 


i^M.rt 




^J = I« 








LL=i 








riOLi^=0 


DO 






n = J 






27 


n = n-i 








if-( iiu 


^-t..' 


-td 


it; 


LL=LL-1 




J JJl "AILLI 


i^ 


«(LL1 =( 


hiJw^ 


-'t(LL) 1/C( J J 


i. 


IK^irt-l 








KSTJ^rtl 








tf.J 







OMGRtUD 
UMt;«ll90 

aM<;fii200 

OiiGRl2lO 
0MOA12ac 
i)HORU30 
0«GR1,;4C 

0NGR1260 

UHGRl2eC 
D»1GB129C 
t/MGRLJJO 
ONGAL313 
0NGRli23 
Of1GRl33!j 
DNGMU<tO 
OMGRli50 
UHGR1360 
0«GRli70 
D«6R1380 
DHQRiitC 
OMGkt<.i?C 
OMGRl^tlC 
0M&K1*20 
UNGRUii:) 
0MGRU40 
•JHGR1-.30 
JMGRUbO 
OhGRU70 

0MCfti'.9C 
DKGRiaOO 
UHG»<1& IC 
Li.<GRl3 20 
J«iGkUjC 
jMG^.ls^C 
jMGRlSbC 
JHGRiSi: 
DMGftli7C 
OlGRlSdC 
UMGK139C 
OHGRloJC 
UMOkitlC 
L>MGW16Zj 
uMGh..l6 3C 
CMGkibi,: 
0MG.^163C 
0^G«lt6C 
£ty,G^lo7C 

OMGkloQC 
OM&Ri^CC 
DliGKiriC 
OhGR17<:; 
LJ1GKIT3C 
Li«Ghl 7-^0 
U«G'<17 5C 

i;«c-<i7fcc 

D«Gi^l77C 
JNG=^176': 
JMGK179C 

JMCRlfeCC 

OMG-iiaiC 
OKGRISZI 

iJMG«185c 
OMGkloiC 
0MGHld7C 
0MGr<ld6C 
LJ>1GRi5S0 
JMGkl90r 
iJMGKiSlC 

uMGrtW^c 

JMGKl JJC 
DMGSl'i^O 

JrlCKl'»7C 

JMi.kl,^': 

aMCf.l^^C 
Df1Gk2CCC 
OrtGR^OlC 



Subroutines GELS and DGELS 

These subroutines solve a system of simi^ltaneous 
linear equations with symmetric coefficient matrix 
by Gauss elimination. Consider the system of simul- 
taneous linear equations 



X 



R 



(1) 



with symmetric m by m coefficient matrix, the upper 
triangular part of which is stored by column in 
m * (m+l)/2 successive storage locations, and an m 
by n right-hand side matrix R stored by column in 
m * n successive storage locations. Solution is done 
by Gauss elimination with pivoting in the main diago- 
nal of matrix A. If matrix R is the identity matrix, 
solution X is the inverse of matrix A. Solution ma- 
trix X is placed in positions of the right-hand side 
matrix R and is stored by column also. Thus, the 
computation of the solution requires no extra m by n 
array of storage. Only an auxiliary storage array 
named AUX with (m-1) storage locations is neces- 
sary. 

Explicitly, the given system (1) is of the form:"*" 



^^11 ^12 ^13 • " ^Im 



^21 ^22 ^23 '" ^2m 



a a a • . • a 
31 32 33 3m 



la ^ a ^ a -. , • a 
\ ml m2 m3 mm 




^11 "12 



In 



21 22 2n 



^31 ^^32 • • • ^3n 



ml m2''* mny 



r r 
11 12 



In 



^21 "^22 ••• ^2n 



(2) 



"31 



32 



3n 



r , r „ . . . r 
ml m2 mny 



The first step is to search the main diagonal of 
matrix A for the element of greatest absolute value, 
say ajj, and to select it as first pivot (p = ajj). 
The reason for pivoting only in the main diagonal 

Of A is that rest-matnc&s of A(^) 



■•"Note that subroutines GELS and DGELS require 
only the upper triangular part of matrix A; that is, 
the elements a^; a^a, agg; ajg, ags. agg;. . . ; 

^Im' ^2m' • • • ' ^mm- These elements are under- 
lined in formula (2). 



Mathematics— Linear Equations 133 



(k = 1,2 m-1) must remain symmetrical during 

the whole algorithm. With ajj , generate the internal 
absolute tolerance for testii^ usefulness of the sym- 
metric algorithm in the following way: 



tol 



JJ| 



(3) 



with a given relative tolerance e . 



Suppose that pivot element a^j is equal to sl-^-^' ^ 
It is not, interchai^e the first rows of matrices A 
and R with the j^^ and the first column of matrix A 
with the jth, and save column interchange informa- 
tion by storing the difference (j-1) of pivot column 
Index j and step counter k = 1 [interchanging column 
1 with column j means interchanging variables x, , 
with Xj. (1 = 1, 2, . . . , n)J . 

Now transform the elements of pivot rows in ma- 
trices A and R by division with p, and the other ele- 
ments by adding -a^j^ times the new first rows of 
these two matrices to the other v rows , thus getting: 



11 



,(1) 
11 



11 
= (1= 1,2,... ,m) 



P 



(1) 

f 1 vl vl 



(1 = l,2,..,,n) 
(1) 



a^ ' (1 = 2,3,... ,m, 
1'= 2,3,...,m) 



(4) 

(5) 
(6) 

(7) 



As column interchange information is saved in the 
first position of the main diagonal, the result of the 
first step is the two matrices: 



/a 1) \2 h3 



22 23 



.(1) 



'^32 ^33 



Im 



2m 



4'^ 

3m 



and 



^m2 ^mS 



,(1) 



■H-Note that transformation of pivot row in matrix A 
destroys pivot column, which is, due to symmetry, 
stored in the same locations . As pivot column is 
used unchanged for transformation of rest of A and 
R, it has to be saved in auxiliary array AUX before 
transforming pivot row. 



R 



(1) 



/" 


r(l) 

12 


...4^ 


/4^ 


22 


r(l) \ 


r(l) 
31 

\ 


32 


• • • ""Sn 
/ 


\ml 


m2 


mn/ 



It is easily seen from equations (4) - (7) that the rest 
of matrix A^-'^) —that is, matrix A^-"-) without the first 
row and first column — is symmetrical and that actu- 
ally only the underlined elements must be calculated 
and stored. Therefore, the range of index 1 in 
formula (6) reduces to 1 = u , v + 1, . . . ,m. 

Now repeat this procedure m-2 times, starting at 
each step with the matrix A^' of the step before 
without the first k rows and first k columns, and the 
matrix r' ' without the first k rows . The total re- 
sult after m-l steps is the matrices: 



'"i 1) ^12 ^13 ••• ^im 



ao-2) a; 



(2) 
23 



4'^ 
2m 



,(m-l) 



V^)-4m 







. . . (1 -m) 

"m '' 



and 



R 



(m-l) 



/" 


r(l) 
12 


...r</) 
In 


/ 'f.' 


r(2) 
22 


r(2) 
' • • '^2n 


4? 

1 .... 


r(3) 
32 




\ ml 


m2 


. . . r(™) 
mn 



134 Mathematics — Linear Equations 



Now work backward and set: 

^(m) ^(m-1) (m-1) . ,(m) 

m-1,1 in-1,1 m-l,in ml , 

^(m) ^ ^(m-2) _ ^(m-2) . ^(m) 
in-2,1 in-2,1 m-2,m-l m-1,1 



,n) 



(m) 
11 



(1) (1) (m) 
""U ^12 • 21 



^13 ^^31 



>(8) 



a o ■ r ,' (1 
m-2,m ml 



Jm-2) 

.(1) 
Im 



1,2, ....n) 



- a 



C «=''^ "> 



After each step of back substitution, rows of solution 
matrix X = r("^) have to be back-interchai^ed ac- 
cording to interchange information in the correspond- 
ing main diagonal element of matrix A^"^" ' . in order 
to get the correct sequence of right-hand side column 
elements corresponding to the sequence of left-hand 
side row elements. 

The only case in which the procedure described 
above can fail to give a solution occurs when at any 
step all elements in the main diagonal of the rest- 
matrix of A^^) become zero, and no pivot element 
can be found. In this case, the procedure is by- 
passed and the error message ier = -1 is given. 
This may — but does not necessarily — mean, that 
matrix A is singular. Possibly subroutines GELG 
or DGELG (which are working with complete pivot- 
ing) will be able to find a solution in cases where 
subroutines GELS or DGELS fail. Actually, because 
of rounding errors , a further check of the absolute 
values of pivot elements is performed by the proce- 
dure. If at elimination step k this absolute value be- 
comes less than tol (see equation 3) , it is likely that 
there was loss of significance in the computation of 
the diagonal elements. But as this may not neces- 
sarily be the case, and as this test depends highly on 
the choice of the relative tolerance e + , the proce- 
dure gives only the warning ier = k-1, which indi- 
cates that there is a possible loss of significance in 
the results computed by the algorithm.'^ut here it 
is also possible that subroutines GELG or DGELG 
will give better results. If there is only one 
equation to solve (m = 1) , the test on loss of signifi- 
cance is suppressed. 



"""For subroutine GELS, a relative tolerance be- 
tween 10"^ and 10"^ is suggested; and for subrou- 
tine DGELS, between lO'^^ and 10"^^ . 
-H-For example, e = 10"^ and warning ier = 3 mean 
that there is a possible loss of about five or more 
significant digits in the initial values of elimina- 
tion step 4. 



SUAROUTlNt G£lS 



ru iULVc rt SyS1£H OC SiHU|.TANtOU& LINEAR tQCATIiJNA hi TH 
SVMMerRlC CufcFftCIE'^r MTi^IX UPPcR IftlANOUiAh 9ARX 0^ MHICH 



IS aSSUNEO to 3E SlUt'tO COLUHNUISt. 



2C 



50 



ec 



JSASb 

CALL SliLSIH. <../"« 



NttP&.lcK) AUX) 



JtSCHIPTION 0<= PARAMETERS 

R - M er N RIGHT HANJ SlOt MATRIX. lOtSTROfEOI 

Ot RcTJxK K COii^TAlNS rH£ SOLUTIO<V OF Tne EQUATIONS. 
k - \jPPik IRUNGULAk PAftT OF THE SYMNETAU 

« oY fi CUEfi^ICIiiNr HATkIX. (oeSTRUYcJI 
M - THt ;%JM»tft nf t^UATlUNS IN THt SYSTeM. 

H - THc '*JMbtR Llf .{[ijlir HANU SIDE VtiCTOrtS. 

tPS - AlH INPyT CONSTANT WHICH li UitO AS RtLATlVfc 

Ti]Li:KAMCfc FOK TliST QH LOSS Cf SI..NI F Ii.A.<4Cfc. 
leK - )<£SJLT[NG ERrtJR PARAMcTgH CUBED AS ^OLLJWS 

I£K>C - UU ERAClR. 

Ick'-i - M AESULT 6cCAUSE Of M LE^S THAN 1 Oft 
PIVOT ciLcKENT AT ANT ELIHINAflUN STEP 
tUUAL TO 0, - 

Uk'%. - bAftNlniG not TO POSSIfiLE LUSS OF SIGNIFI- 
CANCE INOICATcO AT £LIMINATIJN STEP K* I . 
WHcftE PIVuT EL&HENT MAS LtSS TriAN OR 
cyUAL 13 JH£ [NrSftNAL TOUi^ANCt cPS TIHtS 
ASSULUTELY b-lcATtST HAI.M OlAGiitAL 
ELfcMtMT Cf flATRlK A. 
AUK - M AUXILlAKr STU<<AGE ARRaY WITH J|HeN$lON H-1. 

AcMAkKS 

-JPPtS r-*lAi4uULAK PARI OF MAT«IX A IS ASSUMcu TO }t STuRtU 

COLJHNflISc H i^*tM*l)/^ SUCCESiiVc STORAGE LlJCAriaNS, RIGHT 

hAMU iiJc rtATKlX R Ca.'JHNWISt IN N*M SUCCESilVt ST0R40S 

(.GCaTIONS. u^ TidIU«N SJLOriiJN lATHIX R IS SICivEi; CaLUMN*<ISE 

TOO. 

TH£ PKLiCtDjRc ;IV€S REiJLTa IF THE NUmtR OF cUUrtTIONS M IS 

GAtATER THoN ANu PIVJT tCt»1E\TS AT ALL ELIhINATIUN STEPS 

ARE LtPfiHt-f^I f4CM 0. HJWEVER rfARNINli lER-K - IF GIVcN - 

INUICATcS POSSltJLE LOSS Of SliMJf ICANCE , IN CASE LiF A k£LL 

iCAi-tG MAT-tU A ANU aPt'SOPRIATt TOLERANCE EPS, ItR«t( MAY 8= 

IITiRPKEIEJ THAT MATitlX A maS ThE RANK K. NO WARNING IS 

JIVcS IN i:«sz H=I. 

tPRJR PASrtMErtR l£R=-l SiJtS NJT NtCESJAAlLV Mfc•*^4 THAT 

HdTkiA A L'i SIN.;uLAk. as ONLY MAIN DIAGONAL ELEMENTS 

Ahc USED ^S PIVJT ELtncNTS. POSSlbLY SUBRQUTINc ^ELG ItilHlCH 

*i.'«.KS t-ITH UTAL PiVOriMGJ t.i.JLJ BE ASLE Tu F lHi> A SOLUTIGN, 



GELS 
GELS 
SELS 
GELS 
GELS 
GELS 
GELS 
GELS 

GELS SC 

GELS ICO 

GELS lie 

GELS i^C 

GELS 130 

GELS 14Q 

GELS 19C 

.GELS 160 

GELS i7C 

i,cLS lao 

GELS i« 

GELS 2CG 

GfcLS ^lO 

GtLS 12C 

CCiLS J3C 

GELS ^4C 

GELS diQ 

GtLS 260 

GELS dlZ 

GcLS ^30 

GELS 2^0 

GtLS 30C 

GELS JIC 

GELS 320 

GELS iiQ 

GELS 3*0 

GcLS 350 

G£LS )6C 

GELS iJi) 

GELS 3dO 

GELS 3'JC 

GElS *0</ 

GELS '^lO 

Gas *20 

GtLS *30 

GtLS 44C 

GELS 4S0 

GELS -(.'jO 

GtLS *f70 

g£L5 <fao 

GtLS tttO 

GELS iOO 

GELS 510 

,GCLS 52C 



SUdROJUNtS XtJ.fiJiiCTlJH SJSPkDG^A^S RfcuOlkcD 



.HfcTHCD 

SULJTlljAi IS OjNd or MEANS CI- GoUSS-ELIM ( NAT ILN w 

?lVUll»^ It ■■iAii'i LilAGoNAL. U UkDER TO PRtSEKVc 

>Y(1.1ETKY I'^ AlMAINING COtFFlCIcMT MATBICES. 



GELSlKf A.HtNiEPS.IEA. AUX) 



JiMcntSIUV A( l)f RUl tAUXI 1) 
|F(H>^';.24.1 

SEARCH *-i;^ GREATEST HAIN OIAGJNAl ELcMENT 

IE.^=J 

PW = ;. 

L«G 

DC J K=l,n 

L=i** 

lB*AriS( A(L) 1 

|F( ta-PWJJ,3,2 

PIW=rb 

I=L 

CGNriKJL 

TU.«fcPS*PiV 

AAIM UlA'.,U^AL ELEMENT Am=A(J,J» IS FIRST PIVOT ELEMENT, 

RIV CuNlrtlNS THE AdSULUTE VALUE UF All). 



^TAifT ElIrilNAIlLiN LJDP 

lST-3 

nh»n«n 

Lt.^iJ"«-l 
uU Id K = l.-4 

TESr Ui^ USbFULNLiS uF SrHlicTKIC ALGORITHM 

IF<<'IV)24f^4t4 

IF{ IcRW.S.T 

IP<PIV-TaLla,A*7 

IER=K-1 

LI=J-K 

LST-LST+X 



PlVni ROW •icUULTION AND ROW INTERCHANGE iS HIGHI nANJ SILE R 

pui=i./A{n 

DO L-K(N:HtM 

ll-l+lt 

T6"PlVI*<i«LLl 
RlLLl=K(LI 
d R(LI-TS 

IS ELIMINATION ItRMINATta 
1F<>C-H)9. 19.19 

HUM ANJ CJLUNN INTERCHANGE AND PIVUT ROW HEOUCTIOn IN MATRIX A. 
cLEIcNTS Jf PIVOT COLUMN ARt SAVtO IH AUXILIARY veCrOH AUX. 

) L*i-Lsr*/Lr*(<+j-iii/3 

LL«LA 

U-L5T 

DO 14 lt>K.LENO 

L=L+II 

LL-lL*l 

IF(L-LRI12.10.L1 

A(LL)*A(LSTJ 

rH>A(L) 

GO TO 13 

LL-L»LT 

Td-A(LLI 

AILLI-AtLI 

*UX(lII>Ttl 

A(LJ«Plvl*TS 



cLS -j3C 
GELS 340 
i,ELS 550 
GELS i60 
GELS 57C 
GcLS iriO 
GELS 5^0 
GcLS 6&C 
GELS frlC 
. .GELi 6^C 
GELS 630 
GcLs O'.O 
GELJ iSO 
GELS bbO 
GtLS b7C 
GELS t-SO 
GELS 695 
uELS 7».0 
GELS 7iC 
GELS 72C 
CELS 7 3J 
GELS 74: 
GtLS 7&0 
GtLS TcC 
JfcLS 770 
GELS 7b:' 
GELS 79: 
GCLS 30C 
GELS die 
GELS s^r 
GELS d3C 
GELS H40 
GELS biO 
GELS 860 
GcLS 8TC 
GELS dSO 
GELS (JVC 
GELS 90c 
GELS 'iilC 
GELS 920 
GtLS 93C 
GfcLS 94C 
GELS 95C 
GELS 960 
GElS 970 
GELS -iac 
GtLS 99C 
GELSIOCC 
GELSIOIO 
GELSIC20 
GELS1C30 
GELSI040 
GELSlCaC 
GEL51C60 
GELSlOTO 
GELSICSC 
GELS1G9C 
GEL SI ICC 
GELSlllO 
GELS112C 

GELSIUO 
GELSU50 
GELSlloO 
GELS 11 70 
GtLS use 
GELS119C 
GELSI^OC- 
GELSUIO 
GELSI220 
GELSU3C 
GcLS1240 
GELSL250 
GELS1260 
OELSW70 
GELSI2SC 
GELS129C 



Mathematics — Linear Equations 135 



5*Vt vJLUrtN iiHTt-*C'-i* 



lNP0ftH4r lUN 



tLc-ltNT acJUCriU.J ANO SE*i»CH FOR K6<I PIVOI 
PU«C. 
LI.iI-i.ST 
LT-C 

1)0 la ll'K.LtNJ 
PI Vi>-AUXl Jl t 
LfLLST 
LT-Lf*! 

00 IS LLO-l l.k.t.<IL> 
LL»LL*LLiJ 
L-LL«LI 
i3 A(L) =A|LI **'IVI»A(LL 1 
LLSI-llST*!! 

Ib-idi( A( LK) ) 
If ( To-PIV)17,lT.lb 
It PIV=ri3 
l=Lrt 

LL»tK*Ll 
It «(Li»-.<(LLl*t>tVl«K(Lk» 

tf*0 ~tf LL iHliVATldt LUu? 



dAcP. SJb:>IlIUT Iu^. (..^0 <JAC^ I'^rcrtCHM. 

00 ^Z i=i,H 
tST=LST-i I 

ii«n-i 
L^AiLsr I*, 3 

•v'Lir 

DO .^i LI^I1.L:N(J 

K=R*LT 
<;i Td»Ia-4l^)♦r (LL J 

rJ( JI^RI K) 
^* R(ICI = lt> 



KtlW 



uCLS13'JC 
G£LiU20 

(;el:>l)>o 

CELSlJSC 

GtLSli'O 
uELSijs;] 

&£lS1J90 
G£LS1<.00 
GEISUIO 
^£LiiU2J 
GELSU30 
titLSl'i'rO 

^*tLSU60 

GkLSl<.aO 
o£LSl*iSC 

(jifcLSlbC: 
GELSlaiC 
GELSll>^C 

GcLSl53i, 

■.-CLS1561. 

;.tLiii JO 

oELSloCO 
JEi.ilt.iO 

i;tLSi6.;c 

OELiloSO 

itLSibtiC 
G£lSl£,6C 
i*ELSi6 7.: 

GcLSi7: :. 

GtLSWi'j 

GLLSU*.L' 
OELS1751, 

GtLiir?': 

GtLSl MO 

GELSiaOC 

JtLSloli. 
<^fcLSla20 



^UsKJwr i.yt 



jCLS 



SYrtrlLlKlC LOLt^ 



I GF SIHJLTAMtiJUS LlKEAi^ EQUATlO^ilS mITh 
IcDiT HATAU U<>»'cK TklANGULAK PARI Lf khlCH 



ijLiCKlPIlGN G^ PARArtcT 



ClilU.J I 



rtlGif HANJ 

contai.\s r 



,1l>i 



MAIril K 

SJLUr!O.M OF 



THL LgJAIlONi. 

.J.>PlH Ikl*.\GLiLAK fAkT O r^t SVM.HtTK.C JUUbiE 

P^tCl^lJN ^ aV rt CutrrltltM MATHIX. OcSTROYfOI 

Tht fJUHiiLk L<l- tJUATlJNi j ;^ THE irSTtM. 

rnt '>»uMbtH LF ftlJHT nAfjD S I Dt VcCTUftS. 

jlM^Et. PRlClSlJN INPUT Ci>NSrANT MHICH li UbCL. *$ 

Kii«fl¥£ TtiLERANoc FUR ItST ON LilSS uF 

StG.*IHLANLE. 

.^tSJLn^^G erru.* PArtA^tTER cuOlO as fgllJws 

Uk=-1 - NJ kdSJLl dj-rtJiE Uf H LESi THuN 1 OK 
PlVtll tLtMfc,-H( AT ANV £LIMINATIiJN STEP 

tJUAL TQ 0, UtLS 

ltR=< - hAKNlMG uJc TCJ POSSI ,Lt LCiS U^ ^IQHlfl- j£LS 

CANCi 1'*J1C*.1I:J AT LlInINATION STEP A*lt J(-LS 

HHtkc PIVUI cLtMEM ^AS UtiS THAN O* JfciS 

LgJAL rj THc li'iTEHhAL rOLEKiP^C: EPS TlMtS jELS 



JcL^ 110 

UtLS 12: 

DELS li-l 

DEES l<n^ 

UELS ISC 

OEti liO 

UCLS 170 



uEES 1^0 

JtLS i!iC 

DELS .Jiv- 
JcLa ZtfC 
JcLS ^5C 
UELS 26C 
uELS 2 7,; 
JELS zoC 

UtLS i'iC 
j£LS jCO 



■'II. 



AdSULUrei-V jo-lATESF HaIN [ylAtiOi^AL 
ELEMtMT a^ rtATRl« A. 
Lc PKi^lSIU.^ AUXU[AKr STiJRASE A«^AT 



JtLS i-*!, 
JELS iiC 
j£Li 16C 

utts ^7^: 

UcLS ioti 

trtAKKS IJtLS 390 

JPpt^ TKl«ft«GJLA-t PART Uf MATftU A iS ASSUMEG To dt STOftcO ^tLS ^UG 
CjLUMr^yiSc I.'^ H•^H*H/^ SUCLE>SIVE STORAlit LOCATICIUS, HIChT JELS ".IC 
HAUj SIGt MAfKlX « GQLUMMWIic IN h*M ilKCtSSIVE SlOkAGE UtLS -i^O 

LJLAIIuN'x 0>i ^ErUKN SOLUTION MaTSIX R IS STORED CJLUHNWIS6 DELS '• 30 
rju. wEES ■V'.O 

THi. PHaCcJJ^c GIVES «t*JEri if IHE NUMoER jF cJU-illONS H IS JELS *tiiC 
GRfcATER TM-N C ANJ PIVOT £(.Ei4ti*»TS AT ALL EL IHJ WT I UN STEPS wELi *.60 
Akt OltrtKtNT f«U« 0. HOrft^tK UARhlfiG ttLh = K - IF GIVEN - LfELS -J. 'C 

INuiLATcS PGiSJiLE LdSb Jf SIGNIFICANCE- IN GJSt Gf A -ELL JtLS *.bO 
iCALcJ MAI-vU A AtO A^KHClPhlAlL TOLtHANLt EPS. ItR^K HAV Bt Oci.i -iqC 
INrE.<PkiirtJ TftAT MATKlX *. HAi Tm£ RANK K. NU UAHrilUfi Is L>£Li ^O^j 

ilVEN IN t-Sc H=l. OtLS 51C 

tKKoK P«KA.^Ef;f^ ltR = -l UOEi not NcCESSARILy MtAN THAT OElS 5^0 

HAIKiX A li ilNuULAH, AS JNL V HA ( N DIAGONAL ELcHENTS DcLS 3 30 

ARi_ Jifcu -S fIVOT ELEHEnTS, PUSSIttLY SUa«OUTINt OGELG lUHICHOtLS JtO 
•iu^n.:, WITH TOTAL PlVOTiNO) •'OJLJ &E At)L£ TO FIMJ A SOLUTION. GLlS tiSC 

UELS ibC 



fUNCTIUW SJJPkUG-^AMS HfcUUIREO 



iTHUJ 

SCLUriOM iS JONE bV «tANS Of GAOSi-fc Ll MI NA f I ON WlTN 

PIVOTING l.<4 f^AIN l/IAGU^AL. IN ORDER TO P^tESERVE 

SYMrtLIRr l.ij RchAIMNG GOtfFltlENT MATRICES. 



OELS 50C 



DELS 620 
OELS 63C 
DELS 6<r& 



SUdRjOT I'iL UL/tLS<k, A.HiN. EPS . I£R . AUX 1 



UIHt<<lSIl.N Al 1 ItRUI ti^JAI II 

tiOJdLc P-iECi^iIUN Kt At AUX.P I V.Tdt TOE rP I VI 
IFM)^:'..^-*,! 



OcLi <oC 



AltSI HAIK Jl^jLiHAn. tLcHENT 



SEARCH f^ti I 
1 IcR'O 
PiV=. .UC 

L-0 



ifUu-Plv)3, i,^ 

i PIV-TJ 
l"L 

3 i:o.^TlN<it 
IciL-cf i»^i V 

rtAIN UlAGiji.At, cL^HuNT A(II = a(J,J1 IS FIRST PIVOT ELEM 
PiV CO.^TaINj Tut AJSiJLUTi VaLUe ^f AH). 



JIAKI i,Ll.-llN 
LST«C 

Nn«><*H 



TLST i>.-j jitfJl-Ncj 
lF(^iVl(t.2'i,'. 
-. (rl IlRI 1,-3, t 
', 1F(CIV-IUL 16. t. 7 
t. iEHiK-1 

LST'LiT..-. 

PiVI - 1 .G-/«( I I 

'IL 3 L^r-MVfl.M 
LL-L'LI 
Tt^r' Itf I --mLL 1 
K(LL»^K(L 1 
O h ( L ) = I •( 



.10^ MHJ ^.jLJn^ l.'»fLKi:rtA,\, 
LLii^t.^rS oF PlV^I ^t;LJH.s 
■« Lk-L^THL(--lt(»J-ni/2 
LL = lH 
L = L 'j ' 

L-o l-. 1 UK.Lt.JJ 
L=L*i 1 



rMStT^ii, aLuu'^.iTM 



IN ■A^\ iJHT h4«.^ ilOt R 



i.JJ PIV^T MOW REuUlTJON \* 

: '^AVlJ I(* AUXlLl«t.r k^ ii, I , . 



IFd-LRJU.K.ll 
i;> -(Lt)-AILlt) 

f3"Alt) 

Go TJ ij 



11 



• LT 



il Io=A(LL) 

AILL)=-iL) 
I J AUX< I I l-TD 
1-, Alt I -PI Vl-Tts 



rtAi.jt LNFO.trtATIuN 



LLEH£Nt '.clAJCT lUi, ANU icA.^CH 

^•IV«: .J( 

LLST^LST 

LT='. 

00 Id 1 I = K,LcNU 

f'lVl=-AUKlIIJ 

^L = Ll:>r 
LT^LT*! 
tJ'J l-j l.LJ=l I .L;.'0 

L=Li.»Lr 

I'j «tL Ma) I It^iVI^-AILL » 

Ltii^LL jT*I I 

lH = Ll->1 "^X 

if ( ru-->wi I/. 17, If. 
io fJV=Ii; 
l=LK 

j=n»i 

1 7 4JJ Id Lk = K,^><1,M 



oAL< iJbsriTurijj ai«u bA^:< i'*t£Rcha.'^ 

i; If iLu'.-lJ I2i,23,21 
00 i£ 1-2, ^ 

tST'Lsr-i : 
u = n-i 

L=A)Lir )♦ .>UCi 

Tb'RI J I 

LL = J 



NEXT PlvGT 



<-l:i 

■jo 21 Ll-II.LE'^0 

LL=LL*1 

^■tttLl 



11 fi(KJ = To 
23 RtlUkN 



ERRUK RtTURN 

14, Itfi"-I 

RETURN 
End 



GcLS 


^■,;- 


GELS 


7*:; 


DcLS 


71^' 


OtLS 


IV'-. 


OELS 


7i: 


OtLS 


7*^0 


(JLLS 


7v; 


DLLS 


?(»r' 


ULii 


7 70 


OtLi 


73; 


OcLS 


^■^J 


i^ELS 


a:': 


JlLS 


- 1 •;■ 


DELS 


<Sly. 



UtLS 


et.'; 


OcLS 


tj-.'7 


L/tLS 


9 J, 


OtLS 


-li-: 


OcLS 


V2C 


JcLS 


■*ie 



OtLS -,7^ 



D^LSIO^: 


LiELSiC J'" 


JLLjI.-- 


ocLai.'-i'; 


LcLSiO-jr 


G^LSi: 7: 


o-lil.-*'. 


j.LSu y- 


.IfcL J. K'^ 


GclSI 1 K 


jLLbl 1^'- 


;jLL5a>: 


JCLSt l-.] 


JtLii IHO 


utLilK.'; 


c-:.L:.iJ 7, 


jcLSUti.: 


JclSll *L 


U L L S 1 ^ C C 


ut.L >i^i: 


o^LS12?: 


yCLSl^iC 


Glilsi^'.: 


UCLSI23: 


L^fcLSi,..,' 


JLL il. V. 


C-LSl*:o: 


jcLiU'*': 


J.LSliCC 


ucLSi ji : 


jtLSl )2C 


dLL bli.'- 


•jlLSijj','. 


Otiii .M 


j=isi>^: 


UtLSl WC 


ucLSi ).v; 


OtlSlj-. 


DtL ji-,. ; 


OcLSl*.!'. 


OiLSl-.^ 






^tsu^c 


J 


iLSl'.'i J 





LUSl^'V" 


G c L J Ij ', J 


Oi 


llsi?i- 


ij. 


[;Lilb2J 


Ul 


^lSi.j: 


UcLSli-,- 


Jl 


cLiio;o 


J: 


:LSl-J'j.- 


u; 


:LS1'>7'; 


J. 


.Lbl->-l-J 


OtLilS'?': 


Ij- 


: L S 1 f) . ■- 


01 


-LSUi': 


CclSi<>20 



OtLSla-i, 
Ut:I.Si6:3? 
JtESl')-,-", 
L.-LSioTi; 
o^Lilod: 
JtLSl^jiG 

OtLSl'lC 
„ci-Sl7J/') 
OtlSWiO 
jtlSl 7*.0 
OtLSWpC 

GtLS17oC 
ULLil 770 
DELSi7aJ 
OcLS179: 
OcLSidQC 
OtLSlolC 
OtLSld/C 
JtLS|d30 

JcLSis*: 

JcLiU5C 

DcLSiat,. 



136 Mathematics — Linear Equations 



Subroutines GELB and DGELB 

These subroutines solve a system of simultaneous 
linear equations with a coefficient matrix' of band 
structure by Gauss elimination. Consider the sys- 
tem of simultaneous linear equations 

A * X = R (1) 

with an m by m coefficient matrix A of band struc- 
ture and an m by n right-hand side matrix R. Solu- 
tion is done by means of Gauss elimination with 
column pivoting in matrix A. If R is the identity 
matrix, solution X is the inverse of matrix A. 
Solution matrix X is placed in positions of right- 
hand side matrix R and is stored in the same way 
— that is, columnwise in m*n successive storage 
locations. Thus, the computation of the solution 
requires no extra m by n array of storage. 

As storing matrix A by row results in a much 
more effective inner loop than storing by column, 
the procedure assumes that band matrix A is stored 
by row in successive storage locations, the number 
of which is equal to the number of elements appear- 
ing in the main diagonal and upper and lower 
codiagonals. The elements to be handed to the 
procedure by the user are underlined in the 
following explicit writing of formula (1) in the 
special case of a 7 by 7 matrix A with three upper 
and two lower codiagonals: 



a a a a 
11 12 13 14 







a a 
21 22 


^23 


"24 


"25 





^31 ^32 


^33 


"34 


^35 


-36° 


' "42 


"43 


"41 


"45 


'^46 -47 



a a a a a 

53 54 55 56 57 



a„, a.„^ a„^ a„„ 
64 65 66 67 



a a a„„ 
75 76 77 



''ll "^12 • • • ""m 



^"21 "^22 • " ''2n 



^31 ^32 • • • ^3n 



"^71 "^72 




'^ii "12 •••^m 



""21 ^^22 • • • "2n 



r r . . . r 

31 32 3n 



(2) 



r r . , 
71 72 



7n, 



Immediately following the matrix elements there 
must be some auxiliary storage locations used by the 
procedure, such that in the general case of an m by 
m matrix A with "mud" upper and "mid" lower 
codiagonals the total number of storage locations of 
array A is:"*" 



ma = m 



mc 



(mc-mld - l)(mc-mld) 



(3) 



with mc = min (m, 1 + mud + mid). (4) 

That means, in the special case of formula (2), 
that the 33 underlined elements of matrix A must be 
Stored by row in the first 33 sucxiessive locations of 
array A, which consists of 36 storage locations. 
In the first part of the procedure , matrix A is 
searched for its absolutely greatest element, say a^j, 
and the absolute tolerance for testing loss of ' signifi- 
cance 



tol 



« 



(5) 



is generated with a given relative tolerance £ 
Close together with this search, the elements of ma- 
trix A are moved backward, and a triangular area of 
zeros is inserted in the last positions of the first 
(mc-mud-1) rows, according to storage require- 
ments of the Gauss algorithm for band matrices. 
After these manipulations , the special matrix A of 
formula (2) will occupy the 36 positions of array A 
by row as shown in Figure 10 (the underlined ele- 
ments are tiie main diagonal elements of matrix A). 

In order to make the description of the band- 
algorithm easier, the elements of array A are re- 
named according to their arrangement in Figure 10, 



Mathematics — Linear Equations 137 



°u 


°U 


°13 


"14 








^^21 


°22 


°23 


"24 


"25 





"31 


°32 


"33 


"34 


"35 


"36 


°42 


^43 


% 


"45 


"46 


"47^ 


"^53 


^^54 


"55 


"56 


"57 


/ 


"64 


^^65 


"66 


"67 


/ 




"75 


^^76 


V 










a „...a 
mr,3 mr,mc-l 



mri-1,1 mrH,2 mr+1,3"" mr+l,mc-l 



m2 



m3* * * m,mld+l 



mr,mc 



-fS~ 



Figure 10. Array A 

thus generally giving the array shown in 
Figure 11 (main diagonal elements are underlined). 
Each of the first mr = m-(mc - mid - 1) rows in 
this array contains mc elements ; in the following rows 
the number of elements decreases steadily by 1 until 
the last row, which contains mid + 1 elements. 

Now Gauss elimination can start. In the first 
step, search the first column of matrix A 
(that is, the elements of the first column of 
array A with row indexes from 1 up to 1 + mid) for 
the absolutely greatest element, say a^(l= j=l 
+ mid), and select it as pivot element (p = a^). 
Assume that j = 1. If it is not, interchange the first 
rows in array A and matrix R with the j rows. 
Now, transform the elements of the pivot rows (that 
is , the first rows) of array A and matrix R by divi- 
sion with p, and the elements of the following mid 
rows by adding -a-^i times the first rows to the i/ th 
rows (i'=2,3,...,l + mid). At the same time, 
shift back the elements of the i/*" rows in array A by 
one position and insert a zero in the last position of 
each transformed row. This transformation is de- 
scribed by the following set of formulas: 






p 

p 
I'l 



(1 = 1,2,., 

(1= 1,2,,. 
.(1) 



mc) 



n) 



(6) 



(7) 



f 1 



11 



(1 = 2,3, , . . , mc)J 



a(l) = 
J'.mc 



(" = 2,3,..,, 
1+mld) (8 J 



Figure U. Array A renamed 



"=2,3,, 
1+mld) 



. ,n; 



(9) 



Rows with row indexes greater than 1 + mid remain 
unchanged; nevertheless, they are marked with the 
superscript 1. The result of the first step is shown 
in Figure 12 (main diagonal elements are under- 
lined). 



R 



(1) 



'■<;; 


12 


In 


r(l) 


r(l) 


r(l) 


^21 


^22 


••• ^2n 


r(l) 


r(l) 


r(l) 


""si 


'^32 

• 


••• ''3n 


r(l) 


r(l) 


r(l) 


Vl 


m2 


mn 



This procedure is now repeated (m-1) times, start- 
ing at the k* step with array a('^~-'^) and matrix 
R(k-1) . 



Note that the user must provide this number of 

storage locations of array A by the dimension 
statement in his main program. 
■•+In case of a matrix A without lower codiagonals , 
tol is set equal to zero, whether e is zero or not. 



138 Mathematics — Linear Equations 



_L 


°12 


°13 


-»- 


1 ,mc-l 


l,mc 


4? 


"S 


°23 


•• 


„(1) 
2,mc-l 


''2,mc 


4? 


4y 


°33 


•• 


°3,mc-l 
mr,mc-l 


3,mc 
mr,mc 


mr, 1 


mr, 2 


mr,3 


•• 


°mr+1,l 


°mH-1,2 


°mr+l,3 


<s— 


^(1) 
mH-l,mc-l 

m,mld+l > 
/ 


/ 


ml 


m2 


mo 


/ 







Figure 12. Array A 



(1) 



-^J- 



^ 
Y 



'l2 13 ••• ),mc-l l,mc 



22 23 
^ ^32 °33 



i,mc-l z,mc 

,(3) ,(3) 

3,mc-l 3,mc 



, (mr) (mr 

mr, 2 mr. 



mid zeros 



Figure 13. Array A 



(m) 




ID 
N 

-a 

E 



The rows which must be worked through at the k*'" 
step are the rows with indexes i = k, k+1,..., 
ilr = min (m.k + mid). As soon as ilr becomes 
greater than mr, the number of elements in any row 
of array A which have to be transformed decreases 
by one in each step k. The total results after m 
steps are shown in Figure 13. 



R 



(m) 



4? 
41^ 



r<^) 

12 

,(2) 
22 

32 



j.(mr) ^(mr) 
mr,l mr,2 



ml m2 



,(1) - 
in 

,(2) 
2n 

(3) 
r 
3n 

^.(mr) 
mr,n 

Jm) 



Now, working backward, generate solution matrix 
X in the locations of right-hand side matrix R by 
means of the following equations: 



^(m) ^ (m-1) _ (m-1) . (m) 
m-1,1 m-1,1 m-1, 2 m,l 

(l=l,2,...,n) 

(m) ^ (m-2) _ (m-2) ^m 
m-2,1 m-2,1 m-2, 2 * m-1,1 

--1";%- ^m\ a=1.2....,n) 
m-2, i m, 1 



^„., _ (m-mc+1) _ (m-mc+1) 

m-mo+1, 1 ~ m-mc+1, 1 m-mc+1, 2 



Jm) 



m-mc+2, 1 
m 



(m-mc+1) 
m-mc-l,mc 



% a = 1.2 n) 



^(m) _ (1) _ (1) (m) _ (1) (m) 
""ll ^ "^11 ^12 ■ ""21 ^13 ■ ""si 

-...-a</) • r<"^>, (1=1,2.. ..,n) 
l.mc mc.l ^ _ 



(10) 



Mathematics — Linear Equations 139 



Note that in the first mc-1 equations of formuia (10) 
the nxomber of terms to be subtracted increases 
steadily by 1 until this number has reached vmc-1. 
From the (mc-l)st equation up to the last equation 
the number of terms to be subtracted remains con- 
stant. 

The only case in which the procedure described 
above can fail to give a solution occurs when at any 
step (say the k^'^ step) all elements in the k^^ column 
of the transformed matrix A [that is, the elements 
in the first column of array A with row indexes k up 
to ilr = min (m, k + mid)] become zero, and no 
pivot element can be foimd. In this case, the proce- 
dure is bypassed and the error message ier = -1 is 
given. Actually, because of rounding errors, a 
further check of the absolute values of pivot elements 
is performed by the procedure. If at elimination 
step k this absolute value becomes less than tol (see 
equation 5 and second footnote), it is likely that ma- 
trix A is singular, too. But, as this may not neces- 
sarily be the case and as this test depends highly on 
the choice of the relative tolerance e , the proce- 
dure gives only the warning ier = k-1, which indi- 
cates that there is a possible loss of significance in 
the results computed by the algorithm."*^ In case 
of a well scaled matrix A and an appropriate choice 
of the relative tolerance, warning ier = k-1 may be 
interpreted as meaning that the rank of A is less than 
m but not less than k-1. If there are no lower 
codiagonals (mid = 0), the test on loss of signifi- 
cance is suppressed. 



+For subroutine GELB, a relative tolerance be- 
tween 10"^ and 10"7 is suggested; and for subrou- 
tine DGELB, between 10"!^ and 10-16. 
■H-For example, e = 10"^ and warning ier = 3 mean 
that there is a possible loss of about 5 or more 
significant digits in the initial values of elimina- 
tion step 4, and that matrix A seems to have a 
rank less than m but not less than 3, 



PURPOSE 

TC iOLVt A ^YSTtH Cjf" SiHiJL fANeOUS ilNtAK £0UATIUNS HI TI^ A 
CUfcFFICUNT KATMlX Of uAMO STkIATURE. 

U&AGc 

CALL GELafR, 



A.H.N,MUO.Nt.0.ef>S,IEH} 



0£$CKJP1 I£*«l OF PArAMEICRS 

B - rt 6V N RIfcHT HAND SIOE 



MATRJX IO(ST(^arEc:|. 



ceie 

S£LB 
CELe 
SELB 
GELS 

sete 

GELB 

Gtie 

v*tL6 
GELB 

GcLe 
GELB 



122 



Cti RtfUKN R COKiTAJN.S IHi SCiLUTION Lf iMt LgUATIONS.GcLfe 15C 



COE^'FICIENT MATRIX b I TH fiA NU STRUCTU^'E GtLB 

(Dcsraavtui. (itia 

- r;<E NUneLk OF cgUA»|u«S IN TMt StSIEH. OELb 

- THC NUHeeA CF RIGHT HaNO SIDE VECTLKS. GEib 

- The WJ«6£« CF upper CoOlACChALS I THAT <4cANS GELB 
CJUlAGJhALS AbJV€ HAlH uIACONALI. GtLB 

- THt NUHbtR CF LOttH CUJIAGOhALS IThaI HeANS GfcLB 
CuuIASONmLS bUL-JM HAIM OULGNAL). GEL3 

- *r, INPUT CJNSTAf^T ntHICh IS UiEO AS HELATlVt ££i.e 
Ti^LtRANCfc FGk TcST l^H LOSi Of SICM F ICAi^Cc . k,ti.fc 

- KcSULflNG tkXOK PAhAMCtth CCDEO AH FCLLjMS ijtL£ 

- ftU tKRJRf CtLB 

- NU RiSL.LT BEiIAuSe Of wRCNG INPJT PARAKE- GLL6 
IEkS KtHUOtHL;/ CK BECAUSE JF •>! VOT EL£HCNT&fcLti 
AT A<<f¥ cLinira^liOK STtP ECJAL TO Cf GkLb 

- WARNING out TO POSSIBLE LCSii Cf SlCNlfl- GbLo 
CANCt ]N[>ICATtO AT ELIMI NA T lOit STEP K*l, CELd 
WHtKc PtVdT ^LlNENT was LtS:> TriAN OR GtLt) 
EdUAL TJ THc INTfrRNAL TOLEkANCt tP^ TIMES GLLti 



IcH-C 



AdSJLJTtLY C;.<cATtST ELEHEnT Of lATRlX A. 



REMARKS 

6ANJ HATi^iX 
lit. SUCCcSSli 



GcLg 



IS ASbU'lcO Xw bL STOREO rtuWk'I::>t I.\ THE FUST ;>E4.3 

STO*.AGt LOLATIUr^S Of TOTALLY ^tJ:l>fcJ HA G£L6 

SlfJ^AGE LOCATILJ^^S, KHe^c GcLB 

,iA»M««C-HL*(Mi.*ll/i ANi> «E ««A-f1U«( MU* II /2 KlfM GELB 

riC = '*INI«* l*MU'0*KLOJ ( ML =HL-1-MlO» MU-HC- i -HOJ- GEL 6 

^IGHT rtAHO iiJE MATRIX R IS AiSUMtLt TO BE iTukLj CCLUMNyiSc GtLB 

IN N*n SUCCESSIVE STUiAJE IUlATIONS. On Rtlu^N SOLUTION GtLc 

MATRIX R IS STOREi; CuLUM^SM I St TUQ. GkLe 

INPJT PAkAHcItRS «, HUJ* HLU SHOULD SATISfY THi FULLChING GELO 

RESTRICTIONS MUU NuT LESS THAN ^ERD GtLb 

MLI> /^UT Lt^S THAM ZERO GlLS 

kUD+MLu NOT GKEATtR THAN 2*M-2. GELB 

HC ACTILN iiESIOES ERRQK MESSAGE ltA>-l TAKES PLai.c IF THESc GELS 

^tirK.lCTlU[S.S Akc NGT SATISFIED. GlLB 

THt PKLCLUJf.c GIVtb ftfciJLTi if THt RtSTHlCTturij ON INPUT GfcLb 

PARMMLTERi AKE SATlSflcD ANP IF PIVOI ELEMENTS AT ALL GtLB 

ELIMI.4ATIC^4 STEPS AKe JIFFERfeNT FROM 0. HOWt VtR itARNlNG GELB 

IER=il, - IF GIWEN - iKJICATLlk POSSIBLE LUSS (jf Sit/NIFICANCE. GELm ' 

IN CASE Cf A MtLL SCALED :>1ATKIX A AKO APPKUPKImTi. TOLERANCE GtLB ! 

EPS. itk-^H MAV dE INTtKPREIEG THAT KATRIK a HAS T*4t RANK K. UfctB 

fiL kAKNT^G is GiVtN If KAIkIa A HAS SO LObtK CUOl AGONAL. GcLD 

GcLo 

GcLB 
GtLB 
GLLl 



17C 

uc 

2K 



2B0 

iCC 



ibC 
17C 
3rtC 



SUBROJTlNt 



S AMC FUNCTION SUBPKUl,HAHS REi^UlREJ 



tTHOO 

SOLJIiON I^ JOHt bV MEAAtS UF GAUSS ELlHIfUTluK klTH 
COLUMN PIVUTI(«ii ONLY, IN UHOEK TO PRESERVE bANu STRUCTURE 
IN -REMAINING CUi-FFiCIENT MATRICES. 



6 7C 

61C 
63C 



SUbRuUT li'^c GELO(-<,H.M,NtMUOiHLOtEPSt lEHl 



JIHENSILN RUii A<it 

TEST C;.^ »KUHZ INPUT PAkAMETlKS 

IF lMLOI*?,lti 
I iFtMUGI'.ft^,^ 
^ rtC«l*MLu*hUU 

IF(HC*1-M-HI J,3.'.7 

VKCPAKfc INTLOtk PARAMETERS 

mL-NOHBEk Of COLUMNS IN MAT-4IX A 

Mu-Nu»iUER Gf iCAUS TO BE iNScRTEu IH FIRST MOW L.F HaTmIX 
ML"NUrtBtf< UF MISSING tLcMENTS IN LAST ROM Of BATqll A 
Mk-IM;tX cF LAS1 ROM IK MATRIX A mITH HC ELEHtNTS 
H2-T0TAL NUMBER OF ZERuS TO Bt INStRTkD IN MATRIX A 
MA-TOTAL NUflBiR Of STORAGE LOCATJOKS NECESSAKV FOR MATRIX 
NM=^NIJMBtK OF tLtHENTS (N MATRIX R 

J if IHC-il)5.6,'^ 

A MC-M 

5 MU=MC-MUD-I 
ML"MC-Hl(j-I 
MR-M-ML 

MZ-(MU*tHU*ll )/<; 
MA-M^MC-IrtL^I^L*! \l/2 
,4H*=N*M 

MOVE ELthrMS bACKdARU ANU SEARCH FOR AdSQLUreLV GrEaTESI EL. 

iNUr NtCcSSARV iN CASE Uf A mAIRIx MITHQuT LOWER CC'JIAGONALS 

1ER>0 

PIV'O. 

1F<MlU| U,1'*,& 

6 JJ«MA 
J»MA-Mi 
KST-J 

DO 9 K-l,Kir 

Ta-AiJi 

A( JJl-TS 
(fi'AbSl Tol 

iFir(i-PiviB*e«r 

7 PIV-Tb 

a j-j-i 
9 JJ«JJ-1 



INSERT 2ERJS IN FIHST Mu 

IF{HZtl4.14.1C 
IG JJ-J 

J-14^HZ 

IC-MNUO 

DO Li I -I* NO 

DO U K-1,HC 

AlJJI-0. 

IF(K-ICIiltlltl^ 
11 AIJJl-AfJ) 

13 IC-IC*1 



(NOT NcCESSARV IN CASt_ Mi-C) 



GELo o5U 
GELB bbC 
GtLb 670 

...Gti.B odC 
GcLti t.'.C 
GcL6 TOO 
GELB TIC 
GELS 720 
GELS TJC 
CEL8 7<.C 
GELt) 730 
GtLd 7oO 
GfcLE 77C 
GtLB 7a0 
GELB 7';0 
(fcLB 8C0 
GtLb 81C 
GELb 82^ 
GELB oiQ 
GtL3 t>«hC 
GCLB 8:>C 
GELB HaC 
GELS fe7C 
GELB iiO 
GELB B'iC 
GEL6 90C 
GELB 911; 
GELB 92C 
GELB S(1C 
GEcB 9^0 
GELB ySO 
GELB 963 
GtLb 9 70 

IT GELB 96C 
GtLB 990 

Geteicoo 

GELBICIO 
GELdlC^C 
GELBiCiO 
GELB104C 
GELB1C5Q 
GELSIC60 
GELSICTO 
CELBI&9C 
GELB1090 
GELBUCC 
GELBllLC 
GELflU^O 

GElBli^G 

GEL61130 
GtLBIloO 
GEEStirc 
UEL81I8C 
GELBllVC 
GEL81200 
GEtaiZlC 
CELBlJiC 

GuauiO 

G£LBl'i!-<>C 
GELB125C 
CEL8126C 
<*ELS1270 

GELBl^aO 



140 Mathematics — Linear Equations 






J.Ut FjM SINt^ULARITr 



sTmf uccaM(>as I r 1 a« ljop 

iC«MC-l ^ 

00 3S K-lfH 

if |lt-M«-ili6,14,lb 

15 lusr-losT-i 

16 10>I1>ST 

lLK-K*NLO 

iftUft-Htis.iti, ir 

t7 ILU'H 
IG II-KST 

PlVuT StiARCH 1,4 l-UST COLUMN I RljM IN^tK£& FROM 1 -K UP fO 1-ILRI 

to 22 l«K*ILR 
le-AdS(A( III) 
If <rti-PIV>2C.20< L« 

J-l 

JJ-il 

^z U-IWIO 

rtil u« SINOUCA^ITV 

^*v If (PIV-TtJL)=!5.^St2b 

^fi lEK-H-l 

2o PU>1./A(JJ) 

»'Wur «<ot< RtLloo[I^^ anu f<u* i.'^r£KCHA\GE U ri&ht hako slot a 

iO"J-(( 

OCJ 2 7 ]«K,Nh,rt 

TE»»'1V*R| 11 1 

HI JI 1=^1 II 

fivai kOW f<Cc.oCTiLN A.4D ('Ct. I^TERCH«.^'l;t Ih CQEfFlClEhF HAIrIk A 

uO 211 I=JJ,J 
-{I ) = •<( III 

A( 1 1 i-=rb 
it ii-n*i 

tLtHtNT RE^CI l^^ 

1 I»H + 1 

nz»Ksr-ic 

Jj=l-KR-1 

IFIJJ)31i31i^C 
JL IO«I[>-Jj 
31 PiV=-A(IUt 

J-iU*! 

Ob 32 jJ-MUtH.: 

a1J-1I-AIJ)*PIV*m(JJI 
j2 J'J+1 

A(J-l)-C. 

IK MATRIX K 

uO 33 JJ-I,NM,<^ 

R( JJ|>H(JJ)*»>IV»nCj I 

34 tlST-nST*«C 

IFULR-Kfti J6.35.ji. 

35 IC*IC-1 
3ft 10=K-Hf. 

If ( 1DI36. JU. JT 

3i> LotiiTlNJE 

thiii Of CtCUMPL^SirioI. lOLP 



L.ACK SJBSriTuTION 
If (MC-il**>.*'6,J9 

K.ST«NA*H1.-»1L*2 

1I"M 

bU 4b [-2.M 

Il*il-L 
J=I1-Kk 

lf(J}'tt.^l«4^ 

oO 43 J-U.NM.M 

Ta>=Kij) 

rti-KSr*It-2 

IC'J 

UlJ 42 JJ>KST,H£ 

ia=T6-A(JJ»*R( 101 

Rl^)-T3 

if* tC-.lCI';'*,4S> ^5 

iL«IC*l 

CONTlNJt: 

RETUKK 



[:kR£jR KtiruRh 
47 ltR"-l 
RtlURN 
END 



&CLai290 
GELdiioO 
tiELBUlO 
tiELB132C 
CCLaiiiO 

(iueiifC 

CI:Lal3^0 
0£Ldl36C 
GELB13T0 

GtLSiitlC 
Ct'LBli'iO 
OeLBUOO 
GEL ai 41.0 
GELfll42C 
GELBL4iC 

(;elbl^4C 

i^ELei460 
iifcl6U73 

CitL814(IC 

Getiii4so 
cti.ai5<-0 

OElBldi:] 

GELB11>20 

0ct.6l34C 
GELBiSSO 
Gt(.BU:>C 

Ge(.ei!>rc 

uELBl^tiC 

GeLBlS9C> 
G£LBUOC 
i^fcLaiMO 
GELBI62C 
GELHUjC 
GELei&40 

CEL6l&c>C 
l-ELSlbTC 

GELdlo9C 
GELBirc: 
CELSl/lO 

GeLB1740 

oeLbi/sc 

CcLai760 
GtLiJlT7C 
i;£L6l7o3 
GtLB17^0 
GcLBlbi.': 
GElBLc IC 
G£LBLe2C 
GELdl£3C 

GELBldiC 
GELBUoO 
CELai^7c 
CfcLbUbC 
G£Lei69C 
GELS190C 
GeL6191C 
GELl>192C 
GELBI93C 
GELgl94C 
GE16195C 
GELSl^bD 
GE18197: 
G£L6l9dC 

GELeiy-sc 

GELb2CC0 
GtLB2C10 
GiL&2C«C 
G£lB2:3C 
GELB204C 
GEL 6*. CSC 
GtLS2(.bC 
GELB2CTC 
GELB2CoC 
GELB2C9^ 

GELB2ilC 
GEiB212G 
GELB2130 
GEIB214C 

GELB2lbC 
GEib216C 

GEIB217P 

ec(.B2iec 

GELe219C 
G£LdZ200 
GeLB221C 

&ELb22^C 
GEL6^23C 

GELB22->: 
GcLU<2^0 
GtLfi22t: 
Gett22?J 
C£La22S0 
GtL622')C 
Gti.62^CC 

G£LS^320 

CEL623sC 
GEtBi35C 
GtLB2JtC 
GLLB2j7C 
GELe23tiC 
GELB2J9C 
GtL6240C 

CELS24 2G 
GELtt2430 

G£*.a2<,4C 

GfcLB2<i^0 



SUBROUTINE UOELD 

PukPOic 

TC S&LVt A SVSTEM OF SINOLTANEjUS LIHEAK ECUAT IUMS Vi TH A 
CUtfUCltNT MATRIX Uf dANO STRuCTUi^E, 

USAuE 

CALL otjtLblA, AtHf NiMOOiMLJiEPS* lEKl 

OtSCRlPTIC.% uF PARAWtfERS 

K - bOUjLc PKtCiSlON M oV « RIGHT HAND SIDE MATRIX 

(OtSTROvEGj. J.\ REIURAi R CONTAINS THE SjLUTlON 

Of TM£ iCUAIIONS. 
- i-CJoLt ofifcCISIOh M 3f M LCEFFICIEM MAT.*iX niiTM 

AAhiU STKuCtukE (JtSIrvGCtOJ. 
rt - rrt£ rtUHdik OF EitdATlU'^S IN THE SVSTfcK. 

N - ImE NoMtJfcK UF >(IuHr NAIvO siOt vtcrDK:>. 

Hu'J - THE MJUBlk CF JP?c« Cl-OIAGOKALS I THAT MEANS 

(.oOIAoONALS A6JVc H^l>t t'lACCNAL). 
■iLi. - THt MU«UtR uf LOwtH CDOIACOhfcLS (IHAT "ScANS 

CQOlMiOKliLi tElOm MAi,\ i>lAGUNAL). 
cPS - ilNGLc- PRLCIblJN INr'JI CONSFANT KHICH IS USCO AS 

AtLATIVE ICLLiLtMCt foR Tt&T ON LLiS Cr 

SlG.Vlf ICAhCt. 
Id* - ktSJLTINO tfvRJK PA.(A*ieTe« COOEO Ai fULLiirti 

Ifct< = -1 - No kESoLT dECAUSc Of WRQNG IStJjI PARAH£- 

Tfc.o rt.^UO.htJ CR BECAUSE <jf PIVtT ELEMEf.TDtLD ilC 

AT A.^V tLiNl.\-IlCN STtP taUAL fC C, litLB i2: 

IdK^K - KArM^u i;Uc Tu PCSil&Lt LOSS CF SlGNIfl- JcLb jaC 

Ci^Ct INiJiCAftC AT ELlKIN-^IIuN STEP K*l, btL6 i^C. 

Hh£fle PiVtlT titHENF wfiS LtSS THAN OB CLLo J e-C 

EQUAL lb The iMtRKAL ToLtKAhCc EPS TlrttS bcLB J6C 

AbSuLUfcLr uHtATfcST LLcMLNT Lf MATKIX A. JtLE 371. 



otca 


iO 


.OELd 


2J 


OcLB 


la 


OcLfi 


4fl 


U£LB 


50 


otLB 


6C 


UcLB 


7C 


OtLb 


ao 


OELB 


90 


OELB 


ICC 


OtLB 


no 


;)ELB 


120 


OtLB 


1 )r. 


oelb 


140 


OELb 


15Q 


OfcLS 


IbO 


L»cL6 


i7C 


J£LB 


16; 


uELH 


I9r 


utLij 


2C0 


JELfl 


<rlO 


OlLb 


2 2C- 


DtLb 


2iC 


OElC 


i'-C' 


i}i.Lb 


2-C- 


i,H.& 


26 U 


out 


^70 


UtL6 


23i; 


uELb 


£•^1 


uelb 


aJC 



L>A.^J M4TV;a a Is ibiJf'iJ Tj oJ- 
,-iA = rt»^C-.tL* (.■4L* I I/.L A^ j 



rtl^rtT nA.Nv ilJt 


.1A[^, 


U >^ 


ib 


[K .■s.*'! jJ'.C" 


:SS1 






L. 


^AIklx K li 


^Ij 


nc^ L.t-LJn4N 


-Jl- 


Uvl^Jf rK.%4'1i 


-I £« 




'<JJ, 


^11 • 


«tir>^tLri.i\- 




r-Uu 


■*-,T 


Lt 



ti AiS'JMi, 



.jlL.i 39 
iTt^Kcl KUk<t<JSt IN THt flRST C^LtJ 4: 
Of lOlALLY httiitJ MA .^tLb 

rtc = MA-Ml>«(MU*l 1/^ WITH ^cLe 

■.lU, MiJ = MC-l-HUJ. L)i.Lb 



IC 



j:C 



Tb BE 



5.\S- 



Tbf^tb COLUMNWISE bcLo 
UKN SOlUHuN ULLb 



MLi 



^JT L 



iCRC 



Jl :-.xiaTcR Than 

SS-J^ IcR=-l TAK 



■,c Jblli,. ccilQcJ LRHJs ^cSS-J^ IcR = -l TAKLi f>LA^<_ Jf THtbE 

SLbtKicnojj A-^E ^L) r :,AT»>*-itj. 

Ific ^•^^C^-'JkL ^iV[^ Ht-S'JLTi If IHI. RESTRJbULNS iJN i f-t'U T 
iJtkAfi'ircr,!! Jx-.iL iAi;-jfl[iJ A^i"5 IF k" U u T fcLL>ltMi aT ALL 
tLlrii.\ATJ.'i', il^l-i AaC ^If-fLivt.,! FftLH C. Hi.'v; VE^ ^ARf-ilNG 
l£-. = K - if- ^iViiN - l'>*jlCAlLi ^-^^.iiaLc LCSS ijr Si i^Nl MCanCE. 
I\ _i3c „r - bClL S^^LlJ u.^T-i]* A ANO A Pf kbr^il «Tc TULERANCt 
cf'i, ICR = ^ HaY Lt Ir. r..K^KcTc^ HaI flAfRiX A HAi THt nA.\iK K. 
Nu rtA^N;,-... iS Gll/EM ir MATRlA A HAS NO L>3wtR CCDIbGONAL. 

sJav&UriNES k\ij FUNCIij.\ JUoPK0oi<A<1S KEUtllREu 



C0LJK\ r'IVjTi^J uNLr, 

1\ <iMAl-i,i -ji, CCEff Ui 



ia.'^b Ur jMjSS tLiMlMATIuN ^ilh 
IN JRJfcn TO PRfcStHVE fcANO SlRuCTURc 
-T MATnlCcS. 



OtLb Dl 

OtLb fc2i 

JEL« oi 

OELB t><.. 

DtL6 o'i 

OcLB ob- 

UtLb t,?. 

jLLd b3i 



;CUaLL Wc^lil'j.^ R. A.Pl V, TitTOL 



sr 



fc-^O.^. 



JF(MLLiK7,I,l 

1 If (MbOI4J,2,2 

2 MC=lt.-l*_L*,»^UiJ 

If ) ICt 1-.*1-,'', I 3, 



;7 



^^LPA^.L I\Ti:Gt'i r A-< A.-^t I Lr, i 

ni= ^uf-^^a Jf ^JLUrti'jS I-'- matrix a 

MJ-NU«^cR Jf ZtKOS TC ot INJtKTdJ if^ FUST KUH uf MATRIX A 
*'.L="iO>:3t« Jr *liSSlNb ELtMtijTS Ift i.«$T ROH Of MArf<!X A 
MrtMrocX of LibT KOh Irt J^ATRIX A .vITH MC ELcMEi'-rS 
rtZ = rCIAL \J.dt.:n uf- 2L-*Ji T3 it I,«StRT£t IH mATkIX a 
■HaiILTaL WtucK Jf ST^.-<A;;l LuCATIJ.-i NECESSARY fd .MATRIX A 
^^'. = l1JJrtJt'^ Jf .LcMciUS Ii\ 'MATRIX < 

i If (MC-. -1)^,5.- 
4 WC = M 

b i-.lJ = nt.-.-iUD-l 
,■^L = ^■^.■->ILL•-I 



LAk'.m FJ.i AiiiCLUTaLV jf'c'iltl.T LLtW 
.-.ATftlX -ilhO'JI tbW-A CuOUJ^.^ALSI 



Wk = l 


•,-J..L 




;Vi=i 


iMJt I.' 


<U*i> Mi 


I«.A=. 


■l-»rrC-( 


-L«IML * 


\M^I 


M*H 




MJVl 


- ^...> 


,;NTS ?A 


(Nbl 


r \lV<L 


iSARr f 


1 ^1^- 






Pi V: 


■ o.j': 




IFlrtLj) iH 


'• 14. ri 



UtLB 


7i: 


cjcie 


/<c 


JlLS 


1 iZ 


UELd 


IhV 


JEL-J 


r^c 


jtLB 


/bC 


CcLS 


r/'^. 


DLLd 


7 = 


JtLfc 


7^: 


■^LLb 


oC'l 


OcLa 


ei" 


Jt-LB 


3^. 


JcLB 


<)=:■ 


OtLfi 


o4C 


^cLB 


j5(: 


liLLu 




ULLS 


e7'. 


ucLb 


ab."" 


:.i.to 


5-i:: 


ocLB 


VCC- 


LtLb 


9K 


CtLb 


')^^ 


UtL6 


■^JiC 


JcLB 


V4C 


iJtLD 


9^: 


bCLfl 


^1.:; 


CcLB 


9 7i.' 


uti^-o 




Dcta 


94-'.- 


■ivcLtJl 





Iri Fo-Pli/Jy.-;,? 

7 PIVMo 



rir 



I.>« 



If (M2 J I-;, i^, IC 
IC JJ^l 

!..= UMJD 

JO 13 l=i,Mj 

QO 13 ^ = 1 , MC 

a( JJ)=C .uo 
IF(K-IC}U,ll, 12 

11 A( JJ J ^A [ jl 
J=J.l 

12 jJ-JJ*l 



fUST MU KCrti I.^jr .\iCeSSARY [N CASE M^=CI 



fJcLtsl; ■^l 

D=Lbl j5v 

iJcLbl .tij 

jtLbt :7: 

;JcLbIOJ': 
L>tL6lC<iC 

jtLdUc: 
jtLtiU i: 

bf Lsll 3'- 

L*cLHl l',C 

JtlbUaO 

ueLaiiftij 

ucLbl I 70 
OclBllbC 
UcLBll'iO 
OtLol^OC 
Oi:L3i21C 
UdLB1^2b 
JcLS12iO 
OtiBii<,r. 
"OtL6l2SO 
UtL61230 
DtLtJ1270 
ueL6i<;3C 
JEL6129C 



Mathematics — Linear Equations 141 



Subroutines MTDS and DMTDS 



FOR SlNi^JLAKUt HcL'ilii: 

DcLBl Ji-r 

JtlBl3f>C 

iTA-<TJtL'J-1PC*i(T[(J'JLiJJP LicLeiJoS 

l^=MC-l JCL3139C 

1& ij=i;j^r otLftitJC 



Given a general matrix A and a nonsingular upper 
triangular matrix T, these subroutines will perform 
one of the following six operations, depending on 
the value of an input parameter TOP: 
lOP = 1: A is replaced by T-lA. 
ui^r "-— ^-^j;^; jQp _ _^. ^ .g replaced by AT~1. 



flVJf StA^i.M IN fUSr CLLJHN (tiUrt INJtiAti FnUM 1=,-. UP TJ l = lLkl ■JtLBlfJC 

rt,= jda5(A) 111 1 



.-1^J = .^^T*l 





JJ=I-H-(-l 




IrlJJI )t,3I, j: 


3C 


I J=iLi-J J 


j1 


PIi/--i( I^t 




J = 1J'-1 




OJ j2 J j= ■tJ.rti 




-( J-; I =t( J ] *hU!^4( J Jl 


3^ 


J = J*i 




«(j-ii = !:. ^: 




i.^j .-i-vrxis :< 




J^r^ 




■jc a jj-i ,y-i,.-i 




K( jjj -rti J ji *-'iy*-ii J J 


33 


j= j'-rt 


3<. 


Ksr=<sri-^!, 




Il=( lc^-MKl 3!), if,, i^ 


3 = 


iC-JC-i 


3t 


ID=K-^W 




1F( Il)138. id.ir 


i7 


RSF=«jf-!J 


3fc 


CONTINUE 




END ^F U.^OrtPCilTUN LOOP 




bACK sueifiTuTijN 




lF(MC-i )'.t.,'!.6, 3*) 


39 


IC = 2 




KST^M4tML-MC+^ 




1 1=.^ 




UU 4 5 I=Z,M 




KSI-^Sr-r^C 




ii-n-i 




J = 11 -Ms; 




[ F ( J 1 4 I , 4 1 , 4 L 


'-C 


Ksr^<sfj 


•.L 


UO '.^ J-l I,NM,« 




T&-KIJ1 








ID=J 




DC (.^ jj = <ir,MZ 




in=iu+] 


a; 


TK=T^-Aijj|»RI :i;) 


43 


K1JI=(0 




lF(IC-^CI'.4,4i,'.5 


<t<r 


H.= 1C*I 


■i^ 


CfirtTUUt 


-ib 


KE7Ufc"d 




tftrtUH Ktrush 


47 


1ER=-1 




RtTURr* 



lOP =2: A is replaced by (T"!) Ta, 

lOP = -2: A is replaced by A(T-1)T. 

iHiii' ^*^^ ^^'- ^^^ replaced by(T'rT)-lA. 

HtsiHj ^OP - -3: A is replaced by A(tTt)-1, 



id ll^ll*lD Jt:L613^0 

TLSI 'j-^ SINoULafillY iJ.:LiJlt)i: 

lF(PIVi-.7.t7,23 JlL31j2'. 

25 if ( i t'*1^6,<?4,<;3 JcLSlo3C 

^4 JFiPIW-TjL)23f^3.a3 UtLiSlo^: 

2t PW^UUG/il J^) JdLi>l6o:' 

UtL3lt7; 

PIWl)T /<Ut. rvtJUCT ] J.'< ^'JJ K 1>- JMrtK,:rHU^:;t; IN ^IGHT HaNj jIOl R UtLDlji'J 

JU ^'7 I^.'.jN.I.M JcLBW.J 






A( I ) =rii ill j^i.6ir;i : 

fl( n I- 'f jcLei<i_:r. 

I 1 = 1 M I L- c L o U J .J 

l^^^<-!LK) ^ J. J--.. 3-. iJcLtHi'^ 

11=-;. 1 J-LtJlTi-' 



jll^^ ;3? 
0cLe,r :*►■: 



c L a2 1 i 
JcLdii 7 D 

c t L D^ ^ J : 



DtLt.2-.c: 

JtL32-,*.0 
OtLb2'.Sf} 

ueLe2'.t:o 

OcL824rc 
OtL62<-eO 



1, Mathematical background 

a. Calculation of X =T~1a is done using back- 
ward substitution to obtain X from TX =A. 

b. Calculation of Y = (T-1) Ta is done using 
forward substitution to obtain Y from T^y = A. 

c. Calculation of Z = {T^Tj'^A is done by first 
solving tTy = A and then solving TZ = Y. 

The remaining three operations are reducible to the 
above three, 

2. Applications 

Subroutines MTDS and DMTDS may be used to 
compute the solution of a system of equations 
BX = A with symmetric positive definite coefficient 
matrix B. The first step towards the solution is 
the triangular factorization of B by means of 
subroutine MFSD or DMFSD, The second step, 
which may be repeated for different sets of right- 
hand sides A, is the calculation of (tTt)"1a by 
means of MTDS or DMTDS with TOP =3. Another 
useful application is the computation of the product 
A^B'Ia with symmetric positive definite B and 
arbitrary A in only three steps and without addition- 
al storage requirements: 

a. Replace B by T where B =tTt. 

b. Replace A by C = (tT)-1a, 

c. Replace B by CTc. 



142 Mathematics — Linear Equations 









INVr ?^ Sr ( T I, I\Vf«i( (I'='N5fL:>EI I ) 1 J** 1 NVt ^ISE ) TRAHStHJSt U »T 1 ) "ITJS -i' [^ q^ j^ j 

r»-£ T-4 I Jfvr.lJL AH M4TH I K T IS S f :i * 'i CTLUMNWI SErMCHMPaE^SfiD MTOS 'JT "SIC-^I^ 

cCft". 1."^. UPPPS T'«IA^OULAR >fiRT C\L<. -^TOS I'.)) I'Oci ^.'^j 

«'TS lin pr li ( 

i>SAr,e tins K'"^ -j-^iiwrr. 

CflLl .".fCSU.M.N.r , lOP.IER) «TOS HI 



GlVeW GCME'-At KfiTflX rtHITH M "qw^ flt>,j \ CJLJMNS. MliTS Iti) ^q jj 

fjuMPtK 0'- .iows Of MAr-*lx a "»ljs l^n 

M,'MP,EH 0- CCLUMMS OF ■^ararx A M!OS 1=>J 

OIVCN IftiAN&ULAk MATKIjI SfO^-^C CCL J^'N^xI SE JPPER MTOS l'<:) 

IRlANOOf^K PAftT ONLY. IIS NUHSEO "JF '■.:^'i 4NQ MTDS i">') 

fLiLUf^NS t( IS IMPLIED flV COf.PAT I P. I L I TV. KTRS 211 

K = M If UP !S POilTIVe, WTOS ^'0 

K = N IF lOP TS NfC;«fIVE. MTDS 23'J 

OCCUPIES K*(K*H/? STORAGE POSIHONS. MT;) 



.■^ rns] ] 7'; 
MIOSI 1^ I 

"TOSi:?!" 

MTISI.'.'t 

"TO?!?'-.] 
„ ., , HT0SU6J 

"5 1^'^' Lrx-Lr: rTCSl?fO 



n'^LI.-^nb'J^-'lLI -^-(LL I FTPSI i'"'l 

iL = iL*LL Mnsi 3n 

L-L + L"'' MTf)<^ ; -i^r 

LDX-I f)X*L* KTU^l J -0 

IF(^(L)M'..i.iA f^fotii'-ri 

a ILL i--(f.SJ*wa<i.i. nniii ktosh 'i 

"Tnsi -'.0 



INPUT VA-ilAPCf fO"; SHffTIL.^ OF D»E-lIia\ MTCS ^-iO ,- j c ( | fj (;/,,! r, i f f^TO^IJ'iO 



iffPLACta ar INVE4SE(T)*ft Mills 

top --1 - A IS hEPLACEO ftY A'lfJVtflSein MIDS ?70 



KTOS 



icp = 2 - A IS '-tPiA':';:^ ^Y rjve«sf:(T-A.-jiPasE(TM*A mt.t; ^■'■i ,7 jFUfpf 111, ik. it Min^uio 



[C'» : 3 - £ IS i^tPLACt.) -ly iMVcrtSFITJAI.SPQSEaj'THA^TOS ir«1 c ISI'li'Lt/E 



MTn51'. 
KTOSl'. 



MNVF3S=(I-»aNiO'.>S£(Tl«TtMT.^S MO ,p ,fR,, MTO^l'.^n 

fA - "ly.JUl^ii, (--iK'-h P»l.A-'tttk TTS i'O MEND = IM[NO MT')Sl'-50 

lE^ ^-1 -^FANS K A^J^ N «=F 0<( T JfJTH C-flTivc MTflS T^J MK-;4»'i fTOSl^-^O 

AHD/oK ;nP IS ILLEGAL MT.IS V.r. LLD=-I-<^ fTDSI^TO 

I--.^ = ME4MS ::Pc«aI!D\ fc-AS SUCCFiiSFJL '■"'TS J'l MSFt = M1 Hrci-^l^lO 

iFw : I ."Ea^s ;" lANCiiL ^=( «at-;ik I IS ivryji.A^ mtos 'j1 cuti--i vrosi'-^o 

"''-' *"'■"■ Mx=n "Tcisisao 

<="; "^T-JS l^L- LD--M«1 f«TDS15lO 

u-kgutine mios .^av pe used rn calculate n*; sjljiicin of vt.^s ?<^n ^'^i mt,tsi5"'o 



aTIONS FflTH <V1*'-TrJrC P'^SiTIW 



MT35 1^5() 



r.T( fFlc lef.T F-ATRIX. THE FIRST STCp TOwAqOS TH^ iuLLlTION KTUS -V 1 G f^jr) MTISl 

IS !■: J flNGuL'-i; FAf ro'J I MT [::n ?v m'^sns of -^fso. thl sicgno vus -^j 

'4T-"-> IS /!''°LIC*TIDN CF MTDS. "TjS '. 1 ; 

SUH,?lLlTINrs MF5U A>47> "^OS MAY .3^. JSE 3 IN Of. 

ThF ^■^l-:)■JCT IP ANS^r S£ I i I * I NVf '^ SF ( "i 1 ^^V -ITH 

"Cil"IVt:;-Fl\IIPJA\n&IVtNltFF[:iFNTLYi\'"H-FFSTFOS '*'T)S-T.) 

II [■■- 1 flMf.'JLfc cACTap [ZATiON L.f 1= ( .i):T-iiNs>=';s.-^ ( r J ?r I mios '.tj 

?.) ^ULT I^LICAriOiN UF A J\ IMt l.cM 6i I Nv t ft S-H T -^a^SPOS t ( T I I "TiiS '•^■i 

A ib 'EPLA-cO PV C = INV(:"RSr ( fk^A-Ji = '^bF( Tn =A "'OS '■■'-'■'} C D**TD 

W LflLCiJLaTIO,\ nc iHr! kESJL'' '"'JflMING Tk Ai\SP'":<,; C. ! "C '*T)'^ ^■^'^ f OMIC 

Mn^S '-K; C OMTO 

"'ouuvf; ivui FU''JCTij\ ^uPPBi:i,^i>'> ^r.-ui=!'^': mtt.s '"■"•■j c subrcutine o«ids omtd 

»:C\' M'C;'-. 5!0 C tJMTD 

f,r[y' 'li.j C PURPOSE OMTO 

wros ')■■ • C MULTIPLY 4 C6WESAL MATFIX A tiN THE LEU OF FIChT RY DMTD 

IS D'.'^- l>il\". ■'-v:<-A^r) f.roS ■>!-; C INVEftSeiTl.INVERStURANSPOitUn OR INVtRStlTBANSPCSt HOT)) OMTD 

<y : A. "res ': " ! C THt TRIANGULAR MATRIX T IS STORED CCLUMNHISE IM C ir"^PR£ S SE iJ 

ii^''5i(I)l*A IS -■•-■■■!.- JSIn;. «'-.i= --lil C FORM, I.E. UPPEF TCIANGULAR PART ONLY. 



fFTHfO 








TALl-iJ 


L A T [ ; ,\ C F X 


= I WE 


RSf 


si;-isi 


ITUT Ilj\ 10 ' 


lFlflI^ 


If h 


'.Ai. C.U 


LATir'^ '.'F V 


- rvf 


--bt 


FP^VA 


WD SUfSTiTUTIO*. -'2 


■ I!!'. 


r fli f'' 


L'TTi--N TF 7 


-- INVf 


= SF 


^CjLVI 


ijG F tfiST tf; 


ir.SP.-^p 


( T» 


JSl j:^ 


V-'i ;.'iu-.r 1 


1-0 S 1 f 


^■s 



".rQS ^■';^ 



.M,N. T, lOP. lEPJ 



Ei:,w":it H'^TUM'-' I'! CASl .'F RLtoAL 



C ULSCRIPTION Of PAKAMtTERS 

KTr-^, t'.T C A - GIVEN &ENEF6L MAIFIX WITH M fCwS AND ^ CnLUMNs. 

Mils Q*^- C A HUSI 6E OF UOUflLt PRECISICN 

SU'IROUTIN- KT ,1 0, ^l,"^. T , ILIP, ['^"l ''Tv<^. -'■■ C « - NUK3EK Of R :;wS CE HAT.*IX A 

SUOS tio C N - NUKBtt^ LP COLUMNS OF HAIHX A 

KTO': h'-'i t T - i,IVEN TKIAN5ULAK MATRIX STOt-ED COLUMNhlSE UPPER 

0r^EM<^lC\ "Ml. '"Ill ^■TP'; sl'1 C TRIANGULAR PART ONLY, ITS NUMBEK OF AOwS AND 

■inoi'L' t"-'. is'uN ) uM *''^rs ':j c column^. ^ is implied by coMPitiBiLi ty. 

MTUS 71) C K = M If [UP IS POSITIVE, 

^t_rj ,. ^|,s.r-.i<ii[ ^ "''-■' T- ' C K = N If IHP IS hEGATIVc. 

[rjv,,-^,^.l wT.~S 7>: C T OCCUPIES K*(Ktn/2 STOf-AGE POSITIONS. 

if{t)'^_,:,'. "t;s r-.'.' c T Kusr at of uouuLt precisicn 

T-s 7,0 C ICP - INPUT. VARIASlE FOrt SELECTIOK.Gf UPERATIUN 

r lOP = 1 - A IS pEPLACED by INVC'<5E(T»*A 

C lOP d-l - A IS replaced by A«IN»^d^SefI) 

C lOP = 2 - A IS REPLACtO fiV INVER SE I TRANSPOSE I T 1 ) *A 

C lOP =-2 - A IS REPLACED EY A»|NVERSE ( TRAMSPOSt I T 11 

C ICP = 3 - A IS REPLALED fiY lilVE-^SE I TRANSPOSE ( 1 1 -T 1 

C ICP =-3 - A IS REPLACED PV A*lNVES SE ( TRANSPOSE ) Tl •? JOM 

C IE' - RESULTING ERROF PAKAMETER 

C lEB =-1 MCANS M ANiJ N ARE NOT BJTH POSITIVE 

C AND/OS ICP IS ILLEGAL 

C lEF = U MEe.NS aPFRATlON WAS SUCCESSFUL 

C lER = 1 MtA\i TRIANGULAR 1ATRIX T IS SINOlJLAfi 
C 

C -EMAFKS 

C SUSROUTINt OMICS MAY BE USfcD FO CALCULATE T t-E SCLUTION lF 

C A SYSTEM Of EOUATIONS WITH SYMMETPIC POSITIVE DEFINITE 

C COeFFlCIENT MAIKIX. TMt FIRST STEP lOwAROS THE SOLUTICN 

C IS TRIAKGULAH f AC TO ^ I Z A T I CN flV HEANS ^■^ DMfSL, THE StC3ND 

C STEP IS APPLILATION OF DMTDS. 

r SUftf*OUIINES DMfSO AND ONTUS HAY Ht USCO IN ORDcR TO 

C CACULATE The PRODUCT TRANSPOSE I A) « I ^'</ERSE I P t » A .JITH GIVtN 

C SYKMETRIC POSITIVE DEFINITE h AND GIVfM fl IN TrittF STEPS 

r 11 li^IANGULAK FACTDRUATION OF b ( 6 = TKANSPOSt ( T I »I ) 

C ii MULTIPLICATION OF A CN THE LfcET BY I \ VER SE ( Tft ANS P"S£ I T 1 1 

C A IS REPLACED EiY C= INVERSE ( TCftNSPOfE ) T 11 "A 

r J I CALCULAT ILiM OF ThE RESULT FU^M [NC- Tt- AN i POS E ( C I «C 
t 

C SUH-^UUTINES ANO FUNCTION SUfiP*- CGR AMS '^EOUI'^EU 

C NGNE 
C 

C fIt'HCO 

C CALCJLATIUNOFX^I NVtRSfc I T ) "A IS DONE USI NG BACKWARD 

C SUPSTITuriON Tf. CbTAIN X f-Hat* T*X = A. 

C CALCULATIGN OF Y = I NVEJ- SE (I S ANSPTSE ( 1 M * A IS gONE USINi 

C FCKwARD SutJbinuriON TO OBTAIN Y FROM TRANSPOSE I T I 'Y = A. 

C CALCULAIION CF Z - I NVtRSc ( T f- ANSPOSt ( 1 1 * T t*A IS 3JNE 

C SOLVING fl<;ST T- anSPOSEI Tl«v ^ A ftND ThlN T»Z ^ f. It. 

: USING THt AdUVE I.«0 STEPS IN REVERSE ORUER 



lEH-I 




f ElllffJ 




INfi 


lAl 


MN-^"N 




^M = M''C 


♦ 11 


MMl=M-l 




IEF=0 




ICS-.'' 





1F< IA,<M [-!--)- 


li 1 .-1,2 


7 IFU"'>^-'1-. 1 


= . ; 


!N:iIfiL!?' 


5^'Li(TnN OF 


f MCND^l 




LLO^I'^- 




KST^=1 




MOEL=I 





iTOSl'tT. 


IT.;-;;.)!;' 


IT"S' i"' ; 


inslov) 


it:su-'5 ' 


IIDSIO^'J 


ITDSIOT-: 


ITOSIOHJ 


iTTsm- 



OMTO 


^0 


OMTD 


100 


DMTD 


I 10 


OMTO 


120 


DMTD 


no 


DMTD 


140 


OMTO 


ISO 


OMTD 


l-Si) 


DMTO 


170 


DMTD 


180 


OMTO 


190 


DMTD 


200 


DMTD 


?10 


DMTD 


220 


DMTC 


2i0 


DMTO 


240 


DMTD 


250 


DMTD 


?60 


OMTD 


2 70 


DMTD 


260 


OMTD 


290 


DMTD 


100 


OMTO 


lio 


AOMTD 


■i?c 


lOMTD 


JIO 


DMTD 


^'.o 


OMTO 


350 


DMTD 


V.O 


OMTD 


370 


U«TO 


?ao 


DMTp 


^<30 


OMTO 


400 


D-'^TO 


410 


DMTD 


4?0 


nwro 


430 


JMTO 


440 


tJMTO 


<.50 


OMTO 


460 


0«fD 


470 


OMTO 


uao 


OMTO 


490 


OMTO 


500 


DMTD 


ilQ 


OMTD 


520 


OMTO 


Sio 


DMTC 


!)40 


DMTC 


550 


DMTlJ 


SbO 


D«TO 


-iTO 


OMTD 


5B0 


DMTC 


5 '50 


DMTD 


600 


OMTD 


fclO 


Ohio 


620 


DMTD 


^30 


OMTD 


64 


UNFO 650 



Mathematics — Linear Equations 143 



UTlNe DMTOSIA.M.N.T, lOP, ISRI 



TtSI DF DIMENSION 

1 IF(N)2,^,'. 

FStOfi PETUCN IN CASE Of ILLEGAL DIMENSIONS 

2 !eB=-l 



INITIALIZE DIVISICN ?R3CeSS 



KS = M 

1MEN9=M 

TEST SPECIF lED OPERA 
IF 1 lOP IS, 2, 6 

'i MM=:M«(Ntl)/; 
Kf. 1=N-1 
[RS=K 
ICSH 

1 MfcNO=MN-M* I 

t ICPE-MCO( inP+J,31 

in !46S( 10P)-3)7, 1 ,2 
7 IF(lDPE-!)d,Ili,8 

INITIALIZE SOLUTION 

LLD= IRS 



TRANSPOSE (T)» 



DMID 


670 


DHTD 


680 


OMIU 


690 


OHIO 


700 


DMTD 


710 


OKTC 


7^o 


DMTO 


730 


OHIO 


7<-0 


OMIO 


750 


DMTD 


760 


DMTD 


770 


DMTD 


7eo 


CTO 


790 


DMTO 


BOO 


OMIO 


ftlO 


OMTC 


620 


OflTD 


830 


OMTD 


a^o 


OMTD 


8=0 


DMTD 


660 


owro 


870 


OMTO 


«ao 


DMTO 


B90 


DMTO 


900 


DMTD 


910 


DMTO 


920 


D«ro 


930 


DMTD 


9'tO 


CMTC 


150 


DMTD 


960 


UfTO 


970 


OMTD 


<ieo 


DMTO 


990 


OMTDIOOO 


OMTDIOIQ 


OMTDIOOO 


O^TD103fl 


0«roi040 


DMID1050 


liMT01060 


DMT01070 


OMTD1080 


OMT01090 


OMTDIIOO 



TEST FUa NONZtf-b DMCO«JAL TERM IN T 
9 IFl riMSIA) ( 10,3,10 
10 C^ 11 l=MeND,MN, ICS 
U «( n=A( [ J/T(MSTA1 

IS M tOUAL 1 
IF(MMl)2,i5.1Z 
12 DO l-i J = l ,MM1 
MSTA=MSIA*MOfcL 
MDfcL=MOEL*MX 
DO 1*. I=MENQ,MN, ICS 
DSUM=0.00 
L=MSTA 
LDX^LD 

CO 13 K-l.J 
OSU'«-DSUM-T(L >«A(LL> 

LL=IL»LID 
L-l«-LDR 
t 3 10X=L0X*LX 

1* e4LL 1<I0SUH*A(LL> t/T(L I 

TEST €N0 OF OPeRAIION 
15 1F( lE^ 116. 17, 16 
U IER-=0 
RETURN 

17 IFl I0PEI18.18.16 

INITIALIZE SOtUTION OF r*X = A 

18 IER>1 
M€N0-IHENO 

LLD—IRS 

MSTA«M« 

H0£t"-1 

MX=0 

LD«-«Ml 

LX-l 

GOTO 9 

END 



OMIOUIO 

DMToll^o 

0MT0U30 
OMTLi l*iO 
0MT01150 
DMTDU60 
DMIDE170 
DMTDUeO 
0MTC.1L90 
DMTD1200 
DMTDIZIO 
0MTD1220 
OMTCUSO 
DMI012*.0 
DMT01250 
0«T01260 
DHTDiJTO 
0MT01280 
OMT01290 
0MTD1300 
DNT01310 
OMT01320 
DHT0H30 
OHTDU^O 
DWTD1350 
0MTD1360 
0HT01370 
OMTO1360 
ONTO 1390 
ONTDKOO 
DMTD 1*10 
0«TDi*20 
0Mr01«30 
0MTD1*«0 
0MTDU5O 
0MT01*60 
OMTOIATG 

oMToi*eo 

0HT01490 
0KT01500 
DHTD1510 
0MTD1520 
DMT01530 
0«TD1**0 
0MTD1550 
0MT01S60 



144 Mathematics — Linear Equations 



Subroutines MLSS and DMLSS 

These subroutines will compute the least-squares 
solution of minimal length of a system of linear 
equations 



AX= R 



(1) 



with symmetric positive semidefinite coefficient 
matrix A. That is, they will determine that vector 
X of smallest Euclidean length ||x|| for which 
II AX - R||= minimum. 

The matrix A is not used directly as input. 
Instead, MLSS expects the matrices U, T, and Tu 
and the permutation P that would be obtained if sub- 
routine MFSS were used with A as input matrix (for 
details see MFSS under "Final result of elimination"). 

The given vector R is replaced by the solution 
vector X. 

1. Mathematical background 

Instead of (1), solve the system of equations: 

(PApT)PX =PR (2) 

Any solution PX of (2) determines the solution 

P~l (PX) of (1) ; therefore it suffices to consider (2). 

Using the decomposition: 



T 
PAP = 



I o 




'As 


o' 


"I u' 


_UT I_ 




p 


o_ 


p I. 



(3) 



where Ag = (T)Tt (see MFSS), it is easy to see that 
(2) is equivalent to the system: 



As(Xi + UX2) =Ri 
0X2 = R2 - UTRj^ 



(4) 



where PX = 



X2 



and PR = 



Rl 
R2 



If rank (A) = n. 



formula (3) reduces to PAPT = Ag, and (4) is 



AgX =R 



(4') 



In solving (2) , or equivalently (4) , three cases must 
be distinguished: 

a. Rank(A) = n. Then the unique solution PX is 
given by PX -Ag"! R, which is computed easily 
using the triangular decomposition Ag =(T)Tt, 

b. Rank(A) = r < n and R2 = uTr^ (a compatible 
system). Then the solution of minimal length is: 



Xi = (I + UUT)-lT-l(T-l) Trj 

X2 = U^Xi 

Using the identity (I + UUT)-1 = i _ u(I + uTu)-luT 
and the triangular factorization of (I + uTu) = 
^u^U' ^1 i«a-y be computed by the following sequence 
of operations: 

Xi = T-1(tT)-1rj 

X2 = Tu^Tu-l)TuTxj 

Xi = Xi - UX2 

c. Rank(A) = r< n and R2 /^ U^Rj (an incompatible 
system). Then the least-squares solution of minimal 
length is: 

Xi = (I + UUT)-1t-1(tT)-1(I + UuT)-l(Rj + UR2) 
X2 = UTxi 

Xi may be computed using the following sequence of 
operations: 

Xi = Rl + UR2 

X2 = -Tu-l(Tu-l)TuTxi 

Xi = T-1(tT)-1(Xi + UX2) 

X2 = -Tu-l(Tu-l)TuTxi 

Xi = Xi + UX2 

2. Programming considerations 

Cases a, b and c above are easily combined into one 
Sequence of op)erations: 

(1) X = PR (interchange given right-hand side) 

(2) Xi = Xi + U X2 

(3) X2 = -UT Xi 

(4) X2 = (Tu)-l ((Tu)T)-l X2 

(5) Xj = Xi + U X2 

(6) Xj = T-1(tT)-1x^ 

(7) X2 = -uT Xi 

(8) X2 = (Tu)-l ((Tu)T)-l X2 

(9) Xj = X2 + U X2 

(10) X2 = ^'^> Xl 

(11) X" = p-1 X (reinterchange calculated solution) 

In case a, the only steps performed are (1), (6), (11), 

In case b, only steps (1) and (6) up to (11) are 

performed. 

In case c, all steps are performed. 



Mathematics— Linear Equations 145 



SuPt^t UT I NF rL-^s 



PURPCSF 



CSS [S THt ^tT.Qtjr, 5TEP IN ihf PPCCtil) 
CflLCULATiP,)'-, THt LF\<,T SOUiPt*: SncuTION OF hTN;"*! 
Of ft SYSIt*^ Cf^ SIWULTANtOUS LINcflH EgUA|]nN<, ,: 1 1 ( 
PCSITlVe S-HI-OfF INIT*^ COtFt IC ItNI 'MATai Y. 



,U, ft CNK, T-^f (■ , iiyr 



. Itc I 



OfcbCBTPTIP\ r^ PARA»<lTtHS 

ft - COEFFICIFNT MilMX ]^ f/CTCfiEO FOR*-' LT: 

3r SL'e = CUTiWE K^ SS f h '. •' IMTI*lLY GlVi 
ecu Fi- ir. i-^M M^iFi). A sro'.eti :n ^•(^.!l 
fi FfMAir.S UNCHi*T.EC 
!■* - DIMENSION Of COeFFICIENI t-iTWlX 

I5ANK - FAMK OF CrEFFiriENT CiltjK. C flLC L'L « T 1 ' 
SUfPCUTlN' VFSS 
vrCTCO Of C!MrN5(C\ K CLMfllMNG iHf 

SUBSCRIPTS riF PIvriT R'>wS AN1 riOHIKhS. 

PRCOUCT «E?ctffMftTt:;'j IN T?^NS3(^^IT !!■ 
pr-'MUiaTICM W^irh ^aS ftPPLItJ TO =Ck.; 
(IF a IN THE F/f TC» I?AT tUN PFrCESs 
TP.tC IS A fifSULTA'^T l^Pfl-' TF SJ3^L"Lr|l>i 
INPUT VA^IfiBLC WHITH 5Hl'jl.l, CrMAI\ f t- ' 
If THE SVSIfM HF Sli'^Ll *NfnUS ?OUflTir:; 
in Be CCMPATit^LE ANS ; \nN7£R0 VALUE '- 

TN RETURN RHS CCNTArJ'j Ti"" "IMHAl. 1 f ,\ ' 
^^fSULTAN- F^c.^Cy f"*-; A*if. fr - 

ICR = IFANS NO !l«R(:w'. 

IE" =-I >h*NE N AND/fJ' [RANK IS NCJT t>'.,I!lVE 

i*;a^« is 0-jcati:?) THa\ n 

!E0 = 1 hItANS THf FACTO- (;JT lOr. tiJ^■'■]J = [; IN 
ZL"R:i DIVIStJC:' '■NLVG'- IRAT C';r^T'51\S 



ICZ-C 



INC 





MISS 


10 




MLSF 


^0 




MLSS 


«0 




»'LSS 


CO 




"lis 


•.o 


Rt FCR 


NI-SS 


73 


. LENGTH 


WLSS 


PT 


^ SY«ifcT«lC 


-.LSS 


•50 




MLSS 


lOf^ 




KLSS 


t 10 




ML?!^ 


l?'l 




MLSS 


1*0 




MLS^ 


uo 




MISS 


l-sO 


NEHATEn 


f'tSS 


1(^0 


.r,^,'*'=THic 


MLS5 


1 70 


LCCATIPNS 


MLSS 


1^0 




"lSS 


lUT 




KLSS 


?on 


■ M-^iNS HF 


Ml-: 5 


?10 




MLSS 


??0 




"tS^ 


? m 


. THE 


"LSS 


^<.o 


IF ■'HP 


^'L^,S 


?sr, 


1 COLUMNS 


KLSS 


?f-0 




KLSS 


?T0 


•^SS 


"LSS 


/-Rr, 


ALue ze=c 


KtSS 


^an 


■i KNOWN 


>iLSf^ 


?ao 


= «-'3f 


yi^', 


iin 


r Mfl'Ju SIUEI-LSS 


'?0 


SCi.JTltlN 


flS<: 


.'10 



flN(.VP-( "LS 



VALUES ojrsiJt; 



-e '=tAsni 



OfMAfiKS 












THn "IMMAL lE^'GTH SniuFION IS 


Ph 


'ni-ucFo r 


LCX4T tOtJ^ 


nrcjpi FD Hv 


TMt RI'iH 


r -IAN) 


srcc 


SUSSDUTIWe -tLSS 'jOfcS 


TAK^ CAJ': 


"F 


Tr., 


E PFfl' 


WHICH k-AS 


APPLIEO TO 


^nwS AN-) 


■:.n 


...IV.N 


i n? . 


OPFf^ATinM 


j^ pyPAecf-, 


i\. CZ-St^ 


RF 


.1 \: 


IN pr> 


UF I HANK 












SUP.RnnTIN£5 1 


ifT ruMCTiCN 


-,,i=-c^;-,,-.; 


iM^ 


p.:, 


:i,!i''.i . 


N'lf^E 












METHr'" 












Lfi r, u. 


lU 8t THE C- 


^CPPNt^Ti 


rf 


TH^ 


■ fAn 


At-r: 1 HT !(■ 


'|- P IGHT hAMI 


: Sine :: 


?b 


»T[ 1 


"KjN^f 


PAtt XI Gf 


CJKtKilDN ■ 


U6N< Ajij 


■1 


^rri 


irx p.- 


U-\-.ViK. X 


HcN TH[ rui.l 


.■]:■: :u'~, "! '< 


; I/. 


Tin:-, 


ill ARt 



i 


H-^l 




«L'^'^ 


JP 


in 


N 


MLSS 

Mi.sr 

MLS*; 


f.e 






MLS^. 
"1LSS 



Sf cjjLNce 

( I 1 iNTrRrMAV'GE t^ IGHT 
12: X! = XI ♦ U - X^ 
^-To.'.HSfnSf (iJl 
=■ IWERSEf TUl '■ 
= XI * IJ * X? 
= lNV£ftS-(T) e 
s-^i^aNSPCSFIJl 
= INV£i*Sc( TU> '• 
■ U > X? 



INVf '^S£( TiJ^NSPCS? ( tU) 



XI 



1^1 
( 5) 



(t } 



(lo^)XZ = T^ANSPT-.r(iil * XI 

(II) "JflNT-RCHAN"".: CALCULa^'Fn '-.CtUtlfJN 

IF THF SrSTfJ' UF II KilL I ANiCUS iI\[Afl (^OUA I I iZrsiS 

T(J -iF Cr."13,UISL' THF\ SIEPS (? 

r,A'-<:ELl.Er>. 

IF ThL C.OC-FriCIfN' Hirm), ^A*. "AV 

i'f'^rn:MFo flFB (u, (t.i ANo nil. 



(3). C) At; 



tLSS 


'1 = 


!L'^* 


6'iO 


'LSS 


rn,) 


ILSS 


710 


ILSS 


/^O 



ru 1? J-LIO-AN* 

JJ=JJ+l 
W" SUM=SlJ*'*A(JJl«Rf'S[Jl 

GCTOt n, 13,141 , TSw 
13 SUM--Siiyi 

i" sHsni-S'ji 

1"^ ISTA-ISIA*! 

i",OTO{ I'.,2'-?,i01 . ISW 

IN! T| ai_ 1 ?p s'FP I AI C.K 
lf> [STS = IX^ 
lEND^N 

JJ^lTPtlSTA 



T'iNSPCSi; CF T'llANGULAf; MA T -1 1 X 



uivisnw OF 

17 SUM=').00 

on 20 I = ISTA,I'_^C 

IF(fllJJI 1 If, 31i I 3 
Xn FHS<il=(F;-,S(M-SU^)/iiJJ) 

If n-i-\'jii<?,2i,2i 

19 JJ=JJ»|STA 

Sy*i=o.no 

00 20 j=i'^Ta,i 

suM=bU(-.*rt( jj)*FHs; J) 

?n jj=jj*t 

CIV ISI':^ OF M BY TRIANCUL A« " ATKI I 

11 = 1 EM' 

DC 2*. I = ISTA,IE>;D 

RHS( IM = <rtHS(l II-;UM)/A(JJ) 

IFII I-ISTAI Z5,i'>,Z2 

22 KK=JJ-l 
SUM=O.I'0 

on 23 J=nt lEND 
S(jM=sur»a(KK)*PHS( Ji 

23 KK=KK+J 

jj=jj-i r 

?'i !I = !1-1 

?^ IF( I0eFI26,;0,26 

26 CCTO(27, 11,61, IS-m 

PERFOfM STPP (5) 

27 ISW=2 
GOTO 8 

pe-<Fr;-<»< s tep * b i 
:'£ ISTA^i 

lEND^IRANK 

jj = : 

I5k=2 

GOTO 17 

PEflFPr.iH STEP (91 
?9 ISW=3 
GOTO 16 

R^INT EOCHANG: CALCULATEO SnLUT10^' 

30 II^N 
JJ = -1 

Gno <, 

fPfiCfi PETUf-N IN CASE OF U^O CIVISOO 

31 160=1 
?? RETURN 

ERROF OFTURN IN CASC 0*= ILLEGAl OIMENSION 

RE^UR^ 

END 



Ml SSI ioo 

MLSSl ilO 

t-f-ssi :-.^o 
^Lssmo 

"LfSI ><.o 
"LSSI ISO 

"l-S?! '~0 



MLS 



1 IfvO 



"IS 51 JSO 
Ml SSI ^0-" 

MLSSUIO 
MLSSI*.2C 
MLSS 1 17,1 
MLSSI'.AA 

KISS' ^'^O 
"LSSl'.t.O 

'■ILSSi'.rtC 

*':LSs;4')'> 

NLSSl'iOC 
KLS-^I-ilO 
M( SSI 5?C 
ML5SISJ0 
MLS'^li.'-O 
fLSStSSC 
MLSSIS60 
MLSSl bin 
KLSS1590 
MLSS 15-90 
MLSS1600 
HLSS16I0 
»'LSSlb?G 
"LS5.I 6?C 
►'LSf.l6'.0 
MLSSI6^0 
fLSSUftO 
ML5S1&T0 
MLSSI'iSO 
MLSSlfcgo 
MLSS 1 TOO 
MLSS 1 710 
MLSSl 720 
MLSS1730 
MLSS1T40 
MLSS I 750 
MLSSi 760 
MLSS17TJ 
MLSSITSO 
ML SSI 7'50 

MLSsieoo 
MLSsieio 

t-LS^iezo 
MLSS' HJO 

MLSSie'.o 

MLSSI 850 
MLSS1360 
MLSSMTO 
Mtssi eeo 
^;LSS1890 
•*LSS1900 
^■LSSI'JIO 
MLSS1920 
MLSSl'iJO 
MLSSll'.O 
MLSSI950 
MLSS19frO 
kLSSl970 
MtSSi9eO 
MLS5l9go 



CCL""!N'F Mlt^Stfl 



■N, I- A^^, T:Ar . I\C . 



DIMtNSICM A( 1 J,T--4CU). M5M J 
DO'JF^LE PHtCISICM SUM 

TEST '-.f SPfCIFIfrO ■JI»'^^'.i^^S 
rOEF=N-IP%r;K 
IF(MI33. a, 1 
If {IkAMK }ii,^>,Z 
TF( lOLFJ ?3, *,? 

rALrULtlt 4UXM lABY VALUi'S 

ITt= i^A^x-rl 'RAN<tl i/2 

IX2=IHA>JK*I 
NP1=N*1 

iEa = o 



UNO sint 



INTERCMANf-iF R IGHT 
JJ = l 
II = l 

'• DO 6 I - 1 , N 

j=rRAci 1 1 1 
IFU131. 31,5 

5 H0LD=RHS (lit 

PHSUIUPH^I J) 

RHS) ji = h[:l[) 

ft Il=ITtJJ 

IF( J J)3?,7, 7 

PERFOR.-^ STEP ' If NECESS4R 
7 ISW=1 

IF ( IMC'IJEF JP, ?a, S 

CAtCULATf XI = Kl ♦ u * (^ 

e isrA=iTF 

00 10 1=1,1 ^A\K 

ISTd^l'iTA*! 
JJ=I5IA 
SUM=O.DO 
DO 9 J=IX2,N 
SUM^SU-UAt JJl«hHS( Jl 
9 JJ=JJ*J 
10 BHS<n=fHS(I Ur.U'* 
GOTO( 1 1, 2a, II) , ISW 



CALCULAre X? 
11 ISTA=|TE 

DO l-i 1= 1X2, N 

JJ=1STA 

SUM=O.OQ 



TPANSPnSEUn • XI 



•-LSS 


7 = 


KLSS 


790 


■*LSS 


AOO 


MLSS 


Bin 


MLSS 


!i?C 


MLSS 


S30 



MLiS P'JO 



MLSS i'=■^^ 

M| ss S-^O 

■II SS 970 

MLSS 9ao 

MISS 99n 

MLSFlClO 

Mi.ssnio 

ML -^ "^ 1030 

MLSS1040 
MLSSinSO 
"LS; 1060 

PL -^ Sir' 70 

MLSSl.iaO 
MLSSIO'iO 
MLSSI irjo 
^'LSS1 I !0 
MLSSI 120 
.■1LSiJ JIO 
VLSSl 1^0 

MLSsmo 

MLSSllSO 
fLSSIi70 

MLSSI leo 

MLSS! 190 
MLSSI 200 
MLSS1210 
ML5.S12?0 
»'LSS!2iO 
MLSSI2'.U 
Ml SSI 250 
MLS?12^0 
MLSS1270 
MLSS12fiO 
MLSSI290 



SUBrtCUTINE DMLSS 



SUe-ROUTfNE OHLSS IS THE SECCNC STEP IN THE PBCCEOJRE FOF 
CALCULATING THE LEAST SiJUARES SOLUTION OF MINIMAL LENGTH 



OMLS 
.DHLS 
OMLS 
DHLS 
OMLS 
OMLS 
OMLS 
OMLS 



89 



OF A SYSTEM OF S I HUL TANfeOlJS LINEAR EOUATIONS WITH SYMMFTRIC OMLS 90 
PnSITIVE StMI-OEFlNlTE COEFFICItNT M4T31X. 



USAG= 

CALL DMLSS(i,N,MANK, taAC, I.VC ,mS , I Er* | 



DESCRIPTION CF PAHA^IETErtS 

A - rOEFFICIErT MATBIX IN .'^ACTOR^EO FflPM AS GE-^ERATEO 

BY SUBROUTINE MFSS FROM INITIALLY GIVEN SYMMETRIC 
COEFFICIEMT MATRIX A STORED IN N*(N^l)/2 LOCATJPNS 
A REMAINS UNCHANGED 
A "UST e£ OF OOUPLE PPFGISIOM 

N - DIMENSION OF C3EfFlCIC-ia MATRIX 

IKANif - RANK OF COEFFICIENT MATRIX, CALCULATED 3Y MEANS OF 
SUftRPUTINE DMFSS 

IRAC - VECTOR OF DIMENSION N CCNTAIMNG THE 

SUBSCRIPTS OF PIVOT ROKS AND COLUMNS. I.E. THt 
PROOUCT REPRESENIAl ICN IN TRANSPOSITIONS OF THE 
PEftKUTATlCN WHICH WAS At'PlIfO TO ROWS AND COLUMNS 
L.F A IN THE FACTOR I ; AT r UN PROCESS 
TC_1C IS fl EESULTANT CORAY HF SUeCDUTIKE MFSS 
TIAC MUST «F OF OSUELti PRECISION 

INC - INPUT VARIABLE WHICH SHI-ULO COf'Ulr, The VALUE ZERO 

IF THE SYSTEM OF SI HUL I A^EOUS EOUATIPNS IS KNOWN 
TO SE CQMPATIPLF AVO A NOhZEPLl V4LUF CiThEPWISE 

UHS - VECTOR or- iJIMENilON M CCNIAINING THE 

ON RETURN RhS C3NTAINS THF MINIMAL Lf 
RHS MUST BE ?F DPUf^lE PRECISION r>MLS *60 

lER - RfSULTANT fRHQt uAPAMETtP DML "^ 3 7C 

lER =-\ MEANS N ANO/OR IRANK IS NOT PPSITIVF AND/03 DMLS '90 
IHANK IS GREATER THAN N oy,i^ j;oo 

IF« = 1 MLANS '"HE FACTORIZATION CONTAINED I N A MB 
ZECD OrVISO«iS AND/OP TRAC CCNTAf^S 
VALUES CUTSIOE THE FEASIStf RANGF 1 UP '0 



OMLS 100 
OMLS UO 
OMLS 120 
DHLS 130 
O-^LS 140 
OMLS 150 
OMLS 160 
DHLS 170 
O-^LS 190 
OMLS 100 
DMLS 20c 
OMLS 210 
DMLS 220 
DMLS 230 
OMLS 240 
OMLS 250 
DMLS ?60 
DHLS 270 

OMLS 280 

DMLS 290 

DHLS ?00 

DMLS 310 

DMLS 320 

DHLS 310 



REMARJ^S 

THF MINIMAL LENGTH -SOLUTION IS "HOOuCeo IN T^f sT 
tCCATIONS nCCUPIfO &V THE SIGHT hanO SIDE. 
SfJR'nuTINe DMLSS COfS TAKE CA^!i QF THE PERv^TaT)- 

WHICH WAS APPLieo Tp R-ws ano cqlimn:, of a. 

CPf^ATICN IS BYPASSED IN CASC OF 1 NPN PQSI T 1 VF v 
CF iptNK 

SUP^ruTINES AND FU^CTI^N Si,dPRc;3fll!iS REJUIREO 



riML<- 

D ML *■ ".20 
i 'DMLS 430 
DMLS 440 
OMLS 4 50 
OMLS 460 
QML S <. 70 
DHLS 4P,0 
DHLS 490 
DMLS 500 
DMLS 510 
n*<LS 520 
DMLS 530 
OMLS 5£,') 



146 Mathematics — Linear Equations 



Mtrnro 

ifT I, U. TU et THE CGMPONEMTS OF I HC F*CTrSIZ 
4NC LEI THfc PICHT HANfl SIOE 8E Pi^TITlPNcO INT 
PftttI XI UF DIMENSION IRANK ANO A iECONO PA<»T X 

14- t SANK. TH'K The FDLLUMING noe^ATIONS » 

StOIfENCf 

(U INICBCHANCE "» IGMT HAND ?rpF 



1 ?) 



Kl 



(31 X7 



Kl 



TceNSPOSf (u 

(*) y.2 = INVtftSECtUl • INVEkSt I rflANSPDSE IIUJ I • 

151 Kl = XL tU* K2 

<6I XI = (NVtRSEU) • INVt-:R$t<rfi*NSPOSE(TlI '' X 

(7) X? =-TqANSPQSEIUI • XL 

(81 X? = rNVERSflTUJ • INVtI-SEfTCANSPQSC (TU) I «■ 

(<51 Kl = XI ♦ U • X2 

( 101 X? = TKANSPDSE lUl • XI 

llll RElNTtUHAMCE CALCULATED SOLUTION 

IF THT SYSTEM Of SIMJLTftNFOUS LINEAR EOUATIdNS 

If' 8€ CCMPATIPLF IMtN STEPS Hi, (31, («) ANO 

CANCEILED. 

IF TH"^ COfFF[CICNI MATRIX HAS « ANK H, TMEN TH£ 

PEBPQSMCO ABE (II. t*l AND lilt. 



SU«RQUTINE DfLS«( A.Nt l<5aNK,T0AC. INt .^H«,,IEi;| 



OMLS 550 

ONLS 560 

ITION UF A, OHL^ 570 

) A FIBST DHLS 510 

; Ot^ DIMENSIONOHLS 590 

L lEP IN OMLS hOO 

* PMLS 610 

DMLS 620 

OJ^LS 6 JO 

DHLS S'.O 

OMLS 610 

OMLS 660 

OMLS 671) 

OMLS 6B0 

n-^LS 690 

OMLS TOO 

OMLS 710 

DHLS 7?0 

IS SPECIFIEO CMLS 710 



ARE 



PNLY STEPS 



OIHtN^ICSeO uUMMY V*RI*Bl. = S 
OIMENSICN A( 1 I ,T«aCt I I.RH^l 1) 
OOUSLE P«fClSION SUM, .".RHS^TOAf .HOI D 

I6ST '^f SPEClf^lfeO Dir'ENSICn'S 

IDEF-N-I3ANK 

IF{N)33,M,I 
I (f ( IRA><K) ii, 33,? 
3 IF(IDEFrn,>,3 

vALues 





CALCULATE AUXILIA= 


3 


ITC. !i^ANK*( !t(ANK*l 1/2 




1X.'=IRANK,«1 




NPt=N*l 




1EW = 




INTEtiCiiANOE '-ilGHr ! 




JJ'l 




ir = i 


<. 


Pn 6 i=i.N 




J = TRA<;{ 1 D 




1 F ( J ) 3 1 , 3 1 . -^ 


•y 


HCiLD^fiHS) ( I 1 




fiH-:!!! 1 = ((H'^! J) 




EHS( Jl=Hnin 


1^ 


II-! !«JJ 




IKJJl?;,?.-' 




PE>;Fi1c.^ SFEf ? IF * 


7 


ISh=l 




1*- ( INC-I^^F J e.pfi.fl 




CALCULATE t\ -- Xi i 


A 


I5TA=ITE 




DO 10 1=1, [RANK 




ISTA-ISTA*! 




JJ=ISTA 




^uM=o.on 




00 9 J'^IX.'.M 




SUM = SUMtA(JJt<-fiMi( Jl 


9 


JJ=JJ*J 





HHSI I J=»HS( 1 M'^UM 




GOTOUI,?'i.ll), ISH 



«ANSPnSE(Ul • Kl 



; CALCULATE 

11 ISTA=r'F 
no 15 I=M^.N 
JJ=($T* 

suM^o.no 

XI 12 J=l, IhANK 
JJ"JJ*l 

12 SUM=SU«*A( JJI*RHS( JI 
(^0T0(13,1 Jil-VLISW 

U SUM:>-SUM 
1* RHSCn*SU'^ 
15 ISTA»IST4*I 

GOTOI 16,?9,30) , ISW 

INiriALI7F STEP (41 0^ STEP |8I 
l(. !STB = IX2 

!END--:N 
JJ=ITF*ISTA 

DIVISION GF XI RY T-JANSPHSE OF TKIANGULAF MATEIK 
17 SUM=0.00 

DO 20 I-(STA. IfcND 

IF(AUJt lie, 31, IB 
IB «HS( I I^IIHJ 1 I )-SUM|/A( JJ) 

IF( I-JcNTI 19,21.21 
19 JJ-^JJ^IbTA 

SUM=0.00 

ilO 20 J=ISTA, 1 

':UM»'SU'<*A(JJ l*PHS( J) 

JO JJ=JJ+I 

DIVISION OF XI PY Tl* lANCULAH MAHIX 
21 SUM=n.00 
II=IFNO 

DO ?A I=ISTA, lENO 
BHS( U 1^ (HHSn I I -SUM l/Al JJ I 

lF(Il-ISTfl)25.,■:^,22 

?2 KH=JJ-l 
SUH=O.UO 

u" zi j^u, :eno 

Sl/M = SUM*A(»(«; l*KHS(JJ 
23 KX=K««J 
JJ=JJ-I I 

2*. 11 = 1 r-i 

25 [F( lOFF ) 76, 10.25 

26 GOTOI? ', (1,B1, I SH 

PKWFORM STEP 15) 
2 7 !SW=2 
GOTC a 

PfTSFORM STEP (()] 
2 3 [SrA=J 

IF^^o=l«AN^c 



CMLS 7^.0 

PMLS 750 

f\,^ 760 

OMLS 7 70 

PXLS 730 

.D«L5 7S0 

P*«LS BOO 

CMC 5 FIO 

OMLS ^20 

THLS B-\Q 

OKLS fi40 

^^'LS eso 

nMl S fc60 

HMLS flTO 

PMLS bflO 

(iML« (190 

OMIS OOO 

OMLS •'lO 



OMtS 

DML<: 



020 

PML5 '^•*0 
OMLS 9 50 

D»iLS ''(SO 
DHLS 970 
n»«l.S ■530 
DMLS 9'?0 
0"L510nO 
OMLS 1010 

OML «lOiO 

rwLSio-io 

OML Sl'i-'O 
OMl '=1060 

niLSioro 

O'lLSlOBO 
OWL SI J90 

n^"LSiino 

o;'L';i 1 1(^ 

ilMLSI 1 JO 

OMLSino 

D>«Lil l-t-O 
CMIS1150 
DMI. r 1 1 60 
0'<LS1 (70 
DMLSI l<tO 
OML 51 190 
DHL 11 lOO 
1IHL5I2 10 
nMLSI?20 
0«LS12in 



o^u <;i 



'40 



DML5I2SO 
DML '". ! ?60 
O'll M.Vi^ 
CML-Jli^O 
OML<:ir<JO 
0ML51 l-^O 
OML Si:* 10 
OML'iUJO 
tlML'^l'iO 
DMLS134C 
DML SI 5 50 
DMIS1360 
OMLSl 370 
DML SI 3. SO 
OML SI 390 
CMLSl'.OO 
CMLSUIO 
OMLfl^iJO 
DMLSMIO 
PMLSU^O 
DMLSl<i'iO 
DMLf 1<.50 
OML SI*. 70 
OML SI ABO 
OMLS 1*90 

OMisiino 

OML 5 1*^10 
0<LS1520 
DMLS1530 
CMLSl 5^0 
DMLSISSO 
DHL SI 560 
OMLSl^TO 
0'*\. SlSRJ 
D-LSl^qO 
flMLSlSOJ 
[iMLSl6in 

pMtsi'jro 
r'^L<;i6 3i'> 

OMLS! wo 
DMLSI6'.0 
OMLSIf^O 

O'^LSIftHO 
DMI SliS'»0 
OML SI 700 
OMi <;i7l0 
OML'ilT.-O 
DHL SI 7 *T 
OML SI 7^0 
OML SI 7 so 
n><LS17nO 
DMI. <:i7 70 
OMl SI 730 

n^isi7')0 

UMLSl-iOi) 
OMLSltllO 
DMLSm^O 

DML S 1 fl m 



PERFORM STEP (RI 
29 ISW=3 
GOTO 16 

REINTERCHAMGF CALCULATED SOLUTION 
10 H-N 
JJ«-1 
GOTO 4 

FRHOR RETURN IN CASE OF ZffiU OIVISOP 

31 IEP=l 

32 RETURN 

ERROR RETURN IN CASE OF UtEoAL OIMENSION 

33 IE"— I 
RETURN 
END 



OML S 1 diO 
0MLSH50 
0MLSIB60 
DMLSiaTO 
DMLSIRRO 
DMC513V0 
0«L S 1 900 
D/iLSl910 
OMLS 1920 
0MLS1930 
0MLS19<.0 
DMLS1<J50 
0HLS1960 
D'*L51970 
nMLSI<»80 
DMtS19')0 
0MLS20')0 
DMLS2010 
DMLS2020 



Mathematics — Linear Equations 147 



Subroutines MCHB and DMCHB 

These subroutines will compute a triangular factori- 
zation 



-1,T 



A=(Tu) 't^ 



(1) 



of an m by m symmetric positive definite band 
matrix A. They may also be used to replace a given 
m by n matrix R by A-1r, Ty-lR, or (Ty-l)TR, 
depending on the value of an input parameter lOP, as 
shown in Table 3. 

1. Mathematical background 

The upper triangular matrix T^ is computed using 
the following recursive formulas: 

k-1 <2) 

tkj = (1/tkk) (akj - Z tiijtij) k = 1, . . . , m 

i= 1 j =k, k+l,...,m 

k 

(Any symbol E Xj is to be interpreted as zero if 

i = J 
J>k.) 

In the special case j = k, equation (2) may be 
written: 



'-kk 



* i = 1 



ik , k = 1, 2, . . . , m (3) 



When A is a symmetric band matrix with mud 
upper codiagonals, all elements a^j are equal to zero 
if j >k + mud. From formulas (2) and (3) it is easy 



to see that the same is true for ti 



•kj= 



t^j = if j > k + mud 



(4) 



Therefore formulas (2) and (3) reduce to: 

k-1 (5) 

tkj =(l/tkk) (ay - ^ ty^tij) k = 1, 2, . . . , m 
i = io j = k+1,. . . , min 

(m,k+mud) 



Iq =max (1, j-mud) 
tkk=Wa, 



..JT^'.^ 



kk ^ "-ik 

i = i 



E tjk k= 1, 2,...^ 
o 



(6) 



i = max(l, k-mud) 



Computing (Ty ) is equivalent to solving for Y 
in the system of equations: 



t'T Y =R 



(7) 



The solution of (7) is computed using the following 
recursive scheme: 

k-1 (8) 

ykj = (l/tj^) (r^j - X; tikyy) k = 1, 2, .... m 



j =1, 2 n 



Iq =max(l, k-mud) 



After each yy is computed, it may be stored in the 
location of r^i . 

Analogously, computing T^~'^ R is the same as 
solving for X in the system of equations: 



Ty X= R 



The solution of (9) is given using a similar 
recursive scheme: 



(9) 



(10) 



i = k+ 1 

j = l,2,...,n 



io =min(m,k+mud) 

A"1r is computed by first computing S = (T'r)~''R 
in the locations of R, and then computing " 

T-1 S, again in the locations of R, If R = I, this 
process replaces R with the inverse A~l of A. Note 
that in general A~l is no longer a band matrix. 

2. Programming considerations 

The input matrix A is assumed to be stored in 
compressed form, that is, main di^onal and mud 
upper codiagonals rowwise in successive storage 
locations. Therefore, the total storage require- 
ment for matrix A is m + mud (2m-mud-l)/2 
storage locations. The general m by n matrix R is 
assumed to be stored columnwise in nm successive 
storage locations. 

The operations performed by the subroutines 

depend on the actual value of the decision parameter 
lOP. 

Table 3 shows input and output depending on the 
value of lOP. 



148 Mathematics — Linear Equations 



Table 3. Dependence of Input and Output on lOP 





lOP 





I 


-1 


2 


-2 


, 3 


-3 


INPUT 


A in 

compressed 

form 


A 


A 


T 
u 


A 


T 
u 


A 


T 
u 


R column- 
wise 


irrele- 
vant 


R 


R 


R 


R 


R 


R 


OUTPUT 


A in 

compressed 
form 


T 


T 

u 


T 
u 


T 
u 


T 
u 


T 
u 


T 
u 


R column- 
wise 


un- 
changed 


a-'r 


a-'r 


t-'r 

u 


t-'r 


(tIVr 


,T-')^R 



If lOP is not equal to one of the values listed in 
Table 3, no action except error message lER = -1 
takes place. In this case A and R remain unchanged. 
The same is true if mud (the number of upper codi- 
agonals of A) is negative or if m (the number of rows 
of A) is less than 1+mud. 

There is one way in which the factorization 
described above may fail to give a solution, which is 
easily seen from equation (6) . If at any step the 
radicand of equation (6) is not positive, the procedure 
is bypassed, and the error message lER = -1 is 
given. The interpretation may be that matrix A is 
not positive-definite; however, failure is also possible 
due to roundoff errors. 

Backsubstitutions may fail too, as is easily seen 
from equations (8) and (10). If any main diagonal 
element of Ty is equal to zero (this is only possible 
if Tu is given by input), (he procedure is bypassed, 
and the error message EER = -1 is given. 

A further test on possible loss of significance in 
the factorization part is performed by the subroutines. 
If at the kth factorization step the radicand of equa- 
tion (6) is not greater than | EPS, ay^ | , with the 
relative tolerance EPS given by input, the subroutines 
give the message lER = k-1. 

For subroutine MCHB a relative tolerance between 
10"6 and 10""^ is suggested, and for subroutine 
DMCHB, between 10-14 and IQ-l^. The message 
lER =k-l, in case EPS = 10"^, means that there are 
about D or more significant digits lost in the compu- 
tation of the radicand in formula (6) at the kth 
factorization step. The interpretation may be that 
there is loss of significance in the factorized matrix 
from the kth row on, while the results of rows 1 up 
to k-1 may be better. Loss of significance in the 
lower part of the factorized matrix may affect the 
results of matrix divisions. 

For reference see H. Rutishauser, "Algorithmus 
1 - Lineares Gleichungs-system mit symmetrischer 
positiv-definiter Bandmatrix nach Cholesky- 
Computing, " Archives for Electronic Computing , 
vol. 1, iss. 1 (1966), pp. 77-78. 



PURPOiC 

Fr^ A G1V5N PfSITl Vt-OEf INi IE S 3Y M t^flTRIX A talHi SVHME TR I 
9AN0 STRUCTURE AND - IF NECESSARY - A CilVEN GENERAL » BV \ 
.'^IT'^IK "J, THE FOLLUKING C«LCUL'IiaKS (OEPENDENT J>) THE 
VALU£ OF THE DECISION PARAMtTEk lOPI AHE PEPFORHED 
111 MATRIX A IS FACTHBUiO (IF ITP JS NOT NESATIVEI, THAT 

MEANS RAND HATRIX TU WITH UPPEB COJI AGGNALS ONLY IS 

GE^CtATFD ON THE LDCATIGNS CF A SUCH THAT 

TRANSPOSti IU1«TU=A. 
i?l 1ATRIJI R IS 'MULTIPLIED ON THE LEFT 3Y INV£RSE(TUI 

AMO/O^ INVERIlEl TRANSPOSf (lUl 1 AND THE BESUtT IS STOSEO 

\\ THC LuCATJONS nf q. 
IH15 SUHFnUTINE ESffCIALLY CAN be USuD TO SCLVE H£ SYSTEM 
IF SIMULTANEOUS LINEAR LOUATICnS 4«X=ft mITh PCStTIve- 
CEFINITE C^EFUCIFNI ."MATRIX A ^F SY«"^£TRIC flANJ ST^UCIU^E. 



USAGF 

CALL MCM9 IB 



A,M,K,MU0,ICP.EPS.IE^1 



DESCRIPTION Of PAflA'lETER 
3 - INPUT (N CfS 



aiGHT 



] \'PU 



!'-* = 



5 IO'>=-5. -2,-1, 1,2,3 ! 

HA^J S10E f AIR 1 X , 

IN CASE ICP=C rPRclEVANT. 
UTPUT IK CA5ES ICP = 1,-I INVERSE I A ) •», 
IN CASE? lCP=2.-2 lNVEa5E(Tuj*c, 
INCASES ICP=3,-3 INVE^tSE I T-J ANSP JiS t lU 1 I *R 
IN CASE IC;P = tNC-^ANGcC. 

IK CASES I0P = 0.1.2,) M 6V M POS ITI Vc-D.-.-lM T 
C'JcFFKIfNT MATpJU OF SV^METRIC BAND ST = 11C- 
TUf= STHCEO IN nio^ESS'^O FIRM (SEC «£MahKS» 
l"* CiSES ICR = -U-2,-3 •< BV M 34N0 ■<ATRIx TU 
WITH U^-PER CCOtaGHMAlS '^NLV, SI"?.EO IN 

C':MPPEiScD FU^M (i'=E P.triARKSI. 
OUTPUT IN ALL CASES ■iflND <<ATO]X TU WIlH UP^"^?. 

CCOIAGONALS QJLV, STOKEO IN CCMP^SS^EO FOR*^ 
(THAT MEANS LNCHANGCR I*^ 1 0P = - i , -2 . - 3 I . 

INPUT VALUE SPtClFYINC THE NUMSER CF RCWS ^\0 

CCLUMNS CF A a~D THf MuMAga OF aO«S OF '. 

INPUT UALUE SPEC [ FY I *3 THE NUMB Eft OF CHL'JMNS DF R 

MPPtLEVANT IN CASE IOP=OI. 

IVPUT ViLUt Si»ECifYnG TnE VU'^SER OF JPPE^ 

CGDIAuCNALS OF A. 

G'.E OF Th(- VALUiS -3.-2,-1,0.1.2.3 r.IV£N AS INPUT 

A\i) USt'J AS Otf.ISIUN OAPAMfTEK. 

[\PUT VALUf VStU AS S-ELAFIVE TOLERANCE f21 TEST ON 

I -'S3 C.f SIGMIFICANT niGITS. 

^^SOLTINO C-^Pi DASC'fTES CLOEO AS FQLLCWS 
l-i>.= Z - NC EitSCR, 

NO RESULT "if cause Cf MP.'KC- INPUT 
''^'JA-ETckS M,MiJD,JCP (SEE RE^-fiaKSl, 
rjc seC-iUSE .:f A KO-wPCSI TIVE "AOITAS-O AT 
?G^E F4C"^*>lZeiK.N STEP, 

OP e^tCAUSE ::f a iTt.c diagonal tLe-iENT 

AT SOME LiVlSinN STEP. 

hA:;N!Ni> CUE TC PCSSiaLE LCSS OF ;i3M = I- 
Ci^!CE [NCiriTtO ar facto? I ?eTio\ step k,* 
WHERE -^iiilCANO WAS NO L0NGE1 GREATER 
IhAN erS«A(Kf I ,K*n . 



•jpocQ oici CF SV><!-€TFIf rtNf <\T-r:n /. CUNSISTIN" 3F ^A'N 
?I4',a\AL A? "UD U^PE= CCDUG"lNfil.S C^fcSP. 6AN0 MATfllX TU 

c'^iSisn^G :!F MAI': ;iAGc\AL AN3 MUD UPPER rrciAGrNALSt 

:^ :iSSU-l£C TL be SICREC l\ CC'^'i^tSSf J rORf^, I.E. IjhWl^E 
:•. TOTALLY N^fcDED M»Mu.-;»(2*--«un-n/2 SUCCESSIVE Srj^yr.e 
L[:C^TIC^S. Op* RETU-^N U^PcS f,A.ML, f-CtO- TU ( C\ THE LCCA1I3NS 
■:F J1 is iTJpfcD !f, 'i-f SAVE «rAV. 

SIGHT ham: sue HATRIX R IJ BSSU^'EO TC BE STC^FT CCLUMNkISE 
iv (J'M 'UCCSSSIVC '■'3f'G^ LCCfi' lOf.-?. ON CCTuci: -«SUL T M/TE|: 

I^VE^StU»*fi n« invcRs^i iui*k ?k invef'SECTranspcsei tui i*r 

!5 srcrsc.-) C'JLUMNWI^c TLJ (U Th; lUCAIIUNS CF f-. 

i>l.'-JT PA^fi-^ETfcRS v, »i;iO, [m iH-^ULD SATISFY THE fCLLZ^'.t-.G 

-=s^<icri&\5 Mjn \0T L^ss "han Zf-'^c, 

i**"U:) NOT GSr tXl.i. Than m, 
A.3S(I2P) \2T -.a^ATE-* THAN 3. 
V"- \CTnN EESfOES E-^RTB «tSS455 KR"-! TAKES "'.ACE IF T^eSE 
^e^TrilCTIGNS ARE NOT SATISH^J- 

TMC psoCEOUPF GIVES RESULTS I- THE C^ s jo K T Ii;NS C\ INOJT 
o*iAHCT£^S AR£ SATISFIEG, IF ^IJICAN.v^ AT ALL F AC fDP 1 Z AT I ON 
STEPS A^E POSITIVE AVD/^R IF A' L JH'JINAL fcLF^rVTS 3F 
jpsfl SAKJ fflCTCft T[J tRi \CKZ-AC-, 

T«CUT IN£3 AN J FUNCT I CJN SUBPRDG^A«S REQUIRED 



F^Cr:-; I.'ITICN IS OJNE JSI\r, C^:L75<'r-S SaUARF-RCOT MEIHCO. 
M'-ICf- Gf\eSAT?S THE UPPER 3A\ 3 HATRlx Tu SUCh That 
rcn-«(Si>-iS£( TU)«TL--*. TU IS i-'ETJ^vcj j- ^cSULT :^N ThF 
LLCATICNS -F A- FU-^THES. DEPtNJFNT CN TriE flC'UAL VAlJE CF 
irip, ^■IVISI'T'"' Of '■ ?Y T''a\S'>:3- ITUl '^^n/0^ TU IS PtRFC^ffcS 
A,\C THE ''t'-UtT IS ^FTUPNcJ "'. fwi La-..ATIONS CF «. 
fL^■^ aiTFi-aF'CE. SfE ^. ftUHSHlUieS, ALJr-^lTH^US 1 - LIVEARES 
-.L^IZ-i-JNJT-YSTcM »■ I T SYH-EIHISC^'^ PnSITl V-OEF.M'^E^ 

-s'o-irsiif NACH CHQi Er<y - , rc'*;>jriNG (secNives f^c, 

,-l'=lT!^D«:C Cn-1PUTi:,G> , VJL.l. ISS. I (1^661. pp. 77-78. 



mChf 


10 




20 
10 


MCHI 


PCHB 


'tO 


MCHft 


50 


MCHR 


SO 


CHCH6 


70 


MCHB 


AO 


fCHP 


=*0 


MCh" 


100 


MCHlj 


110 


MCHf 


120 


MCHP 


130 


MCHB 


I4Q 


•ICHP 


l')0 


MCHfi 


l.-^O 


MCHfl 


170 


MCHP 


MO 


MCHP 


iin 


HCHR 


zao 


f r.H«» 


210 


MCHS 


??n 


^CH3 


210 


'"CH3 


2',Q 


HCH" 


?so 


m:hb 


2^0 


WCHS 


^To 


«CH6 


?^o 


MCHft 


290 


Mrn.^ 


30 J 


,HCM« 


310 


y-lHS 


3'0 


EMCHrt 


333 


MCHfi 


i4^) 


,m.:h6 


ISO 


MCua 


3V) 


"CHB 


IfO 


T.H" 


3t<r> 


MCMR 


390 


MCHO 


400 


MrHH 


itO 


"CHo 


A?-" 


m:hb 


-fl3 


MCHH 


S'.D 


■*Ch3 


A-iCI 


MCHA 


A60 


MCH- 


•i70 


MCHfl 


<i^0 


KC^T 


-^90 


«Cne 


500 


"C^P 


',10 


fcTH" 


5^0 


.* CHI; 


s^n 


MCHB 


5A0 


"C-ia 


bhn 


«CH = 


•ibO 


f""HP 


S/0 


^ChP 


■^30 


-CHB 


■ii") 


■^:r,3 


6'10 


l-CHc 


frlO 


MCt-a 


*.■"? 


»CJ=* 


* 3) 


"CM? 


O-i'.l 


"r.H5 


.^ST 


mch" 


^hJ 


-.Chi 


670 


MCHS 


6t>0 


MCi?? 


f~.) 


."CHB 


7:-o 


MCH = 


71.1 


VCH^ 


720 


^THP 


T'O 


xMrnfl 


740 


"c^e 


7fO 


*THp 


760 


«CHn 


7 70 


■'C'-? 


7.H3 



'■iZH". 


e>a 


M^H" 


.^M1 


MCPP 


^-3 


•THP 


OiO 


M"-^ 


R';o 


yZH^ 


9 JO 


-CH? 


<310 



SUJ^-QUll NE "ICH^ (^ ■ A, M.N,.^UD, lOP.EPS. IcKI 



TEST ON WHIIVG INPUT P A5 A-'f T l <=. S 

IF(IA1<.1 1CJ)-31 1.1.^3 

MC=MUO»l 

IF |M-HC)<.3. 3,3 

HR=M-MUD 
IER = 

MC IS THe MAXIMUM NUM.^ER C^ ELtHf.TS IF* THE RiJi^S OF ARRAY a 
MR IS ThS INDtX CF THE LAST RU- ! •. fiPRAY A WITH HC CLE"*fNTS 



STA-iT .'^ACTO^IZATIDN Cf MATJTx 4 
If I '"PI?'.,'.,*, 
IEN0=0 
LLOST^vuc 
00 2 3 K-l.M 
ISr= icNO^l 



"CHP. 'J^O 
«CHt 480 

MCHn q^.T 

mchoiooo 
i-chjioio 

MCHei030 
fC-i^lCiO 

MC<-=.'T50 

"CHdlOtO 

MChFlUSO 
MCh°lC<)0 

"CHSl I 10 

"CH=.l 1 10 



MCi 



: !2n 



MCHOi IVO 

"CnailoO 
•'Cf-'il 170 

*":hpi ie,i 

"CHl-llSO 

"CH-iiroa 

-C H6 1 2 1 
•f'CH5t220 
»'CHei230 
MC-^B12'.0 
MCHB125i) 
'»:"El-'60 
KCHpl 2 70 
MCHSL'RO 

HCHt^l^oQ 



Mathematics — Linear Equations 149 



J.K-" "HtZ'^'ir lMI.lv, ..,,*,, ,7 

Ifljlft,...'; «'„« i,^ " "iv.l.Bo/i-iv 

5 ltNO=lfijr)-j ';"«!." l-lsl.l 

6 IflJ-lld,J,T 
T LLr^T = Ll J'T-I Iir!^pin!^ ^ S T A« I h AC< SUfc S T H Uf I L 



IMJIIO.IO.O «'„° M '"" 



Mf 


MP 1 lie 


MC 


Hfl] 5?0 


T. 


Hftl!-(0 


Hfi 


HM )<.0 


»<ri 


'^pt 350 


h"*! 


li-ll ?6fl 


•THBHTO 


»-•:( 


■<i'l jfjfj 


MCMi^l ^00 


HCHHHT) 


MC» 


•11*. 10 


"CH^IUJO 


HCt 


ihl<iin 






nC 3S LL=C,IENO !!rJ2^t^« 

r,.^, • -, -A,m|..^ij (11-11,. 1 "CHfiJTOO 



on 23 [ = r.T.IE\'0 »rHP L *'^ SUm=!.u^^* i( LL )•« ( Lll ) 

11 LL=[SI IK i. J 4-0 *" '"'^^ '^ ^ACKSLtt^I ITur luK 



'CH^.i^lO 


ir.HAi5?o 


H:^'P.l 5n 


IC'"i;-,'.0 


'r.Mfisio 


T.l' MS-iT 


ICH^I^TO 


'■-"^1 510 



»'CHt5pr7o 

MCHP, ^»;T0 



IF(LI_D-«U0U2, li,13 p,iM-,-,,i !^ 



13 ':OMIKUE 

tvc I].- (N.NT > LTCP -O'-i*;''.-^ r "•"••• — • — ••••'••••'*•••'•••"■•..•..•.♦.*♦<<,...<..•••♦. ^r.MfiirfeRO 

TPaNSfJfi-( CLtMPNT ftdl IrnlWpn ^ ^"^'^'^ ^ " ' ' "* ^"^^ °^ *"'^^*^ ""*''' ?ft'*«METEaS Cf PIVOT ELEhEM HCHfi^-iOfl 



16 IF 1 SJM-r }L n 7,17, 19 

17 I F I I F = I H . I 4 . I < 
1 H IFRi--! 



SU'iPOUT INE DMChE 



OHCH 10 



2 1 io=ir*i 



10 ANC t.'^AK uf^.-_;i.-,r C HE*Nt BAND MA 



f^OC ft GIVEN POSlTlVE-nEFINlTE ►- ev M MATRIX A yiTH S V«^ E TR I C 0-CH 5? 

B*:-D ST-uCTu'^t AND ^ If NEC£SSa*.y - A (.Iv^.n gfk^p.l h Hy n onrn 90 

MAIRIK R, THE FOLLOWING CAlCULATiaKS (OcPENDEM O". IhE n^-cV <)0 

ViLUE DF THF OECl-ilON PAftiWtr^R lOP) A^E aE^Prfti-fo r^.p .f,, 

(1) MATPIK A IS FACTfRUfO (IP lOP IS KOT NEGATIVtl, IHAI o-^h 10 



Uopfo Cnoi AGONAL S ONLY IS 



GENERATED ON Trig LCCHIDNS Oi^ A SUCH tMil 



rFiio-ji^i,??.?? vr^^,^.. c r?.ANSPnseiTu)«ru=., (.„-. ... 

r^^Jltr'"' -CHr,,^C C (2, MATRIX fi IS -.ULl I PL 1 £0 CN THf LEFT HY INVE^SEtTUJ OHrn 150 



■'!^ir'/.f!l^'''"':?\M')':' • '■'' '■'^■'' «C"f^i->.^ c r-13 subpcutIn? "es^'?/. u.u' tan .1= useo 10 SGivt r-E iVSTE*. dmc'm mo 



bTfiOT CitVfSIC'J BV TTANSP.'JIst l<f 

LCr.JTI jr;S OF A) 
fST=l 
L'»A)( = ') 



P1V=A( iCTt 



r^c-i-it^f? 


•T H^lOJC 


'«f.^=l'-r3': 


"CHf-tc^C 


fr.H^>1';0 


HCHf lqf,0 


MChf :97C 


ur.uoi<va,(; 


"C-'^iqoo 


'^Cne^COr; 


«^HF.^clo 


Kf.Hs?'^?': 


"CH^^OJfj 


fc^izoi-r. 


*":^-f3i;5', 


«r-.f2P'.0 


*"",'-"=? CO 


HCHt2lj = C 



IN THE LCCAIICNS OF 

L' rAN ri= USEO 10 



£Nrj r,= FACTO- IJ/VT 10', OF -/iri-IX -- «r(.e;,,,,^ C Qf SI'fbLTANECJS L !N 

OEFiMTE OEFFICIfNT 'lATBlX A 0^ SVMMfc T- ic ? AS^^ STAUC ^ueE . C«Ch 200 

D»<*"M 210 

- - - ostzt ty 

PEPA^-E MATPrX JiVISItJNS -CH(^tc^C C CALL OICHE I ? , 4i -.,% ,»i JD. KjP , E^S. I FF ] D-C^- 2J0 

24 ID = N"« HCHflq^o C DESCdPTION OF PA:(AMET;pS nlrT ^-2 

■'u^ir?^''',;';^ '^'^•'•"'^ \ ' ' ''""' '" "''^ l-.P = -3.-2,-|,..2.3 DLUR... - .^ . . U :!.?:;c. 2^0 

F( JENC)?..35.?5 Mr>-oKi3r C « av N ftlGHT hanj SiQg MATPIX. OICh ? 70 

I^I CAS£ ir»=j IP^tLEVANT. o.,r- isr) 

OijTf»uT IN CASES rC = =l,-l I»lVEe''.E ( A t *= . d-''h 29" 

INCASES \-y^=Z,-Z INVfRSEd'JI*^, C^'.H jtJ 

IN CASES i:.Pi3,-l INVEHS6( ri»aSi?-S£(Tui )«3,3H'-'-' i'O 

|f: CASE irP«0 UNCHAN&ED. O't'H 120 

INPUT IN CASES ljP=Ctii2,3 DGJU- P?'^'. I "^.I -,N H ^y ^ijMCr- iiO 

P'JS! 'I Vf-O^FINITE COEFri:i€f.T ii'.T=ix ';p -«-»- ,^0 

, , „, , . .. -. SVMfETftIC iJAND STAUCTUCE STCPEG If. 0*'^ ^-io 

^^''r'^':' „ -CM'=?C'0 C COKP^ESSfL frPM ,S5£ ^eHA>..rS). 0-CM 3« 

.. ^^/ri'^ HCHt2u=c c IN CASES i:p = -i,-?,_3 :r,j3i.e p^c'.i-,;.-:.. v .y wn-'H it^ 



SAr.O viTijr TJ WITH UPf't; CCOU'-.'V.iLS r.^Lt, 



P1V=1.D0/P!V vC-FIUa C OUTPUT IN ALL CA.tS iA-C -Af^IX TJ .II« JP^^^ c-:- ^\o 

■'CH^.^]^o t courj'-'iflL; t^ly. ST'-ieo I'. c','^p^-ss£'^ f-o« n-r- iio 

START rACKSU3STITUTICN-L0r^ f r,H «-r" ^OW GF Ht-^XY » "^"--21^0 C (THAT KEA':: UNC-ANGEJ if IC P — 1 , -2 1 - 3 i' . ' Q-'^H WT 

00 ^n I^f.lD.M MC^E2i<.0 ^ H - INPUT V^LJE SPECIFYING THt NUMaEB 



1=0. DO 



27 LL=IST 
LLL=I 
LLD=LLDiT 



^CHi 


■.^l^o 


»ru: 


- 2 1 10 


HC-fE2i<.0 


"CME^i'.O 


•'C-' 


^2160 


WCH' 


i2I70 


Wt-t 


•2l»0 


•^CH' 


'?l«^C 


"CH' 


^2300 



CCLOfSS T'F A an: T-e Mj^3EJ CF 1G-S 



IFILMAKnO, ■>0,2"' •'€-'^2160 C S - tv^-ur VALj? SP- CI F y| ■■:;, th^ su^Afa rf 

WCH5 2I 7 C ( I oaf LEVANT I' C A S*^ r.P = " I. 

PC^PASE INNEF LOC." wC-PaiBO C *<.jO - lf,?UT VALU= SPECIFriNri Th? NJfOE? Pf u"-''^ 



CEJ'^IAGONALS CF A. 

ONr GF iMi value: --'.-2i-l,C. 1,2.3 Sl.f. AS IvpuT D-'-r- 4-„j 

2210 I"- ANC USEi AS OecISiCS PflaAKETCP. "vr- ^T) 

.,,,- ,,.„ ,„^„ ''C-^r222') •: EPS - SINGLE orE-ISlT. K.sj' V4(.'JE O^EO »< -FL*i:Vt C-rn ',10 

^I :..';'l;^! *-" HC--22-'' ^ TOLEKANCt FC3 TEST f;-. iC^S fe S I S», ! - t Ca", T CI'^ITS. J-f.H 5?T 



OD 2«; L = 1,LMAK fC-?22''0 C !'i - -ESULTI-^f. £3PC-1 oAPAHEr^a CCjED AS flL"-' 

l-^-'LL-LLI) MQi. = 225-0 C IE& = - «'" E-<-t.-, 

^C^';2260 C IEfl^-1 - UC fitSJLT gtrjuSE CF W=C.'i;^ T'-^JT 



LLL=LLL-1 



IF(LLfi-'<U0122,29.2<i HCh<^2250 C C^ e^CA 



LL0=LLD*1 

ENO yf INNER LOOP •'CMF??tO 



M'.PCSITi J 



CHtZZTO C SC«<E FiCTr'UATIJN STf 

St •- A lE'Z OIACr.-tL CLLi'*".' Z^'.- 590 

DI Vi -IC. STEP. J-'--, ^.''0 

WHP^JJG f IF-^i' - KOM.-.C -JL.= TC PGSUSLE L^SS ' ? '.\f.\?\- c^- - t.'". 

■^ANSFO^". eLclENT SO HCHP233-1 C CANCi (t-LICA^Er AT f ACT2^ t 7 1 T i _,'. ST^? r^'C"".. .7". 



ic^T -ADICao was N" L0*':-£'- •"ideate; CC-" 6'.0 

AS EPS«A(i<»l,K*n. c,«-i. f,^-;. 



to 0(n=Pivan3L£(''(T) J -SUM J -CHcJi^iO 

EN'J "F BACKS'J^SI ITu:iO%-Ln?P FG'' •.-TM RO^ D^ fajaix R MCHP2350 C 

»<Ch^2 3^0 r ,,„_-, 

UPQATE PARAKflEBS L-^AX, 1ST ANC LL.IST MCH'>;3'»r} C FEKAi-S -u-_ Ti" 

I'=[HC-< J32, 32i31 -C"a?390 C UPPz- PAi- T OF Sry^ETFIt EA'O 1irS|x A C^NSIST['.G "« ^-AT. T-'-'h -^7,- 

31 L'iAX = K wCMa^iqo C DtAO'NAL AND fJO UF*f3 CC : I AC ' ' -• ;. S I f^.f SF-. dA',C "tTJlX 'I ^-'- --' 

'- IST=IST*<C Vi;H«2<.00 C C.n:IS'1«-C Cf -A|l. :,IAS.;.tL t\r^ -u-> u^ = cc COMO-'MSl -•"- -■',- 

iluU..,.,,, 'Jrllll" ' ;■• t^f-"' '' '' ='"'' '•■ '^-"■'f''iO fOi'i, l.i. ^f..,|'■^ ii'i- r- 

34 cosrixijE "r.Mn?*Ao c ;f ., j; ,„:.£, ,., ,p; ,...j ^j,_ ■ -^^ _;^ ■ 

*'**•* -" ".-..•... , :^:^i:^2 I ;;.]r:!?,;^t^:rir.:^; n^'t^'iiY:].^,:; ,.,-,.- -- ;- 

,F,?L".;«'^;'"- "'""'"'""'' '5 ^""^ " Lcc«,n-,s OF ., liZilTr, c "sr.icTioNs »u: «; Lijs t-^., z€.o. " "- ' ;„:.,:/ 

!■ ISr — .lHOO.IH— -«ri|/J., CrM.,,,^ r „ AOiCICPl SJT GREATER THAN J. i,-,. .,, 

■■"''■O '" r ^° ACTION eESIOfS E-3n: "t5-,[;= Ire, j,<p5 p. .^r .j , „- L. : , 

K.^ "CHi!J5«0 C BESTJICUOMS AlE NCI itUili':, ~^' J^ " '" 

3S IE-lD=ISr-. IrTil^l?, r '"' """OJHE GIVES SES.JLIS I? I«f aEir^ICIK-,, ■, ■.,= „ ,;.-! ''„ 

MC-s^-ieo c ijopf: UNO Firras ij is; N~,£-<~ ?": -^ 



150 Mathematics— Linear Equations 



iCd*"'; REOilIltD 



suei-^ur iN'^s ANfi fiiNCTiON sunn 

f itTHR I?AT inf: IS r^ONT USING CHfllSKY-S SOUAPt-H<"ni MtTHrO, 
WHICH OtNFRATfS THf tUTtf tl*^D "ATRIX TU SUfH IHATS 
Tt AWPf SF I Tul«TU-e. 1U 15. H Tl'Cl.fn «S <:f SUl T r\ iMf 
ll(*TII*iS fir A. fL'KTMtk, tf^tMHNl ON THF ACTUAl VALU6 T.F 
TOP, ['WISION Of V P.T FHANSPC'SI (TIJl ANO/GB TK IS ICPIOUwrO 
AM' IH' PI-MJL1 IS Bflllf.*i(lj Of' Uif LOCATinN'". f;l M. 
rOh fitffRINCt. set H. KUlIStltir.fl, Aiat.SITM^'US l -.llNfAec; 
r,i.f iTMUNcssvsitM Mil '.YMMHf I :.rt'n* p<jsi II v-nn iNin f 

HAhPMA|P|)( MATH CHOIFSKY - , [.IIMPUUM- (A'lCHIVfS ft!H 
£lfCI«n*4IC CHMPUTING), Vfl . 1 . 1 "iV. 1 (IShM, PF.TI-Tfl. 



T^n (IN wtnur; input 
IF( UFi',( inP)-3) l.l,*3 
IF(MUO)*.l,?,? 
HC=M!in*l 
irtM-MCl'VI, 3,3 



ir 



.im 



Mr 11 rnf maximum NunnfR n( tLl-^-^rs In Tnt 
MO IS 'HT INrirx (If THF lA'.r «I(W IN ARBAV a 



SIABT ( ACT'lk IZAI nN I;F MATBJK 

IF) in**iz*..<..<. 

ILOST^MIJD 
DO ? » K= 1 .f^ 
nT.IFNO*l 

iCNn-isi'Muo 

I "^ IJ 1 6 , ft . 5 
. IFNO-riKD-J 

. ir(j-i)R,''..7 

' LLtJST^Ll [I'.I-l 
, LMAXiMg:) 

J = MC-K 

|F I.J)10,li).=5 



STftRI lAClQ-ll/AI UiN-l mP (1V^W K-Tf 

on ;■ 1 1 = i-.i , fFNi) 
in .Mflx) i^. It,, II 

Pf<EPARF INNfR lUrjP 

IL'IbF 
LlO=LLi3:,I 

STA«T JNMFK LHHP 
OQ 1 J L'l.LMAX 
LL=LL-LID 
ll_L=LL*in 

SUH=SUM*A(LL 1*fl( lit } 
If (LLO-MU'Jl 1?, 1*. 13 
' LI D=LL0*1 

I r.QNTi^ue 

FNO OF INNEP LdCP 

TPANSFHRK Elt"f MT A( I I 
, SUM=ftl I l-SUM 

IFtI-I«iI)15.l5,7fl 

AU) lb niAGONAL ELEMENT. tCHPk H 
I IFlSU'i)*-3,^3,16 

IfST (1*1 LOSS nf ^If.MFir.AKT L* K, 1 ' ' 
. IF(SUM-TnL) I Tt 17, |t) 
' IF I irRHH.lfl, 1<* 

COMPUIATICN L'F P I VDT tLf.MINT 
I ('IV=DSO«TI SUW) 
AI I 1=P|V 
PI V=l .00/PIV 
GO TO 21 

AU) IS urr DUGDNAL ELE>*FNI 
) A( 1 MSlW + oiV 

UPDATE ID A^D I MA X 
. ID=IO»I 

IF( ID-J»i3, 23,2? 

• LfA)t = LMAX-l 
1 CONTINUE 

END Of FACinRI/AT lON-LnnP CwfF If - T 
END OF FACTORIZATION Df MATRIX fl 

«**«*>■**■«*«••* •*•*•*«•*•***•■('•***■ 

PREPARr f^alRIK DIVISIONS 
Iff 100)2'., li^. ?*. 
, lO^NeM 

I£ND=f ABSI ir)P)-2 



&N0 WAFNINL 



DMfM tjin 

DMCM 910 
OMCH 1?0 
O-CM 5 It) 
DmCh 9^n 

OfTH T-iO 

iiMCM 9'in 
n«f.M oTd 
r.Mctt '(HO 

OMI.HinOO 

DMr.HioU) 

DMr.HlO'ii] 
')V,l'il()nO 

n^r.m in 
Die HI I in 
[,'■«'■ H J wn 
D'^fi'i I «o 
ii*^f,Hi 1*0 
i;sci*i i-io 
N-'rHiihT 

DTl'i 1 10 
()><[,Hl 110 

P'^r.Hi no 

DMr.H1200 

n^'". HI 7 10 

()-ir.Hi?/T 

• DMr.H'. ? *.) 

nMCin/'.o 

' Mr.Hi7*-i» 
[»«tf,Hl -?70 

iT^r.m 7 MO 

ri>icHi?70 
r)HrMi jii) 

IJMf.HI i|() 

ir«(.Hi 17(1 



f)MC"l«.t)f) 

ni'CHn.iu 

[IMCHI'.^'O 



DM' 



HI 1 iO 



START DIVISION RY TRANSPnSE OF 

L OCA F IONS OF /il 
1ST«I 
LHAK-fJ 
J = -f>P 
LLDSTsMUD 
DO 3* K-I.M 
PIV.AI ISF) 
IF(PIVI26,<.3,26 
PFV=1. DO/PI V 

STA-T ftACKSUflSTITUTICN-LOOP FOR 
DO 30 I=K,IO.M 
SLIH=O.DO 



(ATRI X TU ITU IS STORFD IN 



-IH ROW OF MATai * 



DM(,HI <,*.n 
L«r.Mi«.'>o 
ij-r.Hi <.f.o 
n*"'Hi<,7 
o^r.nifi'io 
rjMr.Mi(,'»o 
i)Mrni50() 
nirn; bio 

tjM[.Ml S^O 

fjHr.Hi^lo 

DM(,H15*0 
OMF.Hl'.SO 

rinrHI s^o 
OMr.Hi "i rti 

RMf.Hl%<*0 

nf»r,Hi5')o 

D'*'"HIi'.00 

Dctr.Hifcio 

DMCH16?0 
nMCHi63n 

OMr.Hl^AO 
OMF.HI^^O 

DMr,Mlf;60 

D'*CHlb7() 
DMr.hlf>HO 

'JMCMlfalC 

DMFMl 700 
DMCMi Tin 

r-*«CMI 7^0 
DMf.Hl 7)0 
DT.Ml 7A0 
UMCHl 710 
0Mr.H17/,0 
0Mr.H17 7O 
OMFHl 780 

O^F, H17*»0 

DMCh;«0O 

nT.Hisio 
OMf.Hiflpn 

nwrHimo 

DHr.MtRAO 
DMCMI flftO 

0''r.Hi*(7o 
Dur. H 1 fi fl 

l"T,HlR9n 

OMr.Mi^OO 
nMcm'Jin 

DMCM19?n 
MCMCH1930 

0Mr.Hi9^a 

DM'-.HI9Sa 
DMCHI9A0 
0MCMI970 
DMCH1980 
DMr.Hi99'i 

■•0MCM70in 

DMCH2030 
CMC HZ 0*0 
0MCH2O50 
0MCM2060 
OMCH2 7O 
DHr.H2080 
Dir.M2090 
DMCH?100 
0MCH2U0 
OHCH?120 
DMfH^UO 
DMCM2140 

DMCH?I60 



If (lM«»t 30,10, 2T 

PMEPARE INNFR lOOf 
2T tL-lSF 
tLL>I 
lLD-LtU5^T 

$TART INN(H LOOP 
00 ?o L'l.LMAK 
LL-LL-llO 
LLL-LLL-1 

SUH-SUH«A(LL)«fllUL) 
IF (LLO-MUOl 28,^9,29 
28 LL0«LLD*1 
2'i CONTINUE 

FND UF INNER LUtJP 

TftiN^FDRM ElCMfNT RU) 
30 t>(I I-P1V*(II( I »-SM«l 

FNO DF fl*tKSU3ST ITUT ILIN-LltOO f 



TH ROM OF HAFRIX R 

1ST AMD t LOST 



UPOATF PARAMFFfRS 

IF(nt-lt l3-!,32, JI 
31 L«««-K 
iZ IST->ISF*MC 

J.J*1 

lFIJI3*,3'i,31 
13 IST-IST-J 

ILDST-LlDil-l 
3A CONTINUt 

(NO UF DlVIIIOi^ BY rRAN';C(JSF f.t 1*T«I« lU 



TU ( TU IS SFDRED ON LnCAIItiNS Of At 



«-TH AQM 01 HAFPI 



StART DIVISION 6T MAlKlR 
IFI IFNO) IS. 3S,4* 

35 15T-M«IHUD*(rt*f1-rtr,n/^2tl 
IHAK^O 

36 I£NO-IST-l 
ISI-lf ND-L1AX 
PIV-A( ISI) 
lF|PIVl3F,*3tl7 

3T PlV-I.DC/PlV 
L-IST*I 

MAkI ^AC.SunsT I nil I (*'-!. 
DO *0 l-K, in.M 
su*i«'),no 

If (l MAXI'.O.^O.'*! 

?t LLL-t 

' tahT I ':nf f- I 00" 

oc 3'» LI = I , irw> 

ILL'Ltl* 1 
■*'* SUH-f IJM*A(Ll )»a ILIL I 
ftJD Ur [NMER LOOP 

TRANf-FOMM ELF^tM H(H 
*0 R(l |'PIV*IM I I )-!>Uf«l 

END DF BACKSUHSFITUFlCiN-LOLP Hi" 

UPOAIt PAOAMfFfdi. IHAK AHO K 
IFIK-MRI«^,«?.«I 
<.! LMAX-LNAK*! 

IF IK)44, *<>, lb 

FNO DF DIVISION 8^ NAThM TU 



tRBOR IXIT IN CAiE OF JRlNf. I N.''U F PARA»»€IFRS OR PIVOT FIEMFNT 

L = SS THAN Hft EQUAL 10 /FKP 
41 IFR — I 
** FETU'^N 
FKIO 



nnr,H?iFo 
0"«f.M? I ma 

DMCHJ^OO 

DMCH.VIO 

OMCH7 7»0 
DHCM-^2^0 

OMr;n/^fco 

OMrH??FO 
liHrM??HO 

0«tCH? 100 
OHf l'2 U« 
OMT.H/ »;»() 
DMf.li^l *(> 

DMCMi' KU 

nif H/ *■.<) 

0HCM717'; 
D'4r,tt2 (fO 
DMCM7AIO 

0*tr.M?*.^o 
UMr.ii?* M} 
tjMrM/'.'.o 
()'4r.i'?4'>o 

(JMCH?*ftO 
DHCH^* 70 

OTn;".»tO 

o.Hf.M/'.qn 

• f)Mr.H?soo 

QIC M^-) 10 

OMfM/'j^O 

DMCM/S'tO 

OMf.M?Shn 
O-^f H2S'0 

nMr.M^'.nn 



W iv*.?0 
nMF.H/* 10 

UMf.tti'/.t.U 

o-'f.ti.'/.'.r) 
OMr,iv^.',D 

l)Mf..<-'f,7t» 

u*ir H 



-TH RLU OF MATRIX 



I. HO 

DMi.ti?».Tr> 

'jMCH^FO'I 

DMf.H?7in 

DMCl*; 7 70 
DMCh;'730 
OTH.'' 74 

o''r,n?7^o 

DM(.H?T.SO 

0<»CH2 770 
D»"CH^7H0 
O^tK^T'/O 

pMf,H2»on 

0MCt-2«l() 
DMFM2H?0 
nMr,H2'»30 
DMr.M7n*n 
ONr,M?ti^O 
D*<CH?»)(sn 
0Mr,H!e7O 

U•i:,H?^^^0 
OMCH2900 
Dlf H291Q 
DH'.H2<>20 
0Mf.H291f> 
nMr.M7'*40 



Mathematics — Linear Equations 151 



Subroutine MFSS and DMFSS 



a. First step 



Given a symmetric positive semidefinite matrix A, 
MFSS will: 

(1) Determine the rank and linearly independent 
rows (and columns) 

(2) Compute a triangular factorization of a 
symmetric submatrix of maximal rank 

(3) Express nonbasic rows (and columns) in terms 
of basic ones and express nonbasic variables in 
terms of free ones. 

1. Mathematical background 

The rank is determined using the method of Cholesky 
(square root method) with pivoting along the main 
diagonal. Pivoting on diagonal elements means that 
the same permutation is applied to the rows and 
columns of A, thereby preserving symmetry. The 
interchange information is recorded in the auxiliary 
vector TRAC. The notation A^i is used for the 
interchanged matrix determined during the rath step. 
The given matrix A is assumed to be stored column- 
wise in compressed form, that is, upper triangular 
part only. 



A = 



^11 H2'" ^In 



a. 



nn 



To allow for easy pivoting, the diagonal terms of 
A are moved into vector TRAC. 

The following two facts will be used repeatedly: 

(I) If S=(Sjj^) is symmetric with Sj-^ > 0, then S 
admits the unique decomposition: 



S = 



t 




1 







t 


V 


v^i. 




_P 


D_ 




_0 


I_ 


Pll ^12^ 






1^21 


^2 


2 _ 











(1) 



where t r/sii, V =(l/t)S^2 ^^'^ ^=^22" V^V. 

(II) If S is symmetric positive semidefinite: 

Sjj s for all j and jsik j s max(sjj) for all i,k 



Let ajj =max(aii), ^ ^jj =0. formula (2) implies 

i 
A = 0, and further calculations are bypassed. 
Assuming ajj > 0, rows 1 and kj = j and columns 1 
and kj of A are interchanged, obtaining Al. 
TRAC(ki) is replaced by TRAC(l), and ki is stored 
in TRAC(l), Decomposition of Al gives: 



a1 = 



11 



Al 



12 



a1 a1 

21 22 



'^n «' 




1 




ti yi" 

tjj V 


(Vl)T I 




D^ 




I 



where tji=/aj^, V^= (l/t^^)A^^ Sind 

Dl = A^2 " (V^)'^V-^. D^ is not calculated explicitly, 
only its diagonal terms are computed and stored in 
locations TRAC (2) through TRAC(n). 

The first row of a1 is replaced by * j^, V^. The 
compressed storage scheme now looks like this: 



11 



V^ 

^h 



b. General step 

Suppose that after m steps (1^ m <n) we have deter- 
mined a transposition vector (ki, k2, . . . , k^), an 
m by m nonsingular upper triangular matrix: 



p,m = 



11 12 



22 



Im 

2m 

t™ 
mm 



an m by (n-m) matrix: 



V^ 



m 



V: 



ym 
2 



ym 
m 



(2) 



152 Mathematics — Linear Equations 



and an (n-m) by (n-m) matrix D™ such that: 

(T™)T [ 



Am Am 
^11 ^12 



Am 
■^21 



D 



Am 
^22 



m 



(yi 



nm 







I 



ym 



I 



(3) 



where A™ = pniA(P"i) , and P™ is the permu- 
tation m^atrix associated with the transposition 
vector (ki,... .kj^). Again, D'^ is not known 
explicitly, but is computable from: 



D 



m; 



^m 

22 



(ym^Tym 



(4) 



T™, V™ and A^ are assumed to be stored in the 
following way: 



V^ 



22 



If A"\ = 0, it follows from (4) and the fact that T>^ 
is positive semidefinite that C^ = 0. Then (3) is 
the desired factorization, and the process termin- 
ates. J£ Affl, ^ 0, there is at least one positive 
diagonal term a^, and we may compute: 



where D'™ =A' ^ _ (v'm)Tv'm_ ^j^^ q jg ^^ 

permutation matrix associated with the transposition 
(m+1, k^^j). Now decompose D ' '^: 



D 



tm+1 
m+l.m+l 



(Vm+1)T J Q p 

_ m+1 



m+1 



m+1, m+1 m+1 



and store t"^ , 1 ™.i.v"^j^, in the first row of 
m+ 1 , m+ 1 m+ 1 

A ' ™ . Let A'^'t-'^ denote the remaining rows and 
columns of A 5i, and rename the elements of V "^ 
as follows: 

.m+1 



•m 



m+1 
l,m+l 

m+l 
' m,m+l 



V 



1 

m+1 
m 



The storage area now looks like this: 



t=^T^T="r (^>kl I 4^«} 



From (4) and (2), max dfP 
i,k I 



< t max ani 



If t s e , the norm of D™ is small compared 
to the norm of A5i, and we interpret this as D"^ = 0. 
Assuming t > €, rows m+1 and kj^+j = m+j and 
columns m+ 1 and kj^+ -^ are interchanged in the 
compressed storage areas, obtaining 



A 'm 

^ 22 



TRAC(kin+i) is replaced by TRAC(m+l). andkj^+l 
is stored in TRAC(m+l). As a result of these 
interchanges: 



QA'"Q 



(T-mjT Q 



(V'"i)T I 







D'nij 



fin V'''^ 



I 



(5) 



m+1 

l.m+1 

m+1 

m+ 1 , m+ 1 



m+1 



V 



^+1 
m+1 
.m+1 
A 22 



^m+l 



Let T'"^"^ be the enlarged triangular t-array indi- 
cated above, (that is, add the column of t's to T™) , 
and let V""'*'-'^ be the V-array. An easy calculation 
shows that we are back in the situation (3) , (4) with 
m replaced by m+1. This completes step m+1. 

c. Final result of elimination 

The above process is continued until for some m=r, 

say, D^=o (in the sense mentioned above) or until 

m=n whichever comes first. In the case r < n, the 
result is the factorization: 



r r r T 
A = P A(P ) ^ 



r T 
(T ) 



r T 



I 







r r 

T V 



I 



Mathematics — Linear Equations 153 



where P is the permutation matrix associated with 
the permutation: 

P''= (r.k )(r-l,k J..(l.k ) 
r r-l 1 

T^ is nonsingular, and we may compute U'^ = 

(T^) "ly'' in the same storage locations occupied by 

V^. An easy calculation shows: 



d. Dependencies among rows and columns 



The basic rows of A are A^ = Ag [I, U ] . The 

nonbasii ^ 

columiiE 

(Ab)1"U. 



nonbasie rows are then U^Aj,. Of course basic 
columns are (Aj))'^, and nonbasie columns are 



e. Systems of equations 



I 




A 
s 







I 


u^~ 


(^V i_ 







0_ 




_0 


I _ 



A^ = 



Where A^ = (T'^)'^T^. We also compute I + (U^) u'' 
and store it in the last n-r rows and columns of 
A, producing the storage scheme: 



Subroutines MFSS and DMFSS may be used to solve 
systems of equations 

AX = R 

with positive semidefinite coefficient matrix A. 
Using the permutation P, this system is transformed 
into the system 



A V = r'^ 



(8) 



U 

r T r 
1+ (U ) U 



where x" = PX and r"^ = PR. li A has rank r=n, 
equation (8) is 



We now operate on I + (U^) U^ in the same way 
that we operated on A. Whenever it is necessary to 
interchange two columns of this matrix, we also 
interchange the same columns of U'^ in the storage 
area. Interchange information is recorded in 
TRAC (r+1) up to TRAC(n). The foregoing proof 
establishes a permutation matrix Q and an (n-r) by 
(n-r) nonsingular upper triangular T^ such that: 

T rTrT rTTrT 

(T^) T^ = Q(I + (U"^) U'^)Q = 1+ (U Q ) (U Q ) 



r r T n-r 

Let T = T , U = U Q and p 



I 



Q 



calculation then gives the final results: 



a"=pap^ = 



T T 

(T ) T = I + U U 
u u 



I 







A 
s 







I 


u 


T 

u 


I_ 















I_ 



An easy 



(6) 



(7) 



n-r r 
where P = P P , The final storage scheme is 



T V 
T 



A X 

s 



R 



-1 -1 -1 T 

which is easily solved since A = T (T ) 

Assuming v <n, the vectors X^, R'^ are partitioned 
as follows: 



X^: 



X, 



x„ 



and R*^ = 



R. 



R, 



where Xj consists of the first r elements of x'^, 
etc. Using the decomposition (6), it is easy to see 
that (8) is equivalent to: 



A^(X^ + UX^) = R^ 



(9) 



0X„ = -U R, + R„ 

2 12 



(By equivalent systems we mean they have the same 
solutions. ) 



= U^i 
has the n-r parameter family of solutions: 



If R2 = U-'^Ri (a compatible system), equation (9) 



X. 



a" R, 

S 1 



UX, 



(10) 



u 



X = arbitrary 



TRAC contains the permutation P in the form of a 

transposition vector (k, ,k„, . . . ,k ). 
12 n 



If R2 7^ U Rj (an incompatible system), it is natural 
to ask for a least-squares solution of (8) , that is a 



2 - 



minimum. 



vector X'l such that Ha'^X'^ - R°|| 

This problem leads to the system of equations: 



154 Mathematics — Linear Equations 



(A°)V = aV (11) 

Given the factorization (6) of A , it is easy to show 
that B" = (a'^)^ admits the factorization: 



b'^ = 



T 
U I 



B 

s 



I U 



I 



where B = A (I+UU ) A . Using this fact, (11) is 
s s s 

equivalent to: 



(12) 



O.X2=O.R2 



which is clearly a compatible system. Therefore 
(12) has the solutions: 



g. Accuracy 

Determining the rank of a matrix on a computer is a 
difficult matter, and it is not claimed that MFSS 
will compute the correct rank in all cases. This is 
an intrinsic difficulty due to the fact that we work 
with finite arithmetic. 

h. Error returns 

Normally IRANK contains the computed rank r. A 
nonpositive value returned in IRANK means: 

IRANK =0 A has no positive diagonal element, 
or |e| a 1. 

IRANK = -1 A nonpositive dimension of A was 
specified. 

IRANK = -2 I + uTu is ill-conditioned and/or 
the relative tolerance € was spec- 
ified incorrectly. 



X^ = B A (R + UR ) - UX 
1 s s 1 ^ 'i 



X = arbitrary 



(13) 



Now the identity (I + UU )~ = I - U(I + U U) U 
shows that it suffices to know (I + U^U)"! in order 
to compute B~l. But by (7): 

T -1 -1 ,^-l.T 

(I + UU) = T (T ) 
^ ' u u 

and Ty~l is easy to compute, since T^ is upper 
triangular. 

f . Solutions of minimal length 

The solutions (10) or (13) contain n-r free param- 
eters Xg, and it is possible to choose them so that 
X"^ has minimal Euclidean length, that is so that 
llx'^ II = min. Some easy calculations show that 
in the compatible case (10), X" is given by: 

T -1 -1 
X, = (I + UU ) A R^ 
I s 1 

T 
X^ = u X^ 

and in the incompatible case (13), a is: 
X = (I + Uu'^)"^a"''"(I + Uu'^)~^(R +UR ) 

i S i ^ 



^2 = U ^ 



se«i 



PPlNli^ 



fF-^S 

►-FSS 



4N0 LIMFAfiLV INOrPENDE'Jr SOWS AND 



SURaOUTINc -(fSS 

-ilVrN A $YM'<eT^[C oisim 

(II DETF'JIIVE TH 
CULJV.NS 

i2l FACT"0 A SVy^FI-ilC iUB^^AT^lX ?F NHXIMAi. PiNK 

(31 EXPPESS NCNSASIC SCwS IN T£>f'iS OF PJSIC ONFS. 

TKDRESS NCNBftSIC COLUMNS l\ IfP-.S OF SSSK DNPS 
FXPRESS BASIC VARIAPLtS IN T^RHS Cf FREE C.NtS 

sueRnuTr^lE ^fss way se ustc *s * p^epiPAr^Bv step f^ 

Cftl-COLATION OF THE LEAST SCJAseS SOLUTION OF MINMAL 
LFNGTH OF fi SYSTEM OF tIN=A(; fQUATICNS WITH SV«|mFT=IC 
positive SEKI-OEFINI TE COfFFICIfNT MATRIX 

USAOF 

CALL MFSS) A.N.EP'i.nANK.TCfl'-) 



F.FSS <'0 
•"FSS 100 



NFS'; 



iir; 



UESCCIPTIDP* rjf t>AftA1ETt-5S 
A - ijpPiP TRIANiULi 



fi PART -X GIV6N SYMfETHC SEMI- 



MF'^S 120 

KFS*^ 130 

MFSS 1*0 

f.FS5 150 

^•FSS lAO 

KFSi ITO 

•*fSS ItfO 

fFSS 190 

fFSS 200 

MfSS 310 

MFSS 220 

MfSS 230 



FPS 

iPfiN"; 



DEFINITE MATRIX STOREi? CQLUMN*.*ISF l^ rOM 

CN PEUFN a CONTAINS THt MATRIX T AND, IF IRANK IS MFSS ?50 

LESS THAN N, THc fiAISICES U ANC TU PFSS 260 

- DIMENSION OF GIVfch MATAIK H KFSS ?T0 

- TESTVALUE FOP ZFBO AFFfCTEO BY ROUNO-CFF NCjISE «F<;r. 2«0 

- EESUL'ANT VflciBBLf. CONTAINING ThF c ft'lK OF GIVtN VFSS 290 
MATOIK a IF A li SEMI-CEFINITE MFSS 300 
IRANK = ^EANS A HAS \'n PPSITIVE niflr.rtjfiL tLEMhNT MFSS ?10 

AND/Ca tPS IS NDT AtSOLUTCLT LESS THAN ONFMFSS 3?0 



IRANK --1 MEAN* DIt'ENSIi'N N IS NOT PPSITIVE 
IfiA\K =-? MFftNS CaHPLETF FAILUfl-, PP5S!»«tY OUt TO 
INADEOuATr R^LATII/E TOLERAWCE FPS 
T-*AC - VECTOF; OF J11c^iSl^^l N Cr>NrAlNINC THE 

SOURCE INDEX Of THF I-TH PIVOY ^Ow IN IT": I-TH 
LOCATION, IHIS Mffii-S THAT TRAC CONTAINS THE 
PRODUCT SePReSEhTATICN CF THE PF^MUTATIOK WHICH 
IS APPLIED Tfl PPWS AN3 COLUMNS OF A IN' Tt-tMS OF 
TRANSPOSITIONS 

«EMAK<S 

EPS MUST BE AaSOLUTELY LESS THAN ONE. A SENSTPLl V4LUE IS 

Sn^lEwHFRF IM EETwrEN K»*<-4l AND 10**(-6> 

THE AerOLUTE V4LUF OF INOjT PitAJ^ETER EOS IS USfO aS 

KFLATIVE TOLEftANCE. 

IN n«OEfl TO PfcESEBVE SYM"£TRY ONLY PIVOTIMC ALONC- 1 HF 

OUi^PNAL IS SUILT (N. 

ALL PIV0TEL£(«ENT5 MUST ef (.REATE'i THAN THE ««SJLUTF VALUE 

0= t^fS TIMES OBICINAL CIACCINAL cLEMCNI 

GTWeaWISE THFY ARf TR€flTeo AS If THEY WERE ;cPO 

MATkIX a RFHAINS UNCHANGED IF THE BESULTANI VILUE lPa^K 

EO'JALS ZfP^ 



SUflROUTINES AKD FUNCTION SUSPI^OGRAMS REaUIii 
NONE 



£0 



METHOD 

THF SOUAi^E -QOI" HETMOO WITH DIAGONAL PivaiINC IS US€D FC« 
CALCULATION Of THE RICHI HAND TRIANGULAR FACTCl. 

IN CJ5E Of AN QSL1 S^V-Cif\HlU MITRIX [HE SmmJl^t 

RET'JRNS THE IRANK X HANK LPf^'i TRI AfUGUL Aii FACTJP T OF A 
SU*^MATDlK OF MAXI.'UL ^fUK, THE ISANK X IN-IFANKt HATFIX U 
ANO THE (N-IRANKI X (N-IRANKI UPPER TRIANCULAB TU SUCH 
THAT TRANSPOSE (TUI»rU=I+TPANSPOS£<UI*U 



SURflOUTINE MFSSt A,N,FPS.i:*ANK,T«AC) 



OIMENSIONFO GUMMY V4CH6LFS 
OIMENSICN Al 1) ,TP«CI I I 
DOUBLE PRtC 15I0N SUM 

TEST OF SPFCIFIEO DIHENSION 
IF(NI 36.36, t 



MFSS 330 
MFSS 340 

MFSS 350 
MFSS 360 
M*^5S 3Trt 
MFSS ?90 
MFSS 390 
f*FSS *00 
*'FSS 410 
MFSS *^0 
MFSS 430 
MFSS 4*0 
MFSS *50 
fFSS ^.bO 
KFSS 470 
•■FSS 480 
»«FSS 490 
MFSS 500 
MFSS 510 
KFSS 520 
"FSS 5?0 
MFSS 540 
MFSS ^50 
Mt^SS 560 
F«FSS 3T0 
MFSS 560 
f'^SS 590 
MFSS 600 
MFSS 610 

ms no 

MFSS 610 
VF5S 640 
MFSS 650 
MFSS 660 
MFSS 670 
-MFSS 680 
MFSS 690 
MFSS 700 
MFSS 710 
MFSS 7 20 
MFSS 7 30 
MFSS 740 
MFSS 750 
MFSS 7^0 
MFSS 770 
MFSS 7ao 



Mathematics — Linear Equations 155 



lt4lJ\ALl7t TCI4*.GULAP F«CTns I 7ATI IS 
1 I«AN« = f> 
ISUR=0 
KPIV=0 
J=0 
PI v=o. 



DO 3 



StABC" FIRST PlVOr ELEMENT 



= 1.N 



ALL ROWS rf 4 



TRAC(K 1 -*( J t 
IF(AIJ (-PfV)3, 3,? 

2 prv=Aiji 

ltPiV = K 

3 CCKTIWUE 

START LOOP 
DO 3Z J^l.M 

* KKI=KP!V-[ 



P£f;f:,f'W PARTIAL COLUMN 1 NTEOC-ANGE 
Jt=KSUS-K«I 
IOC=JI-ISUR 
JJ=I'>IJP-1M1 
00 fe K=JJ, ISUR 

KK=K* 'or 
Hr)LD=fl('< ) 

PcHenRi-* PARTlaL COW INTe^CHA\r,t 



HCl.O = fl(*« t 




A(KKJ=fl( Jl) 




t( 1 1 )=Hn ■) 




7 KK=KK*< 




pe^F^?« pshain: 


^;^, iNrtflC 


JJ=KP|V-l 




Il = lSiiP 




DO C K=],JJ 




HOLD=aiin 




A (I I 1 = A ( J I > 




A( JI JsHi.l ■) 




ii = n»K 




p J[=JI.I 




•5 in ISAWK 1 ?2, 10, 10 





C Recede IfyTEi:CN,''NGE I ^ T c fl\ s pr c ] j ( ^y vECTlJf 

IC TRACtKPIVI^TPaCt I) 
TRACd )-KPlV 

C HOOIfV CURRENT pivQT gQw 

PIV=C. 

jj=rsuH-i 

DP IC K=[,N 

SU*l=O.')0 

; BJUn UP SCALAf- P«ODUCT tf ^E(■fcSS/,PV 

iFiKo: !, ij, :i 

11 DO 1.? J = KM[ , JI 

suK^sii"-' (J i«iirj<) 

iZ JK=JK+1 

13 JJ=JJ*K 
IF(K-I( 1 >,. 14, 16 

U SUM=A( ISU=.)*5UM 

TSST RAOICAND FOH LOSS hf SIGMF'CANCE 
IF(S;JM-A'iSl «1 ISUaCEPSI JZO.^0. 15 
15 A( ISU'*l = r)S(3RT(sU'<) 
KPIV=I*1 
GOTO 19 

14 SUK=(A(J'4)*SU''1(/AI ISUS) 
AIJKJ^SUM 

SEARCH FOR NEXT PIVOT ROM 

TFdIJJl 119, 19,17 
17 TRAC(KI=T?t«CtK(-SUM*SUM 

HOLD=TftAC(KJ/A( JJ» 

IF(PIV-HaL')n8.l9,19 
13 PIV=HOIO 

KPTV=K 

19 JK=jj + I0r. 
liOTH 3? 

CALCULATE fiAT-^K OF OePPN^FNt. I ES (.' 
70 IF( ieANK)?l.?U37 
Zl I«ANK=-1 

GOTO ^ 
22 I«aMK=I«l 

ll*ISue-TRANK 

JI = T I 

00 2t: K=l, IRANK 

JI*JI-I 

JK=ISUB-1 

JJ=K-l 

00 26 J=1,N 

IOC=l'»ANK 

SU»=O.DO 

«il=ji 

KK = JK 

IF|JJ|^5,?5,23 

23 OO 2* L=1,JJ 
I0C=I0C~1 

SUM=SUK-«(KMIJ*A(tCK) 
KMI-KMI-IDC 

24 KKsKK-l 

25 41KK)=tSUM + A(KK))/AfKMn 
?6 JK*JK,«J 

CALCULATE l+TRANSPnSE(Ul "U 
JJ"ISU9-I 
PIV=0. 
KK"ISU8-I 
00 ?I K=I,N 
JJ=JJ*K 



MFSS 790 

»^FS5 eoo 

HF?S 810 

KFSS 820 

HFss aio 

fFS5 8A0 

MFSS 650 

MFSS P60 

*1FSS 670 

WFSS 890 

MF?S 8^0 



MFS5 963 
rPS!^ -570 
VFSc <;an 
fFSS 990 
Kpssiono 
^IFSSIOIO 

wF';!;io;r* 

MFSS103T 

MF^SlOAO 
MFSblO50 

"FSSIO^O 

'<F<;^1070 

HFSS1080 
MFSSIC^O 
•IF^-iUOO 
^■FSMllO 
'4F';S112C 
MFSS113C 
MFSSl !<,0 
HFSSI150 

VFSSE 17? 

"FSSll^O 
•'FSS1190 

MFssizn 

«tsS1220 
'*FSS1230 
MFSSlP'tO 

^■P5Sl^50 

Kf SS17&0 
*'FSS1270 

*'FS5l2fliJ 

MFSS1300 
^•FSSl310 
1«FSS1^?0 

HF^^1330 

MrSS135C 
"FSSIJ&O 
HF5S1 370 
MF^$1 390 
MFSSl i9r- 
MFSSl^OO 
MfSSKlO 
•'F551420 
^■FSSIA30 
MFSSU4n 
"■FSSI^SO 

Mf S'Jl^foO 

1FSS14T0 

wFSsi'.eo 

fFSSlAOO 

MFSSl*iO0 
MF?<;i510 

HFSS1530 
MFSSI^'.O 

MFf SISSO 

MfSS1560 
HFSSl^70 
MFSS1580 
HFSS1590 
KFSSltJO 
Mf SS1610 
M'^SS1620 
''F5'il630 
KFSS1640 
MFSS1650 
MFSI1660 
MFSS1670 
1FSyi630 
MF?;ji6<)0 
^FS5170O 
"FSSITIO 
MFSS1720 
MFSS1730 
MF5SI740 
MFSSl 7'-i0 
MFSS1760 
MF^^1770 
MFSSi730 
MFSS1790 
MFSSISOO 
MFS51P10 

MFSsie^o 
Mf SSI e30 

MF5SIR40 
MFSSldSO 

MFSSie70 

t'Fssiaao 
''Fssie'50 

MFJflSOO 

«fSS1910 

HFSS1920 
MFSS19 30 
MFSS1940 
MFSSI950 
MFSS1960 
MFSS1970 
MFSS1980 
H*'<;SI990 

f1FS52000 

MFSS2010 

MFSS202r 

MFSS2C30 

MFSSiO-iO 

*^FSS2050 

iHFSS20SO 

MFSSZ070 



loc-n 

on 28 JsK.** 

SUM=e.DO 

K1I»JJ*I0C 

DC 27 L=II,KK 

JK-L+IOC 
7 SUM=SyM*fl(Ll*A(JKI 

AlKMI | = SUM 
3 lDC=IOf.*J 

AtJJ»=A(JJt+l.OO 

TRAC(K)=A( JJ ) 

SEARCH NtfXT DIAGONAL ELEMFNT 
IF(D1V-A( JJ) 129. 30, 30 
' tCPIV=K 
K.5Ue=JJ 
PIV-A(jj I 

) ri=n+K 

RK=KK*K 
, CONTINUE 

GOTO 4 
! CONTl^tUfc 
I IFI lfiAN<]35, 3*, 55 
> IFANK=N 
• RE-^UPK 

FHRCH ReTyR^S 

RFTU«K IN CASe OF ILLtGAL OrMFNSlUN 
. lRAhK=-l 
RETURN 

INSTAGLE FACTUF IZATION GF I *T RANSPOSE (U) ♦U 
IRANK=-2 
RfTURN 
END 



MF';s20P0 

fFSS2n90 
MFSS210C 
»'FSS?I10 

.HFSS2 1>0 
Mrs<:2l40 
fFSS2150 
MFSS216a 
MF5S2170 
MFSS2180 
FFSS2l"0 
MFSS2200 
^FS^2210 
MF<;S222a 

«=ssr?3o 

»1FSS22*0 
MFSS2?50 
MFS«2?ftO 
MFSS2270 
HFSS22R0 
fFSS2290 
•^F5S2300 
HFSS231Q 
»"FSS2120 
MFSS2330 
HFSS234C 
MFSS2350 
fFSS2360 
MfSS2370 
KFS'S2390 
MFS^23''0 
HFSS24t>0 
HF5S241C 
MFSS2420 
MFS??4?0 



SUBROUTINE OMFSS 



DHSS 
OMSS 
DMSS 
OMSS 
OHSS 
DMSS 
PMFSS WILL OMSS 
OHSS 



PURPOSE 

GIVEN A SYMMETRIC POSITIVE SEHI DEFINITE MflTRI 

(II OETEHMENE THC HANK AND LrNCARLY INDEPENDENT ROWS AND 

COLUMNS 

(2) FACTOR A SYMMtTftIC SU8MATRIX Of MAXIMAL RANK 
(31 eXPBESS NCNBASIC ROWS IN TERMS OF BASIC ONES, 

EXPRESS NQNSASIC COLUMNS IN TERMS OF BASIC ONES 
EXPRESS BASIC VARUBteS IN TERMS OF fRfcE CNfS 
SU3^nuTtNE DMf55 MAY BE USEO AS A PREPARATORY STEP FOR THE 
CACCU1.ATI0^ OF THF L^aST S^U^RfcS SOLUTION riF K1MM*L 
LENGTH OF A SYSTEM OF LINEAR EQUATIONS WITH f.YMMEfPIC 
POSITIVE SEMl-CEFiNITE COEFFICIENT MATRIK 

USAGE 

CALL DMFSSl A,N.EPS, IRANK,rRAC 1 



70 



DHSS 90 
OMSS 100 
DHSS 110 
OMSS 120 
OMSS 130 
DHSS 140 
DMSS 150 
OfSi 160 
OMSS 170 
OMSS 180 
DMSS 190 
DMS*; 200 
DMSS 210 
OMSS 220 
OMSS 230 



DESCRIPTION PF PARAMETERS 

A - UPP?R TPIAMCUCaR PART 0= GIVEN SYMMETRIC SEMI- 

DEFINITE MATRIX STORED COLUMNWISE IN COMPRESSED FORMOMSS 240 
ON RETURN A CONTAINS THC MATRIX T AND, IF IBANK IS OMSS 2*;o 
LESS THAN N, THE MATRICES U AND TU 
A MUST RE UF DGUSLE PRECISION 

N - DIMENSION Of GIVEN MATSIX A 

t-S - TESIV4LUE FOR 2ERC AF-cCTf^O 3V ROUND-OFF NOIS*^ 

IPANK - RESULTANT VARIABLE, CONTAINING THE RANK Of GIVEN 
MATRIX A IF A IS SEMI-OEFINITE 
IRaNK = MEANS A HAS NO POSITIVE OliGDNAL ELEMENT 



0MS5 260 

DMSS 2 70 

DMSS 210 

OMSS 290 

OMSS 300 

OHSS 310 

DMSS 320 



AND/OR EPS IS MOT ABSOLUTELY LESS THAN ONEOMSS 330 



IftANK =-l MEANS DIMENSION N IS NOT POSITIVE 
IRANK =-2 MEANS COMPLETE FAILURE, POSSISIY DUE TO 
INAO^OUATF RELATIVE TOLERANCF EPS 
TCAC - VECTOR OF DIMENSION N CONTAINING THE 

SQURCc iNDtX OF THE I-TH PIVOT ROW IN ITS 1-TH 

LOCATION, THIS MtANS THAT TRAC CONTAINS THE 

PRODUCT REPRESENTATION OF THE PERMUTATION WHICH 

IS APPLIED TO otlHS AND COLUMNS OF A IN TERMS OF 

TRANSPOSITIONS 

TRAC MUST 6E OF OCIItiL E PRECISION 

fiEMARKS 

tPS MUST ee ABSOLUTELY LESS THAN ONE. A SENSIBLE VALUE IS 

SJMffMHERE IN BcTWEtN 10««(-4» AND 10**t-6l 

THE ABSOLUTE VALUE, OF INPUT PARAMETER EPS IS USED AS 

RELATIVE TOLERANCE. 

IN tiFOER IC P5ESEPVF SYMMFT-Y JNLY PIVOTING ALCNG THE 

DIAGONAL IS BUILT IN. 

ALL PIvrTELE^ENTS "UST Bt\ ^RJATEP THAN THE ABSOLUTE VALUE 

OF EPS TIMES ORIGINAL DIAjONAL ELIfHENT 

OTHE^HISt THEV i-f TCEftTED AS IF THEV WERE 7C-F0 

MATRIX A k.:MAI,ijS U.-.CHANGE9 li' THE RESULTANT VALUE IRANK 

e^UALS 7ER0 

SUgaifJTINfS fiNP FUNCTION SU6PRn.;«iMS -JFOUIREO 
N'lN? 

MFTHT) 

Inc S1UAR€ ^pgr ICTHOD wITm iiaGOfjAL PIVOTING IS USED FCR 

CSLCJL.iT" iriN nF the -IOHT HAWJ '^lANiJJLAC FACTf-;;. 

Ifj r*SF OF a^ tJNLY S^Hl-DEfrjITE ^ATrtlX TH-^ '^UPROUTlNf 
R^TU^NS THf ^«A^^ y, I^Ank UPP' X TRIANCULAR FACTOR T Of A 

SUBMSTWTX rf MAXIMAL i^A,JK, TH- I H ANK X IN-IRANK) MATRIX U 

AND THr IW-IRANK) X (N-IKAViO -JPPrR ^filAN&LLa' TU 'iUCH 
mi J'^mmf.iJ-Jl'^lihlilQiKyiiiUUitU 



DMSS 340 
DCSS 350 
DMSS 360 
DMSS 370 
DMSS 330 
OMSS ?90 
OMSS «^00 
CMSS 410 
OMSS 4?f> 
DMSS 430 
DMSS 440 
DMSS 450 
DMSS 460 
DMSS ^'0 
OMSS 480 
DMSS <.90 
OMSS 500 
DMSS filO 
D.'ISS 520 
OMSS 530 
P«SS 540 
DMSS ■i50 
OMSS S'.O 
O-'SS 5'0 
D'(<;^. 5flO 
D.'ISS '^90 
L"1SS 600 



DMSS '.iO 
D^SS t50 
DMSS (.60 
0'*5S 670 

t^SS bf.Ci 



.C<1SS 



700 



SUa^nuTISE OHF^SI a,N»EPS,|BANH,T=Ar) 



OIHEvSinNLO Cll^,KY VAR.'AflLES 
OIMENSIOV Al 1),T£4C( II 
OOUBLE PRE'"1S10N SUM, A, TkiC ,P I V. HOLO 

TEST "ir SOfCIHED DIMtNSION 
IFIN J3A, 36, I 

INHIALIZE IR!ANGUCaR F AC! OR I / A T ; QN 
IBANK=rj 

ISU6=0 



CSS. 710 
DMSS 7?0 

[;^'ss 730 
r^'ss 740 

OMSS T-'O 
D.'ISS 760 
DMSS 770 
DMSS 7.30 

D^";s 700 

DHSS flOO 
OMS^ 610 
Cf^SS S20 
OMSS 810 
OMSS 840 



156 Mathematics — Linear Equations 



J=0 








PIV=O.DC 








^fA^CH ^IX^- 


;t 


PIVOT ! 


IL-^i^FM" 


00 3 ^. = l.N 








J = J*K 








TRAC(K)^A( J) 








IF(4(J J-PIV ) 3. 


?i 


/ 




PIV-fl( Jl 








KSUB=J 








KPIV-K 








CONTI''(?F 








STAf-I LCCP 


C\ 


ER ALL 


POWS OF 1 


00 3? 1=1, M 








isue=i<^ur^*i 








IMI^I-'. 








KMI=KPlV-r 








IF(K*ri 135, c, 5 









Sf^fC"* PARTfAL COLU^f^ jN'ftRCHA\ ;;. 
'. J1=KSU?-<'*I 

JJ=ISU5-l*n 
DO 6 K = JJ. I 'St'^ 

holo=mk ( 

t dlKM ='*r.Lfi 



-■■1 ?^,J^ I PL PGw 



INTFTHfiNv'.t. 





00 7 K=KPIV, 


,N 














1 1 =K(( -■<.•' 1 
















HOLC = ft<K»' 1 
















fl(KK) = £l I I 1 
















fl( i I ) = ''OL 1 














7 


KK = KK»-K 
















pfpr[:'^■ ' 


>F^■/llf.'I^■t; 


INI 


■^■.-HANf-E 






JJ=KPItf-l 
















If = 1bl'^ 
















DO t rt^I,JJ 
















Han'-/'( 1 T ) 
















fl ( M ) = A 1 J 1 1 
















A( Jl l-nr L-^ 
















U = I I + K 














P 


JI=Jltl 














° 


IFUKrtNK !(■?, 


, I';. I" 














kfC'-eL ifjT:or.Ha\c^ 


: u 


rtfi"' 


cprsi T 1 


10 


TRaC [kPI wi=: 


tRACI 1 i 














t':ac( t ) = •■ ^:v 














M^-^JtV Ci 


Jk-=\T 1 


■ I'/rj 


■<nu 








KK-IMl-IUfi\K 














K-i^rsu-^-^" 
















P[Vr<..fjO 
















(CC^IHANKt 1 
















Jf ^ISMR-l 
















JK=KKI 
















JJ^ISU'-l 
















OC IS K=[.N 
















SlI-'-O.DO 
















PUlLC U'^ 


SCALfiP 


PROUrl IF 


N"^ 


r( Si 




IFUKlU. I J 


. 11 












11 


DC U- J = Kf^T 


.J! 












12 
I! 


J<.JR*1 


..,. 












1* 


SIJW^-VdStHI' 


4uM 













TfcST <<ftOl'"uN? FOfl LCSS uf SIGN1KICAMC5 
lF(SU*<-(;4)Sf A( ISUei'OSLtlE^^l I ) 20, 2,% 15 
IS At iSUbl = OSJ*<T( SU"! 
KPlv=l*l 

GOTn r-; 

It SlJ«=(fi( J1C)*SUM1/A( I SUPl 

SFi^CM Ftic •JfJ'T PIVil» BQV 
IF(AUJ) ll<;. l'3,l T 

17 T«Atl^l=f■^AC(^J-su^'•suH 

MOLD^THfiC in I /MJJ I 
IF{PIV-H'JL?) te.i«. l^J 

ly Piv=HrLn 

KPI V = K 

K5Ue=JJ 

GOTO 3? 

CCLCllLATt H4TR1X 0*- OtPENOfhCKS U 
?0 IK It'aNX 121,?1 . 37 
.--l IRANK = -1 

2? I«ANK=IV.l 

JI = I I 

00 2t <-\,l°tf-tK 
JI=JI-1 

JK=ISU9-1 



JJ = 



-1 



O'l Z ') J ^ ! . N 
I0C= I"^^;^; 

K*11 = JI 

KK = JK 

?3 00 ?i L=1.JJ 
1DC= TOC-l 
SUM=SUM-ft(KHl )«A(K»( ) 

?(, KKi<K-l 

?5 AIKKI =(SfJ'<«A tKK I I/AIKMI) 
26 JK=JK.J 

CALCULITF I*IfiANSPOSt(UI«U 
JJ=ISUS- [ 
PIV=0.00 
KK=(SUB-I 
^0 31 K=I,N 
JJ=JJ*K 
IDC = 

00 26 J=<.N 
SUM=0.00 
KMI=JJ*10C 



OMSS 850 
P-flSS dfeO 
D'-SS rt70 

OMSS aflo 

OMSS Rqo 

orss 'jno 

O-^SS 110 

DMSS J20 

IMS'; «*o 

OMSS 9^0 

O'^SS 960 

0MS5 -JTO 

OMSS "JIO 

0''S^1030 
DMSS1030 

o.-ssioso 
O'-ssio'jn 

Ol-.^l 110 

oiiSL iin 

f>-issirio 
n-issi 1^0 

DMSM l-'iCl 
OMSSl I'.O 
PMSSl ) TO 
D'-SSl lr.1 

EMSS1>')') 

0M5';i?n 
r«ss) ^iFT 

^MSSW^■^ 

C«SS1?70 
C"^SSU'=in 

C'1SSI330 
SMSSl l^-O 
D"SSli50 
tT^SSl ?60 

D-'SSl ^'lO 
fJMSSl ^fJO 
DMS'^l'.OO 
D*'S5,l''n 

[l'-!SS1^13 

D-'SSl'.SO 

o"S';i-.on 

r).*SSH70 

c-ssi-.m 

0y*;':i5i0 
CI''S:il51:) 

01SS153O 

DMS^l'i'iO 
DMSS1^60 
3-1!:Sl ^70 
OMSSl'JTiQ 



1M'iSl6^0 

'"^Sl-s U'» 

n-^ssi6HT 

C^SSKj^O 
D'^SSliSO 
O'-SSlbTO 
CSSl'v-JJ 
D^SSlft-SO 
O^SSITOO 
0«SS17I0 

OMS<;i7>o 

O-'SSlTiO 
C^SSIT^O 
0MSS1750 
t-MSSl 760 
C*«SS1 77G 
0VSS1730 
D«SSl 7''0 
D»^SS1800 

CIMSS1330 

n-ssi fl«>o 

OMSSlfi'jO 
M s S I a 7 .1 
D-^SblPffO 

D-^SS 1931.1 
OMSSliin 
OM<;siq?0^ 
D'^SS1<»*0 
D-^S^lOiO 

CMSS1960 
0-'S!;i970 

PMSS2000 
D-'SS^OIO 

DMS';7n'0 
0''!;S20}0 
DMSS2Q'.0 

0'^SS^060 
0WSS2n^0 

QMS 1^2010 

oMssao^o 

OMSS2100 
n*i?s2 1 10 
D»(SS2120 
DMSS2 1 »0 



00 27 L = ! I,KK 
JK = L*irjC 
2 7 SUM=SUM*A<L I ♦*( J< I 
!l)KM )=SUM 

;'^ iDC=ioc*j 

fl( jjl=a< jjJ + 1.00 
T«AC(K) = A( JJl 

SEARCH titXT OIACUNAL fcLE-ltNT 
IF1P[V-AIJJ1 129,30,30 

29 it^lV^K 
KSUP=JJ 

ofV^'^UJ) 

^0 II=II»« 

31 CONTINU'= 

cnTp A 

i? C'JNTIMUC 

33 IF| IhANK ) iS, ?'.. ib 

3 6 RFTUKfJ 



t"Bi 



Ch ,tEtU«N5 

IIKN IN C.b'if. OF ILLFC 



RETUriN 

[NSTAHLE FACTOR IZA1 ION PF 1 -T kAfJ SPC iE ) U » «U 
>7 ICiNK=-;^ 

KETU'JN 
END 



n«ss?i*>Ei 
nt'^s.'i^o 

n-HSsMKo 

OMSS'l-^O 
C*'S = 22'Vi 
0MSi:!2 10 
DMS?.V?0 



DH<;t 



>/.0 



ry*^s??7o 

D-i'^.S22'?0 
RMS';,' il.' 



r)MSS2i'30 
0«SS,'AIO 

frHS<;?A?o 
crtss.^'i ^a 

DMSS^'.'-O 

0MS*;?*.50 



Mathematics— Linear Equations 157 



Subroutines MFSD and DMFSD 

These subroutines will compute a triangular factor- 
ization of a symmetric positive definite matrix using 
the square root method of Cholesky, 

1. Mathematical background 

Given an n by n symmetric positive definite matrix 
A, we compute an upper triangular matrix R such 

that 

T 
A = R R 



The elements r of R are computed using the fol- 



lowing recursive formulas: 



^Ik = V^U 



J-1 



r, = (l/r..)(a. -X) r..r., ) 
Jk ]] jk ^ 1] ik' 



k=l, 2, 3, .... n 



j=2, 3 n 

k=j, j+1, ... , n 
/ n \„ 



Note: The determinant of A is det(A) =( TT r 1 

— \i=i 7 



2. Programming considerations 

The given matrix A is assumed stored columnwise 
in compressed form, that is upper triangular part 
only. MFSD stores the solution R in the same loca- 
tions as A. 

2 
If any calculated radicand rj^ (k= 1, 2, . . . , n) is 

not positive, further calculation is bypassed, and 
the error parameter lER is set to -1. This means 
that A is not positive definite, possibly due to 
roundoff errors. EER is also set to -1 if the input 
parameter n is less than 1. 

Let all radicands be positive and let rj^j^ be the 
first radicand which is no longer greater than the 
internal tolerance TOL =|EPS aj^,^| . The subroutine 
then gives the warning lER = k-1; however, 
calculation is continued. The warning indicates 
that there may be loss of significance at factor- 
ization step k due to loss of significant digits in the 
2 



calculation of r. 



kk 







MFSD 10 
...MFSD 20 




SU6flOUTIN€ NfSO 


MFSD 30 
MFSD 40 


PURf'OSE 


MFSO 50 
MFSO 60 




FACTOR A GIVEN SYMHETHIC POSITIVE OtflNITE NATHlX 


MFSD 70 






"Fso ao 




US4GE 


MFSD QO 




CALL HFSO<A,N,EPS.IEft) 


MFSO 100 


OESCaiPTION OF PAItAMETER<; 


MFSO 110 
MFSO 120 




A - OPPew IRIANCULAd PART Of THE GIVEN SYMMETRIC 


MFSO 130 




POSITIVE DEFINITE H lY N COEFFICIENT HaTAIX. 


MFSD 140 




■}N R£TU4N A CONTAINS THc RESULTANT UPPtR 


MFSD ISO 




TRIANGULA1 MATRIX. 


MFSO 160 




N - THE NUMAtB Of «OWS tCOLUMNSI IN GIVEN MATRIX. 


MFSO 170 




EPS - AN INPUr CONSTANT WHICH IS USED AS RELATIVE 


MFSC HO 




TOLERANCE FOR TEST 3N LPSS OF SIGNIFICANCE. 


MfSO 190 




lEB - RESULTING ERROR PARAMETER CODED AS FOLLOWS 


MFSO iOO 




IEP-0 - NG EaoCP 


MFSO 210 




IER=-l - NO RESULT BECAUSE OF WRONG INPUT PARAME- 


■ MFSO 220 




TER N on BECAUSE SOME RAOICANO IS NON- 


MFSD 2 30 




POSITIVE IMATRIX A IS NOT POSITIVE 


NFSD 240 




DEFINITE. PTSSI9LY OuE TO LOSS OF SIGNI- 


■ MFSO 2'iO 




FICANCE! 


MFSO 2&0 




I£R«R - MARNING KHICM INOICATES LOSS OF SIGNIFI- 


MFSO 270 




CANCE. THE RAOICANO FOR)4EO AT FACTPRIZA- 


MFSO 260 




TION STEP K*l WAS STiLt POSITIVE BUT NO 


MfSO 290 




LONCEP GRFAT-^R THAN ABSI cPS*AU*l,R*l 11 . 


MFSO SOO 






MfSO 310 




REHAR<S 


MfSO 320 




THE UPPER TRIANG'JLAR PART OF GIVEN HATRIK IS ASSUMED TQ 9£ 


MFSD 310 




STORED COLUMNWISE IN N»tN*tl/* SUCCESSlVt STO'SAGF LOC AT IONS. MFSD ^*3 




IN THE StKE STORAGE LOCATICNS TM= RESULTING UPPER IRIANGU- 


MFSD ISO 




L»a MATRIX IS STORED CCLUM.NWISE TOO. 


MFSO S'.O 




THE PanCEDiIRE CIVES RESULTS IF H IS CREATED THAN *N0 ALL 


MFSO 370 




CALCULATED RADICANOS APE POSITIVE. 


MFSO 360 




THE PRODUCT CF RETURN6Q OIAGOXIL Tc-<^S IS E3UAL TU THE 


MFSD 3<»0 




SOUARE-^DCT OF THE DETERMINANT OF THt GIVFN «AHi|X, 


KFSn *O0 






MFSD -«.10 




SUBROUTINES AND FUNCTION SUBPRDGKA/iS REJJIRcO 


MFSD 430 




NONE 


Mfsn '.»o 






MFSO 440 




METHOD 


MFSO 4S0 




SOLUTION IS DONE USING THE SQUAKd-R^JOT METHOr) 0*^ ChOLESKV, 


Mrsp <.50 




^HE Giver, .H4TSIX IS SEPPESCNTED AS PtOOUCT OF IwO T"; 1 ANGULARMFSO fcTO 




HATHICcS, hMERE The LEt=T HANJ rACTQR IS Trifc Tq«NSPQSE OF 


wFSD 460 




THE RETURNED RIGHT HAND FACTOR. 


Mfsn ".90 






MFSO ^30 






MfSn 5?0 




SUSBOUIINE MFSD(A,\,EPS,IER! 


MFSO S10 






MPS':: 540 






MCSn 550 




DIMENSION At 1) 


MFSO 560 




DOUBLE ^'ECISION 0PIV,3SUM 


M<=S!' STO 






«FSD 5 30 




TEST 'N iiRCNG INPUT PARflXEItP N 


MfSO 590 




IF(N-1J 1?,1,1 


MFSD 610 


1 


IEB-0 


MFSO &10 






MFSO e?o 




INITIALIZE ClAr,CNAL-LO0P 


MfSO 630 




KPIV-0 


«FSD 640 




DO U K=l,N 


■4FS0 6^0 




KPIV-KPIV.tC 


MFSO 660 




INO«KPIV 


MfSD 670 




LEN0=K-1 


MFS:^ 610 


c 




M'SO 690 


c 


CALCULAIE TOLERANCE 


M^SO TOO 




T0L'=A5S(EPS*AIKPIV)I 


MFSO 710 


c 




MFSD 720 


c 


START FACTOfitZATIOh-LOOP CVER K-th BCii 


MF?2 730 




DO 11 l=K,N 


MFSS 740 




DSUM^O.OO 


MFSO 7S0 




IFILENOI 2,4,2 


MFSO 760 


c 




MF50 770 


c 


STABT INNER LOOP 


KFSO 740 


2 


DO 1 L=1,L£N0 


MFSC 790 




LANF"KI>IV-L 


MFSD ftOO 




LIND=INO-L 


KF5C 110 


1 


OSUM^tDSUMtDPLeUILANFMAlLlNOt 1 


KFSO 820 


c 


FNO Of INNE* LOOP 


HFSO B^O 


c 




MFSO 840 


c 


TRANSFOR?" ELcMENT A( INO) 


MFSO 850 


« 


OSUM-DSLE< A( IND) l-OSUM 


MFSO 660 




IFII*KI 10.^.10 


MFSO 870 


c 




MFSC 680 


c 


TEST FOR NEflATIVE PIVOT ELEMENT AND FOR LOSS PF SIGNIFICANCE 


MFSC eto 


5 


If 1S.\GLIOSUM)-TOL) 6,6,<3 


MFSD 900 


6 


IFfDSU"*! 12,12,7 


MFSO 910 


T 


IFIIERI S.d,<) 


MFSD 9?0 


8 


lER'R-l 


MFSD 9^0 


C 




MFSC 940 


C 


COMPUTE PIVOf ELEMENT 


♦-FfP 950 


q 


DPIV'DSOfiTfOSUMl 


MfSO 960 




A(!CPIV>>OPI V 


MFSD 970 




CPIV-I.CO/DPIV 


MFSD 9«(0 




GO TO 11 


MFSD 99C 


c 




MFSOIOOO 


c 


CALCULATE TERMS IN ROW 


MFSCIOIO 


10 


A1IND)<0SU1*Di>IV 


MFS01020 


11 


IND=1M0*I 


MFSDIOIO 


c 




MFSD1040 


c 


ENO OF Q1AG0N4L-L00P 


MF5D1050 




RETURN 


MFS01050 


12 


IER=-l 


MfSD1070 




RETURN 


M«^S01010 




END 


M=S01090 



158 Mathematics — Linear Equations 



SU9RDUT1NE DMFSD 

FtCID^ * GIVFN SV««£TRIC POSUIVE CEFINITt KhTKK > 

USAGE 

C»LL WFSOld.S.fS.ieBI 

OESCRlPTim OF PAftANFTERS 

A - OOUPLE PRECISION UFPE<1 fRIANGULAR PART PF GIVEN 

Srn¥fT9lC POSITIVE OEFIMTE N IT N CnEFFICIENT 
MATFIK. 

UN RETl/'^N A r.ONTftlNS THE ^ESUtTAMr t^PER 
TfllAKGULAft M4THIX IN DOUBLE PHtCISICM. 
N - THE NUfBER OF KOKS (COLUMNSl IN GIVEN "ATRIX. 

EPS - SINGLE "-ECISIOK IKP'JT CONSTANT yHICM IS U!EO 

AS RtLATIVF TCLEaAKCE *-0K TCST CiN LOSS Cf 
Sir-NIF|CANC£. 
ie« - RESULTING ERRnS PARAMETER CCDEO AS FCLLCmS 

lE"t-0 - NO E»RCK 

I?«> = -1 - NO PESOIT SECAJSE UF hRQNG lKt>UT PARAHE- 
TER N CR BECAUSE SO'it RACTCANH IS NCN- 
iTSIIIVE IMATRIX A IS NHT P'"SrTlVt 
DtFIMTF, POSSISLY DUE '^Q IRSS OF SIC«1- 
FICANCFl 
1^R*< - riAHMNG WHICH INDICATES LOSS 0^ SIGNIFI- 
CANCE. THE KAOICAND FHRNED AT FtCTSRIZA- 
TION STEi» K*l WAS SriLL POSITIVE EuT NO 
LQNGtft CS€»Tns THAN ASSI EpS*A I K» 1 .K* 1 ) t . 

REMARKS 

THE UPPEt TRIANGULAR PART OF GIVE*! t»AT«lX IS «SSUH£D TO RE 
STORED CCILUPNMISE IN N«IN*ll/2 SUCCESSIVE ST35«GE LDCftTIONS. 
If. TH? S'ff STOPAGF_ LOCATIONS THE RESULTING 'JPP^R TRIANGU- 
LAR MATRIX IS STORED COLUMMhISf TOO. 

THE PftCCFDURE GIVES RESULTS IF N IS GREATER. TH4N AND ALL 
CALCULATED RAOICANOS ARE POSITIVE. 

THE PFODUC OF PETU^NEP DIAGONAL TfPHS IS ECUAL TO TrtE 
SQUARf-ROOT OF TH5 OEIfRMINANT TF THE GIVEN t*ATeiK, 

SUBROUTINES AND FJNf.TION SUBPPOGHAHS REQUIRED 

SCfiF 

KfTMCD 

SOLUTION IS nCNe USli-O int SCU-RE-BOOT HGTHOO CF CmQLFSKY. 
THE GIVIH -lATRix IS REPRFSENTtP AS P<;OOLICT CF TWO Tfi [ A^jGULAfi 
NITPIfCS. *HEFE THE LEFT HJ:Nf> FACTOR IS THE TRANSPOSE OF 
THE. nETU=iN£5 RIGHT HANU FACT3S. 



SUBRDUTINfe J'^'=SD)AtN,EPS, 



ONSO 


10 


. 01S0 


?0 


0HSD 


10 


0«S0 


40 


DISO 


■io 


'>'<Sf) 


6a 


DfISC 


'0 


DNSD 


no 


0"<S0 


90 


D^^O 


lao 


O'tSO 


110 


0»(S0 


123 


OHSO 


ISO 


DHSO 


1*0 


ONSC 


150 


0«SD 


160 


D'^SD 


wo 


D1SD 


HO 


OMSC 


190 


OMSO 


200 


0*<SD 


210 


D^sn 


??0 


U-^SO 


z^o 


UlSl) 


24-) 


CMS3 


250 


OMSO 


i&o 


DffSD 


^TO 


D«50 


z»o 


D«SO 


??n 


DMSO 


300 


D«SD 


310 


OMSO 


3!0 


OHSP 


3 30 


D*«ST1 


3*^0 


OMSD 


?50 


.OHSC 


3AC 


CSO 


370 


Df«r 


'BO 


D-SP 


390 


DH5D 


•■00 


O'-sn 


410 


OMsn 


420 


C«SD 


*3? 


OMSD 


440 


OMsn 


450 


DFSD 


<i60 


Dt'SO 


4 TO 


CHSO 


490 


iOfsr 


400 


OMSC 


soo 


D-SP 


510 


OHSf 


5?0 


, [)«SD 


530 


o^sc 


540 


OHsn 


550 


CSD 


560 



DlHENSIOn Al 1) 

OOUSLE P'"*=CISICN OOIVtO^UHtA 

TEST CK WROHr. INPUT PAR*?«tT£R N 
IF IN- II I?, 1,1 

1 l€R«0 ' 

INITIALIZE nt Ar.ONAL-LOOP 
KPIVO 

00 11 K<^1.N 
llPIV-KPIV** 
!NO«'<PIV 
L€N0«K-1 

CM.CULATF TGLfPANCE 
TCL'AQSfdfS'SNGLtAlK^lVl) I 

STA^T F»cnAI?*TION-LaOP OVER K-TH itau 
DO 11 I-K.N 
OSON-O.OO 
IFCLENOt ?,4,2 

START INNER LOOP 

2 00 3 L-l.LENO 
lANF-llPIVH. 
LIND*INC-L 

? DSUf*-0SUK«AUANF)««(LlN'7l 
ENO TF INNEf LOOP 

TRANSF3RM ELEMENT AIIND) 
* OSUH.A(INCI-OSUM 
IFII-Kl lO.S.lO 

TEST FOR NEGATIVE PIVOT ELEMENT AND FOR LOSS OF SICNIFICANCE 
5 [F<SNGL(J5U<<)-rrL} «.6.9 
« IF<OSUni 12.12,7 
7 IFtIE«) 8,8.9 
a IFH-R-l 

COfPUTE PIVOT ELEMENT 
9 I>PIV-0SOftT(0SUMl 
A<KPIVI-DPIV 
CPIV-l.CO/DPIV 
GO T'* U 

CALCULATE TERMS IN ROW 

10 »(INOI»OSUM*OPIV 

11 IMD*INO«l 

END OF Dl AGONAL-LDDP 

RETURN 

12 IER--1 

RETURN 
END 



OMSC 5 70 

DMSP 5P0 

OMSO 59C 

D*(SO 600 

D*SO 610 

OMSO 620 

DMSC 69C 

OfSD 640 

Ors*^ 650 

DMSO 660 

O-^SO <-T0 

OMSO 6fl0 

D'-SP 690 

DMSO 700 

DMSO 710 

DMSO 720 

O.^SO 7»0 

DHSO 740 

OMSO 7S0 

OMSO 7«>0 

D«*SO 770 

DMSO TSO 

OMSD 790 

D-SD SOO 

Ot'SD «10 

OfSO t)ZO 

CSD 830 

0M?0 f«0 

o*«so «so 

DMSO 660 

PMSO STO 

OM5 sao 

OMSD 90 
DMSO 900 
OMSD 910 
DMSO 920 
DMSD 910 
DHSO 940 
PMSO 950 
D1S0 960 
OMSD 9 TO 
DMSD 9P0 
CMSC 990 
D««S01000 
OMSOIOIO 
OMS01020 
DMSDI030 
0MSD1040 
O-^SOIOSO 
OM50I060 
OMSOIOTO 

onsoioeo 

0MSD1090 
OMSDllOO 
DMSOlllO 



Mathematics — Linear Equations 159 



Subroutines LLSQ and DLLSQ 

These subroutines obtain the solution of linear least - 
squares problems. Consider a real m by rf matrix A 
of rank n (m > n) with elements aik (i = 1,2, , , . ,m; 
k = 1 , 2 , — , n) and 1 right-hand side column vectors 

Bj (j = 1 , 2 1) of dimension m , written as an m 

by 1 right-hand side matrix B with elements bjj^^ 

(i = l,2,..,,m;k = l,2 1). The problem is to 

determine 1 column vectors Xj (j = 1 , 2 , , . . , 1) of 
dimension n — written as an n by 1 matrix X with 
elements x^]^ (i = 1,2,..., n; k= 1,2,...,1)— such 
that: 



'^11 "^12 • • • ^11\ 



^21 ^^22 ••• ^21 



X X ... X , 
nl n2 nl / 



^^11 ^12 ••• "^IV 



r„. r 



21 "^22 ■ • • ^21 \ (5) 



^31 ^32 ••• ^31 



\r r . r 

, ml m2 ml/ 



||B. -A*X.|| =min. (j = l,2,...,l) (1) 

where |) R|| indicates the Euclidean norm of any col- 
umn vector R with elements r^ (i = 1,2, . . , , m); that 
is: 



l|R| 



V 



i=l 



r. 



(2) 



the orthogonal transformation matrix Q is determined 
so that matrix A Is transformed to upper triangular 
form; that is, all elements a^j^^ with i > k are trans- 
formed to zero. An effective way to realize this de- 
composition is via Householder transformations. 
The algorithm is a recursive n-step procedure de- 
fined by the following recursion formulas: 



A<1) =A 



(6) 



In the special case m = n, solution of the linear 
least-squares problem means solution of the system 
of sim.ultaneous linear equations: 



A * X = B 



(3) 



Solution of the given problem is based on the well 
known principle that transformation of any column 
vector R by an orthogonal matrix Q does not change 
its norm IIRII ; that is: 



IQ * Rll 



IIRII 



(4) 



A(k+1) ^ p(k) , ^(k) 



(k= l,2,...,n) (7) 



In order to get an upper triangular matrix A^'^"^^, 
every matrix p(k) (k = 1,2, ... ,n) should be defined 
so that it is symmetric and orthogonal, and so that it 
transforms all elements of the kth column of A^k) be- 
low the main diagonal to zero. All these restrictions 
to P(k) are satisfied, setting: 



P<'^) = I - /3, * U^'^) * U^'^) 



(8) 



Writing the given problem in the following form: ^ 



with 



'\l \z 



\l ^22 



^31 ^^32 



3 -, b 
ml m2 




'^ll 


\2 


^21 


^22 


"31 


"32 



a , a „ 
ml m2 



• a. 



• a„ 



3n 



. a 



mn/ 



and 



^k (^k ^ ^kk) 



m 



,i^) 



i=k 



(9) 



JE ^k^ ""'^M (^^'^ 

f (k) ^ 
fora;^'<o 



160 Mathematics— Linear Equations 



^^^^(I/t^ *^® identity matrix. All other elements of matrix A(k) do not change. 

U^ ' denotes the transpose of column vector u(k), Naturally, the same transformation is performed 
the m components of which are defined as follows: matrix B. 



on 



(k) 
u. ' = 

1 


for i < k 


(k) 
"k - 


<^k^ 


^ 


1 


ik 


for i > k 



Neither matrices P^'^) (k = 1 2, ... ,n) nor matrix 
Q = p(n) * p(n-l) * _ _ * p(l) are computed explicitly 
since from (7) and (8): 





Using (6) and (7): 




(11) 


B<^) = B 


(22) 


(12) 


B(k-l) = p(k) * B^"^) (k = 1.2..., 


..n) (23) 


(13) 


Usii^ (8) and (23): 






g(k+l) ^ g(k) _ ^(k) , 2(k)T 


(24) 


itly, 


with 





^(k+1) ^ ^(k) _ ^(k) ^ Y(k)T 



(14) 



z(k)T ^ ^ ^(k)T , g(k) 

k 



(25) 



with 



y(^)T ^(k)T ^ ^(k) 

k 



(15) 



Writing the components of row vector Y(k)^explieitly: 



or explicitly 
b' 



(k+1) _ b^ _ ^(k) . ^(k) 

•^ •' i = l,2,...,m) (26) 



with 



yf^^ = for j < k 



.« . X 



J ^ k ^^ 1 1] •' 

i=k 



(16) 
(17) 

(18) 



Using (14), (16), (17), and (18), the explicit transfor- 
mation formulas for matrix A^k) appear as follows: 



(k+1) 

4k - -"i 



^ik^^^ =0 (i= k + 1, k+2,...,m) 



iJ ij i ■'j 

(j=k + l,k+2 n and 

for fixed j, i = k, k + 1 m) 



(19) 
(20) 



(21) 



J '^k 2^ 1 13 

i=k 



(j =1,2,...,1) (27) 



In order to keep roundoff errors as small as pos- 
sible, column interchar^e is performed in such a 
way that, at the k*^ stage, the column of A^k) is 
chosen to be reduced next, which will maximize 
h&^ 1 . Using (19) and (10), the index of this col- 
umn is determined by giving the maximum overall j 
of: 



,(k) 



m 



.(k),2 



J2 H ) a = k, k+1,, 

i=k 



.n) (28) 



After A^k+l) has been computed, it is possible to 

compute s^^-^^ as follows: 



(k+1) _ (k) (k+1) ^2 



= s 



'j " Kj > a = k+l, k+2,...,n) (29) 



Mathematics--Linear Equations 161 



since the orthogonal transformations leave the col- 
umn lengths Invariant. 

After having computed matrices A^'*^^) (upper 
triangular matrix) and B(n+1), the computation of the 
n by 1 solution matrix X is performed by back sub- 
stitution according to the following formulas: 



X , = 
ni 



\i 



a 



<i^-^r' <'-.^ ') 



nn 



(n+1) ^ ki 



%k 



k,k+l k+1, i 



(30) 



If at any stage k (= 1, 2, . . . , n+l) the square root of 
the maximum overall j = k+1, . . . , n of s('^'*"-'^\ say 
piv, is not greater than tol, the rank of matrix A is 
declared to be k <n, and the procedure returns an 
error message to the calling program, thus indi- 
cating that no solution could be found. In this case, 
the last n - k elements of vector IPIV denote the use- 
less columns of matrix A; the remaining useful col- 
umns form a base of matrix A, 

For reference see G. Golub, "Numerical Method 
for Solving Linear Least Squares Problems", 
Numerische Mathematik . vol. 7, no. 3 (1965), pp. 
206 - 216. 



af'^''^) .X - - a.^'^+l) 

Tc,k+2 T<+2,i *" Ts,n-1 



(n+l) 
a: • X .) 

Kn m 



(k = n-j+1; j =2,3, , n and 

i = 1, 2, ... ,1 for fixed j) 



!0 



n-l,i 



(31) 



After any row of matrix X has been computed, 
back interchange of rows is performed according to 
column interchanges in matrices AW in order to get 
the correct sequence of components in the solution 
vectors X, . 

Finally, the vector of linear least squares with 
components 



i=n+l 



a = l,2,...,l) (32) 



is computed, which gives the squares of the mini- 
mized Euclidean norms ||b,- - A * X.|| for all right- 
hand side column vectors B^ (j = 1, 2, . . . , 1). 

The only case in which the whole procedure can 
fail occurs when, at any stage k, no column with 
nonzero parameter ay^ can be found; that is, no non- 
zero main diagonal element can be generated. In 
this case, the rank of matrix A is less than n. With 
respect to roundoff errors, the test is made in the 
following way. 

At first, all elements s| ' are computed according 
to (28) and the maximum overall j (that is, ch is 
determined. With the relative tolerance £ given by 
ii^)ut, the following absolute tolerance is generated: 



tol = ff ■ e 



(33) 



SUSRCuriNE LLSQ 



TU SJLVt UNEAft LEAST StiUARES PROaLEMS, r.E. TJ niHlMia 
THE EUCLIOtA.^ NOAM OF a-A*X. WHtAE A IS A H dY N MATRIX 
WITH M >iDf LESS rHAN M. It* IHt SPfcLIAL CAst « = N iTSTEMS OF 
LINEAR cQJAriJNS HAY A£ iOLVtO. 



JSAi£ 

CALL LLbJ (A. 3i 



H<.^.i.,X.It>lV.EPS,lER.AUXI 



Jc^iCMIPT IUI>4 Ot^ PAKAHEli-RS 

A - ri dt H COEfflCIENF HiTHtK ( l/ESlRaVcO ) . 

.1 - A 6t L RIGHT MAtJJ SlJd MATRIX (Ut 5 Ti^GYciJl . 

A - RJW MUMSt^ UF MATRICES A ANO B. 

N - CJLJ** AlUMitR Qf MATRIX A. «0^ NUMiltR Of MATRIX » 

L - CJLJMN NUHdcR OF MATRICES & aNO X. 

Jt - ."i BY L SULUTIJN MATRIX. 

(PU - I.nTEGtR OUTPUT V£CTOR Gf uiM£f«siON M dNICH 

COMTAIftlS iNI-OrtMATlONi JN COLUMN INTcRCHANGES 

IN .HATRIX A. ISEc ReMAKK NO. 3). 
cPi - INPUT PAAAMSTC^. .JrtlCri SCtCIFItS A RELATIVc 

TJLcRANCt FJi* DcIERMIWATiaN OF RANK jf MATRIX A. 
I6H - A RESULTING ^lO-HOk PA-<AM6TeR. 

AUX - AJXILIARY STj-tAiit AA-tAY UF OIHc.^SUN M4«I2'N,L1. 

u.'J RETURN FIRST t LOCATIONS Of AUX CONTAIN TM€ 

RESULTING LEAST SSUAlcS. 

REMAftKS 

(It NJ AJTlu-^ dESIOEi EiRAOR MciSAGt I£A«-2 I.'^ CASE 
M LESS THAN N. 

(21 NO ACTIOM 6tSI0ES cRRO* MfiSSAGt IfcR — I IN CASE 
JF A ££RJ-MATftIX A. 

(Jl If KAI^K < Jf MAr?*IX A IS fJUNii 10 dE LESS THAN N dUT 
GREATER TrtAf« 0, THt PHOtEJURt RETURKIS HITH ERKUR COOE 
ItR=K INTO CALLING PROGRA.H. THE LAST N-X ELEHkNTS OF 
VcCTJR IPW jyENiTc TnE UStttSS COLUMNS IN MATRIX A, 
The H.iLAh.lniHO Ki^lfJL CJL'J-*.*S FORM A SASc 0.= MATRIX A. 

(<■) If Tfid p!luCcOUKt WAS SUCCciSfUL, tftrtOR PARAHtTEk lER 
IS SET TO 0. 

SUb'<UUTINES A.'^U FUfiCTldN SUflPKOGiirtMS RcdUIREU 



METHIjO 

Hu-UStMULJcR TRANSFGRrtATIOHS AR= JScU 10 TRANSFORM MATRIX 
TO UPPER TRIA.<«GULAR FO^-I. AFTER HAVING ApPLlEii THc SAMt 
TRANSrURMATION TO THE RIGHT HA.MJ SlOt MATRIX Hi AN 
APPROXIMATE SOLUTION Or THe P*lJ6LtM IS COmPuTEi) i»Y 
3ACit sUiJiriruTlUm. rOR RErcUcNLt, SEt 

i. wuLUd, '(OIEkICAL METHOlIS POR SOLVING LINEAR LEAST 
SQUARES PRJdLEMS, NUMERISCMt MATHtMATiK, VOl.7, 
ISS.3 (iq»5l, PP.20i-2l&. 



^UoRJjrlN: LLSJ(A.i.M,NtL.X*IPI V,£PS.IERtAUX| 

J1MENS10.V AU)<dUt .XI U.IPlVI 1 1, AUX (II 

ESHDR TEST 
If (M-.^J j'l,i,I 

GcNE^tATIJN JP Ii-IITIAL VECTOR SUI (-< = I,2 Nl In STOkAGc 

LOcATIUNi AiJAU) IX <1 « 2 1 . . . , 41 

1 PIV=0. 
ItNO'O 

00 4 i>.<ltN 
IP|W(HI =< 
M-0. 

IST-U.^QM 
lbNO-IEND«M 

uo z i>isr,icN-.) 

2 M-H*A( I MAI I I 
AUX(XJ-M 

If IH-?IV)-.,4.3 

KPIV»< 

* COMINJE 

ERROR r£>T 
IFIPI Vt31.3i.S 



OcfX'ii. r.Ji.tRANi,c J=JR CHECKING RAn< Or A 
SJG^SJRTI PIVl 
TJ(. = SIi*AjS(£PSI 



OcCOIPJSITI ON lUjP 
lH=L« ^ 

isr=-M 

CiG 21 <!|.N 

I ST=;sr*4*i 



LLSQ 
..LLSw 
LLSO 
LLSC 
LLSQ 
LLSQ 
LLSC 

LLSQ ao 

LLS;i 90 

LLSO ICO 

LLSQ UC! 

LLSd 120 

LLSQ liO 

LLSQ u:; 

LLSQ l&O 
LLSQ IttO 
LLSQ 170 
LLSG 180 
LLSQ 190 
LLSQ 200 
LLSQ liC 
LLSQ 22C 
LLSQ 230 
LLSU ^-iO 
LLSQ ^50 
LLSQ 260 
i LSg 2T3 
LlSQ 280 
LLSQ 290 
LLSQ 300 
LLSQ 313 
LLSQ 32C 
LLSQ iiZ 
LLSO i*C 
LLSQ 350 
LLSQ 3o3 
LLSQ Z1C 
LLSi; idC' 
LLSQ 39J 
LLSQ tOS 
LLSQ i>lC 
LLS& 'r2C 
LLSO ■»30 
1.LSC- <itC 
LLSQ ii1 
LLSQ <t&D 
LLSQ 47G 
LLSt 4feo 
A LLSQ 4'JC 
LLJQ 50G 
LLSQ >IC 
LLSw 520 
LLSc i>- 
LLSQ 3'fO 
LLS*/ 95C 
LLSu J33 
LLSQ 370 
...LLSQ 5dC 
LLSO 590 
t.LSQ 6j: 
LLSQ SIG 
cLSQ fiZ^i 
LL3Q &3C 

LLSQ 64D 

LLSQ 650 
LLSQ te60 
LL?Q 6/0 
LLSQ 690 
LLSQ fa-SO 
LLiu 7CJ 
LLSQ TIO 
LLSO 7 20 
LLSQ 730 
LLSQ 7-^0 
LLSy !•>) 
LLSQ 730 
LLSU 773 
LLSO 7d0 
LLS3 T90 

llSO JOJ 
llSu ai'j 

LlSQ dlO 
LLSQ J3a 
LLSQ 840 
LLSg d^O 
LLSQ d6C 
LLSQ d/0 
LLSQ ildO 
LLSQ 690 
LLSQ 900 
LLSQ 910 

LLSQ 'iz:: 

LLSQ 930 
LLSO ''i.O 
LLSQ 950 
LLSQ 96C 



162 Mathematics — Linear Equations 



CJLJHN Cf A WITH Ki'lV 



tft I Id. a. 6 

H=AUA(Al 
jlUKdtr*! V)=H 

00 7 l=lSt, Ur^D 
J=l»IfJ 
H=AI II 
A(l }=A( J) 



COMfjTAnJN jf -"AAAMETER SIG 

IF (K-I) 11.11.9 
SIC'C. 

JU iZ 1 = UT,1^N3 
iH,= 4IJ**( I 1«A[ It 

TEST U.-J SJ*i»iJLAalT¥ 



IN CASE KPIV.GT.K 



G£^cKATt C 
H = AllSr ) 



ci SI .;r-* Of pJA4MEr=fi 



ii>i v^<•»Ivl = lP^vl^ t 

IP|VUl=At>IV 



PARrt^cfL-f dtfA 

A( iiri = dtrA 

!)ETA=l./( jl^i'-iiiT^I 

J = N+K 

AU«{ j)=-iij 

iFlK-iNl li. 19, i'i 



Tj^ u.< !.■* -t-rH 



.:aLJ.'1N CF HATRIK i A\D OF 



Jf" MAIK[X A 



TkANiFJi-.i^TlL^ 
Pi V=J. 

i«.PU=J5T 

lju la j = Jil ,N 

ri^t . 

lJU 15 ! = I'jT, Ic Ml) 

I 1 = 1 » 1 J 
H=H*A( I I'rt( I I 1 

^( in --,.( 1 ! I-A( I I'M 
JPJ4fl»G OF cLtfii.-.T i(jj S 

i i = i>r*iu 

ri^Ajx( J i-A( in^Ai n I 

ttUXf J)=M 

lf(H-3iVU8,lS*W 

P[ V = M 

TriANSF J'^'IAf HIN ■])- KluHT r( ft. 

u\J 21 J=K,lH,.-1 
H=0. 

l::NJ= J*K-X 

n = isr 

UQ IJ l=JtlcNiJ 

H = H*A( I I l*o( 1) 

II = U*1 

01} 21 l = J,lcNJ 

1 1=1 i>i 

E;^u ue Dcco«pjsir UN loop 



bACK SJobriTuriUi>< *tiO balk liUtKCHdi 

I=N 

LN=L»N 

Kl V= l./AUX*2*NI 
UU 22 fv^N.LN.N 
X(Nl = PlV-»i(ll 
2e i=I*M 

1F( '*-l)2-3,lt.,2i 

00 23 J=2.N 

jsT = jir-»i-i 

K=N'-N+l-J 

PI V= 1./AJK(R J 

KSI = K.-N 

10=lPIVI^ST)-^iT 

IST=2-J 

UU 2t> K=l.L 

1 1= JiT 

UQ 2-t I = l3r,IttMJ 

ii = n*M 

Zt, h = H-AI 1 I I*x< I I 

A<i ) = j(( II I 

X( I 1 ) = PiV*H 
2b ^ST=^SI*M 



IN i-JcATiON 



lJMPJI AT 
2fa lsI=N*l 

00 29 J=1,L 

H=(M-M)2V.29.^ r 
11 uG ^3 1 =1 iT, IcN3 
2b rt = H+i:( I )*3| i I 

lSr=isr*H 

29 AJXiJI^H 

RETU'<N 



LLASr SyUAiltS 



LLSO -iTO 
LLSQ 'j?- 

LLSu <>9::; 

LLS JliOO 
LLSi^lClC 
LL&J1C20 
LLSQ103C 
LLSGICO 
LLSOiObi 
LLSU106: 
LLSUICTO 
LtStilC'BO 
LLSilC^O 
(-LSCllOC 
tLSClll3 
LLSUIUC 

tt.si:ii3j 

LLS^ll".: 
LLSwll^e 
t-LSwlloC 
LLS0li7; 
LLSUilBO 
LLSJ119: 

LLSQ1213 

LLSW122C 
LLSIJU3? 
LLSJl^'.^ 
LI.SJI251: 
LLSJIioC 
LLS012T: 
ILSQWS" 
LLSyu-J: 

LLSCIJCC 
LLSCUK' 

i.Lb^ij2 ; 

LLSClllJ" 

LLS3U-.: 

LLSJU5J 
».LSUli = : 

LLSgU70 

llSwUs: 

LLSOlii; 
LLS21*.,, 

Li.5wl''l : 

LL50t'-3C 

t-LSi-'lA-^C 



LLi 



11^5 



LLSUl'-a'-i 

LLi^lt'o 

LLSJlsSJ 

L'-SJl^i.'-:' 
LLSjl5 1C 
LLS3l^2C 

iLs^it>>; 

LLS0157; 

LLS3153.- 
tLSjl3^'" 
LLSwL6.'C 
LLSaioi-: 

LLSgi63- 

LL>Jlo-^C 

LLbJlboC 

LLS0ic7C 
LLSOlftiO 

l.LSgi7LC 
LL^mTlO 
1_LSJ1T23 
LLbai7 3C 
LLS317AJ 
i.LiUlT-jO 
LLSJ1T6C 
LL53177J 
LLSii7aO 
tLSJ179J 
LLSaiSO? 
uLSOlfilO 

LLSC133C 

tLiijia-.? 

LLSJlfisD 
LLSJ1660 
LLSC137-; 
llS jldd'J 
LLSwltJ*: 

LLSSl'Ji.'' 

LLS«i**2C> 
LI-SJ1933 
LLS:«19<.: 
LLSwliSC 
LLSul5oL 
LLS3197: 
LLiQl9&L 
LLSQls-'s: 
H.S'J2,CC 



LLi J 



- lO 



LLSy2u3C 
lLS020'.C; 
LL5g2obO 
LLS02C6C 
LLSU2CTC 
lLS<J20dO 

1.LS02IOC 
LLS021 \Z 
LLSg^l2C 
LLS0213C 
LLSOil^O 
LL5g215C 
LLSJ2160 
LLSQ2170 

LLSOiiac 

LLSa219C 
LLSO220C 
LLS022K 
LLSQ222C 
LLSQ223C 
LLSG224C 
LLSa22iC 



tKKufi ftEIUAN IN CASE 1 LESS THA<Y N 

30 l£R=-2 
RtTURN 

t«RClR RETURN IN CASE OF iERQ-MATflU A 

31 l€R=-l 
RETURN 

tRROR RErURh IN CASE OF RANK JF MATRIX A LESS THAN N 
3i IER=K-l 

RETURN 
END 



SuemouTlr^c JllSj 

PUkPCSt 

Tu sJLVc lIN.-AR LcAST SJJAKJS PftJtiLEHS. I.E. TJ HINIHIZt 
Trie £jCLIu>rAN NJ'<M Ur 5-a»X, ^rHtRE A IS A M d Y ,M JlAIftlK 
-ilTri M .^JT LcSi THAN H. Ix THi SPtClAL CASE H = N SYSTEMS 
LiNcAS c3UAr(JNi HAY 6'i SuLtftJ. 



.L.K.lPlV.cP:,.[EH.AUXr 

OcSCklPTlO.N JF ^AKAMcT£KS 

A - JJUoLfc PRct;iSIJ:«i rt oY i-J COEFFlCiENT MATKIX 

( JtiTKJYfcO) . 
d - JJUJLt PRt;,ISlJN « aV L RIGHT HAfilJ iltic MATRIX 

( JcSTROYED) , 
1 - liJrt NUMtJt-* iJf rt-TRlCiS a AhO a. 

,^ - CdLJMN ^^J^^ocR JF HaTkIx a. row NUM3cR JF MATRIX X. 

L ~ CJLUMN NUMbc« JF HATRICcS b ANO X. 

< - JOJtoLt PRcCISlJ.'^ N bY L SOLUTION HAIAIK. 

.f>iV - LVItjcA OUTPUT i/cCTUR UF OIMENSIUN N l*^ICH 

CJi^TAlNa I.\ifORHAT10NS &N LOLUrt\ INTchCHANGES 

lA '(aTRIK a. (SEE REM-RK NO. 31. 
,;PS - SlNJLt P»,tCJSl3i^ INPuT PASAMtTER h/H Urt SPECIFIES 

A RELATIVE TOLcftrtNCE Fji< Jt Tt RMI NAT I JN UF RANK OF 

M^TKIX A. 
It^ - A RtsJLTlOiS t.<:i]R PAr<A;^tI£R. 

AUA - A UUJ3LE PftcClSIJN AJXlclARY STJRAGt ARKAY JF 

i3]-l£f^SI0f>( .-lAXi jJtN . L I . ON RETURN FIRST L LOCATIUNS 

Ur Ajx CuNTAiN FHc RciULTINC LEJST SjUARES. 



( n 


Nj ACIIJiV 3c: 




M LciS THA.N 1 


I ^'1 


.jij A^TIu.^ B£ 




Lf A ^ERJ-MA 


I 31 


IF ■<A.\\ ^ UF 




u-lcATcR THAN 




IcR = K UTU C. 




VciCTOR IPIV . 




Inc kc^lAlNlN; 


(iJ 


IF THE PRJCfci 




IS SET lU 0. 



SiLl^ 



RJR MtjSAiiE lfcR=-2 IN CAit 



lAGE It 



l=-l 



SUES c-tRUK 
TRIX A. 
MATRIX A IS ?^\iHo TC o€ LcSS TMArt N bUT 
C. HE PRUCEJURE AETJRNS wI Trt c RROt* CODE 
ALLING PRaGRArt. Trtt LAST N-K cLEmENTS OF 
JtNJTE THE USELESS COLUMNj IN KATkIx A. 
IG USEFUL COLJ^^S FORM A BaSc Of MATRIX A, 
iJuRi: WAS SUCCciSrUL, ERROR PARAMETER l£R 



iJb'^OJriNis A.j'j FU.^CTiCN aUaJ'RUw'iAHS RcgUIAEJ 

%3NE 

HJuicHl,Li-c« rRA.-^SFJR-^ATIJNS A<E JSEJ fU IkANSrURp4 MATRIX 
ro UPfER r^[ANCULA^ F>j<:4. rtFTc.-t HAVING APPlIc^ ThE SAHt 
fK^^SF^RMATION rn The ^UHI HA^J SluE iHATKlX bt AN 
Ar-P-NJXlMAT^ SOLJTIUN OF \ Ml ^AJjLt.H IS CUM^UT^J dV 
dAi.ik itiBiriTJTIOM. FOR RcFcRt.^Cc. SEE 

J, juLUd, NUHESICAL f.tTriOJS FJR SOLVlNj LINEAR LdAST 
aJdAKtS Pi<l,Sl::MS, NOMcRiiCHc .■^-THEMATI A , VOL.7, 
lis. 3 U-»o-jU PP.2C6-216. 



Ir*! V.tPS.lcR.AUXl 



JIMEi^ilCV A[i(,o(l),XUJ. IPIVtD.AUXUJ 
L/OJdLc PRECISIjN a, [J,X,AUX,PlV,ri,SU,6tTA,TjL 



>jENtRAriO'< UF i.'^ITiAL VECTG^ jIi<I I i^'' i , 2 , . , . ,NI I.N SIJRA&c 
LOLATIJNS AUKIKI ( K =1, 2, . . . , '^I 

1 PIV = D.l10 

LO '. «=l,N 
IPIVI Kl=i( 

H = C .iJO 

isr= it^ju'-i 



IE 



J- I.- 



ou 2 i= !iT 


,1 


^> M = n*Al i J»ft 


( 1 


AUX(<J =r( 




JF(ri-Pl Vl* 


• '• 


i PIW=H 




KP1V=.< 




"i i,l;nt].\jc 




cR^Urf Ttil 




iF(PIVMl, 


31 



jtFI.Vt Ti^LcRA.^Ct FORCHfcCKIS: RAMI. jE 
SIO^JSJRTIPI VI 
rCL=SI^*ADS(cPS I 



iJECu-HpJSI TIvjN lOJP 
LM^L''"*! 



IST = 

LiD £1 < = 1 ,N 

isr=is) *M*i 

UNJ=i i^♦M-^ 
I = KPJ V-"- 
IF ( I la,a, D 

IMcftCrtANJE ^-^H CJLUMN (JF A WITH <p I i/_ jh IN CASE KPJV.JT.K 
6 tl=AUX(K) 

A^JX1^) =AUX(RP1V» 
AUXI KPl V)=H 

ID-]*« 

i/O 7 I = lST,iE.MJ 



LLS02260 
LLSQ22T0 
ILS02260 
LLS02290 
LLSQ2300 
LLSQ2310 
LLSQ2320 
LLSU2i30 
LLSQ23^0 
LLS02350 
LLSQ2360 
LLSQ2370 



DLLS 10 

•DLLS 2C 

DLLS 3C 

DLLS '.C 

OLLS 5: 

CLLS bC 

OLLS 7C 

ULLS dC 

3LLS *#: 

JLLS luO 

DLLS 110 

DLLS 12c 

OLLS l3C 

ULlS I've 

OLLS 15C 

OLLi ItiC 

UL Li 1 70 

DLLS IbO 

ULLS i9i 

DLLS 2CC 

OLLS 210 

DLLS liZ 

DLLS 2jC 

OLLS 2*.^ 

OLLS 230 

OLLS 2(.'; 

OLLS 273 

OLLS 2 30 

UlLS 29J 

OLLS 33;J' 

OLLS JIC 

OLLS hi:i 

tJLLS 33: 

OLLS 3'.0 

ULLS 3iC 

uLLS 350 

ULLS 37C 

OuLi 33C 

DLLS -yiz 

OLLS tO? 

OLLS -ilO 

OLLS «.2a 



DLLS '.'.0 

DLLS -SO 

DLLS '.6C 

OLLS 1.7C 

OLLS 'iSC 

OLLS <.90 

OLLS 500 

DLLS 3i3 

LiLLS 520 



DLLS 15:- 

OLLS 3oC 
OLLS 570 
OLLS SbC 
OLLS 5 9' 
DLLS 6J.. 
..OLLS 610 
OLLS 6 20 
JLlS biO 
OLLS ©-"J 
OLLS o50 
OLLS 660 
DLLS 670 
OLLS 63; 
OllS o'JO 
OLLS 700 
CLLS 71: 
DLLS 72D 
OLLS 73C 
OLLS 7^,0 
OLLS 7br 
OlLS 7oO 
DLLS 7 70 

:;lls 73C 
OLLS 7^^: 

OLLS 69: 

DLLS die 

OLLS a^: 

OLLS 33^ 

OLLS •j'tC 

OLLS d5C- 

DLLS 3oC 

OLLS i7C 
OLLS afiC 
DLLS d-JC 

OLLS 5';o 

OLL5 91C 

DLLS ')2C 

OLLS 930 

DLLa 9',C 

DLLS 9o0 
DLLS S7r 
OLLS S30 
DLLS '»9r 
DLLSIOOC 
OLLSiaiC 
0LLS1C2C 
DLLSniC 
OLLSlCfO 
DLLS 1030 
OLLS1063 
DLLS1070 
OLLSlOdO 
DLLSIO-JO" 
OLLSl ICC 
DLL SI 1 IC 



Mathematics- -Linear Equations 163 



Am = A( J 

7 A(JI=H 

CGMPUTAFllJN OF P^flAMETFO SIG 

8 iF(K-lt Utn,9 

9 blG = O.L)C 

uQ iC I=IST, r^hO 

ic 5iG = sio+A( r)*Ai 1 1 

Si:i=0:.gKT ISiGI 

TtST GN SIN&ULAKI IV 
in biu-TOL I j^ti^. 11 

OtNcRAit l-jkkcCT SIGN UF P&H&neXtR 

11 H=n isr } 

IFIH] I^.i3,l3 

S^VC l.UtRCHAf^G:: Ji-^FdRWfil ION 
L3 iPlVlKPlvt^lPlVi^i 
IPIVK) ^^^>IV 

GtNtKiriiJU 0.= vfcLTui* U« IN K-TH CCLi 

PARAMcrtfi ritTA 

eETA^HtSIG 

"( isn=iitrA 

tCTA=i.i>3/( 5Ii*dfcTA I 

J = N*t( 

Aux( j) = -sii; 

IFU-N)U,lv,19 



KPlv=jsr 

uCi 16 J = jST ,N 

H=U.OC 

L>u 15 1 =isr, it« 

(! = 1*1 J 

M = h*A( I )*A(!f ) 

H=DbrA»M 



AIRIX A AND OF 



uc lo i ^ isr , icNo 

Ai I 1 J =A( 1 I 1-A( I JfH 

UPOATi^MG OF cLeMEiVr S(jt STJScJ IH LJlATION AUKIJI 

ii = isr. ID 

H=AUXI J )-A( I I l«a( I I ) 

AUX( J)=H 



) la. 



17 t>lV = H 
KPl V = J 

id CUNflF'Jje 

rKA.^if. JKMAT luM I 
19 00 Z\. J=K,L 1, 1 



= 1=.I 



H = M»A( I H*ai I ) 
2C 11=11+1 

H=dEra»H 
11 = lii 

^0 21 I=J,lcNO 

bli ) = j( I }-a( II )'*^ 
?i H = I I*i 

tNj Or JSCJHPJS ir i:JN LOOP 



BALK. ijasTirjr iLi'i and aflC< inteschaw!.; 



I = N 

LK=L*H 

•'I V- I. JC/AUA(2» 
JU i^ < = N,L.'<.< 
mK) = Pi V*3( I ) 

^^ i = \*!\ 

iF(N-l| Zt,i>i,ii 

■JO ^i J^^.N 

JST-JST-H-l 

R=NtM*l-j 

PI V= I. JO/AUXIK) 

K.Sr = K-N 

ia=IPH^{n,iTJ-KSl 

IST=£-j 

OO ^5 i». = l,L 

M=fliK3r ) 
lsi=isrt\ 
ifcNLj^i ;t+j-2 
i i=jsr 

JC 2-, I = IST, IcNl 

Zi, H = H-A[ 1 I |*X( I J 
I =1SI-1 

il= 1+13 

K( n = x[ m 

X( I f ) = P| V.H 

25 <iT-KSr*« 



COHPuranoN :;f l^a^t squares 

i.b 1ST = N«1 

itND=C 

CO 29 J=1,L 

lENO=ieNiJ»M 

2b H=M+a( I )*B( I } 
isr=:isrtH 

i9 AUX1J)=H 
SETUkN 



tRKOK RtrURN 
ItR=-2 

RETURN 



N CAiE M LESS THAN N 



ERROR -terUf^N IN CASi OF ZERU-MAFRIX A 
31 IER=-t 

RETURN 

cRRljR <tTURN Ifti CASE Llf RANK UF MATRIX ;. LtSS TH 

RETURN 
trio 



0H.S113C 
DLLSii.,0 
01.LSH5C 
OLlSllbO 
OLL&il70 
0LLS1180 
DLLS 11 9C 
0LLS120C 
DLLS121C 
DLLS122C 
OLLSliBC 
iJLL 312^0 
0LL3U;>C 
CLLSld6C 
DLLil27C 
OLLSl^SD 
0LLSU9C 
ULLSli:JL 
0LLS131G 
DLLS! 3 2-, 
OLLSl J3C 
OLLSlii-O 
i>LLS13^C 
OLLSlsaO 
OLLSl WC 
ULLSI jdC 
0LLS139C 

DLLSl'flC 



ULLSl 



.20 



!:jllsu30 

OLLSli-iC 
ULLSUiiC 
uLLSlt-TC 
i3LLSl-*aO 
JLLbK-^C 
DL L S 1 :i "O 

JLLSiii-; 

iJ..LSl52& 

3LLS1550 
OLLSIs'.U 
OLLSI53Q 
ULLS130C 
CLLil&70 
ULLS11J3C 
DLLSIS-JO 
OLtilbOC 
JLlSlb 10 
L1LL51620 
JLLS1630 
0LlS16^l:- 
OLLS1&50 
DLLSiboT 

iJLLSLo 7C 

DLLSlfc'JO 
i/LLSlu9L- 
DLL Si 7: 3 
0LLS17 10 
ULLSi72C 

ULLil? Ji 

ULLSl?;.': 

JLLS175:; 

OLLS1750 
DLLS 1770 

DLLS17(I0 

JLLS179C 

OLLSldOO 

ULLSidi: 

1JLLSU20 
OLLSlJiJ 
JLLSia<.C 
OLLS193C 
OLLii doO 



JLL 



.ld70 



JLLbiSdJ 
0LLSid9O 
ULLSt9"S 
JLLSl^lC 
DLLSW2: 
JLLSW3J 
Jlj.ilQ'.C 
OLLSiqSO 
JLLS19aJ 
0LLS1^7C 
OLLSlSdi 
OCLS199C 
OLLS20GC 
0LLS2r?ig 
JLLS2J2Q 
JLLSiD3G 
OLLS2C*fO 
OLLi2050 
OlLS2:60 
yLLS2C7C 
i)LLS2L80 
01.LS209C 

JLLS^1?C 

aLLS2L10 
LtLLS2120 
0LLSi;i3O 
DLLS21',0 
i)LLS^i50 
DLLS21bC 
JLLS217C 
iJLLS2l80 
L(LLS2190 
LtLLS223C 
DLLS2410 
DLLS2i2C 
i:JLLS22 3C 

(J(.LS2250 
DLLi2260 
0LLb£270 
ULLS2^B0 
0LLS229C 
UlLSZjCc 
OLLS23 10 
0LLS2320 
aLLS2 3 30 
0LLS2)'.0 
ULLS2350 
OLLS236C 
D(-LS2370 
DLLS23aO 
0LLS^390 
JLLS2'.C0 
OLLS2'41D 



Matrices: Eigenanalysis and Rela ted Topics 
Subroutine EIGEN 

This subroutine computes the eigenvalues and eigen- 
vectors of a real symmetric matrix. 

Given a symmetric matrix A of order N, eigen- 
values are to be developed in the diagonal elements 
of the matrix. A matrix of eigenvectors R is also 
to be generated. 

An identity matrix is used as a first approxima- 
tion of R. 

The initial off -diagonal norm is computed: 



^A-.-r 



(1) 



v^ = initial norm 

A = input matrix (symmetric) 

This norm is divided by N at each stage to produce 
the threshold. 

The final norm is computed: 

-6 



''f=- 



V X 10 



N 



(2) 



This final norm is set sufficiently small that the 
requirement that any off-diagonal element A^j^ shall 
be smaller than i^ ia absolute magnitude defines 
the convergence of the process. 

An indicator is initialized. This indicator is 
later used to determine whether any off-diagonal 
elements have been found that are greater than the 
present threshold. 

Each off-diagonal element is selected in turn and 
a transformation is performed to annihilate the off- 
diagonal (pivotal) element, as shown by the following 
equations: 



X = -A 



Im 

1/2 (A„ - A ) 
^ 11 mm' 



w = sign (M) 



sin 6 = 






'V2(l+Vl 
cos 8 = yj 1- sin^ e 



c^^ 



(3) 
(4) 

(5) 
(6) 

(7) 



164 Mathematics— Matrices: Eigenanalysis 



B = A., cos 6 - A. sinfl 
il im 

A = A., sin + A cos 
im il im 

A^^=B 

B = R , cos e - R. sin 6 
il im 

R = R., sin + R. cos 6 
ira u im 

R, = B 
il 

2 2 

A,, = A cos e + A sin i 
11 11 mm 

- 2A, sin Q cos 6 



'\ 



o 2 

A = A„ sin^e + A cos ( 



(8) 






DO 10 J-l.N 

00 20 fi.N 
IJ-IQ+I 


(9) 






IfU-JI 20,15,20 




15 


RI1J)-1.0 




C 

c 
c 


20 


CONTINUE 


(10) 




CUnpUTE iNiriAL AND FINAL 






25 


iNORM*0.0 
DO ii I'ltH 


(11) 






00 iS J-I,N 

IFII-J) 30.35,30 






>0 


IA-I*(J»J-J|/2 
ANOAM-ANORH'»A(lA}*AIIA) 






33 CJhrlNUE 


(12) 






IFIANORMI lbS,16S,4C 




*0 


AIMJAh- 1 .4L4«SQAT I ANOAN ) 




c 

c 




ANRHX>ANUIM«HANSe/FLOATIN} 


(13) 




INiriALt2t INOICATORS AND i 


c 












JMO-0 








IHR-ANOHH 






45 


THR»TH*/FCaAr(N» 






5C 


L-l 






55 


H>L*1 




c 








c 




COMPUTc >IN ANO COS 


(14) 


c 


60 


H0>(H«N-K)/2 
i.g-IL*L-Ll/2 

LH-L*«0 






6^ 


If* ABiUUMII-rrifll i30»65,65 



mm II 



mm 



+ 2A, sin cos ( 
Im 



^m " <^11" Vm) sine cose 

+ A, (cos^ e - sin^ e) 
Im 



(15) 



(16) 



The above calculations are repeated until all of the 
pivotal elements are less than the threshold. 



SUBROUTINE fcli^tN 

PURPOSE 

CUNPUTE EUEMVALUtS ANJ £ I I^ENVcC TORS OF A R£AL SCNHeTRIC 
MATRIX 



uSAoe 

CALL €IGeN(A,RiN, 



IVI 



DfcSCRIPTION OF PA«AHET£RS 

A - URIOIKAL HATRIX (SrMHETKICI, OCSTROYEO IN COriPUTAriQN. 

HtSJLTAKlT EIGENVALUES ARE MVELOPEO IN OlAi^ONAL OF 

HATRIX A IN DESCtNOINC OROER. 
ft - RESULTANT HATRIX OF EI&LNVtCTCHS (STOREQ CULUHNItl SE . 

IN sahe sequence as eigenvalues) 

H - ufU'ER JF HATRICES A ANU R 
HV- INPUT COJE 

COhPuTE eigenvalues ANO EIGENVECTORS 

1 COHPUTE EIGENVALUES ONLY IR NEcC NOT 6t 
JIHENSlONfcO BUT HUST STILL AppfcAH IN CALLING 
StOUENCt) 

REHAKKS 

ORIGINAL MATRIX A HUST dE REAL SYMMETRIC ISIORAGfc HOOE-U 
HATRIX A CANNOT bt IN THE SAHE LOCATION AS HATRIX R 

SUdRUUTINES t.-iD FUNCTION SU3PK0GHAHS REOUlRcO 
NONE 

HcTHOO 

OUGCNALUATION METHOD ORIGINATED BY JACOEI ANO ADAPTED 
dV VCN NE0-4ANN FOR lAmGE COMPJTtRS AS FGUNU IN 'HMTH£HaTIC< 
ilETHOOS FOR DIOITAl COHPUTERS*. ECITEO 8Y A. RALSTON ANO 
H.S. WIlFi JJHN WILEY ANd SONS, M£t* YORK, 1962, CHAPTER ? 



iJBRjUTlNE tlu£<'4l A,R.N.HVI 
OIHEHSICN AlUtttlll 



IF A UUUBLfc P-^eCISION VERSION Of THIS ROUTINE IS «£ilR£0, THE 
C IN COLUMN I SHOULD BE REHOVEO FRGH TH£ DOUBLE PAcCISION 
ilAIEHENT *MICH FULLO'iS. 

UJU&Cc PRECISIUN A,R.AN0RH,ANRHX.THR,X.V.S1NX,SINX2,C0SX* 
1 CJSX2. bINCS,RAi4GE 

THE C MUST ALiU Bfc' REMOVfJ FROM DOUbL£ fiRELlSlUN HArtHtNTS 
APPEARING IN OTHER ROUTINES UStO IN CONJUNCTION WITH THIS 
ROUTINE. 



EIGE 10 

. .ElGE 2C 

£1G£ iO 

EIGE <.0 

eiGE 50 

EIGE bO 

EIGE 70 

EIGE 60 

EIGE 90 

EIGE 100 

EIGE 110 

EiGE 120 

EIGE 130 

EIGE I'fO 

€1GE ISO 

EIGE 160 

EIGE I'O 

EIGE 130 

tlGE I9C 

£IGE 20C 

EIGE 210 

EIGE 220 

EIGE 230 

EIGE 2*0 

tIGE ^5C 

EIGE 260 

tlGE no 

EIGE 2B0 

EIuE 290 

tIGE 3CC 

EIGE 310 

EIGe 3^0' 

EIGE 330 

EIGfc i'*C 

kLElGE 3bO 

tIGE 360 

cJCE J70 

EIGE iac 

,tIGE 390 

£jce too 

EIGE 410 
EIGt HZO 
eiGE t30 
.EIGE -iAC 
EIGE *iiC 
EIGE 460 
EIGE *.T0 
EIGE *8C 
EIGE 
EIGE 
EIGE 
EIGE 
EIGt 
EIGE 
EIGE 



IGE 

EIGE 



THE OJkJdLt PRECISION VERSION OF THIS SUfiROUTINt HUST ALSO 
CJNTAIN COUSLc PRECISION FORTRAN FUNCTIONS. SOf«I IN STATENENTSEI 
40. 68. 75, ASO 78 HUSf Be CMANGcJ TO OSQRT. ABS IN STATEMENT EIGt 
62 MUST d£ CHANGcU TQ OASS. THE CONSTANT IN STATEHENT 5 SHOULD 
at CHANGtO TC I.CO-12. 



GENtkAlE lOtNIITV MATRIX 



•iANGt=1.0E-6 
IflHV-U 10,25, 



cIGE 

EIGE 
tlGE 
EIGE 
tIGE 
EIGE 
EIGE 
EIGE 
EIGE 
cISE 



5C0 
>1G 
52C 
6iO 
&4C 
5SC 
bbO 
570 
580 
5'JC 
6C0 
610 
i20 
6 3C 



o5 INU-l 

LL-L*LO 

X*G.5*4 A(LLI-A( HHH 
6S Y=-A|LN)/ SORTIAlLN)«A(LHt*N*K) 

IFIXI 70,75,75 
TO V"-Y 
75 aINX>Y/ SORII2.0«U.O+I SQHn 1.0-Y*YII I 1 

SINX2*SINX«&IHX 
73 COSX- SQRTI1.0-SINX2) 

C0SX2"C0SA*CCSX 

SINCS -SINX*C0SX 

ROTATE L AND H CULUHhS 

ILU>M*(L-I) 
IM«*N*(M-XJ 
OG 125 I>I.h 
IQ*U*t-l)/2 

iFii-L) aoai5.eo 

8C IFII-Ml 45,115,90 
65 iH'ltMU 

CO TO 95 
90 1H-H*lg 

95 IFII-L) 10C,ICS,1C5 
ICC IL-I»LQ 

GO TO IIJ 
105 lL»L»lti 
110 X-AIIL)*CO$X-A( IM)*SINX 

A(IMI*A(ILI«SINX*A( fMt*COSX 

AdLt'X 
115 IF(HV-|I 120*125, I2C 
12C ILR-lLiJ + I 

IK««IMJ»I 

X-RCUR)»COSX-ft(lHRJ*SINX 

RUHrt)»R! ILRj*Si<-4X*H( IMRI*C0SX 

RlUkj'X 
125 LONTINJE 

X*2.C*AILHI*SINCS 

Y«A(LL)*L0SX2*A(«IMI*SINX2-X 

X-A<LL)*SINX2*AIHHI •C0SX2-*X 

AlLM)-(AlLLl-A(HHll»SIKC$4^A(LHt*(C0&X2-SINX2l 

A(LLI*Y 

A(HH)-X 



rtSrS FOK CUHPLEIION 
TEST FOR M ■ LAST COLUHn 



130 IFIH-NI 115.140,135 

135 M«H*l 

GU TO 60 
C 
C TEST FtM L « SECOND FROM LAST CULUHN 

14C IFlL-U-l»I 1*5,150,145 
145 L«L*1 

GO ru 55 

I3C IF<IND-1) 16C,155,16C 
155 IND*0 

GO TO 50 

I COMPARE THRESHOLQ tflTH FINAL NORM 

16C IFITHR-AMRHXt 165,165.45 

: SJ*T EIGENVALJti ANO £ I Cei^VEC TORS 

165 iO»-N 

00 1S5 I-I,N 

LL-l*(l*l-ll/2 
JQ-N*( I-2> 
00 185 J-I.N 

JU-JOtN 
HM-J*( J«J-JI/2 

ifiUiihUHHw nOfiis*[is 

17C X>A(LLI 

A{LL)'A(HH) 

A(MM}«X 

IFIHV-ll 175*185,175 
175 DO 1«C K-1,N 

]LR-IO*K 

IHR>JO-»R 

X-RllLAt 

R(lLRI-fc([HRJ 
laC R( IHRJ*X 
laS CONTINUE 

KETURN 

END 



EIGE TOO 

EIGE 710 

EIGE 720 

EIGE 730 

EIGE 740 

EIGE 7SC 

EIGE T60 

EIGE 770 

EIGE TaO 

EIGE T90 

EIGE 80C 

ElGE 810 

EIGE B20 

EIGE SiO 

EIGE 840 

EIGE 85Q 

EICE 860 

EIG£ 870 

EIGE 880 

EJC£ 890 

EIGE 90C 

EIGE 910 

CIGE 920 

EIGE 930 

EIGE 940 

EIGE 950 

EIGE 960 

EIGE *70 

EICE 980 

EIGE 990 

EIGEIOOC 

EIGEIOIO 

EIGE1020 

EICEIC3C 

£IGEli:4C 

EI6E105C 

ElSElCbO 

tIGElCTO 

EIGEIOBO 

EIGE1C90 

EIGEllQG 

EIGEUIC 

eiGEI120 

CIGE113C 

EIGE1140 

EI&E115C 

E1GE1160 

EIGEllTO 

EIGEllBO 

£iGEU90 

EIGE1200 

EIGE 1210 

EIGE1220 

E1GE1230 

EIGE124C 

ElGfcl250 

EIGE126C 

£IG£1^7C 

EIGE 1280 

£IG£1290 

EICE13CC 

EIGEUIC 

EIGE132C 

£IG£ti3C 

EIGE134C 

E1GE1J5C 

EIGEI360 

EIGE137C 

EIGE1380 

EIGE1J9C 

EIGE14CIC 

£1GEI41C 

tIGEl*2C 

clGEl*3C 

£IGtl<.4C 

£IGEi*5C 

EICE1460 

CIGE147C 

EIGEUac 

tIGE149C 

EIGE 1500 

EI&E1510 

tIGE152C 

£IG£1530 

EIGEI54C 

tlGtl550 

t IGE 1560 

EIGE1570 

£IG£158C 

EIGE1590 

CIGEI6C0 

;ClCE1610 

EIGE 16 20 
EIGEi6 3~ 
£1G£16<40 
ElGE 16^0 
EICE 1660 
EIGE 1670 
EI&E16t)0 
tIGE1690 
EIGCUOO 
EIGE1710 
EIGC1720 
blCElT30 
t IGE 1740 
EICE175C 
fcIG£1760 
EIGE1770 
tlGtl780~ 
EIGE1790 
EICEiatC 
EICE1810 

EIGei83C 
E.fG£J84Cl 
EIGE185C 
E1GE1S6G 
ciGE187C 
EIGElaSO 
EI6Eia90 
EIGE1900 
clGE19lC 
EICE1920 
EICE 1930 
EIGE1940 
E1GE1950 



Mathematics — Matrices: Eigenanalysis 165 



Subroutine NROOT 

This subroutine calculates the eigenvalues, Xj, and 
the matrix of eigenvectors, V, of a real square non- 
symmetric matrix of the special form B'Ia, where 
both B and A are real symmetric matrices and B is 
positive-definite. This subroutine is normally 
called by the subroutine CANOR in performing a 
canonical correlation analysis. The computational 
steps are as follows. 

A symmetric matrix (storage mode 1) is formed 
by using the upper triangle elements of the square 
matrix B. Then the eigenvalues, hj, and the 
matrix of eigenvectors, H, of the symmetric matrix 
are calculated by the subroutine EIGEN. 

The reciprocal of square root of each eigenvalue 
is formed as follows: 



ANO X. 



where i = 1, 2, .... m 

m = order of matrix B 



(1) 



ith 



The matrix B~l/2 jg formed by multiplying the 



j"-" column vector of H by ^j, where j = 1. 2 m. 

The symmetric matrix S= (B~l/2)' AB~l/2 ^g 
formed in the following two matrix multiplications: 



Q=(b"^/2)'A 



S = QB 



-1/2 



(2) 
(3) 



and eigenvalues, Aj, and the matrix of eigenvectors, 
M, of S are calculated by the subroutine EIGEN. 

The matrix W = fi-l/^M is formed, and the 
vectors in W are normalized to form the matrix of 
eigenvectors, V, by the following equation: 



v.. 

ij 
where 



W-- 



V 



SUMV. 
J 

i = 1. 2. 



(4) 



] 



1, 2, ., 



m 
m 



m 

SUMV. = y; 

J ,-1 



W. 



(5) 



SUBROUTINE NROOT 

PURPOSE 

COMPUTE EIGENVALUES *N0 EIGENVECTORS Of * REAL NONSVMMETRIC 
NATRIK OF THE FORM 6-INVERSE TIMES *. THIS SUflROUTINE IS 
NORMALLY CALLED BY SUBROUflNE CANOR IN PERFORMING A 
CANONICAL CORRELATION ANALYSIS. 



20 



USAGE 

CALL NROOT 



IM.A.B.XL.Kl 



NROO 
. NROQ 
NROn 
NROO t,Q 
NROO 5 3 
NROO 60 
NROO TO 

NROO ao 

NROO 9C 

NROO 100 

NROO LIO 

NROO 120 

NROO 130 

NROO K.0 



DESCRIPTION Of PARAMETERS 

M - ORDER OF SgUARE MATRICES 

A - INPUT MATRIK (M X Ml . 

6 - INPUT MATRIX (H X Ml. 

XL - OUTPUT VECTOR OF LENGTH H CONTAINING EIGENVALUES Of 

R-INVERSE TIMES A. 
K - OUTPUT MATRIX (M X Ml CONTAINING EIGENVECTORS tOLUMN- 

REMARKS 
NONE 

SUBROUTINES ANO FUNCTION SUBPROGRAMS RCQUIREO 
EIGEN 



REFER TO M. rf. COOLEY AMD P. R. LQHNfS, ■ MUL ( I VAR I AT t PHII- 
9!f"^**^^.''9?-^"f BEHAVIORAL SCIENCES'. JOHN UlLEY ANO SONS. 



1^62, CHAPTER i. 



NKUii I SO 

NMIICt tti^ 

NMCIII 1 tc 

NHIII] I HD 

NHIXI ■'(() 

NHIHI /OO 
NH(HJ ^'10 
NROO ^/O 

NHCJI) p to 

NKUO ;"iO 
NROI) ?^0 
NRnt) 2«iO 

NRon ^ro 

NKdO 2B0 
NttOU 29 
NHdO IQO 
NROO 110 
NMIJd »2f: 



SURRQUTINE NROOT (H. A, 6. XL, XI 
DIMENSION A( II ,aU) .KLll l,K( II 



IF A OOUBLE PRECISION VFRSION OF THIS RnUTlNt IS DLSIRtO, I 
C IN COLUMN I SHOULD BE REMOVED FROM THE OOUHLE PRtCISION 
STATEMENT WHICH FOLLOWS. 

OOUBLE PRECISION A, 8, XL . X, SUMV 

IHE C MUST ALSO BE REMOVED FROM DUUHLt PRECISION STAItMfNIS 
APPEARING IN OTHER ROUTINES USED IN CUNJUNtTION WITH IHIS 
ROUT INE. 

THE DOUBLE PRECISION VERSHf^ Of THIS SUBROUMNF MuS T At ill nrciii 

CONTAIN OOUBLE PRtCISION FORTRAN FONCIIONS. SORT IN SlATt 
no ANO 175 MUSI BE CHANGtO TO OSQMI, ABS IN SIATtMtNf it 
MUST BE CHANGED TO DABS. 



, .NKOt) ISO 
NKOU 160 

NHfU] iro 

NH(ii) mo 

NHOU J40 
.NKOll -4 00 

NROO 410 
NROO 420 
NROO 4 30 
NROO 4t4C 
NRurj 45? 

NRfin 4&0 

NHOII 4 70 
NROn 4iO 
NHUU 49^ 

NROll blO 
NRIIO SIO 



COHPUIt EIGENVALUES AMD flGENVECTORS OF 6 

00 100 J=2,M 
L=M*( J-1) 
DO 100 J-1, J 
L=L*1 



C THE MATRIX fl IS A REAL SYMMETRIC MATRIX. 

MV = 

CALL EIGEN «B.X,M,MVl 
C 

C fORM RECIPROCALS OF SQUARE H03T OF EICENVAluFS. tH( RtSuiT 

C ARE PREMULTIPLIEO BY THE ASSOCIATED EIGENVECTORS. 

L = 

DO 1 10 J=1,M 
L«L»J 
no XL(JI = L.O/ SORTI ABSiaiDI) 
K=0 

00 115 J^l.M 
00 115 l=t,M 

115 B<K»iX(K)»XL(Jl 
C 

C FORM ( e**(-|/2l JPRIME • A ♦ {a**l-|/'2|| 

C 

00 120 1=1, M 
N2-0 

00 120 J=l,M 
N1=M*(I-|I 
L=M*IJ-1) »| 
X(LI=0,C 
00 120 K=1,M 
NI = NI*^I 
N2«N2*l 
I2D X(L)-X(LI *6(N1)«A(N2) 
L-0 

00 130 J=|,M 
00 130 I- I, J 
NI'I -M 
N2-M*|J-ll 
L-L*l 
AILI-0.0 
00 130 K=l,H 
Nl = Nl«-M 
N2=N2»I 
130 A(LI=AtLl«^XINll*B(N2l 
C 

C COMPUTE EIGENVALUES ANO EIGENVECTORS OF A 

C 

CALL EIGEN (A,X,M,MV) 
C=0 

00 140 l-l,M 
L>L»I 
140 XL(I i=Aai 
C 

C COMPUTE THE NORMALI/EO EIGENVECTORS 

C 

00 150 I-ltM 

N2»0 

00 150 J=l,M 

N1=I-M 

L-M*( J-lltl 

4(LI-0.0 

DO 150 K=l,« 

Nl=Nl»M 

N2»N2*i 
150 A(LI>A(LI»B(Nll*X(N2l 

L«0 

(t=0 

00 190 J=1,M 

SUMV-0.0 

DO 170 l«l,M 

L=L*1 
170 SUMV=SUMV»A(LI«A(LI 
175 SUMV- SORTISUMVI 

00 180 I-|,M 

«-*:*i 

ISO XIK):A(K|/SUMV 
RETURN 
END 



Ml NISNKUO 5 10 

C NMOII '>40 

NKIIO •.50 

NROII 560 

NKI1I1 '> to 

N«nrj sno 

NROll •>'*'} 

NKIIK iOO 

NHun (, 10 



NRIH) I ir 

NRijfj un 

NHIJO /JO 

NROI] /4" 

N«()(] 7S0 

NMOn ThO 

N«IJ() 7 70 

NRlin 7H0 

NRDII 790 

NHUO HOO 

NROO RIO 

NROO H^O 

NRnil H »0 

NKOll 840 

NRUII HSO 
NRIJU H'.O 

Nkon uro 

NKOO 8>10 

NROO H90 
NROO 900 
NROO 91C 
NROO 920 
NROO 9 JO 
HROG 940 
NROO 950 
NROO 960 
NROO 9T0 
NROO 9flO 
NROO 990 
NROO 1 030 
NKOOIOIO 
NR001020 
NROOIOIO 
NROOn40 
NROQIOSO 
NR0Qn60 
NROO 10 70 
NROniOBC 
NROO1090 
NROOilOO 
NROOt 110 
NROOI120 
NROO I HO 
NROOt 140 
NROO 1 1 50 
NR001160 
NROOl I 70 
NROQUaO 
NR001t90 
NROai200 
NH0QI21C 
N«OOI22D 
NROai^ JO 
NRO1J1240 
N«0ai250 

NR0012 TO 
NR00128D 
NR0ai290 
NROOl )0C 
NR00I3IC 
NROOl )2D 
NROOl 3)0 
NROOl 140 
NROOl 350 
NROOl 360 
NKOO13 70 
NRCQDSD 
NR0Q1390 
NROOI430 
NROOL 410 
NROO 14 20 
NROOl 4 30 



166 Mathematics— Matrices: Eigenanalysis 



Subroutine ATEIG 



c. Use of the Hessenberg form 



This subroutine computes the eigenvalues of a real 
upper almost- triangular matrix (Hessenberg form 
— see subroutine HSBG) using the double QR itera- 
tion of J. G. F. Francis. 

1. Mathematical background 

a. Definition of the QR Iteration 

Let A be a real or complex nonsitigular matrix of 
order n. Then a decomposition of A exists of the 
form 

A = QR 

where Q is unitary and R is upper triangular. If 
the diagonal elements of R are real and positive, 
Q is unique. Consider now the sequence of matrices 
A'P) defined recursively by 

A<°> = A, A^P> = Q<P> R^P>. A^P"1) = R<P)q<P>p. 0. 

Note that A^^^-""^ = Q^P^* A^^^ Q^^^ for p > 0; hence it 
follows that A^P) is similar to A for all p. 

Furthermore, if A satisfies certain conditions, 
it can be proved that A^P) tends to an upper triangu- 
lar matrix as p -» 0= ; thtis the eigenvalues of A are 
the diagonal elements of this limit matrix. 

b. Convergence 

If the moduli of the eigenvalues are distinct, the 
elements afe) below the main diagonal of A^P) tend to 
zero, as do^-'l^i | P/ l^j I P, the eigenvalues being 
subscripted so that | X i | > | X j+i] 

Thus, in general, the eigenvalues appear on the 
main di^onal, starting from the last position, in 
increasing order of moduli. 

So, when the smallest eigenvalue ^n has been 
found, we can reduce the order of the matrix by 
ne^ecting the last row and column and find ^n-i 
by the same process, without any special deflation. 

Note that the speed of convergence is consider- 
ably improved when the origin of the eigenvalues is 
shifted close to X.^- 

Such a shift, say s'P), can be introduced before 
an iteration and the opposite one afterwards. Then 
the iteration can be written as: 

a^p>-s<p>i=q^p)r^p) 

A<P"^)=r<P)q<P) + 3<P)i 

In general, A^j^ , for p large enough, can provide 
an efficient value for s(P). 



The Hessenberg form is preserved under^the QR 
iteration. Thus, a reduction of the initial matrix to 
the Hessenberg form can give a significant saving of 
computation in each iteration for the QR decompo- 
sition, the lower part of the matrix consisting only 
of the codiagonal terms. 

Before each iteration, the codiagonal terms will 
be inspected. If some of these are zero, the matrix 
will be split according to this occurrence, and the 
iteration will be applied to the lower main subma- 
trix only. 

d. The double QR iteration 

Let A be a diagonalizable real iq)per Hessenberg 
matrix. Such a matrix must be expected to have 
complex conjugate pairs of eigenvalues, ff these 
pairs are the only eigenvalues of equal modulus, it 
can be shown that they will appear as the latent roots 
of main submatrices of order 2. In this case, if a 
shift is close to one of these roots, it will be com- 
plex, and we will have to deal with complex ma- 
trices, although the initial one is real. The use of 
the double QR iteration avoids this inconvenience. 
Taking s^P"'"-'^) = s<P), consider the transforma- 
tion giving a(P+2) from A^P): 

^(P+2)^q(P+1)*q(p)*^(p)q(P)q(P+1) 

It can be proved that the product Q Q de- 

rives from the QR decomposition of the matrix M = 
(A^P) - s<P) 1) (A^P) - s(P+l)l), which is real. 

In fact, Francis (1961, 1962) showed that only 
the first colunrn m^ of M is necessanr for determin- 
ing the transformation which gives A'P'''^) from a'p), 
if they both have the Hessenberg form. 

Practically, the first part of the double iteration 
consists of the application of an initial transforma- 
tion NJ A(p) N, where Nj is unitary and such that 



Ni m, = ± 



Lllei 



This leads to a matrix which 



no longer has the Hessenberg form. 

Thus, the remaining part of the iteration will in- 
volve the application of (n-1) successive transfor- 
mations, which have the same form as the initial 
one whose matrices Nj are such that the resulting 
matrix A^P^^) has the Hessenberg form. 

This process can fail when a subdiagonal term of 
the given matrix is zero. In this case, the matrix 
can be split, and the iteration is performed on the 
lower main submatrix only. 

In the subroutine, Ni are Householder's matrices. 



Mathematics— Matrices: Eigenanalysis 167 



2. Progr amm ing considerations 

At each iteration, the latent roots x-, and x, of the 
lower main submatrix of order 2 are computed. 
Then, the followii^ situations can occur: 

a. The term a^ -i^n-2 ^^'^ be taken as zero. 
Then, x^ and X2 are eigenvalues of the original ma- 
trix, and the order of the matrix is reduced by 2. 
lANA(N) and lANA(N-l) are set to and 2 respec- 
tively. 

b. The term ajj^n-l can be taken as zero. In 
this case, a^ jj is an eigenvalue of the original ma- 
trix, and the order of the matrix is reduced by 1. 
IANA{N) is set to 1. 

0, One of the last two subdiagonal terms is 
stable through one iteration. Then the smaller one 
is considered as zero. The corresponding compo- 
nents of lANA are set to 0, 1, or 2, according to a. 
or b. 

d. The maximum number of iterations is reached. 
In this case, the smaller of the last two subdiagonal 
elements is taken as zero. The corresponding com- 
ponents of I AN A are set to 0, 1, or 2, according to 
a. or b. 

The user can check the results by inspecting the 
subdiagonal terms of the matrix on return from the 
subroutine, according to the vector I ANA, in the 
following way: 

If for each lANAff) containing 1 or 2, 2sisM, 

|A(I,I-l)|^10"^(|RRfl) |+|rI(])J), 
then RR(I) and Rl(l) were computed with a satisfac- 
tory accuracy. 

For reference see: 

(1) J. G. F. Francis, Computer Journal . October, 
1961 4-3, January, 1962 4-4. 

(2) J. H. Wilkinson, The Algebraic Eigenvalue 
Problem. Qarendon Press, Oxford, 1965. 



AIEI 



10 
20 



£t.e|iCLIl^E #TEIG 



IE 1l-( EICt^V»LLE£ CF » (tE4L «L*0CST TR IfhCUL'Aff HttniX 






I. IAK«,U] 



f CRCIH Cf rt-E I'^lflK 

t ll-E IKFCT »'<TRI)i, ^ ev f 

tip veCICfi CC^T«l^l^c IhE RfciL P*bi 

CK HM.»K 
fl WEC1CR CCMAIMNC ll-E IC«GlK«Pt PARIS Cf THE EIGEK- 

V4LLES CK RfcTtRK 

VECICO hl-CS£ CI''E*!lCh fLSl EE CRE'TEP THAN Gfl ECU* 



Of IMt EIGENVALUES 



.ATEI 
ATEI 
AIEi 

ATEI 
ATEI 
ATEI 
ATEI 
ATEI 90 
ATEI too 
ATEI 110 
ATEI 120 
ATEI l?0 
ATEI 140 
ATEI 150 
ATEI [60 
ATEI ITO 
ATEI ISO 
ATEI 190 



IC ff CCATAlNlkC C^ RETUfifi IhCICAIIQKS AflOLl ThE kAY ATEI 200 



ElCEhWALUES APFEAREC I SEE r<ATH. OESCRIPTIOM 
It Slli CF TfE FIRSl CirEASICA ASSIGMEO TC THE ARRAY A 

l^ ThE CALLING PRCCKAf tit-Eh THE fAIRIX |$ Ih OCUCLE 
SLBSCHIfliC DATA !ICRAGE fCCt. 
lA.*- t,Hh 1h£ ¥t1f>lx IS U SSP fcfCICB SIGRAGE fCOE. 

FEf-AUt; 

TK CRICIKAL KAIBIX IS CtSIRCYEC 

l^t CI^EASICA Cf PR ANC PI P(jST tlE GREATER CB ECtJAL TC P 



SLdPCLTUtS A^C FLfiCTlOh 
hCt-f 



ftncc 

CP CCLGLE ITERAIICh 



lieFRCCRAI'S PECtlREO 



ATEI 210 
ATEI 220 
ATEI 230 
ATEJ 240 
ATEI 250 
AIEI 260 
ATEI 270 
ATEI 280 
ATEI 240 
ATEI 300 
ATEI 310 
ATEI 920 
ATEI 330 
ATEI 340 
ATEI 3S0 
ATEI 360 
ATEI 370 
ATEI 380 



('EFEPEACES 

J.C.f. fPAKCIS - THE CP TRAASFCRMA IKh THE CCHPUTCR 

JCLPKAL, vet. 4, NC. 3. CCTCfiER lS6i, VOL. 4. hC . 4, JAKUARVAIEI 390 
1S(^. J. F. bILKlNSUN - 1*-E AtCEERAIC EIGENVALUE PRCfLC^ - ATEI 400 
ClAPEkCCfc PRtS<, CXFCRC, I<65. ^Tfj l^^ 

ATEI 4Z0 

168 Mathematics — Matrices: Eigenanalysis 



UERCLTIAE ATEICIH.A.RR.Ri.UfcA.tJi 

CiPtfSICfc *UI.««IU,*llIl|.PRJi(2|,PRIIi|,UW(|i 

IMECtf f.Pl.C 

EI-l.C(-e 

EC-I.CE-< 

ElC-l.CE-K 

CEITA-C* 

PAXIT-'C 

IMIIAlUATICh 

2C M'fi-1 
ih = M*lA 

^^>I^*ll 

IFIMI 3C,IKC.3C 
3C KF-h*! 

ITEP'TICh CCCMER 
If>C 

PCCIS CF Tl-e ihC CRCEP WAIN SUBHATRIli AT IHE PREVIOUS 
IliBATltlk 



CC 4C l-i.i 
FPPnt<C.C 

4C ffltH'Q.C 



LIST IfcC SCfiCIAGChAL EiEPEATS AT TfE fPEVICLS ITERATION 



Fih-C.C 
FAM-C.C 

CRKlh St-IFT 

F-C.C 
S"C.C 

SCCT; cf IK LChfB fHh 2 ev 2 SUBfAIRI 

^i■^ i-i 

Ihl'lK-ll 

n»l-IM*H 

Mf>l'IM*M 
6C I>Alf IMl-AlhM 

L-MT 

V>4.C«A(h tKMi thKIi 

IElAe5lbl<L*Ef) ICC*ICC,«5 
tf I«u*w 

IF(AeSlU-Ar'A;i|IL.AE£(Vtt«E6t C1,e7.6E 
67 I-C.C 
it L-UIMKU4AINM1/2.C 

V<><Cf>TIA££{lt)/2.C 

JFn)14C.7C.7C 
7C 1F(L) eC.7b.7£ 
7* PPIMl-LiV 

RRIM-L-V 

CC TC I^C 
EC hF(IM|tC-V 



ff^lh 



.(.♦V 



CC IC i:C 

ICC if (i)i;c.iic.uc 

lie »^P(M)-«IMM) 

fH |^ )><(kA) 

CC TC 13C 
12C FR1M)-/UM 

HPIN l-A(Mhl} 
13t PIIM-C.C 

PHM I'C.C 

CC IC 1(C 
14C PRIMLL 

R1(M}*V 
PJ(M«-V 

i£c iFih:ii;tc.i;EC,iec 

Uii; Cf CCNVEPGEUCE 

I6C MA2-MM-Ii 

f>r'CC-PPlM)*PPIMI«ft|(NI|«RI(MJ 

tFS-EIC*£CKT(PPCCt 

If IAESI<(Mh2)l~EPSI12eC,l<6Cw4C 
24C IFtAeSIA(KM)J-ElC«AES(A|NM) I l>CC,13CC.250 
25C IF4A£S{FAM-A(niK2)|-AeSU(MN:i)«£6l 124C« L24C,Z6C 
i6C If (AeSIFAk-nNhJ||-AES(A(NMM«E£M;4C.l240.30C 
3CC IFt ll-^AKIII 22C,12',C,12^C 

ccpfcte ife sufr 



2;c j«i 

CC 3tC I'i.i 

«-Kf-I 

Ifl4tS(PF(KI-FRH|ni«AtiSIRIIK) 

I *«i;!iKitKni) 24c,;ec,3tc 
;4C J-JM 

!(C fCMIhLE 

CC IC (44t,4tC.4CC.4ECI,J 

'r^iC t^'C.C 

J-C.C 

GC IC UC 

^tC J'hti-j 

(-•■p{JI«f»i(Jl 

;-HK( JMfPtJI 
CC TC tec 
4eC tohidlMtFi-lMI-rilUKRKM) 
5»PP(N)«SHIM I 



PKIU) l-CELIA*! Afi«(PfllK) I 



im Hf Li(J UC HtCtACChiL l£fl»'S AKC ri-t PCCT« Cf IH 



5CC FAh-A(AM| 

fAA|«A(AlA2) 
CC ilC 1-1, < 
K-AP-1 
FFFIII-CRUI 

52C Fli||||-PI|t(| 



StAKCF FCa A PABiniCN CF IFE PATRI«. CEFINEC BY f AND Q 
UCC,6CC,;25 



f-k; 

If lA- 
525 IPI-M 

CC SEC J'i,K2 

IFI-IFI-ll-i 

lF<Ae£U(IP|n-EPSI <CC.tCC,53C 



ATEI 430 

ATEI 440 
ATEI 450 
ATEI 460 
ATEI 4TQ 
ATEI 4S0 
ATEI 440 
ATEI 500 
AIEI 510 
ATEI 520 
ATEI 530 
ATEI 540 
ATEI S50 
ATEI 560 
ATEI 570 
ATEI 580 
ATEI 590 
ATEI 600 
ATEI 610 
ATEI 620 
ATEI 630 
ATEI 640 
ATEI 650 
ATEI 660 
ATEI 670 
ATEI 660 
ATEI 690 
ATEI 700 
ATEI 710 
ATEI 720 
ATEI 730 
ATEI T40 
ATEI TSO 
ATEI 760 
ATEI 770 
ATEI 780 
ATEI 790 
ATEI BOO 
ATEI 810 
ATEI 820 
ATEI 830 
ATEI 840 
ATEI 850 
ATEI 860 
ATEI 870 
ATEI 880 
AIEI 890 
ATEI 900 
ATEI 910 
ATEI 920 
ATEI 930 
ATEI 940 
ATEI 950 
ATEI 960 
ATEI 9T0 
ATEI 980 
ATEI 990 
ATEttOOO 
ATEIlOtO 
ATEI 1020 
ArEI103a 
ATEI 1040 
ATEI 1050 
ATE 1 1060 
ATEI1070 
ATEIlOaO 
ATEI 1090 
ATEIUOO 
ATEIlllO 
ATEIII20 
ATEItl30 
ATEI 1140 
ATEIllSO 
ATE II 160 
ATEtlirO 
ATEIllSO 
ATEI1190 
ATEIIZ-JO 
ATE11210 
ATC11220 
ATEI1230 
ATEtl240 
ATEI 1250 
ATE1I260 
ATEUJTO 
Ar£11280 
ATEI1290 
ATE 1 1300 
ATEI1310 
ATEI 1320 
ATE 11330 
ATEI1340 
ATEI 1350 
ATEI1360 
ATEIL370 
ATEI13S0 
ATEI1390 
ATEI1400 
ATEI1410 
ATE11420 
ATEI 1430 
ATE 11440 
AIE1I450 
ATEI 1460 
ATEI1470 
ATEI14aO 
ATEI1490 
ATEII500 
ATill5I0 
ATEUSZO 
ATEI1530 

ATEII550 

ATEII560 

ATEI1570 

ATEIlteO 

ATEI 1590 

ATCI1600 
ATE 116 10 
ATEII620 
ATEIldlO 
ATEII640 
ATEI1690 
ATEIt660 
ATEIU70 
ATEI167S 
ATE11680 
ATEI1690 
ATEIITOO 
ATEIITIO 



53C ^n^'^n*^^ 
iFif i>iriF4i4 

C>A(IPIF 1*1^1 lPlPt-SI*A(t(>IP2l*«(IP[P4l)*« 
IF iClb^CtttC,i4,C 

i^c iFi«e!unPii««<iPiP«i})*(ies(i(iPiPMA(ifif24 

1 11 -ieStCMEPS) tiCUZCSbC 
iiC F-hl-J 
■eC CCMIME 
tec C-P 

CC TC ttC 
t2C H«F-1 

(,-FI 

IF iFi-i) tec.eec.csc 

£SC CC etc 1«2. PI 
IH'IPi-l*-l 
lF(iBS(4(IFII)-EPSIAeC.6e0.6eC 

eec c*c-i 

c 

C CP CCLeiE MERiTICf. 

c 

tec ii-(p-iJ«i^«p 
in>ii-u 

IFI1-PI12C.]CC,12C 
ICC IFl-lMl 

IF1P-I1P«1 

c 

C IM11/ll2«IICf CF IhE TRA^<FCIlf«TIC^ 

c 

£l-i{II)*(«lll)-SJ«i(IIPI*«llPIt*fl 
C2-A(1FIMM(1PIF)4«(1II-S1 
CJ>«(IF IMAI1PIP*1I 
«(1F1«]J-C.C 
CC TC 7EC 
72C Cl-«l in > 

lfll-K2\m,T>Cf7tC 
74C C2'mH*it 
CC U 7(C 

7tC e3»c.c 

leC C«P>£CP1IG1«C1«C<«G^4G3«C3) 

IFtCfPlECCEtCeCQ 
eCC JF(GllE<C«e'iCtE4C 
e3C C4P--C«F 
f4C 1-Cl-tCiF 

Fsn-ci/i 

FSI2-Ca/1 
JLPFI>;.C/I1.C«P!I1*FS11«PSI^«PSI2I 

CC ic eec 
etc *iFn-i.c 

FSIl-C.C 
fSli-C.C 
£eC 1F( l-CI^CC.S6C .9CC 
sec IfU-FIS/C.S4C.S2C 
S2C 4(I11I--C4P 

CC ic sec 
S4C «(iIlJ>-i(Ill) 
C 
C (<Ck CFER41ICh 

c 

«£C IJ>I1 

CC IC^>C J-l.K 

1«FS114«IIJ4l) 

IF( l-fkll«EC.lCCCtlCCC 

sec 1P2J-1J4Z 

1*7«FSI2««UP2JI 
ICCC tI«-iLFt-««(T4A(iJ)t 

*IIJ4ilMIIJ«ll-PSIl«tT* 

IF I I-*>111C2C« 1C4C.1C«C 
1C2C 4IIF2Jl>J(IF2J)-F<i;4EIA 
1C4C 1J>IJ*14 

c 

C CCLL^K CFEPAIICh 

C 

IF 1 i-Ki)icec. ictc.icec 
ictc lt*tk 

CC TC IKC 

icec i>*i«; 

IICC IF-IIF-I 

CC iiec d-c*K 

JIF-IP4J 

Jl-Jlf-n 

t-FSll*«(JIPl 

IF( I-t>llII2C.lUC.lI4C 
U2C JIF?«J|F«I* 

I-1«PSIi««IJlF2l 
i\*,C ETA>ILFf (li«( Jl I ) 

«(JII-JfJll-£IA 

^IJIF I>«IJ1F|-ET««PSI1 

IFIl-flltUC. IICC. IIEC 
tl£C l(J[F2l>i(JlP2l-EIA*FSW 
ueC CCKTIhLE 

IF( l-^<ll<cc.l2iC.l;2C 

12CC JI-IIO 

J|F-JI«1/ 

JIF2>JIF«I4 

EI#««LFE^<PS12««IJlPi} 

>( JI1*-ET« 

i(JIFI--ETJ*PSIl 

#lJIF2l"*lJIF2l-tr*»FSI2 
I22C II-I1F41 

IT'lT*! 

CC u tc 

: 

C EKC CF lUAJIICh 



I24C lFlilf5(<l^*.llt'«£St«lM^iJll i3CCii2ec.i2ec 

C 

C UC EICEhVALiES t^'VE eEE^ FCL^C 



IFU<1MCC.14CC.2C 

CKt EICE^h^LLC (-«! SEEh FCtl^C 

titUI-C.C 

IF(M )I4CC. UCC,132C 



CC TC 
EhC 



ATEUT20 
ATEI17>0 
AT6I1740 
ATEIIT90 
l)-SI««eS(«(IPlP2*2)ATEIIT60 
ATE11770 
ATEI1780 
ATeil790 
"> ATEIISOO 

ATEi taio 

ATEIL820 

ATEIiaSO 

ATEI183S 

ATE 1 1840 

ATCI18)0 

ATCII8&0 

ATEII870 

ATEIl6aO 

ATEI1890 

ATEIHOO 

ATEI1910 

ATEI 1920 

A1EI1930 

ATEI 1940 

ATEIt9S0 

ArE]L960 

ATEI 1970 

AT€U980 

ArEU990 

ATE I 2000 

ATEI2010 

ATE1202O 

ATE I 2030 

ATEI2040 

ATE12090 

ATEI2a60 

ATEI20T0 

ATEI2080 

ATEI2a90 

ATEI2100 

ATEi2110 

ATEI2120 

ATEI213n 

ATEI2I40 

ATEI2150 

ATEIZIAO 

ATEI2170 

ATEI21S0 

ArE12190 

ATE 1 2200 

ATEI22I0 

ATEI2220 

ArEI2230 

ArEI2240 

ATEI2250 

ATEI2260 

ATEI2270 

ATEI2280 

ATE12290 

ATEI230a 

ATEI2310 

ATEI2320 

ATEI2330 

ATEI2340 

ATEI23$0 

ArEI2)60 

ArEI23TO 

ATEI23BO 

ATEI2)90 

ATE12400 

ATEI2410 

ATE 1 2420 

ATEI2430 

ATEI2440 

ATE124SO 

ATE 12460 

ATE12470 

AT£I24a0 

ATEI2490 

ArEI2500 

ATEI2S10 

ATEI2520 

ATEr2S)0 

ATE12540 

At6t2950 

ATEI2S60 

ATEI25rO 

A1C12580 

ATE 1 2990 

ATE 1 2600 

ATE126I0 

ATEI2620 

ATEI2630 

ATEI2A40 

ATEI2690 

ATEi2660 

ATEI2670 

ATEI26a0 

ATEI2690 

ATEI270a 

AIEI2710 

ArEi2r2a 

ATEI2730 
ATEI274Q 
ATEI2750 
ATEI 2760 
ATEJ27T0 
ATEI2780 
Af£I2790 
ATE I 2900 
ATEI2aiO 
ATEI2820 
AT£I2a30 

ATEizaso 

ATEI2860 
ATEI2e70 
ATEI2880 
AT£Ua90 
ATEI2900 
ArE12910 
ATEI2920 
ATEI2930 
ATEI 2940 
AT£t2990 
ATEI296a 
ATEI2970 



Subroutine HSBG 

This subroutine reduces an n by n real matrix A by 
a similarity transformation to upper alm6st- 
triangular (Hessenberg) form. Each row is 
reduced in turn, starting from the last one, by 
applying a suitable right elimination matrix, and 
similarity is achieved by also applying the left 
inverse transformation. Thus the eigenvalues of 
A are preserved. 

1. Mathematical background 

Let A (P) denote the matrix obtained from A^*^) = A 
after reducing rows n,n-l, . . . ,n-pr+-l. The simi- 
larity which transforms a(p) to A (P^^) is as 
follows: 

a. First we determine a pivot element a^ip k 
whose column subscript k is such that 



n-p, k 



max ^(p) 

i 



n-p, 1 



,i = 1,2, 



,n-p-l 



b. If the pivot element a^zl k= 0, no trans- 
formations are necessary; that is, the (p*-l)th 
similarity is the identify transformation. Other- 
wise, if it is necessary (kj^ n-p-1), we interchange 
the kth and (n-p-l)th columns so that the pivot 
element is in the subdiagonal position. The same 
interchange is applied to the rows of A^P'. The 
resulting matrix is similar to a'P', and, to ease 
the notation, we denote it by a'P'. 

c. Define multipliers 

t>j - an-p,j/an-p, n-p-1 ]=1,2, . , . ,n-p-2 
Then the (p<-l)th similarity is given by the following. 



Right elimination: 
77 (P) - o..(P) 



1] 



= aij 



-b 



(P) „ (P) 



*i, n-p-1 



i=l,2, ,..,n-p 
j=l,2,...,n-p-2 

-. (P)-, (P) 



Left inverse transformation: 



otiier indices 



a, 



(P^l) . _ a (P) + F '^ h <P) - (P) 

i=l 



Mathematics — Matrices: Eigenanalysis 169 



^ (p*l) ^- (p) 



ly n-p-1 



Finally, A^"^" ' will have the upper almost-tri- 
angular form. 

For reference see J. H. Wilkinson, The Alge- 
braic Eigenvalue Problem. Clarendon Press, 
Oxford, 1965. " 



LK-K.L I 

DO 260 J-1 ,L2 
JK-K4J 

280 S«=S»4(LJI»4( JK) 
300 AtlKMS 



Sei iHk LOhtR PAKT tjf ThE HATAIX lU ^Ef-0 



DO 510 I" 

310 Ai n-o.o 

GO TO 20 
360 RtTURN 
END 



LtLI*. lA 



M'j'lC1070 
Miftoioao 
HS<1C10^C 
HSUOUQO 

H^ecmo 

HS*1CII?0 

H'jRon JO 

HSHCl 1*.0 
HS6C1150 

HSBCllTO 

HSftcimo 

HS1CJ190 
HS8C1200 
MS1C1210 
MSft&l220 
HSBf.l^'JO 



iUORnuTINE HS6G 

PURPOSE 

TO ftEOuC£ A REAL MATRIX INTO UPPER A(.HO$T TFIANGULAC FOFH 

USAGe 

CALL H58G(N,A,I*) 

OEiCftlPTION OF THE PARAn€T€KS 

H OAOER OF THE HATRIX 

A THE IftPUT MATRIX, N (<Y N 

lA SIZE at- THE FIRST OIHENSICK ASSIGNED TC THE AHF^AY 

A IN The calling pcucram when the mtihix is in 
OaudLE SUBSCRIPTED DATA STORAGE MOOE . IA = N MHEN 
THE MATRIX IS IN SSP VECTOf. STORAGE HICt. 

REMARKS 

THE HESSENHEPG FOKM REPLACES THE PRICINAL MATRIX IN THE 
ARRAV A. 



MtTMOO 

SlMLAtiry TCAhSFL'RMATIUNS USIh-O fcLEMENTAty tLI»1IN/TI0N 
MATRICES* WITH PARTIAL PlVUTIhG. 

f eFEPENCES 

J.H. KUXINSON - THE ALGE6kAlC EIGENVALUE PRCflLFM - 
CLARENDON PRESS, nxFnRU, l'J65, 



SUe^OUTINE H$(iG(N,A,IAl 

OIMENSIOh AUI 

DCUOLfe PRECISION S 

L«N 

NIA>L*IA 



LI A«( 



-lA 



L IS The BCn index Of THE ELIMINATION 
no IFlL-31 360,^0.40 

40 L I A^L lA-I A 
Ll-L-1 
L2»Li-l 

SEARCH FOR THf PIVOTAL ELEMENT IK THE LTH ROW 

ISUe = LIA4'L 

iPiv=isue-iA 

PlV=AbS(A( IPIVt) 

IF(L-J>) 90,90,50 
50 H-JPIV-IA 

DO to I=L,M,1* 

T'ABSIAI I 1 ) 

IF(T-PIVI 80,80,60 
60 IPIV°I 

PIV=T 
BO CONTINUE 

VO IFtPIVI 100,320.100 
10 IFfPlV-AeS(A( ISJ8I ) I ISO, tUO, 1^0 

INTCKCHANGfc THE CuLUMNS 



UO M-IPIV-l 

DO 140 I-l.L 
J««*l 

T-A< J( 
K'^LIA.I 

A( JI<AIK) 

140 A(K)=T 

INTt^CMANGt THE RTtaS 

H-L2-M/IA 

UV 160 1=L1.NIA.|A 
T>AI I ) 
J= l-M 
A( l|iA(J) 
160 A(J|sT 



TERMS OF THE ELEMFNTARY TR ANSf ORMATi CN 



RIGHT TRAN^PURHATIUN 





J = 


-lA 








OC 


z^io i-i 


.L2 






J = 


J«^IA 








LJ 


= L*J 








DO 


221 K-l 


.LI 






KJ 


«X*J 








KL 


-K*LIA 






^20 


A(KJ)=AIKJI-A(LJ1 


•A(KL> 


2*0 


CONTINUE 










LEFT TRANSFORMATION 




K-- 


-lA 








UU 


300 l«I, 


iN 





HSBG 10 

. ..HS6G 20 

HSBG 30 

H^QC 40 

HSBG SO 

HSBG 60 

hS*G TO 

Hsac 80 

HSBG 90 
HSRC 109 

Hsac 110 

HSfiG 120 
HSeG 130 
HS8G 140 

Hseo 150 
Hseo 160 
HSBG ITO 
HS8C 180 
HSBG 190 
HSBG 200 
nSBG 210 
H55C 220 
HSBG 230 
MS6C 240 
HSflG 250 
HSBG 260 
HSeC 270 
HSeC 280 
H$eC 290 
HS8D 500 
HSfiC 310 
HSBf. i20 
HSBG 330 
HSflr, 340 
. .HSBC. 3^0 
HSSG 360 
HSbG 3TC 
HSdG 380 
HSBG 390 
HS8G 400 
HS80 410 
HS9G 420 
HSBG *30 
HS8C 440 
HS6G 4S0 
HSBG 460 
HSeC 4T0 
HSBG 480 
HSBG 440 
HSSG 500 
HSBG SIO 
MSflG 520 
HSSG 5 30 
hS9C 540 
HSaO 550 
MS9G 560 
HSflG 570 
HSSC 580 
HS8C 590 
MSBG 600 
riSBG 610 
HSSG 620 
MS9G 630 
HSSG 640 
HSBG 650 
HSBG 660 
MS6G^6T0 
HSBG 660 
HSSG 690 
HS5G TOO 

Msac 710 

HSaG 720 
HSSG T30 
MSBG 740 
HS9G 750 
HS8G TtO 
HSBG 770 
HSSG 760 
HSSG 790 
HSeC 600 
HSBG 810 
MSaC 620 
hSSG 630 
hSRG 640 
HS8C 850 
HSBG 860 
HSBG 8 70 
HSBG 980 
HS8G 890 
H5BC ^00 
HSBG 910 
HSBG 920 
HSBG 930 
hS8C 940 
riSaC 950 
HSSG 960 
HS8C 970 
HSeC 980 
HSSG 999 
hSBGIOOO 

Hsecioio 
HSacio20 

HSBGtOSO 
HSeGl04C 
HSSGI050 
H$BC1060 



170 Mathematics --Matrices: Eigenanalysis 



Polynomials: Operations 



Subroutine PSUB 



Subroutine PADD 



/o 



SUBROUTINE PAOD 



IOIMZ*X,IOIHX. Y.IOIHYI 

DESCRIPriON OF PAftAHETEAS 

I - VECr3ft OF RESULTANT CUEFF IC lENTS, ORDERED FROH 

SMALLEST 10 LARGEST POWER 
lOINZ - OINENSION Of t (CALCULATED) 
X - VECTOR OF COEFFICIENTS FOR FIRST POLYNOMIAL. 

FROM SMALLEST Tl LARGEST POWER 
lOinx - orHENSION OF X lOEGReE IS loinx-ii 
Y ~ VECTOR OF COEFFICIENTS FOR SECONO POLYNOMIAL 

0A06RED FAOM SMALLEST TO LARGEST POWER 
lOIMY - OIMENSION OF Y (DECREE (S IOIMY-11 



30 



60 
70 
80 



REMARKS 

VECTOR I HAY BE IN SAME LOCATION AS EITHER VECTOR X OR 

VICTOR Y ONLY IF THE OIMENSION OF THAT VFCTQR fS NOT LESS 

THAN THE OTHER INPUT VECTOR 

THE RESULTANT POLYNOHIAL MAY HAVE TRAILING ZERO COEFF IC lENTSPAOD 2J0 

PAOD ^80 
SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

NONE 



PADD 
PAOD 
PAOO 
PAOO 
PAOD 
PAOD 
PAOO 
PAOO 
PADO 
PAOD too 
PAOO 110 
PADO 120 
PAOO 130 
PAOO 1 40 
PAOO 150 
OROEtlCOPAOO 160 

PAOO iro 
PADD lao 

PAOD 190 
PADO 200 
PAOO 210 
PAOO 220 
PAOO 2 30 
PAOO 240 
PADO 2S0 
PAOO 260 



METHOD 

OINENSION OF RESULTANT VECTOR lOlHZ fS CALCULATED AS THE 
LARGER OF THE TWO (NPUT VECTOR OIHFNSIONS. CORRESPOND! NO 
COEFFICIENTS ARE THEN ADDED TO fORH /. 



SUBROUT INE PAOOIZ , I DIMZ . 
OlMENSlCm Zt 1 I .K( II .Y( I) 

Test oinENSioNs of sumhands 

NOIM= lOIMX 

IF ( lOtHX-IOIHVI 10.20.20 
I NOIM=I[)IHY 
' IF(NOIM) 90,90,30 
I DO 80 I >l.NOiH 

IFI I-IDIMXI 40,40.60 

IFI I-tOIMYl 50,50, TO 
I 21 I )'X( ll*Y( I } 

GO TD ac 

21 I )-Y< I ) 

GO TO 90 
1^(1 ! = )(( II 
' CONTINUE 

lOlMZ^NOlM 

RETURN 

END 



lOIHX, Y. lOIHYl 



PAOD 290 

PADO )00 
PAOO 310 
PAOO 320 
PAOO 310 
PAOO 340 
PAOO JSO 
PADO 360 
.PAOO 3 TO 
PAOO )60 
PAOD S'lO 
PADD 400 
PADO 4 10 
PADO 420 
PAOD 4 30 
PADO 440 
PAOO 450 
PADD 460 
PAOD 4T0 
PADD 480 
PAOO 490 
PAOD 5 00 
PADD 5 10 
PAOD 520 
PAOD 530 
PAOO 540 
PAOO 550 
PAOD 560 
PADO 5 70 
PAOO 5 80 
PADO 590 



SUHR(JUIIN( P^UH 

PURPOSE 

SUHTRACr ONE PULYNfJHIAL FROM ANUIHtR 

USAGE 

CALL PSUn(;,IDIM/,X,IDIMX,Y,lDIMn 

DESCRIPTION OF PAMAHLILHS 

I - VtCriR or RISUTANI CULfFHIINIS, ()H(Jf HI tl I HJIH 

SHALLESI IU lARGtSI PUWl K 
lOlM/ - OIHfNSlUN IU I (CALCULAliO) 
X - VECIIIH U( COLTFICftNtS FOR ll«<ir P(HYNI)H|AI, OHDI HI 

FROH SHAILTSI ft LAKGfSr PtIHLM 
lOIHX - DIHCNSKIN OF X (UIGREL IS IDIHXI) 
Y - VfCIJK Ul CIKirtCIlNIS FIIH SfCONU PtMYNriNIAI, 

aHOTRtO FKOH SHALLESI Ttl tARCISt PdHt M 
lOfMV - DIMCNSION OF Y (OLCRLF IS lUiHY II 

RE HARKS 

VECrrjR / HAY Hf IN SAHt LOCATION AS M t Ml R VIC KIR K (Ik 
VECrUR Y UNLY IF 1 HE DIMrNSlUN Uf THAI VICTOR IS Nl)f M SS 
THAN THE GIHtH INPUT VlXTtlR 
THE RfSULTANI PniYNOHIAI MAY MAVL TRAUINC /I KU CDt f f ICI I N( 

SURAOuriNFS ANU FUNCTION SUHPKUGRAMS RTOUIRLD 
NDNF 

METHOD 

OINFNSION OF RISUITANI VFCIUH lUlM/ IS CAICUIATIU A\ THI 
LARGER Uf THL IWn INPUT VEC1UH DIHt.NSIUNS. COE f T I C II N T S I 
VECTOR Y ART (HtN SUHTHALTfO fHtIN CORRT SPIINOI Nt: CUMIICIINI 
IN VECIUK X. 



SUBROUTINE PSUB(Z,IOIh; ,X 
DIMENSION 2t II, Kill ,YI II 



tnlMX, Y, lUIHYt 



TEST DIMENSIONS DF SUMHANDS 

N01M< lOIHX 

IF ( IDIHX-IOIHYI I0,?0,70 
I NDIH>I0IMY 
I IF iNDIHt 90.90,30 

I 00 ao I -1. NO in 

IF (i-IOIMXl 40.40,60 
I IF I I-IOIHYl 50,50, TO 
> m l-XI I l-Y( I t 

GO TU 80 
I 21 I l--Y(I ) 

CO TO SO 
I ZII|-X(lt 

CDNTINUF 

lOIHZ-NOIH 

RETURN 

END 



I'SUK 40 

PSUH 50 

PMJH AO 

PSUB /O 

PSUH «0 

PSUH 90 

PSUM 100 

psu« no 

PSUh li'O 

PSUM 1 10 

PSUH 140 

PSUH 150 

ripsuii 160 

PSUH 1 10 
PSUO I HO 

psuri 190 

HMiH ,'00 
PSUtt 210 
P-.UIJ /20 
p\uh y in 
PSUH 240 
PSUK 250 
PSUH //,o 

SPSIJH 2/0 
PSUH 2110 
PSUH /90 
(",UH 100 
PSUH ilO 
PSUH 320 
PSUH J 10 
PSUH 140 

spsun 150 

PSUH 360 
PSUH */0 
.PSIJB 1«0 
PSUH 390 
PSUH 400 
PSUH 410 
PSUH 420 

PSUH * »0 
PSUH 440 
PSUH 450 
PSUH 4hO 
PSUH 4 ro 
PSUH 4H0 
PSUH 490 
PSUH 500 
PSUB 510 
PSUH •>?0 
PSUH 530 
PSUH 5^0 
PSUH 550 
PSUH 560 
PSUH Sro 
PSUH 540 
PSUB 590 
PSUH 600 



Mathematics — Polynomials: Operations 171 



Subroutine PMPY 



Subroutine PDIV 



SUBROUTINE PMPY 



PURPOSE 

MULTIPLY TWO POLYMOHEALS 



USAGE 

CALL PMPYIi«(OIHZ, 



x.ioiMx.r.ioiiiYi 



DESCRIPTION OF PARAMET€RS 

I - VECT3R Qf RESULTAUT COEFFICIENTS, OROEHEO FROM 

SMALLEST TO LARGEST POWER 
lOIMZ - DIMENSION OF 2 (CALCULATEDI 
X - VECTOR OF COEFFICIENTS FOR FIRST PQlYNQHUt., OROEREDPHPY 160 

FROM SMALLEST T3 LARGEST POMER 
IDIMX - DIMENSION OF X (DEGREE IS IDIMX-H 
Y - VECTOR OF COEFFICIENTS FOR SECOND POLYNOMIAL. 

OROEREO FROM SMALLEST TO LARGEST POWER 
lOIMY - OIMENSION OF V I DEGREE IS lOIMV-l) 

REMARKS 

I CANNOT 8E IN THE SAME LOCATION AS X 
I CANNOT BE IN THE SAME LOCATION AS Y 



METHOD 

OIMENSION OF Z IS CALCULATED AS 101 MX* I DIMY-l 
THE COEFFICIENTS OF I ARE CALCULATED AS SUM OF PRODUCTS 
QF COEFFICIENTS OF X AND Y , MHOSE EXPONENTS AOO UP TO THE 
CORftESPONOING EXPONENT OF Z. 



SUBROUTINE PMPY (Z, I OIMZ ,X, lOIMX. Y, IDIMY ) 
DIMENSION Zdl.XdltYU) 

IFI [DIMX*IOtHYI 10.10.20 
' IOIMZ=0 

GO TO 50 
I IOIMZ = IDIMXi-IDIMY-l 

DO 30 1=1, IDIM? 
t Z<I I =0. 

00 *0 [=1, lOIMX 

00 -fO J = l,[0IMT 

K=I ♦J-l 

ZUI=X(ll*Y(Jl*Z(KI 
I RETURN 

END 



PHPY 


10 


PMPY 


It) 


PMPY 


*n 


PMPY 


•iO 


PMPY 


60 


PHPY 


70 


PMPY 


80 


PMPV 


90 


PHPY 


100 


PHPY 


no 


PMPY 


l?0 


PHPY 


1)0 


PHPY 


MO 


PMPY 


150 


;dphpy 


160 


PHPY 


170 


PMPY 


ISO 


PHPY 


190 


PMPY 


200 


PMPY 


?in 


PHPY 


??a 


PHPY 


230 


PHPY 


7*0 


PHPY 


250 


PMPY 


26 


PHPY 


?T0 


PHPY 


280 


PMPY 


790 


PHPY 


■)00 


PHPY 


310 


PHPY 


ipo 


PHPY 


^^n 


PHPY 


3*0 


PMPY 


)50 


.PHPY 


IAD 


PMPY 


370 


PMPY 


)ao 


PMPY 


^90 


PMPY 


«00 


PMPY 


*10 


PHPY 


470 


PHPY 


430 


PHPY 


440 


PHPY 


450 


PMPY 


460 


PMPY 


470 


PMPY 


4B0 


PMPV 


490 


PMPY 


500 


PHPY 


510 


PMPY 


520 



SUeROUTINE POIV 

PURPOSE 

DIVIDE ONE POLYNOMIAL BY ANOTHER 

USAGE 

CALL POIV (P. I 01 MP, X.I 01 MX, Y, lOIMY.TOL, IERI 

DESCRIPTION OF PARAMETERS 

P - RESULTANT VECTOR QF INTEGRAL PART 

lOIMP - DIHENSION OF P 

X - VECTOR OF COEFFICIENTS FOR OIVIOENO POLYNOMIAL 

ORDERED FROM SMALLEST TO LARGEST POWER. IT IS 

REPLACED BY REHAINOER AFTER DIVISION. 
IDIMX - OIMENSION OF X 
Y - VECTOR OF COEFFICIENTS FOR DIVISOR POLYNOMIAL. 

OROEREO FROM SMALLEST TO LARGEST POWER 
lOIHY - DIHENSION OF Y " 
TOL - TOLERANCE VALUE BELOW WHICH COEFFICIENTS ARE 

ELIMINATED DURING NORNALIZATION 
lER - ERROR CODE. IS NORMAL. I IS FOR ZERO DIVISOR 

REMARKS 

THE REMAINDER R REPLACES X. 

THE DIVISOR Y REMAINS UNCHANGED. 

IF DIMENSION OF Y EXCEEDS DIMENSION OF X, lOlMP IS SET 

ZERO ANO CALCULATION IS BYPASSED 



METHOD 

POLVNOHIAL X IS DIVIDED BY POLYNOMIAL Y GIVING INTEGER 
P ANO REMAINDER R SUCH THAT X = P»Y ♦ R. 
DIVISOR Y ANO REMAINDER VECTOR GET NORHALIZEO. 



SUBROUTINE POI V IP, I 01 HP. X. I DIMX. Y. lOI HY ,TOL . lER I 
DIMENSION P( LI.XI II ,YUI 

CALL PNORH ( Y, lOIMY ,TDL I 
IFMDIHVI 50,50,10 
10 IDIMP'I0IMX-IDIMY4l 
IFIIOIHPI 20.30.60 

DECREE OF DIVISOR WAS GREATER THAN DEGREE OF DIVIDEND 





20 


IOIHP-0 




30 


IER=0 




40 


RETURN 


C 






c 




Y IS ZER( 


c 








50 


IER = 1 
GO TO 40 



START REDUCTION 

60 IDIMX=I0IMY-1 

I-IOIMP 
70 II=I»IatHX 

Pt ll-X( II l/YI IDIMYI 

SUBTRACT MULTIPLE OF DIVISOR 

00 eO K=l. IDIMX 
J=K-l*I 
X(JI-XIJ)-P(II*Y(K1 

80 CONTINUE 

1 = 1-1 

IF( I } 90.90,70 

NOP.HALIZE REHAINOER POLYNOHIAL 

9C CALL PNaRHIX.EDINK.TDLI 
GO TO 30 
END 



PDIV 10 

POIV 20 

POI V 30 
POlV AO 
POIV 50 
POIV 60 
POIV 70 
POIV 80 
PDIV 90 
POIV 100 
PDIV 110 
POIV 120 
PDIV 130 
POIV 140 
. POIV 150 
PDIV 160 
PDIV 170 
POlV ISO 
POIV 190 
POIV 200 
PDIV 210 
POIV 220 
POIV 230 
POIV 240 
POIV 250 
POIV 260 
POIV 270 
POIV 280 
TO POIV 290 
POIV 300 
POIV 310 
POIV 320 
PDIV 3)0 
POIV 340 
POIV 350 
PART PDIV 360 
POIV 3 TO 
PDIV 380 
POIV 390 

POIV 400 

POIV 410 
POIV 420 
POIV 430 
POIV 440 
POIV 450 
PDIV 460 
POIV 470 
POIV 430 
POIV 490 
PDIV 500 
POIV 510 
PDIV 520 
PDIV 530 
POIV 540 
POIV 550 
PDIV 560 
POIV 570 
PDIV 580 
PDIV 590 
POIV 600 
PDIV 610 
POIV 620 
PDIV 630 
POIV 640 
PDIV 650 
POIV 660 
POIV 670 
POIV 680 
POIV 690 
PDIV 700 

POIV no 

PDIV 720 
POIV 730 
POIV 740 
POIV 750 
PDIV 760 
PDIV 770 
POIV 790 
POIV 790 
PDIV 800 
POIV 810 



172 Mathematics— Polynomials: Operations 



Subroutine PC LA 



Subroutine PADDM 



SUBROUTINE PCLA 



PURPOSE 

MOVE POLVNOHtAL X TO V 



USAGE 

CALL PCLAtY.IOlM 



. lOIM 



0€SCRIPTION OF PARAMETERS 

r - wecraH of rpsultant coefficicnts, oftoeREo from 

SMALLEST TO LARGEST POWER 
lOIMY - DIMENSION OF Y 
K - VECTOR OF COEFFICIENTS FOR POLYNOMIAL. ORDERED 

FROM SMALLEST TD LARGEST POWER 
lOIMK - DIMENSION OF X 



METHOD 

lOIMY IS RCPLACEO 6V IDIMX AND VECTOR X IS MOVtD TO 



SUSRDUriNf PCLA I Y. 101 MY* X, 101 MX I 

DIMENSION K( II.YIII 

IOIMY=IOIMX 

IFUOIMXI 30*30.10 
10 00 20 [ = 1, lOIMX 
20 Yl 1) = X( II 
30 RETURN 

END 



PCLA 10 

,.PCL» 20 

PCLA JO 

PCLA ^0 

PCl* 50 

PCLA 60 

PCLA TO 

PCLA 80 

PCLA 90 

PCLA 100 

PCLA 110 

PCLA 120 

PCLA 130 

PCLA 1*0 

PCLA 150 
PCLA 160 
PCLA 170 
PCLA 180 
PCLA 190 
PCLA 200 
PCLA 210 
PCLA 220 
PCLA 230 
PCLA 2*0 
PCLA 250 
PCLA 260 
PCLA 270 
PCLA 280 
.PCLA 290 
PCLA 300 
PCLA 310 
PCLA 320 
PCLA 330 
PCLA 3*0 
PCLA 350 
PCLA 360 
PCLA 370 
PCLA 390 
PCLA 393 



sueRouriNE paoom 

PURPOSE 

ADO COEFFICIENTS OF ONE POLYNOMIAL TO THE PRODUCT OF A 
FACTOR 8Y COeFFICIENTS 3F ANOTHCR POLYNOMIAL 



USAGE 

CALL PAOOMfZ, IDIMi, 



X.IDIMX.FACT.Y.IOIMY) 



DESCRIPTION OF PARAMETERS 

I - VECTDR OF RESULTANT COEFFICIENTS, ORDERED FROM 

SMALLEST TO LARGEST POWER 
IDf« - DIMENSION OF Z ICALCULATED) 



PODM 10 
. POOM 20 
POOM 30 
PDOM *0 
POOM 50 
PDOM 60 
PDDM 70 
PDOM 80 
PDOM 90 
PDDM 100 
PODM 110 
PDDM 120 
PDDM ISO 
PDDM L*0 
PDOM 150 
POOM 160 



- VECTOR OF COEFFICIENTS FDR FIRST POLYNOMIAL. DROEREOPDDN 170 



FROM SMALLEST T3 LARGEST POWER 
IDIMK - DIMENSION OF X lOEGREE IS IDlMX-lt 
FACT - FACTOR TO BE MULTIPLIED BY VECTOR Y 
Y - VECTOR OF COEFFICIENTS FOR SECOND POLYNOMIAL, 

ORDERED FROM SMALLEST TO LARGEST POWER 
lOIMY - DIMENSION OF Y (OECREE IS IDIHY-11 



REMARKS 

VECTOR I MAY 6E IN SAME LOCATION AS EITHER VECTOR X OR 

VECTOR Y ONLY IF THE DIMENSION QF THAT VECTOR IS NOT LESS 

THAN THE OTHER INPUT VECTOR 

THE RESULTANT POLYNOMIAL MAY HAVE TRAILING ZERO COEFFICI ENTSPODM 290 

PDOM 300 
SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

NONE 



POOM 180 
PDOM 190 
PDDM 200 
PDDM 210 
PDDM 220 
PDOM 230 
PODM 2*0 
PODM 250 
PDOM 260 
POOM 270 
PDOM 280 



METHOD 

DIMENSION OF RESULTANT VECTOR lOIMZ IS CALCULATED AS THE 
LARGER OF THE TWO INPUT VECTOR DIMENSIONS. COEFFICIENT IN 



VECTOR X IS THEN ADDED TO COEFFICIENT IN VECTOR 
BY FACTOR TO FORM Z . 



PODM 310 
PDOM 320 
PDOM 330 
PDOM 340 
PODM 350 
PDDM 360 



SUBROUTINE PAODMIZ. IDIM^.X, IDIMX.FACT . Y, [ DI MY ) 
DIMENSION ZIU.Kdl ,YIU 

TEST DIMENSIONS OF SUMMANOS 

NOIM^ IDtMX 

IF{ IDIMX-IDIMV I 10, 20,20 
I NDIH=IOIHY 
I IF(NDIMJ 90,90, 30 
' DO SO I=1.ND1M 

IFI l-IDIHK) *0, 40,60 
■ IF( l-IOIMY) 50.50,70 
' Z(I t=FACT*Y( Il+Xm 

GO TO 80 
\ til l=FACT»v( I ) 

GO TO 80 
' 21 I l=Kt I) 
I CONTINUE 

I0IM2=N0IH 

RETURN 

END 



MULTIPLIEOPODH 370 
POOM 380 
PDDM 390 

POOM *00 

POOM *10 
POOM *20 
POOM *30 
PODM 4*0 
POOM <,50 
PODM *60 
PDOM *70 
POOM AfiO 
POOM 490 
PODM 500 
POOM 510 
POOM 520 
POOM 530 
PDDM 5*0 
PODM 550 
PDDM 560 
PDDM 5 70 
PODM 580 
PDDM 590 
PODM 600 
PDDM 610 
PDDM 620 



Mathematics — Polynomials: Operations 173 



Subroutine PVAL 



Subroutine PVSUB 



SUSftOUTINE PVAL 

PURPOSE 

EVALUATE A POLrNDMIAL FOR A GIVEN VALUE OF THE VARIABLE 



ro 



USAGE 

CALL PVAL(RES,AftG,Xt IDIHKI 

DESCRIPTION OF PARAMETERS 

RES - RESULTANT VALUE OF POLYNOMIAL 

ARG - GIVEN VALUE OF THE VARIABLE 

t - VECTOR OF COEFFICIENTSt ORDERED F' 

LARGEST POWER 
lOIMX - DIMENSION OF X 



ROM SMALLEST TO 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

NONE 



MCTHOO 

EVALUATIOI^ IS DUNE 



MEANS QF NESTEO MULTIPLICATION 



RES=0. 

J=IOIMX 
1 IF(J)3,3,2 
Z RES=RES*ARG*XI J( 

J = J-l 

GO TO 1 
3 RETURN 

END 



PVAL 
..PVAL 
PVAL 
PVAL 
PVAL 
PVAL 
PVAL 
PVAL 
PVAL 90 
PVAL 100 

PVAL no 

PVAL 120 

PVAL UO 

PVAL 140 

PVAL ISO 

PVAL L60 

PVAL 170 

PVAL lao 

PVAL 190 
PVAL 200 
PVAL 210 
PVAL 220 
PVAL 230 
PVAL 2*0 
PVAL 2 50 
PVAL 260 
PVAL 270 
.PVAL 280 
PVAL 290 
PVAL 300 
PVAL 310 
PVAL 320 
PVAL 330 
PVAL 3*0 
PVAL 350 
PVAL 360 
PVAL 3T0 
PVAL 380 
PVAL 390 
PVAL *00 



SLERCLIlhE PVSUB 

PLRFCSC 

SLinilLIE VARIieLf Of A FClYNOMIAL BY ANC1HEP PCLYNOPIAL 

CALL rvSUB(2.IClP2.Jl.lOIPX.V.IGlMy.taCSt(ltkCRK2t 

CESCPIPTICI^ CF PiRAfEIERS . 

I - «ECTC« CF COEFFICICNIS FOR RE£UL1AM PCLYMCHIALt / 

CRCtPfC FRCH SfAiLEST TC lARCESI POkER 
IC1P2 - CIPChSICN CF I 
X - ^ECTCfl Cf COEFFICIENTS fCR CRIGIN^L fCLVKCMIAL, 

CRCERCC FRCI« SMALLEST TC lARCEST PCtiER 
ICIPX - CfPEKSICh CF « 
Y - VECTCfi CF COEFFICIEKTS FCR PCLYNCMIAL hHICh IS 

SUCSHIUICO FCR VARIABLEt CRCEKED FRCP SMALLEST TO 

LiRCESI PChER 

icifv - cifEhsich Cf y 

hCRKl - MCRKIhC STCMAGE ARRAY (SAPE OIPEhSICh AS 11 
hC«K3 - hCRKIKC STCRACE ARRAY (SAPE ClPEkSICf AS H 

REPJRKS 

StBRCUIIKES the FLNCTIOK SCCPRCCRAPS RECIjIREO 
fPFY 
FACCM 
PCLA 

PE1FCC 

MJRIABLE CF PCLVNCtilAL % IS SUBSTltLIEC BY PCLYNCPIAL Y 
IC FCR^ PCiVlkCPIAL I, CIPEKSICN CF K£h PCLVI^CMAL IS 
lICIMX-lJfllCIPY'lMU UeROUTIhE REQUIRES ThC hORK AREAS 



SLBRCUTUE FVSuen.ICI*'i,J(.ICI#')i.1i. ICir'Y.hORKl.hORKf ) 
CIPEhSlCk i(II.)lll).YUI.WCfiKl(ll,kORK2lll 

lESl CF CIMEhSlCkS 

IF (1CIP>-11 l.!t3 
1 ICIPi-C 

3 IC1P2-1 

IF (ICIPY'ICIMX-ICIKT) 2,2.* 



KCCllU'l. 



cc 



i« 



. 1CI»> 



.Ihll 



CALL Fr'Ft{bCRI<<iita2.V,ICIKY,kCRKI 

can FCL«lkCRK|,lMl,hCCKi,Ikt2 1 

f ACT-«(I) 

CALL FfLtPUiICIPR.Z.ICIfZ.rACI.kCRKl.Un 

ICI^i-IC 1K> 

CCMIfLE 

C( IC ; 



30 
*0 
50 



PVSU 
.PVSU 
PVSU 
PVSU 
PVSU 
PVSU 
PVSU 

PVSU 80 
PVSU to 
PVSU 100 
PVSU ilO 
PVSU 120 

PVSU no 

PVSU 1*0 
PVSU 150 
PVSU 160 
PVSU 170 
PVSU t«0 
PVSU 190 
PVSU 20O 
PVSU 210 
liVSU 220 
PVSU 230 
PVSU 2*0 
PVSU 250 
PVSU 260 
PVSU 270 
PVSU 260 
PVSU 290 
PVSU 300 
PVSU 310 
PVSU 320 
PVSU 130 
PVSU 3*0 
PVSU 350 
PVSU 3«0 
PVSU 3 70 
PVSU 300 
..PVSU 390 

PVSU *aa 

PVSU *10 
PVSU *20 
PVSU *30 
PVSU **0 
PVSU *50 
PVSU *60 
PVSU *70 
PVSU *80 
PVSU *90 
PVSU 500 
PVSU 510 
PVSU S20 
PVSU 530 
PVSU 5*0 
PVSU iSO 
PvSu 560 
PVSU 5 70 
PVSU 590 
PvSU 590 
PVSU 600 
PVSU 605 
PvSU 610 
PVSU 620 
PVSU 630 



1 74 Mathematics— Polynomials : Operations 



Subroutine PILD 



Subroutine PDER 



SUBROUflNt PILQ 

PURPOSE 

EVALUAte POLVNOMIAL AND ITS FIRST OERIVAIIVE FOR A GIVEN 
ARCUHENT 

USAGE 

CALL PILD (POLY, OVAL .AHCUH, X, tDIMK) 

OESCRIPTION OF PARAMETERS 

?OLt - VALUE OF POLrNOMIAL 

OVAL - DERIVATIVE 

APGUM - ARGUMENT 

K - VECTOR OF CDEFFICIENrS FOB PQLYNaMIALi OROEREO 

FROM SMALLEST T3 LARGEST POWER 
lOIMK - OIMENStON OF K 

REMARKS 
NONE 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
PQSO 

MErHOD 

EVALUATION IS DONE BY MEANS OF SUBROUTINE PQSO OUADRATIC 
SVNTH€TrC DIVISION) 



PILD to 
20 

30 



SUBROUTINE PILD ( POLY ,OVAL » ARGUM, X, I 01 MXI 
DIMENSION X( L I 



P=ARGUH*ARGUM 
Q^-ARGUM«ARGUM 



CALL PQSO I OVAL , POL V.P.OiKtIOIMX) 
POLr^ARGUM*OVAL*POLr 



60 



.PILO 
PILD 
PILD 
PiLD 
P[LD 
PILD TO 
PILO 80 
PILO 90 
PILD 100 
PILO 1 10 
PILO IZO 
PUD 130 
PILO 140 
PILD 150 
PILD Ih^ 
PILO 170 
PILO 180 
PILD 190 
PILD 200 
PILD ZiO 
PILO 220 
PILD 230 
PILO 2*.0 
PILO 250 
PILO 260 
PILD 270 
PILD 290 
PILD 290 
PILD 300 

.PILO 310 
PiLD 320 
PILD J30 
PILO 340 
PILD 350 
PILD 3&0 
PILD 370 
PILO 380 
PILD 3*)0 
PILD 400 
PILD 410 
PIlD A20 
PILO 430 
PILD 440 



SUBROUTINE PDER 



POLYNOMIAL 



• IDIMK 



OESCRIPIION OF PARAMFTFRS 

Y - VECTOR OF CQfFFICICNTS FOR DER 

SMALLEST TO LARGEST POWER 
IDIMY - DIMENSION OF Y (EQOAL TO lOIMX 
X - VECTOR OF COEFFICIENIS FOR OR I ' 

ORDERED FROM SMALLEST TO LAUGE 
lOIMX - OIMtNSION OF X 

REMARKS 
NONE 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 



J PDf « 

POtR 

PDER 

PDER 
PDER 
PDER 
POER 
POtR 
POtR 
PDER 
POtR 
POtR 

IVATIVE. ORDERED FROM PDtB 
PDER 

-II POER 

PDER 
POER 
POER 

poeR 

PDER 
PDER 
PDER 
PDER 
PDER 
POtR 
PDER 
LESS ONE. DERIVAIIVEPOER 



METHOD 

DIMENSION OF Y IS SET AT DIMENSION 

IS THEN CALCJLATEO BY MULTIPLYING COEFFICIENTS BY THEIR 

RESPECTIVE EXPONENTS. 



SUBROUTINE POERIY.IOIH 
DIMENSION X( I), Y< 1) 

TEST OF DIMENSION 
IF ( 101 MX-lt 3. 3, I 
IDIMY=!DIMX-I 

EXPT^O. 

on 2 1= It IDIMY 

ExpT = exPTn. 

Y( I ) = x) !• i(«ExPr 
GO TO 4 

IDf MY=0 

RETURN 

ENO 



PDER 
POER 
PDER 
.POER 
POER 
PDER 
POER 
POER 
PDER 
POER 
POER 
POER 
POER 
POER 
PDER 
POER 
PDER 
POER 
PDER 



140 
150 

160 
170 
IBQ 
190 
200 
210 
220 
2 30 
240 
250 
2fcO 
2TQ 
280 
290 
300 
310 
320 
330 
340 
350 
360 
370 
390 
390 
400 
410 
420 
4 30 
440 
450 
460 



Mathematics — Pol5Tiomials: Operations 175 



Subroutine PINT 



Subroutine PQSD 



PINT 



10 



suflRnuTiNe PiNr 

PURPOSE 

FIND IMfEGRAL Of A POLYNOMIAL Wl IH CONSrANT OF INTECAATION 
eOLJAL TO ZERD 

USAGE 

CALL PINr(¥,IOIMY,X,IDIMXI 

OeSCRIPriQN OF PARAMETERS 

Y - VECT3R OF COEFFICIENrS F0« INTEGRAL* ORDERED FROM 

SMALLEST TO LARGEST POMEfl 
IDIMY - OIMEMSION OF Y lEQUAL TO IDIMXtU 
K - VECTOR OF COEFFICIENTS FOR ORIGINAL POLYNOMIAL, 

OBOERED FROM SMALLEST TO LARGEST POWER 
IDIHX - DIMENSION OF X 



SUSROUTtNES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

OIMENSION Of Y IS SET AT DIMENSION OF X PLUS ONE, AND THE 
CONSTANT TERM IS SET TO iERO. INTEGRAL IS THEN CALCULATED 
BY OIVrOING COEFFICIENTS SY THEIR RgSPECTIVE EXPONENTS. 



SUBROUTINE P INT ( Y ,1 OIMY.X , I DIMX ) 
DIMENSION XCK, Y( n 

I0IMY=101MX*1 
Y( 11=0. 
IF(IOIHX) 1.1.2 

1 RETURN 

2 EXPT=1. 

DO 3 I«2.rOIMY 
Y) I } = K( I-l 1/BXPT 

3 EXPT=EXPT*1. 
GO TO 1 

END 



60 



.PINT 
PINT 
PINT 
PINT 
PINT 
PINT 
PINT 80 
PINT 90 
PINT 100 
PINT 110 
PINT 120 
PINT 130 
PINT 140 
PINT 150 
PINT l&O 
PINT ITO 
PINT 160 
PINT 190 
PINT 200 
PIN-T 210 
PINT 220 
PINT 230 
PINT 2<i0 
PINT 2S0 
PINT 260 
PINT ZTO 
PINT 280 
PINT 290 
PINT 300 
PINT 310 

.PINT 320 



SJBROUTINE PQSD 

PURPOSE 

PERFORM QUADRATIC SYNTHETIC DIVISION 

USAGE 

CALL PQSO(A,B,P.Q,X, lOIMXI 

DESCRIPTION OF PARAMETERS 

A - COEFFICIENT OF I IN REMAINDER (CALCULATED! 
B - CONSTANT TERM IN REMAINDER (CALCULATEOI 
P - COEFFICIENT OF t IN QUADRATIC POLYNOMIAL 
a - CONSTANT TERM In OUADRATIC POLYNQHIAL 
X - COEFFICIENT VECTOR FOR GIVEN POLYNOMIAL. OR 

FROM SMALLEST TD LARGEST POWER 
lOIMx - OIMENSION OF X 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 



METHOD 

POLYNOMIAL IS DIVIDED BY THE QUADRATIC 
THE LINEAR REMAINDER A*Zt8 



Z*»2-P*Z-Q GIVING 













OIMENSION X( I) 








PINT 


360 




PINT 


370 




PINT 


360 


J=IDIMX 












2 Z=P*A*S 


PINT 


410 






420 




PINT 


430 




PINT 


<i40 


GO TO i 


PINT 


450 


3 RETURN 




460 


END 



•P.O.X, IDIMX) 



20 
30 

40 



PQSD 
..PQSD 
PQSD 
PQSO 
PQSD 
PQSD 
PQSD 
PQSD 
PQSD 90 
PQSD 100 
PQSD tlO 
PQSD 120 
PQSO 130 
PQSO 140 
PQSO 150 
PQSO 160 
PQSD 170 
PQSO IBO 
PQSD 190 
PQSD 200 
POSO 210 
PQSD 220 
PQSD 230 
PQSO 240 
PQSO 250 
PQSO 260 
PQSD 270 
PQSO 2 80 
PQSD 290 
PQSD 300 
.PQSO 310 
PQSD 320 
PQSD 330 
PQSD 340 
PQSD 350 
PQSD 360 
PQSO 3T0 
PQSO 380 
POSO 390 
PQSO 400 
PQSO 410 
PQSD *20 
PQSD 430 
PQSD 440 
PQSD <.50 
PQSO 460 



176 Mathematics—Polynomials: Operations 



Subroutine PCLD 



Subroutine PGCD 



SUBROUriNE PCLO 

PURPOSE 

SHIFT OF ORIGIN (COMPLETE LINEAR SYNTHETIC DIVISION) 

USAGE 

CALL PCLOtX.IOIHXtUI 

DESCRIPTION OF PARAMETERS 

X - VECTOR OF COEFFICIENrS. OROEftED FROM SMALLEST TO 

LARGEST POWER. IT IS REJ>LACEO flV VECTOR OF 

TRANSFORMED COEFFICIENTS. 
lOIHX - DIMENSION OF X 
U - SHIFT PARAMETER 

REMARKS 
NONE 

SUfiftOUTINfS AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

COEFFICIENT VECTOR XIII OF POLrNOMIAL PIZ) IS TRANSFORMED 
SUCH THAT 0(£}-PIZ-UI WHERE QUI DENOTES THE POLYNOMIAL 
WITH TRANSFORHEO COEFFICIENT VECTOR. 



SUBROUTINE PCLD (X. lOIMX.UI 
OIHENSION X(11 



J=IDtHX 








IF (J-KI *, 


r4. 


p3 




X(J-ll=X(J- 


-11 


l«U*XIJI 


J=J-1 








GO TO 2 








K=K.*1 








IF 1 lOIMX-K) 


5, 


1 5.1 


RETURN 








END 









PCLO 


10 


.PCLO 


?0 


PCLO 


30 


PCLO 


*0 


PCLO 


S3 


PCLO 


60 


PCLO 


TO 


PCLO 


80 


PCLO 


90 


PCLD 


100 


PCLO 


110 


PCLO 


120 


PCLO 


130 


PCLD 


UO 


PCLD 


150 


PCLD 


160 


PCLD 


IIQ 


PCLD 


leo 


PCLD 


i<)n 


PCLD 


700 


PCLO 


210 


PCLO 


7?0 


PCLO 


?30 


PCLD 


Z*0 


PCLD 


?50 


PCLD 


260 


PCLO 


270 


PCLD 


280 


PCLD 


290 


PCLD 


300 


PCLO 


310 


PCLO 


320 


PCLD 


310 


PCLO 


340 


PCLO 


350 


PCLD 


360 


PCLO 


370 


PCLD 


360 


PCLD 


^90 


PCLD 


400 


PCLO 


4LQ 


PCLD 


*70 


PCLO 


430 


PCLO 


**0 



SUBROUTINE PGCD 

PURPOSE 

DETERMINE GREATEST COMHON DIVISOR OF TMO POCYNOMIAtS 

USAGE 

CALL PGCD I X, I 01 MX, V, lOIMY .HORK.EPS.l E«l 

DESCRIPTION OF PARAMETERS 

X - VECTOR OF COEFFICIENTS FOR FIRST POLYNOMIAL, 

OROEREO FROM SMALLEST TO LARGEST POWER 
DIMENSION OF X 

VECTOR OF COEFFICIENTS FOR SECOND POLYNOMIAL, 
ORDERED FRON SMALLEST TO LARGEST POWER. 
THIS IS REPLACED BY GREATEST COMMON DIVISOR 
DIMENSION OF Y 
WORKING STORAGE ARRAY 

TOLERANCE VALUE BELOM WHICH COEFFICIENT IS 
ELIHINATEO DURING NORMALIZATION 
RESULTANT ERROR CODE WHERE 
lER^O NO ERROR 
IER=L X Oft V IS ZERO POLYNOMIAL 



lOIMX 



I 01 MY 

WORK 
EPS 



lER 



C REMARKS 

C IDIMX MUST eE &REATER THAN IDIMY 

C IDIHV=1 ON RETURN MEANS X AND Y ARE PRlHEt THE GCO IS 

C CONSTANT. IDIMX IS DESTROYED DURING COMPUTATION. 

C 

C SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

C PDIV 

C PNORN 



GREATEST COMMON DIVISOR OF TWO POLYNOMIALS K AND V IS 
OETERMINED ^Y MEANS OF EUCLIDEAN ALSORITHM. COEFFICIENT 
VECTORS X ANO Y ARE DESTROYED AND GREATEST COMHON 
DIVISOR IS GENERATED IN Y. 



SUBROUTINE PGCO(X, IDIMX.Y, IDIMY , WORK, EPS, lER I 
DIMENSION X( 11, y( 1) ,WORK( I) 

DIMENSION REQUIRED FOR VECTOR NAMED WORK IS IDI MX-I D I MY* I 

1 CALL POIVIWORKtNDIMtX, IDIMX, Y, lOIMY, EPS, lER) 
IFI lER} 5,2.5 

2 IFIIDIMXI 5.5,3 

INTERCHANGE X AND Y 

3 00 4 J=1,10IHY 
WORK(II=X(JI 
X(J).Y( J) 

** Y(JI=WORKIll 

NOIH-IOIMX 

IDIMX=IOIMY 

IOIMY=NDIM 

GO TO I 
5 RETURN 

END 



PGCD to 
..PGCD 20 
PGCD 30 
PGCD ■'.0 
PCCO 50 
PGCO 60 
PGCD TO 
PGCO BO 
PGCO 90 
PGCD 100 
PGCO 1 10 
PGCO 120 
PGCD 130 
PGCO L40 
PGCO 150 
PGCD l&O 
PGCD 170 
PGCD lao 
PGCD 190 
PGCD 200 
PGCO ZIO 
PGCO 220 
PGCO 230 
PGCO 240 
PGCD 250 
PGCO 260 
PGCO 2 70 
PGCO 2S0 
PGCD 290 
PGCD 300 
PGCD 310 
PGCD 320 
PGCO 330 
PGCO 340 
PGCD 350 
PGCD 360 
PGCD 3 70 
PGCO 380 
PGCD 390 
PGCO 400 
PGCO 410 
.PGCD *20 
PGCD 430 
PGCO 440 
PGCD *50 
PGCD 460 
PGCO 470 
PGCO *80 
PGCO 490 
PGCO 500 
PGCO 510 
PGCO 520 
PGCO 530 
PGCO 540 
PGCD 550 
PGCD 560 
PGCD 570 
PGCD 580 
PGCD 590 
PGCD 600 
PGCD 610 
PGCD 620 
PGCO 630 
PGCO 640 



Mathematics—Polynomials: Operations 177 



Subroutine PNORM 



Subroutines PECN and DPECN 



$UBHOuriNe PNORM 



VECTOR OF A POLYNOMIAL 



USAGE 

CALL PNORtUK. lOIMX.EPS 

OeSCRIcrlON OF PARAMETERS 

X - VECTOR Of ORI 

SMALLEST TO L. 

IDIHX - DIMENSION OF 

EPS - TOLERANCE BEL 

REMARKS 

IF All coefficients are 

POLYNOMIAL M I TH IOIMX = i 

SU8RtWTINES AHO FUNCTION 
NONE 

METHOD 

DIMENSION OF VECTOR K 
COEFFICIENT tllTH AN AB 



GINAL COEFFICIENTS, 0H0ER6D FROM 
ARGEST POWER. IT REMAINS UNCHANGED 

IT IS REPLACED BY FINAL OIMENSIQN 
OW WHIC^ COEFFICIENT IS ELININATEO 



SUBPROGRAMS REQUIRED 



IS REDUCED 6Y ONE FOR EACH TRAILING 
SaLUTE VALUE LESS THAN OR EQUAL TO EPS 



SUBROUTINE PNORM( X, lOI MX, EPS I 
DIMENSION XI I) 

t IfllDIMXI 'tt'tfZ 

2 IF(ABS(X( IDIMXn-EPS) 3. 3. A 

3 IOIMX=IOIMX-l 
GO TO 1 

4 RETURN 
END 



PNOR 


10 


PNOR 


?0 


PNOR 


30 


PNflft 


40 


PNOR 


50 


PNOR 


60 


PNOR 


70 


PNOR 


80 


PNOR 


90 


PNOR 


100 


PNOR 


no 


PNOR 


V20 


PNOR 


1)0 


PNOR 


1*0 


PNOR 


150 


PNOR 


160 


PNOR 


170 


PNOR 


lao 


PNOR 


no 


PNOR 


?00 


PMOR 


210 


PNOR 


220 


PNOR 


730 


PNOR 


?40 


PNOR 


250 


PNOR 


260 


PNOR 


?T0 


PNOR 


260 


PNOR 


290 


PNOR 


^00 


PNOR 


310 


PNOR 


^?o 


PNOR 


HO 


PNOR 


343 


PNOR 


■»5D 


PNOR 


160 


PNOR 


370 


PNOR 


3B0 


PNOR 


3V1> 



PjX 



i-1 



= eps for 



X ^ 



These subroutines perform the economization of a 
polynomial for symmetric range. 

A given polynomial P(x) with coefficient vector 
P = (Pj, . . • .Pjj). representing a function f(x) with a 
maximum error eps over the range (-bound, bound) 

n 
— that is, I f(x) - Y, 
i=l 

bound — is reduced to a shorter coefficient vector, if 
possible, representing f(x) over the same range with 
a maximal error absolutely less than tol by means of 
telescoping. 

The Chebyshev polynomial T ,(t) has 2^~^ as co- 
efficient of t^"-"-. As a consequence, t'^"-'- may be 
replaced by T^_j^{t)/2^~^ plus a polynomial in t of 
degree n-2. 

This means that the telescoped polynomial: 



\(x) 



E Pi X 

i=l 



i-1 



- (p . bound 
n 



-V2-2) 



T , (x/bound) 
n-1 



is of degree n-2 representing f(x) over the range 
I X I = bound with a maximal error err absolutely less 
than epsj^ = eps + | P^ | .bound ^ /2^~ , since 
|Tn_i(t)|^lfor|t|^l. 

If epsi is less than the tolerance tol, the proce- 
dure may be repeated with P^ instead of P, and eps^ 
instead of eps. 

This iterative scheme results in a polynomial 
approximation to f(x) which possibly consists of fewer 
terms and thus may allow the computation of f(x) with 
less effort than the original approximation P(x). 

Naturally, tol should be greater than eps. 

For reference see K. A. Brons, Algorithm 38, 
Telescope 2, CACM vol. 4, 1961, no. 3, pp. 151-152. 



178 Mathematics — Polynomials: Operations 



eouho 
eps 



TOL 



WORK 



SUSROUriNE PECN 

PURPOSE V 

ECONOMIZE A POLrMOHIAL FOR SYMMETRIC RANGE 

USAGE 

CALL PECN (P.N.BOUNO.EPS.TOL.MOftKl 

DESCRIPTION OF PARAMETERS 

P - COEFFICIENT VECTOR OF GIVEN POLYNOMIAL 

OH RETURN P CONTAINS THE ECONOMIfEO POLYNOMIAL 
N - DIMENSION OF COEFFICIENT VECTOR P 

ON RETURN N CONTAINS DIMENSION OF ECONOMIZED 

POLYNOMIAL 

RIGHT HAND eOUNDARY OF RANGE 

INITIAL ERROR SOUND 

ON RETURN EPS CONTAINS AN ERROR BOUND f^OR THE 

ECQNOHUEO POLYNOMIAL 

TOLERANCE FDR ERROR 

FINAL VALUE OF EPS HOST BE LESS THAN TOL 

WORKING STORAGE OF DIMENSION N (STARTING VALUE 

OF N RATHER THAN FINAL VALUE) 

REMARKS 

THE OPERATION IS BYPASSED IN CASE OF N LESS THAN I. 

IN CASE OF AN ARelTRARY INTERVAL (XL,XR) IT IS NECESSARY 

FIRST TO CALCULATE THE EXPANSION OF THE GIVEN POLYNOMIAL 

WITH ARGUMENT X IN POWERS OF T = ( X- I KR-XL ) /Z t . 

THIS IS ACCOMPLISHED THROUGH SUBROUTINE PCLD. 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

SUBROUTINE PECN TAKES AN IN-IJST DCGREE POLYNONIAL 

APPROKIMATION TO A FUNCTI^IN FIX) VALID WITHIN A TOLERANCE 

EPS OVER THE INTERVAL ( -BOUND. BOUND) ANO REDUCES IT IF 

POSSIBLE TO A POLYNOMIAL OF LOWER DEGREE VALID WITHIN 

THE GIVEN TOLERANCE TOL. 

THE INITIAL COEFFICIENT VECTOR P IS REPLACED 6Y THE FINAL 

VECTOR. THE INITIAL ERROR BOUND EPS IS REPLACED BY A FINAL 

ERROR BOUND. 

N IS REPLACED BY THE DIMENSION OF THE REOJCEO POLYNOMIAL. 

THE COEFFICIENT VECTOR OF THE N-TH CHEBYSHEV POLYNOMIAL 

IS CALCULATE3 FROM THE RECURSION FORMULA 

A(K-l I =-A(K*l l*K«L»U*(K-t J / ( < N + K-2 ) • 1 N- K*2 I I 

REFERENCE 

K, A. BRONS, ALGORITHM 38, TELESCOPE 2t CACM VOL. ■*, 1961, 

NO. 3, PP. 151-152- 



SUBROUTINE PECNI Pt N.BOUND, EPS. TOL, WORK) 

DIMENSION PID.HORKdl 
FL=BOUND*eOUND 

TEST OF DIMENSION 

1 IF(N-1I2,3,& 

2 RETURN 

3 IF{EPS*AeSIP< l))-T0L)'i.*,5 

* N = 

EPS=£PS+AaS(P(l)) 

5 RETURN 

CALCULATE EXPANSION OF CHEBYSHEV POLYNOMIAL 

6 NEN0<N-2 

WORK(N)>-PtN) 

DO 7 J«1,NEND,2 

K = N-J 

FN=INEN0-l*K»*(N6N0+3-KI 

FK-'K*(K-ll 

7 W0RK(K-1)--M0RK(K*I l»FK*FL/FN 

TEST FOR FEASIBILITY OF REDUCTION 

lF(K-2)fl,B.9 

8 FN-AeS(W0RK< l> I 
GOTO 10 

9 FNaN-l 
FN=ABS(M0RK(2)/FN) 

10 IFiePS*-FN-T0L)ll,lU5 

R EOUC E POL YNOH I AL 

11 EPS=EPS*FN 
N«N-1 

00 12 J>K,N,2 

12 P1J-11=P( J-1 l*WORK( J-1 I 
GOTO 1 

END 



70 



PECN 
..PECN 
PECN 
PECN 
PECN 
PECN 
PECN 
PECN 
PECN 90 
PECN 100 
PECN I 10 
PECN 120 
PECN 130 
PECN 140 
PECN 150 
PECN 160 
PECN ITO 
PECN ISO 
PECN 190 
PECN 200 
PECN 210 
PECN 220 
PECN 230 
PECN 2*0 
PECN 250 
PECN 260 
PECN 270 
PECN 290 
PECN 290 
PECN 300 
PECN 310 
PECN 320 
PECN 330 
PECN 340 
PECN 350 
PECN 360 
PECN 3T0 
PECN 3ao 
PECN 390 
PECN 400 
PECN 410 
PECN 420 
PECN 430 
PECN 440 
PECN 450 
PECN 460 
PECN 470 
PECN 480 
PECN 490 
PECN 500 
PECN 510 
PECN 52C 
PECN 530 
.PECN 540 
PECN 550 
PECN 560 
PECN 570 
PECN 580 
PECN 590 
PECN 60O 
PECN 610 
PECN 620 
PECN 630 
PECN 640 
PECN 650 
PECN 660 
PECN 670 
PECN 680 
PECN 690 
PECN 700 
PECN 710 
PECN 720 
PECN 750 
PECN 740 
PECN 750 
PECN 760 
PECN 770 
PECN 780 
PECN 790 
PECN 800 
PECN 810 
PECN 820 
PECN 830 
PECN 843 
PECN 850 
PECN B60 
PECN 870 
PECN B80 
PECN 890 
PECN 900 
PECN 910 
PECN 920 
PECN 930 
PECN 940 
PECN 950 
PECN 960 



SUBROUTINE 0P6CN 



CALL DPECNIP.N, SOUND, EPS, TOL, WORK) 



OeSCRIPTIQN OF PARAMETE 
P - OOUBLE PHECl 

POLYNOMIAL 
ON RETURN 
r^ - OIHE^SION OF 

ON RETURN : 
POLYNOMIAL 
BOUND - SINGLE PRECI 
EPS - SINGLE PRECI 
ON RE TURN EP 
ECQNOMUEO 
TOL - SINGLE PRECI 

FINAL VALUE 

WORK - DOUBLE PREC I 

I STARTING 



SION COEFFICIENT VECTOR OF GIVEN 

CONTAINS THE ECONQMIZEO POLYNOMIAL 

COEFFICIENT VECTOR P 
CONTAINS DIMENSION OF ECONOMIZED 

SION RIGHT HAND BOUNDARY OF AANGE 
SIDN INITIAL ERROR BOUND 

CONTAINS AN ERROR BOUND FOR THE 
DLYNOHIAL 

SION TOLERANCE FOR ERROR 
OF EPS MUST BE LESS THAN TOL 
SION WORKING STORAGE OF DIMENSION N 
LUe OF N RATHER THAN FINAL VALUE) 



REMARKS 

THE OPERATION IS BYPASSED IN CASE OF N LESS THAN 1. 

IN CASE OF AN ARBITRARY INTERVAL iKL.Xfl) IT IS NECESSARY 

FIRST TO CALCULATE THE EXPANSION OF THE GIVEN POLYNOMIAL 

WITH ARGUMENT X IN POWERS OF T = ( X-(XR-XL) /2 » - 

THIS IS ACCOMPLISHED THROUGH SUBROUTINE OPCLO, 

SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

SJBROUriNE DPECN TAKES AN (N-llST OEGREE POLYNOMIAL 

APPRQXIMflTJON TO A FUNCTION FIX) VALID WITHIN A TOLERANCE 

EPS OVER THE INTERVAL ( -93UND.BOUNDI AND REDUCES IT IF 

POSSIBLE TO A POLYNOMIAL OF LOWER DEGREE VALID WITHIN 

THE GIVEN TOLERANCE TOL. 

THE INITIAL COEFFICIENT VECTOR P IS REPLACED BY THE PINAL 

VECTOR. THE INITIAL ERROR BOUND EPS IS REPLACED BY A FINAL 

ERROR BOUND. 

N IS REPLACED BY THE DIMENSION OF THE REDUCED POLYNOMIAL. 

THE COEFFICIENT VECTOR 3F THE N-TH CHEBYSHEV POLYNOMIAL 

IS CALCULATED FROM THE RECURSION FORMULA 

A(K-ll=-A(K»l)»K*L*L*(<-l)/MN»K-2)*(N-Kt2ll 

REFERENCE 

K. A, BRONS. ALGORITHM 38, TELESCOPE 2, CACM VOL- 4. 1961, 

NO. 3, PP. 151-152. 



SUA ROUT IME DPECNtP. NtBOUNO.EPS. TOL, WORK! 



DIMENSION P( II .WORK(l) 
DOUBLE PRECISION P.WORK 



FL=60UND*80UN0 

TEST OF DIMENSION 



3 IFiePS*ABS(SNCL(P( 1 I) I -TOL 14. 4, 5 

4 N = 
EPS=EPS*ABS(SNGL(P(1))1 

5 RETURN 

CALCULATE EXPANSION OF CHEBYSHEV POLYNOMIAL 

6 NEN0=N-2 
WQRKINI =-P(N] 
DO 7 J=l,NeN0.2 
K = N-J 

FN=INENO-l+K>»(NEN0t'3-KI 
FK=K*(<-ll 

7 WORKIK-ll=-WORKIK*l )«06L£I F|£.*FL /FNl 

TEST FOR FEASIBILITY OF REDUCTION 

IF:k-2)8,8,9 
9 FN=D49S(W0«K( U I 

GOTO to 
9 FN=N-1 

FN=aBSISNGLlW0RK(2) l/FN) 
10 IFlEPS + FN-TOLlll.ll ,5 

REDUCE POLYNOMIAL 

ti EPS = EPS»FN 

N-N-1 

DO 12 J=K,N.2 
12 P( J-11 = P( J-n»WO«K( J-ll 

GOTn 1 

END 



DPCN 10 
.DPCN 20 
DPCN 30 
DPCN 40 
DPCN 50 
DPCN 60 
DPCN TO 
OPCN 80 
DPCN 90 
DPCN 100 
DPCN 110 
DPCN 120 
OPCN 130 
OPCN 140 
DPCN 150 
DPCN 160 
DPCN 170 
OPCN leo 
OPCN 190 
DPCN 200 
DPCN 2 10 
DPCN 220 
DPCN 230 
OPCN 240 
OPCN 250 
DPCN 260 
DPCN 270 
OPCN 280 
DPCN 290 
DPCN 300 
OPCN 310 
DPCN 320 
OPCN 3 30 
DPCN 340 
DPCN 350 
DPCN 360 
DPCN 370 
DPCN 380 
DPCN 390 
OPCN 400 
OPCN 410 
DPCN 420 
OPCN 433 
DPCN 440 
OPCN 450 
DPCN 460 
DPCN 470 
DPCN 480 
OPCN 49 
DPCN 500 
DPCN 510 
OPCN 520 
DPCN 530 
DPCN 540 
.OPCN 550 
DPCN 560 
OPCN 5 70 
OPCN 580 
OPCN 5 90 
OPCN 600 
OPCN 610 
DPCN 620 
OPCN 6 30 
DPCN 640 
DPCN 650 
OPCN 660 
OPCN 670 
DPCN 6S0 
OPCN 690 
DPCN 700 
OPCN 710 
DPCN 720 
DPCN 730 
OPCN 740 
DPCN 750 
DPCN 760 
DPCN 770 
DPCN 780 
DPCN 790 
OPCN 600 
DPCN SIO 
DPCN 820 
DPCN 830 
DPCN 840 
OPCN 850 
OPCN 86D 
OPCN 870 
DPCN 880 
OPCN 890 
OPCN 900 
DPCN 910 
DPCN 920 
OPCN 930 
DPCN 940 
DPCN 950 
OPCN 963 
OPCN 970 
OPCN 980 
DPCN 990 
OPCNIOOO 



Mathematics — Polynomials: Operations 179 



Subroutines PECS and DPECS 

These subroutines perform the economization of a 
polynomial for unsymmetric range, 

A given polynomial P(x) with coefficient vector 
P = (Pi. • •• .Pjj). representing a function f(x) with 
a maximal error eps over the range (0, bound) — 

n 
that is, I f{x) - J^ p. X 

i=l ^ 
bound — is reduced to a shorter coefficient vector, 
if possible, representing f(x) over the same range 
with a maximal error absolutely less than tol by 
means of telescoping. 

The shifted Chebyshev polynomial T^_, (t) = 



i-1 



= eps for = X = 



"^n-l (2t - 1) has 2^^~^ as coefficient of i^~^. As a 
consequence, t""-*- may be replaced by T^_i (t)/2^^~^ 
plus a polynomial in t of degree n - 2. 

This means that the telescoped polynomial 



n 

Pj (X) = E Pi ^ 

i=l 



i-1 



(p^. (bound)" -^7 2^" ^) T^_^ (x/bound) 



is of degree n - 2 representing f(x) over the range 
= X = bound with a maximal error err absolutely 
less than eps, = eps + | Pj, | • bound'^"-'-/ 2^^^"*^, 
since | T^.^ (t) | = 1 for S t = 1. 

If epsi is less than the tolerance tol, the proce- 
dure may be repeated with P^^ instead of P, and epsj 
instead of eps . 

This iterative scheme results in a polynomial 
approximation to f(x) which possibly consists of 
fewer terms and thus may allow the computation of 
f(x) with less effort than the original approximation 
P(x). 

Naturally, tol should be greater than eps. 

For reference see K.A. Brons, Algorithm 37, 
Telescope 1, CACM vol, 4, 1961, no. 3, p. 151. 



SUfiROUriNC PECS 

puflpDse 

ECONOMI/AriON OF A POLYNOHUL FOR UNSYHHETRIC R4NGE , 

USAGE 

CALL PECS (P.NfBQUNDtEPSt TOL, WORK) 

DESCRIPTION OF PARAHETEffS 

P - COEFFICIENT VECTOR OF GIVEN POLYNOMIAL 

N - DMEMSIQN OF CO£fFICIEMT VECTOR 

eOJNO - RIGHT HAND BOUNDARY OF INTERVAL 

EPS - INITIAL ERROR BOUND 

TOL - TOLERANCE FOR ERROR 

WORK ' WORKING STORiGE DF OIMENSION N 

REMARKS 

THE INITIAL COEFFICIENT VECTOR P IS REPLACED BY THE 

eCONOHUED VECTOR. 

THE INirrAL ERROR BOUND EPS IS REPLACED BY A FINAL 

ERROR BOUND. 

N IS REPLACED BY THE OIMENSION OF THE REDUCED POLYNOMIAL. 

IN CASE OF AN ARBITRARV INTERVAL IKi.Xftl IT IS NECESSARY 

FIRST TO CALCULATE THE EXPANSION OF THE GIVEN POLYNOMIAL 

WITH ARGUMENT X IN POWERS Of T = (Jt-KL). 

THIS IS ACCOMPLISHED THROUGH SUBROUTINE PCLD. 

OPERATION IS BYPASSED IN CASE OF N LESS THAN I. 



HEIHOO 

SUOROUTINE PECS TAKES AN (N-llST DEGREE POLYNOMIAL 

APPROKIHATION TO A FUNCTION FIX) VALID WITHIN A TOLERANCE 

EPS OVER THE INTERVAL (OtBOUNOl AND REDUCES IT IF POSSIBLE 

TO A POLYNOMIAL OF LOWER DEGREE VALID WITHIN TOLERANCE 

TOL. 

THE COEFFICIENT VECTOR OF THE N-TH SHIFTED CHEBYSHEV 

POLYNOMIAL IS CALCULATED FROM THE RECURSION FORMULA 

AKI = -A(K*I >«K*L»(2«K-U/12*(N*K-l)*(N-tC*IM. 

REFERENCE 

K. A. BRONS. ALGORITHM 37, TELESCOPE l. CACM VOL. A^i 1961. 

NO. 3, pp. 151. 



SUBROUTINE PECS ( P,N .BOUND, EPS, TOL .WORK I 

DIMENSION PdUMORKIl) 
FL=60UND*0.5 

TEST OF DIMENSION 

1 IFIN-112,3,6 

2 RETURN 

3 IF(EPS»ABS(P(m-TDLK,4,5 

4 N = 
EPS=EPS*flBSlP( 1)1 

5 RETURN ' 

CALCULATE EXPANSION OF CHEBYSHEV POLYNOMIAL 

b NEN0=N-1 

MORKf NI>-P(N1 

00 T J=l,NEND 

K = M-J 

FN=IN£ND-UK)*(N-KI 

FK=K*(K+K-l» 
T WORKIKl=-«QRKIK*ll*FK.*FL/FN 

TEST FOR FEftSlBILITY OF REDUCTION 

FN = ABS(MORK( II I 
IF(EPStFN-T0Lia,8i5 

REDUCE POLYNOMIAL 

a EPS=EPS*FN 

N=NENO 

DO 9 J=1,NEN0 
9 P( JJ=P( J)*WORKl Jl 

GOTO I 

END 



20 



50 



PECS 
.-PECS 
PECS 
PECS 
PECS 
PECS 
PECS 
PECS 80 
PECS 90 
PECS IDQ 
PECS 110 
PECS 120 
PECS 130 
PECS 1*0 
PECS 150 
PECS 160 
PECS 170 
PECS 180 
PECS 190 
PECS 200 
PECS 210 
PECS 2Z0 
PECS 230 
PECS 2*0 
PECS 250 
PECS 260 
PECS 2 70 

PECS zao 

PECS 290 
PECS 300 
PECS 310 
PECS 320 
PECS 330 
PECS 3*0 
PECS 350 
PECS 360 
PECS 370 
PECS 380 
PECS 390 
PECS *00 
PECS *10 
PECS *20 
PECS *30 
PECS **0 
PECS *50 
PECS *60 
PECS *70 
.PECS *80 
PECS *90 
PECS 500 
PECS 510 
PECS 520 
PECS 530 
PECS 540 
PECS 550 
PECS 560 
PECS 570 
PECS 580 
PECS 590 

pecs 600 

PECS 610 

PECS 620 

PECS 630 

PECS 6*0 

PECS 650 

PECS 650 

PECS 6T0 

PECS 6B0 

PECS 490 

PECS 700 

PECS 710 

PECS 720 

PECS 730 

PECS 7*0 

PECS 750 

PECS 760 

PECS 770 

PECS 780 

PECS T90 

PECS 800 

PECS SIO 

PECS B20 

PECS 830 

PECS 940 

PECS aso 

PECS B60 



180 Mathematics— Polynomials: Operations 



SUflfltXjriME DPECS 

PURPOSE 

ECONOHrZATIDN OF A POLrNOMlAL FOR UNSYMHETRIC RANfE 

USAGE 

CALL OPECS(P( N.eOUNOtEPStTOLf WORK) 

0€SCBIPriON OF PARAMETERS 

P - DOUBLE PRECISION COEFFICIENT VECTOR Of GIVEN 

PQLYNOHIAL 
N - OIMENSIOW OF COEFFICIENT VECTOR P 

BOUND - SINGLE PRECISION RIGHT HAND BOUNOARV Of INTERVAL 
EPS - SINGLE PRECISION INITIAL ERROR BOUND 

TOL - SINGLE PRECISION TOLERANCE FOR ERROR 

WORK - DOUBLE PRECISION WORKING STORAGE Of DIMENSION N 

REMARKS 

THE INITIAL COEFFICIENT VECTOR P 15 REPLACED 6Y THE 

ECONOMIZED VECTOR. 

THE INITIAL ERROR BOUND EPS IS REPLACED BY A FINAL 

ERROR BOUND. 

M IS REPLACED BY THE DIMENSION OF THE REDUCED POLYNOMIAL. 

IN CASE OF AN ARBITRARY INTERVAL (XL.XRJ IT IS NECESSARY 

FIRST TO CALCULATE THE EXPANSION OF THE GIVEN POLYNOMIAL 

WITH ARGUMENT K IN POMEtS OF T = (X-KLI. 

THIS IS ACCOMPLISHED THROUGH SUBROUTINE DPCLD. 

OPERATION IS BYPASSED IN CASE OF N LESS THAN 1. 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

NONE 

METHOD 

SUBROUTINE DPECS TAKES AN IN-IIST DEGREE POLYNOMIAL 

APPROXIMATION TO A FUNCTION F{Xl VALID WITHIN A TOLERANCE 

EPS OVER THE INTERVAL tCBOUNOI AND REDUCES IT IF POSSIBLE 

TO A POLYNOMIAL Of LOWER DEGREE VALID WITHIN TOLERANCE 

TOL. 

THE COEFFICIENT VECTOR OF THE N-TM SHIFTED CHEBYSHEV 

POLYNOMIAL IS CALCULATED FROM THE RECURSION FORMULA 

A(KJ = -A(K*ll*K»L*(2«K-ll/(2*IN*K-ll*{N-Ktm. 

REFERENCE 

K, A. BRONS, ALGORITHM 3T» TELESCOPE I. CACM VOL. *. 1961, 

NO. 3. PP. 151. 



SUBROUT INE OPECSl P. N, 80UND»EP5 , TOL , WORK I 



DIMENSION PI I).WORK(l) 
DOUBLE PRECISION P.WORK 



FL=90UND*0.5 

TEST OF DIMENSION 



3 IF(EPS»ABS(SNGL(P(l H l-T0L)*,*r5 
A N = 

EPS=£PS«-ABSISNGL(P( KM 

3 RETURN 

CALCULATE EXPANSION OF CHE9YSHEV POLYNOMIAL 

6 NEND=N-1 
MORK)NI=-P(N» 
DO 7 J= 1*NEND 

FN=(NEND-l*KI*(N-Kl 

7 WORKIKl=-MORK(K*n*D6LE(F(CI«OBLE(FLt/DSLE(FN) 

TEST FOR FEASIBILITY OF REDUCTION 

FN=0A6S(W0RK| 1) I 
IFIEPS+FN-TOL 18,8.5 

REDUCE POLYNOMIAL 

8 EPS=EPS*FN 
N-NENO 

00 9 J=liNEND 

9 PIJ}=P( J)*^U0RK(J) 
GOTO I 

END 



OPCS 10 

.OPCS zo 

DPCS 30 

OPCS *0 

OPCS 50 

OPCS 60 

OPCS TO 

DPCS 80 

DPCS 90 

DPCS ;oo 

DPCS 110 
DPCS 120 
DPCS 130 
DPCS 140 
OPCS ISO 
DPCS 160 
DPCS 170 
OPCS 180 
DPCS 190 
OPCS 200 
DPCS 210 
DPCS Z20 
OPCS Z30 
DPCS 2*0 
DPCS 250 
DPCS 360 
DPCS 270 
DPCS 290 
OPCS 2 90 
DPCS 300 
DPCS 3 ID 
OPCS 320 
OPCS 330 
OPCS 340 
OPCS 350 
DPCS 360 
OPCS 370 
OPCS 3B0 
OPCS 390 
DPCS *00 
OPCS 410 
OPCS 420 
OPCS 430 
DPCS 440 
DPCS 450 
OPCS 460 
DPCS 470 
OPCS 4B0 
.OPCS 490 
DPCS 500 
DPCS 510 
DPCS 5 20 
DPCS 530 
DPCS 540 
OPCS 550 
OPCS 560 
DPCS 5 70 
OPCS 580 
OPCS 590 
DPCS 600 
OPCS 610 
OPCS 620 
OPCS 630 
DPCS 640 
OPCS 650 
OPCS 660 
DPCS 670 
DPCS 680 
OPCS 690 
OPCS 700 
DPCS 710 
DPCS 720 
OPCS 730 
DPCS T40 
DPCS 750 
DPCS 760 
OPCS 770 
DPCS 780 
OPCS 790 
OPCS 800 
OPCS 81C 
OPCS B2Q 
DPCS 830 
DPCS 840 
DPCS 850 
OPCS 860 
OPCS 870 
DPCS 880 
DPCS 890 
DPCS 900 



Polynomials : Roots 

Subroutine POLRT 

This subroutine computes the real and complex 
roots of a real polynomial. 
Given a polynomial 

N 

f(z) - X; a z^ (1) 

^ n 
n=0 



let 



Z = X + lY be a starting value for a root of f(z). 



Then: 



n n 

Z = (X + iY) 



(2) 



Define X^ as real terms of expanded equation (2). 
Define Y^ as imaginary terms of expanded equa- 
tion (2). 
Then for: 

n = 

X = 1.0 
o 



n > 



X 



X • X , - Y. Y , 
n- 1 n- 1 



Y = X • Y + Y • X , 

n n - 1 n - 1 



(3) 

(4) 



Let: 



Then: 



U be the real terms of (1) 

V be the imaginary terms of (1) 



N 



U = E ax 



n =0 



n n 



(5) 



N 



V = y; a Y 

n = 



(6) 



or: 



N 

V = a + y a X 
o ^—', n n 
n = 1 



(7) 



V = 



N 

E a Y 
■*— '. n n 
n = 1 



(8) 



Mathematics — Polynomials: Roots 181 



au 

8Y 



N 

E n- X -a 
n = i »-l ' 

N 

- V n Y a 

'-' . n -1 n 

n = 1 



(9) 



(10) 



Note that equations (3), (4), (7), (8), (9), and (10) 
can be performed iteratively for n = 1 to N by saving 

X , and Y 
n - 1 n - 1 

Using the Newton-Raphson method for computing 
AX, AY, the result is: 



AX 



AY 



V-^ - U^ 
r 8Y ^ 8X 



\ aY 9X 





ir^fer 



(11) 



(12) 



after applying the Cauchy-Riemann equations. 
Thus, for the next iteration: 

X' = X + AX 

Y' = Y + AY 



SUBROUTINE PIXRT 

PURPOSE 

CMPUreS THE REAL *N0 CaMPLEX ROOTS DF A HEAL POLYNOHIAL 



10 



40 



TO 



USAGE 

CALL POLRTI)(C0F,COF,M,R0OTR,ROOTI, 



ERl 



oescRipriON of paraheters 

XCQF -VECTOR OF M*I COEFFICIENTS OF THE POLYNOMIAL 

DRPEREO FROM SMALLEST TO LARGEST POMER 
COF -WORKING VECTOR OF LENGTH H*l 
M -ORDER OF POLYNOMIAL 

ROOTR-RESULTANT VECTOR OF LENGTH M CONTAINING HEAL ROOTS 

OF THE POLYNONIU 
ROOTI-RESULTANT VECTOR OF LENGTH M CONTAINING THE 

CORRESPONDING IMAGINARY ROOTS OF ThE POLYNOMIAL 
lER -ERROR CQOE WHERE 

IER-0 NO ERROR 

IER>1 H LESS THAN ONE 

IEfl>2 M GREATER THAN 36 

ieR«3 UNABLE TO DETERMINE ROOT WITH 500 INTERATIONS 
ON 9 STARTING VALUES 

IER=4 HIGH ORDER COEFFICIENT IS ZERO 



PLRT 
.PLRT 
PLRT 
PLRT 
PLRT 
PLRT 
PLRT 
PLRT 
PLRT 90 
PLRT 100 
PLRT llO 
PLRT 120 
PLRT 130 
PLRT 140 
PLRT 150 
PLRT 160 
PLRT 170 
PLRT 180 
PLRT 190 
PLRT 200 
PLRT 210 
PLRT 220 
PLRT 2J0 
PLRT 240 
PLRT 250 
PLRT 260 
PLRT 270 
PLRT 280 
PLRT 290 
PLRT 300 
PLRT 310 



REMARKS 

LIMITED TO SfcTH ORDER POLYNOMIAL OR LESS. 

FLOATING POINT OVERFLOW MAY OCCUR FOR HIGH ORDER 

POLYNOMIALS BUT WILL NOT AFFECT THE ACCURACY OF THE RESULTS. PLRT 320 

PLRT 330 
SUeROUTINES AMD FUNCTION SUBPROGRAMS REQUIRED 

NONE 



METHOD 



NEWT0N-RAPHS3N ITERATIVE TECHNIQUE. THE FINAL ITERATIONS 
ON EACH ROOT ARE PERFORMED USING THE ORIGINAL POLYNOMIAL 
RATHER THAN THE REDUCED POLYNOMIAL TO AVOID ACCUMULATED 
ERRORS IN THE REDUCED POLYNOMIAL. 



SUBROUTINE POLR TI XCOF, COF, M, ROOTR.ROOri , I E« 1 
DIMENSION KC0F(n,C0F<ll,R00TR(l),R00T[IM 
OOUeLE PRECISION XO, YO, X, Y, KPft, YPR .UK.UY, V, YT , 
1 OX. OY, TEMP, ALPHA 



:T,U.XT2, YT2,SUMSQ, 



IF A DOUBLE PRECISION VERSION OF THIS ROUTINE IS DESIRED, THE 
C IN COLUMN I SHOULD BE REMOVED FROM THE DOUBLE PRECISION 
STATEMENT WHICH FOLLOWS. 

DOUBLE PRECISION XCOf ,COF ,ROOTR, ROOTI 

THE C MUST ALSO BE REMOVED FROM DOUSLE PRECISION STATEMENTS 
APPEARING IN OTHER ROUTINES USED IN CONJUNCTION WITH THIS 



PLRT 340 
PLRT 550 
PLRT 360 
PLRT 370 
PLRT J80 
PLRT 3 90 
PLRT *ao 
PLRT 410 
PLRT 420 
.PLRT 430 
PLRT 440 
PLRT 450 
PLRT 460 
PLRT 470 
PLRT 480 
PLRT 490 
PLRT 500 
PLRT 510 
PLRT 520 
PLRT 550 
PLRT 540 
PLRT 550 
PLRT 560 
PLRT 570 
PLRT 590 
PLRT 590 
PLRT 600 



THE 0OU8LE PRECISION VERSION NAY SE MO0IF[E0 BY CHANSIM tHF 
i'*!!^'?^ *5 SJArttENT Ti Td 1.00-12 ANO IN ifATE^Sr „ \^ 



IC«*0 

IFIXCOF(N»11I10.29,LO 
10 IFINI t5.15,32 

SET EMWl COM TO I 



15 lER-L 
20 RETURN 



SET EMOR COOC fO 4 

2S ICR-4 
GO TO 20 

SET ERROR COOC TO 2 

30 ICR-2 

GO TO 20 
}2 IflN-3«l $9.35.10 

39 NX-N 
NXX-N*t 
H2-1 

KJl - N*l 

DO 40 L-l,KJl 

BT-KJi-L+l 

40 COFCMT»-XC0F(LI 

SET INITIAL VALUES 



45 X0«. 00500101 
VO'O.OIOOOIOl 



2ER0 INITIAL VALUE COUNTER 



IN-0 
90 X-XO 
C 
C INCREMENT INITIAL VALUES AND COUNTER 

XO— |0.0*Y0 

ro— lO.O*X 
C 

C SET X ANO Y TO CURRENT VALUE 

C 

«-xo 

Y-YO 

IN-tN«L 

GO TO 94 
95 IFIT-I 

XPR-X 

YPR-T 
C 
C EVALUATE PGLYHOHIAL ANO OERIVATIVES 

59 ICT-0 

60 UX-0.0 
UY-0.0 
V -0,0 
VT-0.0 
XT-1.0 
U*COFfN«ll 
IFIUI 49,130.69 

65 00 70 l-l.M 

L -N-I*l 

TEN^-COFILl 

Xr2-X«XT-Y»YT 

VT2-X*VT*Y«XT 

U-U*T€«MXT2 

V-V*TeNr*TT2 

EI-I 

UX"(;X*FI*XT*TENP 

UY-UY-FI»YT*TeNP 

XT-xr2 
70 YT-TTZ 

SUH$a-UX*UX»UY*UY 

IFISUMSQI T5, 110*75 

79 OX«(V*UV-U«UX)/SUM$g 
X-X*OX 

Or--fU«UV«V*UXI/SUHSQ 
Y-T+OY 

78 IFfOABS(DV|*OA0S(DXI-L. 00-09) 100,80,80 
C 

C STEP ITERATION COUNTER 

C 

80 ICT-ICT^t 
IFIlCT-9001 60,<9,85 

85 IFI IF IT 1100*90.100 
90 1F(IN-5I 90.95.95 
C 

C SET ERROR CODE TO 9 

C 

95 IER-3 

CO TO 20 
100 00 109 L-l.MXX 
RT-RJl-L*! 
TEMP-XCOFIHTt 
ICOFINTI-COFILI 
105 CQFILI-TENP 
(TERP-N 
N-NX 

NX-ITENP 

IFI IFITI 120.55.120 
110 IfriFir* 115.50,115 

119 X-XPR 
Y«YPR 

120 IFIT*0 

122 lFIDABSIYI-l.0D-4*OAflSIXK 135,125,125 
125 ALPHA>X«X 

SUHSQ-X*K4^Y*Y 
H-N-2 
GO TO 140 
130 X-0.0 
NX-NX- 1 
NXX-NXX-l 
135 Y>0.0 

SUNSQ-0.0 
ALPHA*X 
N-N-1 
140 C0E(2)-C0FI2)*ALPHA«C0FI1I 



PLRT 610 
PLRT 620 
PLRT 6M 
nRT 640 
PLRT 450 
.....PLRT 660 
PLRT 670 
PLRT »«o 
PLRT 690 
PLRT 700 
PLRT 710 
PLAT 720 
PLRT 710 
PLRT 740 
PLRT 790 
PLRT 760 
PLRT 770 
PLRT TOO 
PLRT 790 
HRT 890 
^LRT 810 
PLRT 820 
PLRT 830 
PLRT 840 
PLRT 850 
PLRT 860 
PLRT 870 
PLRT 880 
PLRT 890 
PLRT 900 
PLRT «tO 
PLRT 920 
PLRT 950 
PLRT 940 
PLRT 990 
PLRT 960 
PLRT 970 
PLRT 900 
PLRT 990 
PLRTieOO 
PLRTIOIO 
PLR 71020 
PLRTtOSe 
PLRT1040 
PLRT 10 90 
PLRT1060 
PLRT1070 
PLRTI080 
PLflTt090 
PLRTllOO 
PLRTlllO 
PLRT I I 20 
PLRT1130 
PLRT1140 
PL»ni90 
PLRT 1160 
PLRT1I70 
PLRTlllO 
PLRTII90 
PLRT 1200 
PLRT1210 
PLRT1220 
PLRT1230 
PLRT1Z40 
PLRT 12 90 
PLRTlZiO 
PLRTU70 
PLRTt280 
PLRT 1290 
PLRT 1300 
PLRTUIO 
PL*ri320 
PLRTI130 
PLRT 1340 
PLRT 1390 
n.RT1360 
PLRT1370 
PLRT I 380 
PLRT 1390 
PLRT 1400 
PLRT1410 
PLRT 1420 
PLRTliSO 
PtRT1440 
PLRT 1450 
PLRT1460 
PIRT1470 
PLRT1480 
PLRT 1440 
PLRT1500 
PLRTISIO 
PLRT1920 
PLRT 1530 
PLRT 1940 
PLRT1950 
PLRT1560 
PLRT15 70 
PLRTt980 
PLRT1590 
PLRTtiOO 
PLRT 16 10 
PLRT1620 
PLRT1630 
PLRT1640 
PLRT1490 
PLRT1660 
PLRT1670 
PLRT1680 
PLRT 1690 
PLRTirOO 
PLRTITIO 

Kmm 

PLRTITSO 
«.«I17M 
PLRTirso 
PLKriTAO 

fLRTlTSO 

»i«ri7«o 
pinTiaoo 
PLurisio 

PLRrifljO 

PLitria3a 

PLftTtS40 

»L«ri«$o 
nRTia»o 
ptRiiaro 

flRTlul) 



182 Mathematics— Polynomials: Roots 



IM DO 150 I.-2.N 

ISO CDr(L*ll-COFa«tl*tlPH«>COFILI-SUMS0«CaFIL-ll 

199 KOOTIItlZI-V 

RO0rRIN2l-K 

N2<N2*I 

IFISIMSOI 160. IM. 160 
160 y— V 

SU<ISO>0.0 

GO TO 159 
165 IFINI 20,20,69 

END 



rt«Tl«90 
fLUtlMO 
PlKTlllO 
PLftT192a 
PlMlSiO 
PLftTl960 
PLftri990 
ri.llT1960 
FLUTltrO 

PLRri9ao 
PLIHH9a 



Subroutines PRQD and DPRQD 

These subroutines find the roots of a real polynomial 
by means of the QD-algorithm with displacement. 
The progressive QD-algorithm is a fast device for 
calculation of all roots of a polynomial P(x) with real 
coefficients when there are no approximations to the 
roots available. 

The roots of P(x) = are determined by solving 
for the poles of Q(x)/P(x) where Q(x) is some poly- 
nomial of smaller degree than P(x). In the foUow- 
ii^, n is used as the symbol for the degree of P(x). 
Using the derivative P'(x) for Q(x) has the advantage 
that the poles are simple even in case of multiple 
roots of P(x). 

Start of the QD-algorithm requires the continued 
S-fraction: 



c 
1-e 



1 
1-. 



— of P' (X)/P(X) 



This calculation is performed using the Euclidean 
algorithm. By means of normalization such that the 
highest coefficient is 1, Qq (x) is obtained from 
P(x), and Vi (x) from P' (x). Then ej^ and qj^ are 
calculated from the iteration scheme: 

qj^Qj^(x)= X. Pj^(x)-Qj^_^(x). k=l,2 n (1) 

^k ^k+ l^''^ = ^k^"") ' ^k^''^ ' k = 1, 2, . . . . n-1 (2) 

using the fact that all elements Qj(x) and Pj^(x) are 
normalized by definition. 

The following example is an illustration for this 
iteration scheme: 

2 3 
P(x) =l+3x+3x+x ,n=3 



3 2 

Q (x) = X + 3x + 3x + 1 



2 2 

P^(x) = X + 2x + 1 , q^Q^(x) = -X -2x-l, q^= -1 



Q^(x) = x + 2x + 1 , e^ PgCx) =0 . e^ = 



Mathematics — Polynomials: Roots 183 



where Q^ (x) is a common divisor of P' (x)/P(x) and 
qi = -1 is the value of the real root which factors out 
first. 

The above iteration scheme breaks down if some 
intermediate value of q^^ with < i < n is equal or 
approximately equal to zero. In this case an error 
code is set to 4, which indicates that no S -fraction 
exists for P' (x)/P(x). 

If Qq and P]^ have a common divisor of degree j , 
this common divisor is obtained as Qn_-j, and nec- 
essarily e^.^ Pj^_.+;L= 0. 

Due to roundoff errors, all coefficients of 
®n-i Pn-j+ 1 cannot be expected to vanish exactly; 
therefore, allowance is made for coefficients of 
small absolute value. 

If the highest coefficient of e^.j Pn_j+ 1 is small 
in absolute value but some lower coefficient is not, 
the error code is set to 4, and the subroutine is 
abandoned. 

The coefficients e. , qj^ obtained by the Euclidean 
algorithm form the first row of the QD -array indi- 
cated by superscript 0. 



,(0) JO) JO) JO) 



, (0) . (0) 



m 



m 



If xk and xjj+ ^ are of equal absolute value, then 
the roots of 



(v+1) 



(V) 



(v)^ (V) 



-(V '^v7)--v'\ri'= 



(5) 



converge to xjf and Xj^+j^. The same reasoning applies 
if the relation | xj^ ( = | xj^+ 1 \ holds only approxi- 
mately. 

The QD -algorithm in the form (3), (4) suffers from 
the fact that convergence is rather slow. By means 
of displacement of the origin a form is obtained 
which is asymptotically of quadratic convergence. 

The strategy is as follows. Start with displace- 
ment t = 0. 

I. As soon as convergence is indicated to a real root 
-- that is, e^ is sufficiently small (internal 
test value 0. 01) — perform a displacement by the 

^ (V) 

amount q . 
m 

(v) (v) 
Starting with q^^ ', e^ ', use instead of (3), (4) 

the iteration scheme: 



t = t + q 



(V) 

m 



(6) 



Jl) 



^r 4" 



,(1) 



^' 



.(1) 






, k = 1,2, ... , m 



(7) 



Normally m is equal to n but it may be smaller If a 
common factor exists. 

The following rows are obtained by means of the 
relationships: 



(v+l)_ ^ (v)_(v) /„(v+l) 



= q, 



k+ 



KV' 



, k = 1,2, . . . , m-1 



(8) 



„ (v+1) _ „ (V) , ^(v) ^ (v+1) 

q. ~ ^i i ~ i-1 ' 1= !.•••. «i (3) 



(v+1) (v) 

Values e^ and e ^ are thereby set equal to 

zero. 



(v+1) i Vl . , 
"i = (v+1) • i=l.-".'«-l 

^i 



II. If convergence is indicated to a root pair — that 

(v) (v) 

(4) is, e is less than e^ _ and sufficiently small 

(internal test value 0.01) — calculate the dis- 
criminant of the quadratic equation (5): 



tc^ether with e 



(V). 



e (^) = 0. 
m 



Let xj denote the roots of P(x) ordered in de- 
creasing absolute value. If P(x) has only roots of 
different absolute value, there is convergence of 
the qj^ - column to the value x^. Complex roots are 
indicated by oscillation of certain q-values. 



D =. p * p - qf^^ * q (^^ 
m nn-1 



with 

P=0.5(q<^) +e(^\ + q(^>) 
m-1 m-1 ^m ' 



184 Mathematics— Polynomials: Roots 



If D is positive, provide for a real displacement 
of amount P - /d or P + ITd, whichever has the 
smaller absolute value, and proceed according to 
(7), (8). 

If D is negative, three complex displacements 
are applied in sequence: the first by amount 
P + i i/TdT , t he se cond by -2i /IdT , and the 
third by V + i /IdT , resulting in a total real 
displacement of amount P. 

Instead of (6), (7), (8) the following iteration 
scheme is then obtained. Starting with: 



Values e 



t 



= t + P 



* (v) (V) 

q = q ' + e; 



* 2 






\ = 


% 


^h 


calculate for k = 2,3 m: 


* 




\ \ Vl 


** 






Pk 




** * 2 
= Pk-1 K-1 / \ > 



- p 



^k-1 



** 



** ** (v+3) 

"k-l * \-l - \-2 



-'C^^-'il^^^^ 






Jv+3) 
■'k-l 



Finally set: 



** ** 



(Vl % /'ik-7'^(i-Pk) 



(v+3) 



** (v+ 3) 
m m-1 



(9) 
(10) 

(11) 
(12) 
(13) 



(14) 
(15) 
(16) 
(17) 
(18) 
(19) 
(20) 



(v+3) 




(v) (v) 

e and qj^ are thereby set 



equal to zero. 



m. 



If none of the values e^^' , and e '^' is suffi- 
ra-1 m-2 

ciently small, the relationship (3), (4) is used 

with no displacement at all. 



Regarding termination of the iterative scheme 
given by I. , n. , III. there are two possibilities: 



If e 



(V) 



10 



is negligible (internal test value is 
"° in single precision and 10~16 in double preci- 



(21) 



sion), a real root is factored out. 

(v) 
2. If e ^ is negligible (with the same internal 

test values), a pair of roots is factored out. 

A maximum of ten times the number of coeffi- 
cients using I. , II. or in. is allowed. At every itera- 
tion step for one and the same root or root pair, the 
internal test value for convergence and the internal 
test value for acceptance of a displacement are in- 
creased by ten percent. 

In case of convergence: 

1. For a real root -- 

real part of root = t + q^^ 
complex part of root = 

2. For a real root pair (characterized by D>0) — 

real part of first root = t + P + \/V 
complex part of first root = 
real part of second root = t + P - /d 
complex part of second root = 

3. For a complex root pair (characterized by 
D < 0) — 

real part of first root = t + P 
complex part of first root = /-D 
real part of second root = t + P 
complex part of second root = - V-D 
As soon as a root or root pair has been factored 
out, m is reduced by 1 or 2 respectively and the 
whole procedure I. , n. , III. is repeated with original 
values of internal test values, until m = — that is, 
all roots have been calculated — or m = 1, when the 
last real root is factored immediately. If P' (x), 
P(x) have a common divisor, the whole process is 
repeated for this common divisor. Thus, the com- 
plete factorization of the original polynomial P(x) is 
obtained. 

Some remarks are in order: 

1. The QD-algorithm is a nonlinear relationship 
and therefore sensitive to roundoff errors. Small 
intermediate q-values cause loss of accuracy. 
Therefore, aU divisors are checked before division 
is actually performed. If a divisor is small in 



Mathematics— Polynomials: Roots 185 



absolute value due to loss of significant digits, the 
error parameter is set to 3 indicating possible 
instability of calculation, and further calculation is 
bypassed. 

2. If a maximum of 10 * n iteration steps is 
insufficient for calculation of all roots, the error 
parameter is set to 1, indicating poor convergence. 
Further calculation is bypassed again. 

3. If the original polynomial has a degree less 
than one, the error parameter is set to 2 indicating 
that no root exists. 

4. If, in case of a complex displacement, q , 
or q_ gets very small due to loss of significant 

digits, and the calculated e ^^ ' is less than the 

internal test value TOL, a pair of roots is calculated 
from the quadratic equation: 



Z ** * (v+3) ♦♦ * 



[e ** -I 



(22) 



which is easily obtained from (5), 

5. A final test of accuracy is made after calcu- 
lation of all roots of the given polynomial. The 
calculated roots are used for calculation of the 
corresponding coefficient vector. If this calculated 
coefficient vector has less than a specified number 
of correct digits (the maximal relative error must be 
less than TOL), the error parameter is set to -1 
indicating that calculation of all roots was successful 
only with poor accuracy of results* 



loots OF A GIVEN POLyNQMIAL 



SUfiAOUTtNE PRQO 

PURPOSE 

CALCULATE ALL REAl AND COMPLEK 
ttlTH REAL COEfFICIENIS. 

USAGE 

CALL PRQ0{C,ICtQ,E,P01. IR. lERI 

OESCRIPriON OF PARAMETERS 

C - COEfFICIENr VECr3R OF GIVEN POLYNOMIAL 

COEFFICIENTS ARE ORDERED FROM L OM TO MIgh 

THE GIVEN COEFFICIENT VECTOft GETS DIVIDED BY THE 

LAST NONZERO TERM 
IC - DIMENSION OF VECTOR C 

Q - tfORKING STORAGE OF DIMENSION IC 

ON RETURN CONTAINS REAL PARTS OF ROOTS 
e - WORKING STORAGE OF DIMENSION IC 

ON RETURN E CONTAINS COMPLEX PARTS OF ROOTS 
POL - WORKING STORAGE Of DIMENSION IC 

ON RETURN POL CONTAINS THE COEFF/CIENTS OF THE 

POLYNOMIAL WITH CALCULATED ROOTS 

THIS RESULTING COEFFICIENT VECTOR HAS DIMENSION IRh 

COEFFICIENTS ARE ORDERED FROM LOW TO HIGH 
IR - NUMBER OF CALCULATED ROOTS 

NORMALLY IR IS EQUAL 10 DIMENSION IC MINUS ONE 
lER - RESULTING ERROR PARAMETER. SEE REMARKS 



30 



REMARKS 

THE REAL PART OF THE ROOTS IS STORED IN 0(11 UP IQ Q(ir) 

CORRESPONDING COMPLEX PARTS ARE STORED IN EUl UP TO EdflJ 

lER = MEANS NO ERRORS 

lER = 1 MEANS NO CONVERGENCE WITH FEASIBLE TOLERANCE 

lER » Z MEANS POLYNOMIAL IS OEGEMERATE (CONSTANT OR ZERO) 

lER - i MEANS SUBROUTINE WAS ABANDONED DUe TO ZERO DIVISOR 

K MEANS THERE EXISTS NO S-FRACIION 



lER 



PRQD 

..PROD 

PROO 

PROD 

PROO 50 
PRQD 60 
PROO 70 
PRQD BO 
PROO 90 
PROO 100 

PRQD no 

PROO 120 
PROD 130 
PROO 1^0 
PROO 150 
PROO LfrO 
PROO I TO 
PROO ISO 
PROO 190 
PRQO 200 
PROD 210 
PROO 220 
PRQO ^J0 
PRQD ?40 
PROO 250 
IPRQO 260 
PROO 270 
PROD 280 
PROO 290 
PROO 300 
PRQO 310 
PROD J20 
PRQO 3 30 
PROO 3^0 
PROD 350 
PROO 360 
PROD 3 TO 

PROO sao 

PROO 390 



liR —I MEANS CALCULAfEO COEFFICUNT VECTOR REVEALS POOR 

ACCURACY or THE CALCULATED ROOTS. 

TMC CALCULATED CQEFf ICIENI VECTDK HAS LESS THAN 

1 CORRECT DIGITS. 
THE FINAL COMfAKISON SETUCeH GIVEN AW C*LCUtAT£D 
COEFFICIENT VECTOR IS PERFOMEO ONLY IF ALL ROOTS HAVE BEEN 
CALCULATED. \ 

THE HAKIMAL RELATIVE ERROR OF THE COEFFICIENT »EC?0« 1$ 
RECOROEO IN Qllfttll. 



SUBROUTINES AND FUNCTION SUBPAOCRAHS REQUIftCD 
NONE 

METHOD 

THE ROOTS OF THE POLYNOMIAL ARE CALCULATED BY MEANS OF 

THE OODriEMr-OIFfEREIICE ALCORITHN UITH DISPLACEMENT. 

REFERENCE 

H.RuriSHAUSER, OER OUOTIEHTEN-aiFFERENtEH-ALGORI THHUS. 

BIRKHAEUSER. BASEL/STUrTCART. t«57. 



SUBROUTINE PRgOfC. 1 C.Of £iPOL. IR, ICR) 
C 
C DINENSIONEO OUNNT VARIABLES 

DIMENSION El ll.QI II .C( ll.rOLI 1 I 
C 

C NORMALICATION OF GIVEN POLYNQHUL 

C TEST OF DIMENSION 

C IR CONTAINS INOEl OF HIGHEST COEFFICIENT 

lER-O 
IR-IC 
EPS-l-E-6 
TOL-I.E-3 
LIMIT-10*IC 
KOUNT-0 
i IF! IR-1IT9,79,2 
C 

C DROP TRAUING ZERO CaEFFIClEKTS 

2 lF(C(IRII«,3,<t 
1 IR-IR-L 
GOTO I 
c 

C REARRANGEMENT OF GIVEN POLVHONIAL 

C EXTRACTION OF 2ER0 ROOTS 

« O-l./Ct IR) 
lENO-IR-L 
ISTA-I 
NSAV-IR*! 
JBEC-I 
C 

C Q<J}-1. 

C 0IJ4^I1-CIIR-I)/C(IRI 

C QIIRl-CIJI/CIIRI 

C WHERE J IS THE INDEX OF THE LOWEST NON2ERO COEFFICIENT 

DO 9 1-1, IR 
J-NSAV-I 
|F(CII1I7.».7 

s Gorai6.ai,jBEc 

6 NSAV-NSAV*| 
QdSfAI-D. 
EMSTAI-O. 
l5TA-ISTA+t 
GOTO « 
T J8EC-2 
a 0(JI-C( ll«0 

CIII-QIJI 
9 CONTINUE 
C 

t INITIALIZATION 

ESAV-0. 
QdSTAI-O. 

10 NSAV-IR 

CONPUTATION OF DERIVATIVE 
EXPT>IR-ISTA 
EUSTAI-EXPT 
DO 11 I-ISTA,IEW> 
EXPT-EXM-l.O 
POL(I*ll-EFS*A8S(0f I«IU«EPS 

11 E(I«lt-Q(l«ll*EXPT 

TEST OF REMAINING DIMENSION 
IFI ISTA-ICNOI12.20«60 

12 JENO-IEHO-I 

COMPUTATION OF S-FRACTION 
00 19 I-ISTA,JENO 
IF<l-ISTAIt3,|6*l) 

13 [FIAB$(Eltll-POLII«lllI4.I4*14 

THE GIVEN POLYNOMIAL HAS HULtlPLE ROOTS, THE COEFFICIENTS OF 
THE COHNON FACTOR ARE STORED FROM QINIAV) UP TO QIIRI 

14 NSAV-I 

DO t» K-I.JEND 

lFIASSIEfKII-POLIK»llllS,IS.M 
19 CONTINUE 
GOTO 21 

EUCLIDEAN ALGORITHM 
14 DO 19 K-I, TEND 

£|K«II-EU»1I/EII) 
q(K*|l-E(K*ll-0(K*ll 

iFiK-i I la.tr.ie 

TEST FOR SHALL DIVISOR 
17 IFIA6S(Q(l*lM-POLI 1*1 1 I SO. 80, 19 
It Q(K«1I-Q(K«1I/0M«II 

POLlK*ll-POLf«t«LI/ABSIQ( l«in 

E(i(l-OIK«II-EIKl 

19 CONTINUE 

20 QIIR)--q(|Rl 

THE DISPLACEMENT EXPT IS SET TO AUTOMATICALLY. 

EUSrA).0..0(ISTA*ll E(NSAV-ll,Q|NSAVI,EINSAV|-0.. 

FORM A DIAGONAL OF THE QD-ARRAY. 
INITIALUATIQN OF BOUNOARY VALUES 

21 EIISTAI-0. 
HRAN-NSAV-1 

22 E(NRAN*1I>0. 

TEST FOR LINEAR OR CONSTANT FACTOR 
NRAN-ISTA IS OECREE-t 
IF(NRAN-ISrAI24,21,31 

LINEAR FACTOR 

23 Q(ISTA*II>g(ISTAi-l)*€XPT 
E( ISTA*ll-0. 



PROD 400 
PROO 410 
PRQO 420 
PRQD 430 
PROO 440 
PROO 490 
PRQO 440 
PRQO 4 70 
PROD 4 BO 
PROO 490 
PRQO SOD 
PROO 910 
PRQO 120 
PROO 910 
PROD 540 
PROO 550 
PROO 940 
PRQO 9 70 
PRQD 9«0 
PRQO 990 

.PROO 600 

PRQO 410 
PRQD 420 
PRQO 630 
PRQD 440 
PRQD 490 
PRQD 440 
PROO 470 
PRQD 4B0 
PROD 490 
PROO 700 
PRQD 710 
PRQO 720 
PRQO 790 
PROD T40 
PROO 750 
PRQO 740 
PRQO 770 
PRQO 7«0 
PRQO 790 
PRQO a 00 
PRQO BIO 
PRW) B20 
PROO a 90 
PRQO B40 
PRQO B90 
PRQO 460 
PRQO BTO 
PROO BBO 
PRQD a90 
PRQO 900 
PRQO 910 
PRQO 920 
PRQO 930 
PRQD 940 
PRQD 950 
PROO 960 
PRQD 970 
PRQO 9B0 
PRQO 990 
PRQDIOOO 
PROOlOlO 
PROD1020 
PRQDI030 
PRQOI040 
PROOIO90 
PR0O1060 
PROOIOTO 
PRQDIOBO 
PRaol090 
PROOllOO 
PRQOltIO 
PRQ0I120 
PRQ01130 
PRQD U 40 
PftQDI150 
PRQOIUO 
PRQ01t70 
PRQOliaO 
PRQOI190 
PRQO1200 
PRQDlflO 
Pft001220 
PRQ012 30 
PRODI 240 
PR001290 
PRODI 260 
PRQO1270 
PROOtZBO 
PRQO 12 90 
PRQ01300 
PRQOl 9 10 
PRQD 1920 
PRODI 330 
PRQOl 340 
PRQOt350 
PRQOl 960 
PR 001370 
PRQDtSaO 
PROO 1390 
PRQ01400 
PROO1410 
PRQOl 420 
PRQOt430 
PRQ01440 
PR001490 
PRODI 440 
PRQ01470 
PRQOl 410 
PRQD1490 
PROOt900 

nmm 

PROOt920 
PRQDt930 
PRQOl 940 
PRQ01990 
PRQOl 540 
PRQOt970 

PR0O19B0 

PR0O1590 

PRQ01600 

PRQOlfrU 

PRQD1420 

PRQOt490 

PRQ0I440 

PRQD1450 

PROD I 640 

PRQOl 6 70 

PRQ01680 



186 Mathematics— Polynomials: Roots 



TESt FQA UNFACT3RE0 COMMON DIVISOR 

24 E< ISTAl-ESAV 

IFt [R-N$AV)60,60,25 

INITIALIZE qO-ALGORITHM FOR COMHON OIVISaR 

25 ISTA-NSAV 
€SAV-EI ISTAl 

GOTO 10 



TEST FOR REAL ITY 
IF(a)27,28,2a 

COMPLEX ftOOT PAIR 

27 Q(NRAN)-P 
Q(NRAN»il<P 
EINRAN)-T 
EINRAN*U>~T 
GOTO 29 

REAL ROOT PAIR 

28 QINRANJ-P-T 
q(NRANt'l|':P*T 
EINRAN>>0. 

REDUCTION OF DEGREE BY 2 (DEFLATION) 

29 NRAN=N)t*N-2 
GOTO ZZ 

COMPUrATIOH OF REAL ROOT 

30 Q(NRAN*1>-EXPT*P 

REOUCnON OF DEGREE BY 1 (OEFLATION) 
NRAN=NRAN-1 
GOTO 22 

START QD-ITERATION 

31 JBEC=ISTA»1 
JENO'NRAN-1 
TEPS=£PS 
TDELT-l.E-2 

32 K0UNr>KGUNr4-l 
P-QINRAN>1} 
R>AB$(E1NRANII 

TEST FOR CONveRGEHCe 
IFIR-TEPS)30. 30,33 

33 $>ABSIE(JENDn 

IS THERE A REAL ROOT NEXT 
IF($-ft)36r38,3A 

IS OISPLACEMENT SMALL ENOUGH 
3* IF(R-T0ELT136, 35.35 

35 P-0. 

36 0-P 

DO 37 J'JSEG.NRAN 
Q(Jt>Q( JI*eiJI-E(J-ll-0 

TEST FOR SHALL DIVISOR 
IF(A6S(0(Jn-POL< J) )S1.B1«3T 

37 EIJ)»0(J+l)*EtJ)/Q< J) 
QINRANUl— E«NRANI*Q(NRAN*ll-0 
GOTO 54 

CALCULATE DISPLACEMENT FOR DOUBLE ROOTS 
QUADRATIC EQUATION FOR OQUBLE ROOTS 

X**2-(Q(NAANUgCNRAN*ll»E(NRAN))*XtgiNRANI*aiNRAN» Il- 
ls P=0.5*(Q(NflANI«-E(NRANl*Q(NRAN*LI) 
0-P*P-QINRANl*afNRAN>l) 
T>SQRT(A8SI0)I 

TEST FOR CONVERGENCE 
1F(S-TEPSI26,26,39 

ARE THERE COMPLEX ROOTS 

39 IFIQU3|40t40 

40 IF(PK2t4Lt41 

41 T — T 
«2 P=P*T 

R=S 
GOTO 34 

MODIFICATION FOR COMPLEX R30TS 
IS DISPLACEMENT SMALL ENOUGH 
*3 IFIS-rO£lT)*4t 35,35 

INITIALIZATION 
** 0=QIJBEGI*EIJBEGI-P 

TEST FOR SMALL DIVISOR 
IFUeS<0)-P0L(JBEG)l8l.flU45 

45 T-IT/QI**2 

U-ei JBEG)*0( JBEC*lt/IO*(l.*TH 

V=Q*U 
«0UNT=KOUNT»2 

THREEFOLD LOOP FOR COMPLEX DISPLACEMENT 
DO 53 J'jeEG.NRAN 

o«a( j*ii*£(j*ii-u-p 

TESr FOR SMALL DIVISOR 
IFIABSI Vl-P0L(Jl»*6.*6,49 

46 tF( J-NRANiair4T,Bl 

47 EKPT=EXPTtP 
IFIABS(E(JEN0ll-TOL>4e.48.6L 

48 P"0.5*l V«0-E( JENOI I 

0=P*P-| V-U»*(0-U*T-0*W*(l.*TI/0( JENOl 1 

T-SQRTUBSIOM 

GOTO 26 

TEST FOR SMALL OIVlSOR 

49 IF(ABSf01-P0L(J*M I 46,46,50 

50 H=U*0/V 

T*r»(v/ai**2 

Q(J)"VH(-E( J-l I 

U-0. 

IF{J-NRANI5L,52.52 

51 U-Q( J»2)*e(J»ll/IO*(l. + T) I 

52 V=0*U-M 

TEST FOR SMALL OIVISOR 
|F(A8S(0<J>I-P0LUI 181.81.53 

53 El J»=H»V*(l.*TI/Q(JI 
QINRAN* tl=V-elNRANI 

54 EXPT-EXPT*P 
TEPS-TEPS*!.! 



PR00I690 
PRODI TOO 
PRQOiriO 
PR001T20 
PROD 17 30 
PRODI T40 
PRQ01T50 
PROO1T60 

pROOirro 

PRODI 780 
PRQDir90 
PRQOtBOO 
PRQOiaiO 
PRQ01B2Q 
PRQ01B30 
PRQOI840 
PR0OLS50 
PRQOLB60 
PRQOlSTO 
PRODISRO 
PROD 1690 
PR0D1900 
PRa0l910 
PRq0l920 
PRa01430 
PR001940 
PRQD1950 
PRQ0L9&0 
PA001970 
PRQD198a 
PRQ01990 
PROO2000 
PRQDZOIO 
PRQ02020 
PROD2030 
PRQD2040 
PR002050 
PftOD2D60 
PROD20 7O 
PROO2080 
PRQO2090 
PROO2100 
PR0D2110 
PRQ0Z120 
PRQDZiaO 
PRQO2140 
PR0021S0 
PRQO2160 
PRQD2170 
PRQD2180 
PRQ02190 
PRQO2200 
PR0O2210 
PRQ02220 
PROO2230 
PRQ02240 
PRQD2250 
PR0D226a 
PRQ022 70 
PRQD22Ba 
PRQ02290 
PRQD2300 
PRQ02310 
PROO2320 
PRQD2330 
PRQ02340 
PRQOZ350 
PRQ02360 
PRQO2370 
PRQDZ380 
PRQ02i90 
PRQ02400 
PRQOZ^ 1 
PRQD24Z0 
PRQ02430 
PR0D2^40 
PRQ02450 
PRQD2460 
PRgO2470 
PRQ024B0 
PRQ02490 
PRQD2500 
PRQD2510 
PR002529 
PRgD2530 
PRQD2540 
PRQD2550 
PRgOZ560 
PRQ02570 
PRQD2580 
PR00Z590 
PRQD2frOO 
PRQD2610 
PRQ02620 
PR002630 
PR002640 
PR002650 
PR002660 
PRQ02670 
PRg026S0 
PRgD2690 
PR002700 
PRQD2T10 
PHOO2720 
PRG02 730 
PR002T40 
PRQ02750 
PR002 760 
PR002 7 70 
PRgD2 780 
PRQOZ790 
PR002600 
PR002810 
PHQ02820 
PR0O2830 
PRQ02840 
PRQ0285a 
PRgD2B60 
PR0O28 70 

pRgozsao 

PRQ02B90 

PROO2900 
PROO2910 
PROD2920 
PRaD2 93Q 
PRQD2 940 
PRQO2950 
PR002960 
PRQ02970 



TDELT>TD£Lr*L.l 
|F(ROUNT-LIMITI 32,5 5,55 

NO CONVERGENCE M ITH FEASIBLE TOLERANCE 

ERROR RETURN IN CASE OF UNSATISFACTORY CONVERGENCE 

55 lER-l 

REARRANGE CALCULATED ROOTS ^ 

56 IENO>NSAV-NRAN-I 
E( ISTA)>ESAV 

1F( IENDI59,59.57 

57 00 SB 1>1.[EN0 
J>1STA*I 
K-NRAN4'1*I 
E{J)=E(K) 

58 Q<JI='QIK) 

59 1R-[STA*IEN0 

NORMAL RETURN 

60 IR=IR-l 

fF( IR)78,78,61 

REARRAMCe CALCULATED ROOTS 

61 DO 62 l-l*IR 
Q(I >-Q( I»l) 

62 E(1I-E(I»1I 

CALCULATE COEFFICIENT VECT3R FROM ROOTS 
POL(IR»tl=l. 
IEN0»IR-1 
JBEG=L 

DO 69 J>ltlR 
ISTA»IR+1-J 
0-0. 

P=Q( ISTAl 
r»E( ISTAl 
IF( T)65,63,65 

MULTIPLY WITH LINEAR FACTOR 

63 DO 64 [-ISTA.IR 
POL(n«0-P*POL(I*l) 

64 O-POLd+Xl 
GOTO 69 

65 G0Ta(66.6TI* J6EG 

66 JBEG«2 

POLl ISTA)*0. 
GOTO 69 

MULTIPLY WITH OUAORATIC FACTOR 

67 J6EG=1 
Uep«p*T*T 

p.p*p 

00 68 l>ISrA,IENO 
POLl n«O-P«P0L( l*lt ♦U*POL( 1*2) 
frB O'POLI Ivlt 
POHIRI=0-P 

69 CONTINUE 

IFI IERI7B.7C,78 

COMPARISON OF CDEFFICIENT VECTORS, IE. TEST OF ACCURACY 

70 P-0. 

DO 75 I't.IR 
IFIC(IU72,71.72 

71 0-ABS(POL( I)) 
GOTO 73 

72 O-ABSI (POLl I )-C(I ll/C( 1 )l 

73 IF(P-ai 74.75,75 

74 P»0 

75 CONTINUE 
IFIP-TOLl 77.76,76 

T6 lER— 1 

77 QIIR*1I=P 
E(IR+L)>0. 

78 RETURN 

ERROR RETURNS 

ERROR RETURN FOR POLYNOMIALS OF DEGREE LESS THAN I 

79 IER=2 
IR«0 
RETURN 

ERROR RETURN IF THERE EXISTS NO S-FRACTION 

80 IER^4 
IR-ISTA 
GOTO 60 

ERROR RETURN IN CASE OF INSTABLE QD-ALGORITHM 

81 IER>3 
GOTO 56 

END 



SUeR(XiriNE DPRQO 

PURi'OSE 

CALCULATE ALL REAL AND COMPLEX ROOTS OF A GIVEN POLYNOMIAL 
KITH REAL COEFFICIENTS. 

USAGE 

CALL 0PR001C. iC, Q.E.POL, IR, lER) 

DESCfllPriON OF PARAMETERS 

C - COEFFICIENT VECTOR OF GIVEN POLYNOMIAL 

COEFFICIENTS ARE ORDERED FROH LOM TO HIGH 

THE GIVEN COEFFICIENT VECTOR GETS DIVIDED 8V THE 

LAST NONZERO TERN 

DOUBLE PRECISION ARRAY 
IC - DIMENSION OF VECTOR C 

Q - WORKING STORAGE OF DIMENSION IC 

ON RETURN Q CONTAINS REAL PARTS OF ROOTS 

DOUBLE PRECISION ARRAY 
E - WORKING STORAGE OF DIMENSION IC 

ON RETURN E CONTAINS COMPLEX PARTS OF ROOTS 

DOUBLE PRECISION ARRAY 
POL - WORKING STORAGE OF DIMENSION IC 

ON RETURN POL CONTAINS THE SOEFFICIENTS OF THE 



PR0029aO 
PRQ02990 

PR0D3000 
PRaO3010 
PRQO3020 
PR003030 
PRQD3040 
PR«33050 
PR003060 
PROO3O70 
PROO30B0 
PRgO3090 
PRQO3100 
PRQ03UO 

pRgoaizo 

PRQD3130 
PRQ03140 
PftOO3L50 
PRg03t60 
PRQD3170 
PR0D3180 
PRQ03190 
PR003200 
PR003210 
PRQD32Z0 
PR0D3230 
_ PRgO3240 
PRQ03250 
PROD3260 
PRQ03270 
PRQO3Z80 
PRQ03290 
PRQD3300 
PROD3310 
PRQ0332a 
PRQ03330 
PRQ03340 
PRQO33S0 
PR0O3360 
PRODS 3 70 
PR003380 
PRQ0339a 
PAQD3400 
Pft(K>3410 
PRQ03420 
PRQO3430 
PRQ03440 
PRQO3450 
PRQD3460 
PRQ03470 
PR(JD34aO 
PROO3490 
PRQD3S00 
PR0035 10 
PROD 35 20 
PRQ03530 
PRQ03540 
PR0D35S0 
PRQ03560 
PR0O3570 
PRQ03SBO 
PRQD3590 
PRQO3600 
PRQ03610 
PR0D3620 
PRQ03630 
PRQ03640 
PRQO3650 
PRQ03660 
PRQD3670 
PRg03680 
PRQ03690 
PROD3700 
PRQ03710 
PRQO3T20 
PROD3T30 
PRQO3740 
PROO3T50 
PRg03T60 
PRQD377Q 
PRQ03T80 
PRQ03T90 
PRQD3B00 
PROOSeiO 
PRQO3820 
PRQD3630 
PRQ038AO 
PRQO3B50 
PRQD3B60 
PRQO3870 



opRg 10 

..OPRO 20 

OPRQ 30 

DPRO 40 

OPRQ 50 

OPRQ 60 

OPRQ 70 

OPRQ 80 

OPRQ 90 

OPRO 100 

OPRQ 110 

vm m 

OPRQ 130 
DPRO 140 
OPRg 150 
DPRO 160 
OPRO 170 
DPRg IBO 
OPRQ 190 
OPRQ 200 
OPRQ 210 
DPRQ 220 
DPRg 2 30 
OPRQ 240 
OPRQ 250 
DPRQ 260 
DPRQ 270 



Mathematics — Polynomials: Roots 187 



POLYNOMIAL KITH CALCULAICO ROOTS 

THIS RESULTING COefFICIEST VECTOR HAS OINENSION IR* 

COEFFICIENTS Aft£ OROEREO FROM LOW TO HIGH 

DOUBLE PRECISION ARRAY 
IR - NUMBER OF CALCULATED ROOTS 

NORMALLr IR IS EQUAL TO DIMENSION IC HIMUS ONE 
lER ~ RESULTING ERROR PARAMETER. SEE REMARKS 

REMARKS 

THE REAL PART OF THE ROOTS IS STORED IN Qdl UP ro QdR) 

C0RR6SP0N0INC COMPLEX PARTS ARE STORED IN E<ll UP TO ECIRt. 

lER = MEANS NO ERRORS 

lER = 1 MEANS NO CONVERGENCE «ITH FEASIBLE TOLERANCE 

lER = 2 MEANS POLYNOMIAL IS DEGENERATE (CONSTANT OR 2ER0I 

lER - 3 MEANS SUBROUTINE MAS ABAMOOMEO DUE TO ZERO DIVISOR 

I6R = * MEANS THERE EKISTS NO S-FRACTION 

lER =-1 MEANS CALCULATED COEFFICIENT VECTOR REVEALS POOR 

ACCURACY Df THE CALCULATED ROOTS. 

THt CALCULATED COEFFICIENT yECTOR HAS LESS THAN 

6 CORRECT DIGITS. 
TH£ FINAL COMPARISON SETHEEN GIVEN AND CALCULATeO 
COEFFICIENT VECTOR IS PERFORMED ONLY IF ALL ROOTS HAVE BEEN 
CALCULATED. 

THE MAXIMAL RELATIVE ERROR OF THE COEFFICIENT VECTOR IS 
RECORDED IN g( IR«-1I . 



METHOD 

THE ROOTS OF THE POLYNOMIAL ARE CALCULATEO BY MEANS OF 

THE QUOTIENT-DIFFERENCE ALGORITHM WITH DISPLACEMENT. 

REFERENCE 

H.RUTlSHAUSER, DER QUOTl ENTEN-D I FF E RENZE M-ALGDRI THMUS , 

8IRKHAEUSER, BASEL/STUTTGART. 1^57. 



SUBROUT INE DPRQOfC. ICt Q. E, PX. IR t lER) 
C 
C DIMENSIONED DUMMY VARIABLES 

DIMENSION E( l)tQ( 11 .CI ll.POLl I) 

DOUBLE PRECISION Oi EiO,P, T.EXPT.ESAV.Ut V, W,C ,POLtEPS 
C 

C NORMALIZATION OF GIVEN POLYNOMIAL 

C TEST OF DIMENSION 

C IR CONTAINS INDEX OF HIGHEST COEFFICIENT 

IR^IC 

IER=0 

ePS=1.0-i6 

TQL=l.E-6 

LIHIT=tO*IC 

KQUNT=0 

1 IFt IR-l 179,79,2 
C 

C DROP TRAILING ZERO COEFFICIENTS 

2 IFICt 1R}14.3.4 

3 1R=IR-1 
GOTO I 

C 

: REARRANGEMENT OF GIVEN POLYNOHIAL 

t EXTRACTION OF ZERO ROOTS 

4 0=l.ODO/CIIR) 
IEN0=IR-1 
TSTA=1 
NSAV=IR«^1 
J6EG=l 

: 0(JI>t. 

: Q(j*i»=ciiR-n/ctiRi 

Q<IRI=C<J)/C< IRl 
: WHERE J IS THE INDEX OF THE LOWEST NONZERO COEFFICIENT 

DO 9 I=ltIR 
J=NSAV-I 
IF(C(m7,5,7 

5 GOrOlb.SI , JBEG 

6 NSAV^NSAV^-I 
Q(ISTA)=0.00 
EI ISTA)=0.00 
ISTA=ISTA+1 
GOTO 9 

7 JBeG=2 

8 Q(J)=CI 11*0 
Ct I) = QIJ} 

9 CONTINUE 

INITIALIZATION 
ESAV'0.00 
QIISTA)=0.00 

10 NSAV-IR 

COMPUTATION OF DERIVATIVE 
EXPT=IR-ISTA 
Ft ISTA)=EXPT 
00 11 I-ISTA,I€ND 
EXPT"EXPT-1.0D0 
POL (1*1 )=EPS*DABS(Q( 1*11 I»CPS 

11 E(l»ll=Q(I*l)»EXPT 

TEST OF REMAINING DIMENSION 
IF( ISTA-IEND)12,20, 60 
L2 JEND=IEND-1 

COMPUTATION OF S-FRACTION 
DO 19 I=ISTA,JENO 
IF(I-ISTA)n.l6.13 

13 IFOABSIEI I I I -POL (I »IJ I 1*,14,16 

THE GIVEN POLYNOMIAL HAS MULTIPLE ROOTS, THE COEFFICIENTS DF 
THE COMMON FACTOR ARE STORED FROM Q(NS«V1 UP TO OIIRI 

14 NSAV=I 

00 15 K=I.JENO 

IF(OABSTErK) ) -POL (•(■M)}15,15,80 

15 CONTINUE 
GOTO 21 

EUCLIDEAN ALGORITHM 

16 DO 19 K=I,IEND 
ElKtll = E(K»II/E(l 1 
-QIK*1I='E(K*1I-Q(K«1I 

IF(K-I) 16, 17.18 

TEST FOR SMALL DIVISOR 

17 [F(DABSiaiI*llr»-POL(I*ll»BO,80,19 

18 QlK4-L)>a(K<^t)/aU*l I 

P0L(K*ll=POL(K*Il/OABS(Q(I+in 
E(Kl=giK»n-ElKt 

19 CONTINUE 

ZP 0(IRI=-0(IRI 



opRO zeo 

IDPRg 290 
DPRO 303 
OPRO 310 
OPRQ 320 
OPRQ 330 
DPRQ 340 
OPRQ 350 
DPRO 3«0 
OPRQ 370 
DPRQ 380 
OPRQ 390 
OPRQ 400 
OPRQ 4 10 
OPRO 420 
OPRQ 430 
OPRQ 440 
OPRQ 450 
OPRQ 460 
OPRQ 470 
DPRQ 480 
OPRQ 490 
OPRQ 500 
DPRQ 510 
OPRQ 520 
OPRQ 530 
OPRQ 540 
DPRO 550 
OPRQ 560 
OPRQ 5 70 
OPRQ 5 BO 
OPRQ 590 
DPRQ 600 
OPRQ 610 
OPRO 620 
OPRQ 630 
.. . DPRQ 640 
OPRO 650 
OPRQ 660 
OPRQ 670 
OPRO 660 
OPRO 690 
OPRQ 700 
DPRQ 710 
OPRQ 720 
DPRQ 730 
DPRQ 740 
DPRQ 750 
DPRQ 760 
DPRQ 770 
DPRQ TflO 
OPRQ 790 
DPRQ BOO 
DPRQ 810 
OPRQ 820 
OPRQ 830 
OPRQ 940 
OPRO 850 
OPRQ 860 
DPRQ 870 
OPRQ 880 
OPRO 890 
OPRQ 900 
OPRQ 910 
DPRQ 920 
OPRQ 930 
DPRQ 940 
OPRQ 9S0 
OPRQ 960 
OPRQ 970 
OPRQ 980 
OPRQ 990 
OPRQIOOO 
DPRQIOIO 
OPRQIOZO 
OPR01030 
OPR01040 
OPR01050 
OPROL060 
OPRQ1070 
OPRQ1080 
DPRaiO90 
DPRQI 100 
OPRQlllO 
0PRQ1120 
DPRQI 130 
DPRQ1L40 
OPRQI150 
OPRQI160 
DPRQI I 70 
OPRQIiaO 
DPRQ1190 
DPRQ1200 
0PR012I0 
0PRQ1220 
0PRQ1230 
DPR01240 
OPRQ1250 
DPRai260 
DPRQIZTO 
DPRQlZaO 
DPRQt290 
OPRQI300 
DPRQ1310 
0PRQ1320 
OPRQ1330 
0PRQU40 
DPR01350 
DPRQ1360 
PPRO1370 
0PRQ13BD 
DPRQI 390 
DPRQI400 
OPRQMIO 
DPRQ14Z0 
OPR01430 
DPR01440 
DPRQ1450 
OPRQI4&0 
0PRQ1470 
OPRai4B0 
0PRQ1490 
OPRQI500 
OPHOI510 
DPRQ1520 
OPR01530 
OPRQI540 
DPRQ1550 
0PR01560 



THE DISPLACEMENT EKPT IS SET TO AUTOMATICALLY. 

E( ISTA»=0.,0) ISrA*l> E(NSAV-1),Q(NSAVI ,E(NSAVI=0. 

FORM A DIAGONAL OF THE QO-ARRAY. 
INITIALIZATION OF BOUNDARY VALUES 

21 E(ISTAt=0.00 
NRAN=NSAV-| 

22 E<NRAN«-1MO.OO 

TEST FOR LINEAR QR CONSTANT FACTDR 
NRAN-1STA IS DEGREE-l 
IF(NRAN~lSrA124,23, 31 

LINEAR FACTOR 

23 0nSTA*ll=Q( ISTAtn*EXPT 
E( ISTA*ll=0.DO 

TEST FOR UNFACTORED COMMON DIVISOR 

24 ei I5IA)=ESAV 

IF( IR-NSAVI60.60,25 

INITIALIZE QD-ALGORITHH FOR COMMON DIVISOR 

25 ISTA=NSAV 
ESAV=e( ISIAI 
GOTO 10 



TEST FOR REALITY 
IF(OI2T,28,28 

COMPLEX ROOT PAIR 

27 Q(NRAN)=P 

Q(NRAN*1I=P 
£(NRftNI =T 
e(NRAN»l)=-T 
GOTO 29 

REAL ROOT PAIR 

28 aiNRAN)=P-T 
OINRANtll=PtT 
E(NRANI=0.00 

REDUCTION DF DEGREE BY 2 {DEFLATION! 

29 NHAN=NRAN-2 
GOTO 11 



REDUCTION OF DEGREE Bv L IDEFLATIONI 

NRAN=NRAN-l 
GOTO 22 

START 00-ITERATION 

31 JBEC=ISTAtl 
JEN0=NRAN-1 
TEPS=£PS 
T0ELT=1 .E-2 

32 KOUNT=KOUNT»l 
P=Q(NRAN*1I 

R = ABSISNGLIE(NRAN1 1 I 

TEST FOR CONVERGENCE 
IF(R-TEPSI30,30,33 

33 S=ABS(SNGLIE(JENOII I 

IS THERE A REAL ROOT NEXT 
IF(S-R) 38,38, 34 

IS DrSPLACEMENT SMALL ENOUGH 

34 IF(R-TOELTJ36,35,35 



-ll-O 

TEST FDR SMALL DIVISOR 
IFI DABS (QUI I -POL (J )l8t,81.37 
37 E( Jl=QIJ+l}*E( JI/QIJl 

0(NRAN*U=-£(NRANl4-Q(NRANtlI-a 
GOTO 54 

CALCULATE DISPLACEMENT FOR DOUBLE ROOTS 
QUADRATIC EQUATION FOR DOJBLE ROOTS 

X**2-|QINRANt*0(NRAN+l) + E( NRAN H •X*0( NRANl •0( NRAN+1 1 = 
3B P=0.5D0*(Q(NRANI*E(N«ANI*Q(NRAN*1) I 
O=P«P-Q(NRAN»*0(NRAN»l) 
T=DS0RT(DA8S(OI ) 

TEST FOR CONVERGENCE 
IF(S-TEPSJ26,26,39 

ARE THERE COMPLEX ROOTS 

39 IF10»43,40.40 

40 IF(P)42,4l,41 

41 T=-T 

42 P=P*T 
R = S 
GOTO 34 

MODIFICATION FOR COMPLEX RJQTS 
IS DISPLACEMENT SMALL ENOUGH 

43 1F(S-T0ELT144,35,35 

INITIALIZATI3N 

44 0=H{JBEGI*E(jeeGI-P 

TEST FOR SMALL DIVISOR 
IF( DABS (01 -POL ( Ja£G)>9I,8l,45 
<.5 T = (T/0)«*2 

u=f/jBeci*o(j8fC*it/(o*(Looo*rn 

v=o+u 

THREEFOLD LOOP FOR COMPLEX DISPLACEMENT 
KOUNT=K0UNT*2 
00 53 J=JBeC.NRAN 
0=01 J + 11*-E(J*1I-*J-P 

TEST FOR SMALL DIVISOR 
IF(DABS(V)-POL( JI } 46, 46, 49 

46 IFI J-NRANIBI,4T,ei 

47 EXPT=EXPT*P 

IFI ASSISNGLI E(JEND) )l-T0Lt4S,4S.SI 

48 P = 0.5D0»{V*O-ElJENOn 

= P««'-( V-UI*(0-U*T-0*M*< l.DO*ri/Q( JENOI I 
T>OSORT(OABS(OI » 
GOTO 26 



DPR015T0 
OPRQ1580 
OPRQ1590 
OPRQI60D 
OPRQISIO 
OPROiiZO 
DPRQI&30 
DPRQ1640 
0PR01650 
0PR0I660 
0PRQ1670 
0PRQ16B0 
0PRQ1690 
DPRQI 700 
OPRQIT 10 
OPR01720 
0PRQ1730 
0PR017*0 
OPR01750 
DPRQI 760 
0PRQ1770 
0PRQ17e0 
0PRai790 
DPROieOD 
OPRQ1810 

oPRQiezo 
opRQieao 

OPRQI840 
OPR0ie50 
0PR01860 
DPR01870 

OPRQlaBO 

OPRQ1890 

DPRQ1900 

0PRQ1910 

OPR01920 

DPRQ1930 

DPRQ19.*3 

OPRQ1950 

OPR01960 

DPRQ1970 

0PRQt980 

DPRQ199C 

DPR0233D 

OPRQ2010 

OPRQ2020 

DPRQ2O30 

DPRQ2040 

OPR020SO 

OPR0ZD60 

DPRQ20TO 

DPftQ2080 

DPRQZ090 

OPRQZIOD 

OPR02110 

OPRQ2120 

OPRO2130 

DPR02140 

OPRQZISO 

OPROZ160 

DPRQ2I70 

0PRQ2183 

DPRQ2190 

0PRQ2200 

DPRQ22iO 

OPRQ2220 

OPRQ2230 

DPROZ240 

DPRQ2250 

OPRQ2260 

DPRQ2270 

DPRQ2290 

OPRQ2290 

OPR02300 

OPRQ2 310 

OPRO2320 

OPR02330 

0PR02340 

DPRQ2350 

OPRQ2360 

DPRa2370 

0PRQ236D 

DPRQ2390 

DPR02400 

0PR02410 

DPRQZ420 

0PR02430 

OPROZ440 

DPR02450 

OPRQ2460 

DPRQZ470 

DPR024aO 

OPR02490 

OPRQ2500 

0PftQ2510 

0PRQ2520 

0PRQ2530 

0PRQ2 54C 

DPR02550 

0PRQ2560 
0PRQ2570 
DPRQ2580 
DPRQ2590 
DPR02600 
DPRQ2610 
DPRQ2620 
DPRQ2630 
DPRQ2640 
DPRQ26S0 
DPR02660 
DPRQZ670 
0PRQ26B0 

OftAd2&40 
DPR02700 
0PRQ2710 
DPR02720 
OPRQ2730 
OPRQ2740 
0PRQ2 750 
DPRQ2760 
DPRQ2770 
DPRg2T80 
OPRQ2790 
OPRQZeOO 
DPRQ2810 
DPRO2820 
DPROZ830 
DPR 02840 
0PRQZ8 50 



188 Mathematics —Polynomials: Roots 





OPRQzeao 


TEST FOR SMALL DIVISOR 


OPflQZSTO 


*■» IFI0A8S(ai-P0L(J*tl )46t«6,'50 

50 H''U»0/V 


OPRQ2680 
0PRQ2890 


T=T*(V/0)««2 


OPR02900 


Q( JI=V*W-E(J-1I 


OPRQ29tO 


U'0.00 


0PRQ29Z0 


If (J-NRANI51, 52*52 S 


0PR02930 


51 U-Q(J*2I*E(J»1>/I0*(1.D0«TI) 

52 VxOt-U-M 


0PRq2940 
0PRQ2950 




OPRQ2960 


TEST FOR SMALL DIVISOR 


DPRQ29 70 
DPRQ2980 


IFI0ABS(Q(J)l-PQLIJ)iai,8l,53 


53 £(J)-y*V»I1.000+Tl/Q(Jl 


DPRQ2990 


0(NRANtl)=V-ECNRANt 
54 eXPT=EXPT*P 


OPRQ3000 
OPRQ3010 


TEPS=rEPS»l.l 


OPR03020 


TDELT=TDELT*l.l 


DPRQ3030 


tFU0UHT-LIHin32,55,55 


OPRQ3040 




DPRQ3050 


NO CONVERGENCE WITH FEASIBLE TOLERANCE 


DPRq3060 


ERROR RETURN IN CASE OF UNSATISFACTQRV CONVERGENCE 


0PflQ3070 


55 lER'l 


OPRQ3O0O 


REARRANGE CALCULATEO ROOTS 


OPRq3090 
0PRQ3100 


56 lENO^NSAV-NRAN-l 


DPRgaiio 


E{ ISTAI'ESAV 


0PRQ3L20 


If (IEN0J59, 59,57 


OPRQSDO 


5T DO 58 l-l,IENO 


DPRQ3I*0 


J=ISTA*I 


OPRQSISD 


K=NRAN*1+I 


DPRQ3160 


E(J1>E(KI 


OPR03170 


58 Q(J|>Q|K) 


OPRQ31B0 


59 IR=ISTA*!EN0 


OPRQ3190 




0PRQ3200 


NORMAL RETURN 


DPRQ3210 


60 IR-IR-1 


DPRQ3220 


1F(1R)78, 78,61 


DPRQ3230 




0PRQ3240 


REARRANGE CALCULATED ROOTS 


OPRa3250 


61 DO 62 I-l.IR 


0PRQ3260 


Q(ll=Qf!*I) 


OPRQ32 70 


62 EU}>EI 1 + 11 


OPRQ3280 




0PRQ3Z90 


CALCULATE COEFFICIENT VECTOR FROM ROOTS 


DPRQ3300 


POL(IR*1)=1.00 


OPRQ3310 


ICND=IR-l 


DPRQ3320 


JBEG-1 


DPRQ3330 


DO 69 J=L,IR 


0PR03340 


ISrA=IR+l-J 


0PRg3350 


O'O.DO 


OPRO3360 


P=Q( ISTAI 


OPR03370 


r-E| ISTAI 


DPRQ33B0 


If (T)65.63,65 


OPRQ3390 




0PRQ3400 


HULTIPLV WITH LINEAR FACTOR 


0PR034ID 


63 00 64 I=[5TA,IR 


DPRQ3420 


POL(Il==O-P*P0L( I + l) 


DPRQ34 30 


64 Q-POL( I+ll 


0PRQ3440 


GOTO 69 


DPR03i50 


65 &0Tai66,67),JeEG 


0PRQ3460 


66 JSEG=2 


DPR03470 


POL(ISrAl«0.00 


DPRQ3«aO 


GOTO 69 


OPRQ3490 




OPRQ3500 


flULTIPLY WITH QJAORATIC FACTOR 


DPRa35lO 


67 JBEG»1 


DPRQ3520 


U>P*P»T*T 


DPRaa530 


P=P+P 


DPRa3540 


00 68 I*1STA.IEND 


DPRQ3550 


PDL(I)-0-P*POL( I*1IH)»P0L( 1*2) 


0PRQ3560 


68 D=PDLII»l» 


DPRQ3570 


POLIIRI=0-P 


OPRQ3580 


69 CONTINUE 


0PR03S90 


IF(IERI78, 70,78 


0PRQ3600 




OPRQ3610 


COMPARISON OF CaEFFICIENT VECTORS, IE. TEST Of ACCURACY 


DPRQ362Q 


70 P=O.DO 


OPRQ3630 


00 75 I-l.IR 


DPRQ3640 


IF(C(Ill72f71,72 


DPRQ3650 


71 O^OABSIPOLUII 


DPRq3660 


GOTO 73 


0PRQ36T0 


72 0=DASSMP0L{II-CI1) )/CII 1) 


0PRQ3680 


73 IFCP-0t74,75,75 


DPRQ3690 


74 P=0 


0PRQ3700 


75 CONTINUE 


OPRQ37L0 


IFtSNGLlPI-TQLI 77,76, 76 


OPRQ3720 


76 IER--1 


OPRQ3730 


77 Q(IR*11=P 


0PRQ374G 


El IR«^1)>0.00 


OPR037S0 


78 RETURN 


0PRQ3760 




DPRQ3770 


ERROR RETURNS 


0PRQ3780 


ERROR RETURN FOR POLYNOMIALS OF DECREE LESS THAN 1 


DPRQ3790 


79 rER=2 


DPRQSeOO 


IR=0 


DPRQ3810 


RETURN 


DPR03820 




0PRQ3630 


ERROR RETURN IF THERE EXISTS NO S-FdACTIQN 


0PRQ3840 


80 IER*4 


OPRQ3850 


IR=ISTA 


OPR03S60 


GOTO 60 


DPPQ3870 




OPR03880 


ERROR RETURN IN CASE OF INSTABLE QD-ALGORITHM 


DPRQ3B90 


81 IER=3 


OPRQ3900 


GOTO 56 


OPR039IO 


ENO 


DPRQ3920 



Subroutines PRBM and DPRBM 

These subroutines compute the real and complex 
roots of a real polynomial 



p(x) = c + c X + . . . +c ^ X 
1 2 n+1 



using Bairstow's iterative method of quadratic 
factorization. 

1. Mathematical background 

Every real polynomial of degree greater than one 
can be factored in the form p(x) = q(x)r(x) where 
q(x) = X + qgX + q^ is quadratic. If q(x) is reduc- 
ible, that is, if q(x) is a product of two real linear 
factors, p(x) has a pair of real roots; and if q(x) is 
irreducible, p(x) has a complex conjugate pair of 
roots. If r(x) has degree exceeding one, it too may 
be factored as above, and so on. The quadratic 
factors of p(x) are determined by subroutines PQFB 
and DPQFB. See those routines for a detailed 
description of Bairstow's method. 

2. Programming considerations 

The subroutines need only the coefficient vector 
C = (C]^, , . , cjq) and the number of coefficients 
IC = n+1 as input. They give as output an error 
parameter lER, the number of computed roots IR, 
the real and complex parts of the computed roots in 
vectors RR and RC, and — - if all the roots have 
been computed — the coefficients of the polynomial 
with the computed roots stored in the vector POL. 

If p(x) is a constant, that is, if C2 = C3 = . . . = 0, 
we set IR = 0, lER = 2, and return to the call 
program. 

Otherwise, let IR = max j j I c^ j^ I . Then 



we may write: 



P(x) = Cj.^ p(x) p(x) 



P(X) = Pj^ + PgX + . . . + PjX 



J-1 



P(x) 



K 



K, andpj =CK+i/ciR, j = 1, 
J, and pj ^ 0. The coefficients of p 



where K 2 0, J = IR 

2, .... u, ana p^ f= u. ine coefficients of p are 
stored in POL(l) up to POL(J) and POL(J+l) up to 
POL(IR) are initialized to zero. If an exponential 
overflow occurs during the calculation of the pj we 
again set IR = 0, lER = 2 and return control to the 
calling program. 



Mathematics— Polynomials: Roots 189 



The following example illustrates the procedure 
so far: 

p(x) = 0+0. x+50. x^ +40.x3 +30.x4 +20-x5 



6 7 8 9 

+ 10-x + 0-x + O'X + O'X 



\ / 
IC = 10 



IC: 



50 



40 



30 



20 



10 



IR = 7, J = 5 
POL RR RC 



1: 



IR: 
\ 



5 
4 
3 
2 
1 


















- 


- 



2 3 4 
p(x)= 5+4x+3x +2x +x 



p(x) = X 



3. The Bairstow iteration 

Upon entering the main part of the routine we 
assume 



p(x) = Cj^ p(x) p(x) 



where 



P(x) = Pj + Pg^ ^ 



+ P. 
] 



x^ 



1-1 



(P, = 1) 



is the polynomial with the unknown roots, and 

P(x) =P^^1 ^ Pj^2X + . . . +Pjj^xIR-J-UxIR-J 

is the polynomial generated from the computed 
roots. The coefficients Pj, P2> • • • . PiR ^-^e 
stored in POL(l), POL (2) , . . . , POL(IR). Now 
there are three possibilities: 

(1) j = 1. All the roots have been computed. IR 
is decreased by 1 in order to record the number of 
computed roots and control is passed on to the last 
phase of the subroutine (the appendix). 

(2) } =2. The last root is x = -pj. This is 
recorded by setting RR(IR - 1) = -Pj and 
RC(IR - 1) = 0. The polynomial p(x) is multiplied 
by the linear factor x + p-, , occupying after multi- 
plication the locations POL(2) up to POL(IR). IR 
is decreased by 1, thus recording the number of 
computed roots, and control is passed on to the 
appendix. 



(3) j ii 3. In this case the polynomial p(x) is 

factored by means of subroutine PQFB or DPQFB, 

where the quadratic factor qj + q2X + x^ of the 

previous step is used as the initial guess (in the 

first factorization x^ is used). If factorization is 

not successful, it is restarted with the initial guesses 

2 2 2 

-Qi +q2'^ + x , -q, -q2X+x and q^^ -q2X + x . If none 

of these trials leads to a successful factorization, qi 
and q2 are increased by 1 (at most nine times). If 
after a maximum of 40 trials factorization is still un- 
successful, IRis decreased by J, thus recording the 
number of computed roots, and the rest of the sub- 
routine is bypassed giving the error message IER= 3. 

If any one of these trials is successful, p(x) is 
divided by the determined quadratic factor, occupy- 
ing after division the locations POL(l) up to POL 
(J -2). Then the polynomial p(x) is multiplied by the 
same quadratic factor and occupies after multipli- 
cation the locations POL(J-l) up to POL(IR) . At 
least the quadratic equation is solved, and the real 
and complex parts of the two roots are stored in the 
corresponding locations of RR and RC. After de- 
creasing j by 2, the main part of the subroutine is 
reentered. 

Assuming that all the roots of the polynomial 
have been computed, the coefficients of the poly- 
nomial p(x) are shifted into the locations POL(l) up 
to POL(IR), and POL(IR+l) is set to 1 (ffi, is the 
number of computed roots) . 

Furthermore, the absolutely greatest error of the 
coefficients of the resulting polynomial is generated 
using the formula 



a = max 
i 



(<Pi 
where 6. =< 

1 P.- 



c.)/c. 
1 1 



if c. i^O 
1 

if c = 
1 



1,..., m 



The number a is stored in RR(IR+1) giving the user 
some indication of the accuracy reached by the sub- 
routines. The warning lER = -1 is given if a>€ 
(€ = 10"^ in single precision and e = 10"" in double 
precision). The warning lER = -1 is overridden by 
the warning lER = 1 , which is given if any quadratic 
factorization fails to converge. (See PQFB.) 

For reference see J. H. Wilkinson, "The Evalu- 
ation of the Zeros of 111- Conditioned Polynomials 

(Parts 1 and 2)", Numeriische Mathematife , vol. 1 

(1959), pp 150-180. 



190 Mathematics — Polynomials: Roots 



SURPCUT IMT PFBM 

10 r.AtruiATf ALL PTAl AND COMPLI^K ROOTS nf A r. I ve« 
PClYMnflAL W[TH fltAl f-Ot FF I C t FN! S. 

r-t.Li pr:»k (C,rc,.*R,RC,POt,iR,rERj 



PRHM in 

. . . PRSn 20 

PRRM )0 

PFet" *o 

PRAM %0 
PREIH 60 
PRSH 70 
PR8M BO 
PPPM qO 
PR6M 100 
PRAM 110 
PRBH 120 
T I [A Of tARAMfft^KS PRBH 1 }0 

■ r - INPUT VFCrOR CONIAIMNG Tht COEfflCIENTS OF THf pttBH UO 

- r,iv€N PGIYNOMJAL. COEFflCIENIS ARE CHDEREO FROM PRBIi 150 

- LflW in HluM. ON HEtURN CHEfFJClENIS ARE 1 V I Dt D PftflN 1 60 
RY THE LAST NtlNiFRC TERM. PDRH | 70 

If - ot-^fNsioN Of vtrroBS c, br, rc, ano pol. prrh i ho 

- fi« - WtSUtTANT VECI3R OF atAL PA^IS Of IHE MOOTS. PRBM 190 

- r-C - RESULTANT VtCTPR OF COMPLEX PARIS Of IHE ROOTS. PRBM ?00 
. °ri - RFSULtANF veCTDP OF COEFFICIENTS OF THE POLYNOMIAL PRBM 210 

WITH CALCULATED ROOTS. COEFFICIENTS APE OfiDE«ED PRWM !>Q 

FROM LOW TO HICH |SE£ REMARK *1. pngH 3)0 

IB - OUTPUT VALUE SPECIFYING THE NUMBER ^E CALCULATED PRBM 2^0 

HOOTS. NOflMAtLV IR IS FOUAL TO IC-1. prbh ?S0 

lEk - RESULTANT FRPOP PARAMETER CDOtO AS FOLLOWS PRBM 260 

ieR = - NO ERROR, pf,B„ p,o 

tFR=l - SUHBOUTIhE PafB RECORDS POOR CONVERGENCF PRBH JflO 

AT SUME OUAORATIC fACTORHATfON MITNlN PRBM 290 

50 ITERATJDN STEPS, pftflM 100 

IEfi=2 - POLYNOMIAL IS OEGENERATe, I.E. ZERO OR PftBN Jio 

CONSTANT, p«8H 320 

OR CVtRFLCW IN NORMALIZAtlTN OF GIVEN PRflM 3 30 

POLYNOMIAL, PRbh 3*0 

IEF=3 - THE SUflPOUTINE IS BYPASSEO 0U£ TO PRBM 150 

SUCCESSIVE ZE-iO DIVISORS OP OVERFLOWS PRBM 360 

IN OUAORATIC FACTORIZATION OR Du£ TO P«8M 3 70 

COMPLETELY UNSATISFACTORY ACCURACY, PRAM 380 

IfF=-I - CALCULATED COEFFiriENT VFC TQti HAS lESS PRWM J<)0 

THAN TMREf CORRECT SIGNIFICANT DIGITS. PRBM *00 

THIS REVEAL J PCX)R ACCURACY Cf CALCULATED PRBM -ilO 

BOPTS. PRBM *20 

''^*^*'='^5 PRBM **,f) 

(t) REAL PARTS Of THf ROOTS ARE STORED IN BRdI UP TO RRCIRIPRSH 450 

AND CnRPESPONDING COMPLEK PARTS IN RClll UP 10 RCURt. PRBM 460 

I?l ERROR HESSAGE IER=I INDICATES POOR CONV€<*CfNCE WITHIN PRBM 470 

SO ITERATION STEPS AT SOME OUADPQTIC FACTORIZATION PRAM 480 

PERfOBMfcO BY SUBROUTINE PCFR. pf^gM 4-50 

(3J NQ ACTION BfiSIDES FPHOK MESSAGE ieR = 2 IN CASE Of A ZERO PRBM 500 

OR CONSTANT POLYNOMIAL. THp SAME ERROR MESSAGF IS GIVEN PRfiM 510 

IN CASE OF AN QVEPFLOH IN NOFMAl I ZAT I ON Of GIVEN PRBM 520 

POLYNOMIAL. PRB„ 530 

(4J ERROR MESSAGE (ER^3 INDICATES SUCCESSIVE ZERO OIVISORS PRBM 540 
OK OVERFLOWS OH COMPLETELY UNSATISFACTORY ACCURACY AT PRBM 550 
ANY OUAORATIC f AC TOP I Z A T I ON PESF'IOMED BY pRgM 560 

SUBfOUTINE P9FB. IN THIS CASE CALCULATION IS BYPASSED. PRBM 570 
IR RECORDS THE NUMBtR Of CALCULATED ROOTS. PRBM 580 

POLI IJ .....POLIJ-IRI ARE THE COEFFICIENTS Of THE PRBM 590 

REMAINING POLYNOMIAL, HHERE J IS THE ACTUAL NUMBER OF PRBM 600 
COEFFICIENTS IN VECTOR C (NORMALLY J-ICI. PRBM 610 

(5) IF CALfULATtU COEFFICIENT VECTOR HAS LESS THAN THREE PRRH 620 

CORRECT SIGNIFICANT DIGITS THOUGH ALL QUADRATIC PflflN 630 

tACTORUATIONS SHOWED SATISFACTORY ACCURACY, THE ERROR PRBM 640 
MESSAGE IER*-1 IS GIVEN. PPHM 650 

(61 THE FINAL COMPARISON BETWEEN GIVEN ANO CALCULATED PRBM 660 

COEFFICIENT VECTOR IS PEHFORMEO ONLY IF ALL ROOTS HAVE PR8M ft?0 
BEEN CALCULATED. IN THIS CASE THE NUMBER Of ROOTS IR IS PRBM 6B0 
EQUAL TO THE ACTUAL DEGREE Of THE POLYNOMIAL (NORMALLY PRBM 690 
IP-IC-IP. THE MAXIMAL RELATIVE ERROR OF THE COEFFICIENT PRBM 700 
VECTOR IS RECCROEO IN RRIIft*!). pftSH 710 

PRBM 720 

SUBRPUTINES AND FUNCTION SUBPROGRAMS REQUIRED PRSM 730 

SURRQUTINE POffl OUADPATK fACTOfllZATION Of A POLYNOMIAL PRBM 740 

BY BAIRSTQW ITERATION. PRbm 750 

PRBM 760 
"ETHHO PRe„ 7,0 

THE ROUTS Of THE POLYNOMIAL AH E CALCULATED BY MEANS OF PRBM 780 

SUCCfSSIVf OUAOPATIC FACTORIZATION PERFORMED BY BAIRSTOW PRBM 790 

ITERATION. X*»2 IS USED AS INITIAL GUESS FOP THE FIRST PRBM BOO 

OUAORATIC FACTOR, ANO FURTHER EACH CALCULATED QUADRATIC PRBM 810 

FACIDR IS USED AS INITIAL GUESS FOR THE NEKT ONE. AFTER PRBM 820 

COMPUTATiCiN cr ALL ROOTS THE CflEFflCIENT VECTOR IS PRBH 830 

CALCULATED ANO COMPARED WITH THE GIVEN ONE. PRBM 840 

fOR REFERENCE, SEE J. H. WILKINSON, THE EVALUATION Of THE PRBM 950 
ZEROS OF ILL-CONDITIONED POLYNOMIALS (PART ONE AND TWO), PRBM 860 

NUMERISCHE MfllHEM/^TIK, VOL . 1 (19591, PP. 150-160. PRBM 870 

PRBM 880 

PRBM 890 

PRBM 900 
SUBROUTINE PR tM (C, IC, RR ,«C , POL W R , I f F 1 PRSM 910 

PRBM 920 

PRBM 930 

DIMENSION C< n .fiPI 11 ,RC( n .POLd l,Q(41 Prrm 940 

PRBM 950 

TFSr CN lErtDING ZEBC COEFFlCIENrS PRBM 960 

?PS= l.E-3 PRBM 9T0 

L IM^50 pRf,H 980 

IR-IC* I PRBM 990 

1 I*'=IP-1 PRflMlOOO 
leilR-lK?.'.?,? PRBMiniO 

2 IF<C)I«t M, 1.5 PRBM1020 

PRRM1030 
WORK 'JP nm aOf)T-j AND N')WMAL!Zr B'MfllNjNC "OLYNCMIAL PR8MIO*0 

^ '£"=0 PRBM105U 

PRBM1060 
PRBM1070 
PPBMIOflO 
PRRMI090 
PRBMIIOO 



ir(j-2)j 



. 10.14 



IPLIL Vf«;f 



I Al IS rOllAL TU ONE 



L = 

A=C( im 

DO 8 1=1,1" 
IF(L 14,4, 7 
4 If (CM 1)6, 5 
•i RRd 1=0. 
XL ( n=o. 
POL( Jt=0. 
J:J-I 
GO TO R 
t L = l 



1ST 



J = 
7 Jsjt 1 

C( M=C( M/n 
POL ( J) ^C( ] ) 
ati L OVfi^FL (N) 
IF(N-?)4?,fi, H 
P CrlMINUt 



CI-0. 



srn 



PRBMl 110 
PRBHl 120 
P«fl«l 1 30 
PRBMl 140 
PRBM 1 150 
PRBMl 160 
PRBMl 170 
PRBMUaO 
PRBM1190 
PRBMl 200 
PHBMI2I0 
PRHft2?0 
PRBM1230 
PRBf 1240 
PRBMI250 
PRBMl 260 
PRBMI270 
PR6M128J 
PRBM1290 



PRBMl 100 
PRBMl 310 
PRflMl ^?n 
PRttMl ilO 
PRBMl 140 
PPBMl JSQ 
PHHMI Ito 
PRHMI WIJ 
PRBMl iHQ 
PRflMl 390 
PRtlM1400 
PRBMl 410 
PRBMl 4?0 
PRBM 14 10 



UH-K( t t'( *J| s 

10 A=PU( ( n 

RPMSTI = -A 

RC( I5T 1=0- 

IP=|fl-l 

G?=0. 

If ( IR-1> I 1, 1 ], 1 1 

11 DO 12 I=?,1H 
01=02 
'j^^POL (1*1) 

1? POUn-A»0?*Qt 
\ i POL I IR* I ) - f , g;' 
CO »0 V. 

THIS IS bRANf.H TU COMPARISON Of CUEFFICIENI VECTORS C AND POL PRBmIIso 

Uti.^li. r.l r.:-.M-_.LrN(.WI*L is ORtAIfR than one PRBMl^ftO 

14 DO 2 2 L=I,10 
N= I 

15 tl( 11=01 
C(2)=0? 

CALL fUf B(POl , J,U, L IM, I I 
IFd 116,24,?) 

16 If <0I I IP. I 7, 18 

17 ir(0?)ia,2l, Ifl 
Ifl CO TO II9,20,I9,?IJ,N 
19 tl=-01 

N = N* 1 
G(J TO 15 
?0 02=-0? 
N=N* I 

CO in 15 

'/\ C|cl.*Qt 
2? C2M.-Q2 



PRBM1470 
PRHM14aO 
PPflMI490 
PRBMl 500 
PR8MI510 
Pt;BM1520 
PRHMl',30 
PftOMi540 
PRBM 1 550 



FPPOR fKI' nut TO UNSATISFACTORY RESULTS OF FACTURIZATIO 

IR^IR-J 

RETURN 

WORK UP FESULTS OF QUAQRATIC FACTORIZATION 
2» lER-^l 
?«> Ol'QIU 
02=012) 



PRHM1570 
PKBM1580 
PKBMI 590 
PRAM 1600 
PRBHJAIO 
PR6H1620 
PRflHUlO 
PRaH1c40 
PPBH1650 
PHBH1660 
PRBMIbTO 
PRBM I 6 80 
PRBM1690 
PRBMl 700 
PRHHl/lO 
PRUMl 720 
PRBMl 7 30 
PRBMl 740 
PRBMl 750 



PERFORM DIVISION Of fACTORIZEO POLYNOMIAL BY OUAORATIC FACTOR PRBMl 760 
fl=0. 



A:0. 
1=J 

25 H--gi*B-0?*A*PftL ( I I 

POL( n = a 

R = A 
A = H 
1 = 1-1 
IF(I-?I26,25,?5 

26 P0L(2I=B 
POC( ll=A 



29 POLtLJ=P0L(LI*P0L(L*n»Q2*0l 
P0L< IR)=PnL( IKI*Q2 



PRBMl 77U 
PRBMl 7Hn 

pRbMi rm 

PRBMl BOO 

PRHMIBIO 

PRHMltJ^O 

PRBHl b 10 

PRMMiHAO 

PRBMlbSU 

PRBMl B60 

pRBMiaro 

PRBMl HBO 

MULTIPLY POLYNOMIAL WITH CAlCUCAIEO ROUTS BY OUAORATIC FACIUR PRBMl B9U 

•■""*"' PRHMIVOO 

If(J-LI2?,27,?9 PRttMI9lO 

27 DO 28 1 = J,L PBflM19;'0 

2fl PQLn-ll=POL(I-|J*POL(l )»Q2*P0L( 1*1 I •01 PRBMIVIU 

PRHM1940 

PRHni950 

PRBMl 9bO 

CALCULATF POOT-PAIP FROM OUADRATir fACTOR I*K*Q2»X*QI pHRM|970 

P««MI9flO 
PKBM1990 
PPBM2C00 
PRHM7010 
PRHM7020 
PKBM20)0 
PRBM2040 
PPRM2050 
PRBM20ftO 
PRHM2070 
31 B=H*SIGN(B.HI PRbM70«0 

PPHM209(J 
PHHM/IOO 
PR8M/I 10 
PRflM2120 
"RAM? I 30 
PRMM2140 
PRBM2150 
PRBMPH.O 
PRBH2iro 

SHIfT BACK FLFMFNTS Uf POL BY I ANO CUMPAPE VfCTCIBS POL ANO C PPHH^'lnu 
3) IR=IR-l PRBM2I90 

PR8M??(!(' 
PRBMi?2IO 
PR8M2 220 
PRBM2 2 30 
PHBM2/40 



.5*0-? 
A=H*H-Ol 
P.>SQRT(ABS( A) t 
IF(AI30, 30, 31 
30 RR(ISr)=H 
RC(IST)=B 
IST=IST*I 
RR(IST)=H 
RC(ISTI=-8 
GO TO 32 



RR( JSII -01/B 
FCI ISTI=0. 
ISI'IST*! 
RP( IST(=fl 
fiC(IST)=0. 
3? I5T=|ST»1 
J = J-2 
GO TO 9 



on 3fl (=1,IK 
Q1=C(1I 
C?=POL(I ♦!» 
POL( I 1=02 



If (01)35,36,35 

35 02=(0l-02l/0l 

36 C;2 = A8S(0?I 
IF (02-AI 38, 38, 37 

3J^ A = C? 

38 CONTINUE 
I = lK< 1 
POtl 11=1. 
RHII ) = A 
RC( I 1 = 0. 
IF( IfP l?"!, J<),41 

39 If (A-£nS)41,41,40 



PH8M2250 
PRflM??60 
PflflM22T(; 
PRBM?? HO 
PRBM7?90 
PMBM2 300 
PPBM2 310 
PRttM2l7r) 
PRHH2 J30 
PRBM? 340 
PR6M2 35fJ 
PRBM2 360 
PRBM2'170 

C WARNINi DUF TO POOR ACCURACY Of CALCULAItO CQEFflCIENT VECTOR PRfiM?iH() 

AQ IFB=-1 PPBM2190 

41 WfTURN PRaM2400 

C fmia EUi out re Bfct^fvur poly 

C NORMAL I/AIK" 

42 IEfi=2 
10=0 
RETURN 

tNO 



LYNOMIAL 3R OvERHOW IN 



PRBM24?0 
PRflM24 30 
PflflM?44() 
Pfi6M/4 50 
PR'1M;'4^0 



PRaM?470 



Mathematics— Polynomials: Roots 191 , 



SJB50UTIME OBOHM 

PURPCSE 

TC CALCiltaTt ALL «E AL «ND COMPLEX 
POLYNOHiAL WITH 'EAL COEFF I C I tNTS. 



RLJQTS CF 4 GIVEN 



liPRBf IC, Ki«R.RC.POl,IR,IF-ft» 



DPRB 

DPD& 
OPRe 
OPftS 
OPRR 
DPKP 
OPPP 
OPRR 
DPrte 



DESCRIPTION C fARiMEIb(«i 

C - CCUSLE PRECISION INPUl VECTOR CONTAIMNC THE 

COEfFI'^It'^rS 0^ THE GIVtN t'OLYNOHIAL. COEfr[CIENTS DPAB 

iRE OROcREC FPOH L&k TC HIGH. ON TF^UPN COEFFI- 0P=!' 

CIENTS ARE OIVIOfD Br THE LftST NON/ERC? TERM. DPRf^ 

IC - OIMFNSIJN Qf VECTORS C, RR , «C. BNC PCL. DPRP 

BR - RESULTi\|T OPiJBLE PRECISION VECTr^i PF REAL PARIS OPH'^ 

OF THE ROUTS. ''**'^*" 

CC - BFSULTavT OCUSLE PRECISION VECTOR LF COMPLEK PARTS OP^ft 

Of The ^ccts. 

PUL - KtiSULTANI DOUBLE PRECISION VECTOS. HF CCEFFICIENTS 

CF THE POLYNOMIAL WITH CALCULATED ^lOOTS. 
COEfFICieMS aoE a(-DP3F0 FROM LOW TO HIGH (SEE 

REMARK '•), 

IW - 3UIPUT VALUF SPECIFYING THE NUK6EP C^ CALCULATED 

ROOTS. VORMALLY IR iS EQUAL TO lC-1 



•^ESJLTANT 
IE« = 1 



PCF 



P&ctH^TF.p. CODED AS ffilLOWS 



NO ERROR, 



DPRP 
OPRB 
DPRF 
DPRp 
OP>*e 
DPifP 
DPRP 

DP^F 

DPRP 



SUeROUTIhE i)P0F6 RECORDS POOR CQNVERGENCEOPRB 

AT SCWE QUADRATIC F AC v;iR I Z AT I ON WITHIN OPRB 

100 ITERATION STtFJS, C'?''? 

ieP=2 - POLYNOMIAL IS DEGENERATEt I.E. ZERO Oft OPRB 

CONSTANT, DPRP 

na nVERFLflH \K NOHMALi^ATinN OF GIVEN DPRB 

POLYNOMIAL. °^^^ 

,Ert=3 _ TH- SUBROUTINE IS RYPASSFD QUE 10 OPfiP 

SUCCESSIVE ZcftO DIVISORS OR OVERFLOWS CPRB 

IN CUADRATIC FACTCRUATION OR DUE TO 0PR6 

COMPLfTFLY UNSATISFACTORY ACCURACY, OPRB 

,EB=_1 _ CALCULATED COEFFICIENT VEfTQt HAS LESS OPRB 

THAN SIX CORRECT SIGNIFICANT DIGITS. DP«6 

THIS REVEALS POOR ACCURACY OF CALCULATED OPRB 

RrnTS. ^^^^ 

OPRB 

MtPKS OPRB 

in R-^AL PARTS OF THE BOOTS ARE STORED IN RRlil UP TO RRIIRIOPRB 

AND Cr-Ri^ESPONOING COMPLEX PARTS IN RCU) U" TO RCCIRI. DPR3 
(2) ERROR viesSAGF 1FR=1 IKOICATFS POOR CONVERGENCE WITHIN DPRP 

100 ITEfiATIDN STEPS AT SCHE QUADRATIC FACT0CI2ATI0N DPRS 

f-tRFDRMEO BY SUBROUTINE DPQFB. OPRB 

O) ^(0 ACTION BESIDES ERROR MESSAGE lER-? IM CASE OF A ZERO OPRE 

n« CONSTANT POLYNOMIAL. THE SAME ERROR MESSAGE IS GIVEN OPRfl 

[N CASE OF AN OVERFLOW IN NORMALIZATION OF GIVEN '"""'' 

POLYNOMIAL. 
(Al ERROR MESSAGE IER=3 IMDICATES SUCCESSIVE ZERO DIVISORS 

OR JVERFLOrfS OR CC^PLETELY UNSATISFACTORY ACCURACY AT 

ANY 3JADRATIC FACTORIZATION PERFUHHEO RV 



OPRR 
OPRB 
DPSe 
OPRB 



<;UBROUTINe DPQFB. IN THIS CASE CALCULATIO^ IS BYPASSED. DPPP 
IR RECORDS THE NUMBER OF CALCULATED ROOTS. OP«B 

POL(l) .....POL(J-IR) ARE THE COEFFICIENTS OF THE DPRB 

HfHAINING POLYNOMIAL* WHERE J IS THE ACTUAL NUMBER CF OPRB 

COfPFIClENTS IN VECTOR C (NC^MALLY J=ICI. 0'*F " 

(51 IF fALCULATEO COefFICIENT VECTOR HAS LESS THAN SIX D?RB 

CORRECT SIGNIFICANT DIGITS THOUGH ALL QUADRATIC OPRB 

FACTORIZATIONS SHOWED SATlSFACinRY ACCURACY, THE ERROR OPRB 
MESSAGE IER=-1 IS GIVEN. OPRB 

(61 THE FINAL COMPARISON BETWEEN GIVEN AND CALCULATED OPRP 

COEFFICIENT VECTOR IS PERFORMED ONLY IF ALL ROOTS HAVE OPRB 
=t6EN CALCULATED. IN THIS CASE THE NUMBER OF ROOTS IR IS OPRB 
EQUAL TO THE ACTUAL DEGPEE CF THE POLYNOMIAL (NORMALLY DPRB 
IB=ir.-i). THE MAXIMAL RELATIVE ERROR OF THE COEFFICIENT DPRP 
VECTOR IS RECORDED IN RRIIR*!). °^^^ 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED DPRB 

SUfifiOUTINE DPQFB OUAORATIC FACTORIZATION OF A POLYNOMIAL OPB« 

BY BAIRSTOW ITERATION. 



METHOD 

THE ROOTS OF THE POLYNOMIAL ARE CALCULATED BY MEANS OF 
SUCCESSIVE QUADRATIC FACTORIZATION PERFORMED PY SAIRSTOM 
ITERATION. X*»2 IS USED AS INITIAL GUESS FOB THE FIRST 
QUADRATIC FACTOR. AND FURTHER EACH CALCULATED QUADRATIC 
FACTOR IS USED AS INITIAL GUESS FOB Th€ NEXT ONE. AFTER 
COMPUTATION OF ALL ROOTS THE COFFFICIENT VECTOR IS 
CALCULATED AND COMPARED KITH THE GIVEN ONE. 
FOR REFERENCE, SEE J. H. WILKINSON, THE EVALUATION OF THE 
ZEROS CF ILL-CONDinOhEO POLYNOMIALS (PART ONE AND TWO), 
NUMERISCHE MATHEMATIK, VOL.1 (I95qi, PP. 150-180. 



SUBROUTINE DPRBMt C, I C.RR, RC.POL, IR . 1 EK I 



DIMENSION C( ll.R«(l),RC(ll.POLIl)tQ(<tl 

DOUBLE PRECISION C ,RR .RC ,POL , Q, E PS . A, B. H,01 ,QZ 

TEST ON LEADING ZERO COEFFICIENIS 
EPS=l.D-6 
1_IM=100 
IR=IC»l 

1 IR=IR-l 

IF! IR-l)'.2,<.3,2 

2 IFIC(IR) ) 3. t.3 

WOFK UP ZERO ROOTS AND NORMALIZE REMAINING POLYNOMIAL 

3 IER=0 
J=IR 
L=0 
A=C1 IPt 

DO a I < 1 , I R 
IFILK.'.,T 

4 IFICdl 16.5.6 

5 RR(I 1=0. DO 
PCU I-O.DO 
POLIJ1=O.DO 
J=J-l 

GO TO B 

6 L-l 
IST=I 
J = 

7 J=J*l 

C(l t=C(I I/A 

P0C<JJ=C(I1 
CALL OVERFLfNl 
IF(N-2)«2,e.e 
e CONTINUE 



120 

n.1 

1=0 

\hO 
I'O 

lao 

ISO 
200 
?10 
2?0 
2(0 
2'VO 
2i0 
?6J 
."70 
2?0 
2^0 
300 
310 
320 
5 -C 
340 
3^0 
360 
370 
3no 
390 
400 



SOO 
510 
520 
530 
540 
550 
560 
5 TO 
5 SO 
590 
600 
610 
620 
610 
640 
650 
660 
670 
610 
690 
TOO 
710 
720 
730 
740 
750 
760 
7 70 
730 
790 
800 
BIO 
820 
B30 
840 
850 
860 



DPRB 
DPRB 
DPRB 
OPRB 
0PR8 
DPRB 
DPRB 
OPRB 
DPRB 
OPRB 
DPRB 8S0 
DPRB a**© 
OPRB 900 
DPRB 910 
..DPRB 9Z0 
DPRB 930 
DPRB 940 
OPRB 950 
OPRB 960 
DPRB 970 
DPRB 980 
OPRB 990 
DPRBlOOn 
DPRBIOIO 
DPRB1020 
DPRBIOSO 
DPRB1040 
DPRB105U 
DPR61060 
OPRBI070 
DPR8I080 
DPRB109Q 
DPRflUOO 
OPRBUIO 
DPRBU20 

opRflino 

DPRB1140 
0PR?)II50 
DPRei!60 
OPRBllTO 
OPRB 1 ISO 
DPRB 1190 
DPRB 1200 
DPR61210 
DPfl61220 
OPR61230 
OPRB 1 240 
OPRB 12 50 
DPRB I 260 
0PR812T0 
DPRei280 
DPRei290 



START bAIRiTCW ITERATION 
C1=0.00 
02=0, DO 
^ IF(J-2131, 10tl4 

DEGREc RE RcSTPOLY^OMUL IS EOUAL TO ONE 

10 A = P0H11 

RRIIST1=-A 

CC(IST)=0.D0 
IR-lR-1 
02=0.00 
IF(IB-lin,l3,U 

11 00 12 1=2, IP 
01=02 

C2 = P0Hl + l) 

12 PPLl I »=A»a2*Ql 

13 PQH If;*l) = fl*Q2 
GO TO 3'. 

THIS IS BRANCH TO COMPARISON CF COEFFICIENT VECTORS C AND POL 

DEGREE OF RES TPOL YN1M1 AL IS GREATfC THAN ONE 

14 OD 22 L=l, 10 
K*I 

15 0(11=01 
0(?I =02 

CALL nPCF-^(POL.J.O,LIM. n 

IF 1 1 116, 24, ra 

16 iFiQiiie.i7,ia 

17 IFIQ2)ie.21.l8 

IB GO TO ( l<9, 20,19,21 1 .N 
IP C1=-0I 

N = N+1 

QO TO 15 

20 O2=-02 
N=N+1 

GO TO 15 

21 21=1.00*01 

22 02=1.00-02 

EFFCf EXIT DUE TO UNSATISFACTORY RESULTS OF f ACTOR I ZATION 
iER=3 
II< = 1R-J 

RETURN 

WORK UP RESULTS CF QUADRATIC FACTORIZATION 
2? lfR=l 

24 ci = c(n 

02=012) 

PERFORM DIVISION OF FACTDRIZEO POLYNOMIAL Bv QUAOPATIC FACTOR 
B=O.DO 

A^D.no 

1 = J 

.75 H=~01*e-0?*A*P0Ln ) 

pPLi n = B 

F=A 

A-H 

1=1-1 

IF( I-2)2t.26.25 

26 P0L(2l=e 
PCLU1=A 

MULTIPLY POLYNOMIAL WITH CALCULATED ROOTS BY CUADRATIC FACTOR 
L=1R-1 
1F(J-H27.Z7,2'? 

27 00 28 I=J,L 

25 POL I I-ll=fDL(I-lJ*POL( I )*Q2*PCL( I + l)«QI 
?q POL ( L) -POL fLl*PCL(L*U "02*01 

PaLIIRt=P0L(Ifll+C2 

CALCULATE ROOT-PAIR FROM QUADRATIC FACTOR X»ll*a?*X*Ql 
H=-.500»C? 
a=H"H-Ql 

B = 0SQRT(DA6SMn 
IF(AI30,30,3l 

30 PR( ISTI=H 
RC(IST(=B 
IST=lSTtl 
pe(ISTI=H 
RC(IST(=-'i 
GO TP 32 

31 B = H*DSIoN('i.HI 
PP{ISTI=Ol/fi 

p,cnsTi=o.oo 

IST=ISTtl 
Rq(ISTI=B 
KCI ISTI=0.D0 
12 1ST=IST+1 
J=J-2 
GO TO 9 

SHIFT 8AC< ELEMENTS OF POL BY I ANO COMPARE VECTORS POL AND C 

33 IR=1R-1 

34 A=0.00 

DO 38 1=1, IR 
01-C(I t 
02=P0LII+ll 
POU 11 = 02 
lFIQll35,36i 35 

35 02=(Q1-021/Cl 

36 02=0A8SIQ2l 
IF(02-A)3e, 38,37 

37 A=02 

3ti CONTINUE 
l=IR*l 
POL! 1)= I. 00 
RRM l = A 
PCI I 1 = 0.00 
IFII€RI39,39,41 

39 IFIA-EPS141,4l,40 

mmc ouf rt? poor Mcma of cmcmm Cdtrrium num 

40 IER=-1 

41 RETUFN 

ERROR EXIT DUE TO DEGENERATE POLYMOMIAL OR OVERFLOW IN 
NORMAL f ZATION 

42 IER«2 
IR=0 
RETURN 
END 



DPR6I300 
DPR81310 
0PRei320 
OPRei330 
OPRni340 
DPRB 1350 
0PR8136Q 
DPRai3T0 
0PR61380 
OPRB 1 390 
DPRfit400 
DPR8I4L0 
OPR'31*20 
0PR61430 
DPRBU40 
OPR8I450 
OPRB1460 
DPR81470 
DPRB 1480 
DPRB1490 
OPRB 1500 
OPP61510 
0PRB1520 
DPRBI530 
DPRBISAO 
DPRR1550 
0PR81560 
DPRB1570 
0PRB1580 
DPR8I590 
DPRB1600 
DPRB1610 
DPR81620 
DPR61630 
DPP81640 
0PRB1650 
DPRB1660 
DPRB1670 
DPPB1630 
00061690 
DPRB I 700 
DPRB1710 
DPABITZD 
0PPB1730 
0PR61740 
OPRBITSO 
DPRei760 
DPRB1770 
DPR81780 
DPRei790 
DPRB1600 
0PRBI810 
OPRE'1820 
0PRBlfl30 
0PRBie40 
0PRB1850 
DPCBl B60 
0PRB1870 
0PR61880 
0Pfi61890 
OPRB1900 
OPRBl^lO 
DPR61920 
DPR61930 
0PRS1940 

0PRei95a 

DPRB 1 960 
DPRB1970 
0PRB198O 
0PRB1990 
0PRB2000 
aPRB2010 
DPRB2020 
DPR 82 030 
OPR62040 
OPRB2050 
0PR52060 
DPRB2070 
0PR62080 
DPRB2090 
DPRB2I00 
0PR8Z110 
DPRB2120 
0PR6Z13O 
0PR82L4O 
OPR82150 
dpi: B2 160 
DPR62170 
DPR 62 L 80 
0PR62190 
DPRB2200 
DPR 82210 
DPR62220 
0PRB2230 
DPRB2240 
OPRB2250 
0PRe2260 
DPRB22T0 
0PRB2280 
DPRB 2 290 
DPPB2 300 
0PR82310 
DPRB2320 
DPRB2330 
DPRB23AO 
DPR82350 
0PRB2360 
DPRB2370 
0PRB2 3B0 
0PRflZ390 
DPR62400 
DPRB2410 

mmio 

0PRB2430 
DPRB2440 
0PRB2450 
0PRB2460 
DPRB2470 
0PR62480 
0PRB2490 
0PR82500 
0PRB251O 



192 Mathematics — Polynomials : Roots 



Subroutines PQFB and DPQFB 

These subroutines use Bairstow's iterative method to 
find an approximation to a quadratic factor of a given 
polynomial p(x) = C1+C2X+ . . . +Cjj+]^xi (deg p(x) =n s 
2 , cj real) . 

1. Mathematical background 

2 
Let Q(x) = X + Q2X + Q1 be any quadratic polynomial 

with real coefficients. Then p(x) = R(x)Q(x) 

+ B(QjL, Q2)x + C(Qi, Q2), where C(Qi,Q2) = a^, 

B(Ql> Q2) = ^2, R(x) = a3+a4X+. . . +a^+ixn-2 , and 

if i > n+1 



^7Wi+rVi+2 ifi=n+l,...,2 



^rVs 



if i=l 



Of course, if q(x)=x + q2X+qi is a factor of p(x), 
then: 



and 






Suppose that Q(x) is an approximation to q(x) ; then 
Ql and Q2 are approximations to q^ and q2 respec- 
tively, and if A Qj and A Q2 are such that: 



and 






Then: 



and 



C(Q^ + AQ^, Q^ +AQ2) =0 
B(Qj+AQ^, Qg +^Q2) =0 



(1) 



Instead of solving (1) for AQj^ and AQ2, we solve: 
8 



C(Q , Q + rr- C(Q , Q ) A Q 
^^l'^2) aQ ^^l'^2' ^1 



9 



N, 



and 



^ ^/<S'^2)^^2 =° 



a 



> (2) 



^^^'V- ^^^^%'V^i 






for AQj and AQ2. Equation (2) is the linearization 
of (1). To solve (2) we must find _!_ B(Qj^, Qg) 

and — C(Qj , Qg) , i = 1 , 2 . To do this w;e define 



a. if i>l 

1 



-I 

i |a^ -Q^B if i=l 



and then 



if i>n+l 



..1 



Now: 



ar. 



8Q, 



9r.,, ar „\ 

1+1 „ i+2 

= ~r -Q Q 

i+1 ^2 8Q ^1 8Q„ 



and 



9r 



"= -r. 



-Q„ 



i+1 



8r 



aQ i+2 ^2 dQ 



Q 



i+2 



1 9Q, 



/ 



By an easy induction on i it follows that: 



8r. ar. 



In particular: 

8a„ 8r„ 

8B ^ 2_ ^ 2^ ^ _ 

8Q, 8Q, 9Q, 4 



i=l,..., n+1 



\ 



9Q2 8Q2 SQg ■ 3 



dC 
8Q^ 


8Q^ 


'^1 

+ Q 
8Q^ ^2 


^^2 

aQ^ 




-h 


-S^4 




9C 
8Q2 


'h 
'% 


-8Q/S 


^^2 
aQ2 




-h 


- S ^3 " ^4 





> 



■^'•2 = 



/ 



Mathematics— Polynomials: Roots 193 



and if we let: 



S = ^4 



B = s 
1 3 



A, = s„ - r„ 
1 2 2 



\ 



A = r. 



/ 



then we can rewrite (2) as: 

(B +Q„CJAQ, +(A +Q B )AQ, =A + Q„B 



1 "^2 1 



1 2 1' 



C AQ + 
1 ^1 



B^ AQ^ = B 



of the polynomial p(x) is tested; if p is of degree 1, 
there is no further computation and lER is set to -2; 
if p is of degree 2, Q(l) and Q(2) are set to C(l) and 
C(2) respectively, Q(3) and Q(4) are set to zero, 
lER is set to zero, and computation is terminated; 
if p is of degree greater than 2, the main part of 
the subroutine — the Bairstow iterative procedure — 
is entered. 

Every approximation Q(x)=x^+Q2X + Qi to a 
quadratic factor of p has associated with it a con- 
stant CC, called the norm of the modified linear 
remainder and hereafter referred to as the norm. 
It is given by CC = CA- 1 A| +CB- 1 b! where: 



CA 



\ ' 



C(2) 



|C(1) 



if |C(1)|^ |C(2)| 
if |C(1)|>|C(2)( 



which simplifies to: 



and 



B^ AQ^ + A^ AQg = A ) 
C^ AQ^ + B^ AQ^ = B ^ 



(3) 



CB 



|C(1) 



C(2) 



if |C(1)|<|C(2)| 



/ . . 



[C(l)|s|c(2)| 



Solving (3) we find that: 



AQ^ = 



^Qo 



A B - B A 



C A - B B 



\ 



Since there is no guarantee that the Bairstow method 
will converge, several accuracy tests are performed 
at the end of each iteration. Depending on the out- 
come of these tests , which in part involve CC , either 
the computation is terminated or another iteration 
is performed. 
Letting: 



EPS = 



/ 



10 ° in single precision 
10"14 in double precision 



We can now replace Q^ by Q. + AQj, 1=1,2, and 
repeat the above procedure. 

2. Programming considerations 

The input consists of a vector C of polynomial 
coefficients (0(1) is the constant term), the dimen- 
sion IC of C, a vector Q of dimension 4 with Q(l) 
and Q(2) containing initial guesses for the coeffi- 
cients of a quadratic factor, and an upper bound 
LIM for the number of iterations to be performed. 

First JSJC is determined such that C(J)^0, 
C(K)=o for K>J. If Jsi, there is no computation 
and the error parameter lER is set to -1. If J>1, 
the poljmomial is normalized by dividing all the 
coefficients of C by C(J) , the coefficient of the 
leading term. If overflow occurs during the nor- 
malization, computation is terminated and EER is 
set to -1. If no overflow occurs, the degree (J-1) 



and: 



EPSl 



10 ^ in single precision 
10-16 in double precision 



the tests are described below. 

a. If |a|sEPS*|C(1)| and] b|^EPS*|C(2)| 



or 



if |AQi|fiEPS*|Qi I and |AQ2|^EPS* |Q2| , com- 
putation is terminated after setting rER = 0, Q(l) = 
Ql, Q(2)=Q2, Q(3)=A, andQ(4)=B. 

b. If |AQi|^EPSl*|Qi| and|AQ2|^£PSl*|Q2|, 

and if |AQi/Qi| or | AQ2/Q2 | is not smaller than 
its value for the previous iteration (this is gen- 
erally due to roundoff errors) , computation is ter- 
minated after setting IER = 0, Q(l)=QQi, Q(2)=QQ2, 
Q(3)=AA, and Q(4)=BB where QQj, QQ2, AA, and 
BB are the values of Qj, Q2, A, and B belonging to 



194 Mathematics — Polynomials: Roots 



a previous iteration — the iteration with the smallest 
norm. 

c . If no convergence occurs within LIM itera- 
tions and if the last norm is not greater than CD/lO, 
where CD is the norm associated with the quadratic 
factor x2, results are generated as in b. with the 
exception that lER is set to 1 . If the last norm is 
greater than CD/10: 

(1) If the initial guess for the quadratic factor 
was x^, the results are generated as in 

b. with the exception that lER is set to -3. 

(2) If the initial guess for the quadratic factor 
was not x2, the subroutine restarts with 
x^ as the initial guess. 

d. If exponential overflow or division by occurs 
during any iteration, results are generated as in b. 
with the exception that lER is set to -3. 

For reference see: 

(1) J. H. Wilkinson, "The Evaluation of the Zeros 
of Ill-Conditioned Polynomials (Part I and n), " 
Numerische Mathematik, vol. 1 (1959), pp. 
150-180. 

(2) F. B. Hildebrand, Introduction to Numerical 
Analysis . McGraw-Hill, New York/Toronto/ 
London, 1956, pp. 472-476. 



SUeROUTlN€ PQFB 

PU«POS£ 

TO FIND AN JtPPnaKIHATlGN 01 X I -Q l.Q2«X.X4X TO A OUAOKATIC 
FtCIOR Of > CIVEH rOLVWHItL fIXI KITH (Ml COCFFIC tENTS. 



.PQFB 
PSft 
FOFB 
POFt 
POf« 



«0 
TO 



US ACE 

CtlL POFelC.IC.O.LIH.IEDI 



OESCKIPTION OF PARAHETEPS 



«0 



POFB 
POfB 

PQFB loo 

PWB 110 

PQFB 120 

PQFB IJO 

PQF> 140 

PQFB 150 

PQFB IfrO 

poFi no 



INPUT VECTOIt CONTAIIIINC THE COEFFICIENTS OF P(l(l - 
CI II IS THE CONSTANT TERN (OINENSION ICI 
IC - OIHENSION OF C 
g - VECTOR OF DINENSIDN « - ON INPUT 0(11 AND 0<2I MUST 

CONTAIN INITIAL GUESSES FOR 01 ANO 02 - ON RETURN QIIIPQFB IBO 
•NO 0(21 CONTAIN THE REFINED COEFFICIENTS 01 ANO 02 OFPOfB Ho 
0<XI, NHIIE 0(31 ANO 0(41 CONI«l« THE COEFFICIENTS A POFB 200 
ANO B OF A-*e*X. WHICH IS THE REHAI NOt A OF THE QUDTIENTPQFB 210 
OF P(«l BT 0(11 PQFB 220 

IIK - INPUT VALUE SPECIFVINO THE NtXINUN NUNBER OF PQFB 2}0 

ITERATIONS TO BE PERFORMED pQFB 240 

lER - RESULTINC ERROR PARAHETER (SEE RENARRSI POFB 2S0 

lER* - NO ERROR pgFS 260 

lER. 1 - NO CONVERGENCE HiTHIN-lIN ITERATIONS PQFB 270 

lER— 1 - THE POLVNOHIAL PIKI IS CONSTANT OR UNOEFINCO PQFB 2a0 
- OR DVERFLON OCCURRED IN N0RHALI2INC POI PQFC 240 
THE POLVNOHIAL PI XI It OF DEGREE I PQFB 300 

NO FURTHER REFINEMENT OF THE APPRO! I NAT I ON TOPOFt >10 
A QUADRATIC FACTOR IS FEASIBLE* DUE TO EITHCRPOFB 320 
DIVISION BV 0, OVERFLflU OR AN INITIAL GUESS PQFB 3S0 
THAT IS NOT SUFFICIENTIV CLOSE TO A FACTO* OFPOFS 340 
POI PQFB 350 

PQFB 340 
PQFB 370 
THERE IS NO COHPUTATION OTHER THAN THE PQFB 3B0 

POSSIBLE NORMALIZATION OF C. PQFB 390 

IF lER— 2 THERE IS NO COMPUTATION OTHER THAN THE PQFB 400 

NORMALIZATION OF C. PQFB 410 

IF lER >-3 IT IS SUGGESTED THAT A NEU INITIAL GUESS BEPQFB 420 
MADE FOR A OUAORATIC FACTO*. 0> NOHEVE*. KILL CONTAIN POFB 430 
THE VALUES ASSOCIATED WITH THE ITERATION THAT VIELDEO POFB 440 
THE SMALLEST NORM OF THE NODIFICD LINEAR REMAINDER. POFB 450 

IF lER'l, THEN. ALTHOUGH THE NUMER OF ITERATIONS LIM PQFB 440 
WAS TOO SMALL TO INDICATE CONVERGENCE. NO OTHER PROS- PQFB 470 
LEMS HAVE BEEN DETECTED, ANO HILL CONTAIN THE VALUES PQFB 4SO 
ASSOCIATED HITH THE ITERATION THAT TIELOEO THE SMALLCSTPOFB 490 



REMARKS 
11) 



(21 



lER— 2 ■ 
IER—3 



IF lER- 



13) 



(41 



(5) 



NORM OF THE MODIFIED LINEAR REMAINDER. 

FOR COMPLETE DETAIL SEE THE OOCUHENTATION FOR 

SUBROUTINES POFI ANO OPOFB. 



SUBROUTINES ANO FUNCTION SUBPROGRAMS REOtilRED 
NONE 



METHOO 

COMPUTATION IS BASED ON BAIRSTON'S ITERATIVE METHOO. (SEE 

UlLKINSON. J.H.. THE EVALUATION OF THE ZEROS OF ILL-CON- 

OITIONED POITNOMIALS IPART ONE ANO TMII , NUMERISCIC lUTHE- 

NATIR, VOl.l (1959), PP. 150-lBOt OR HILOEBRANO, F.B.* 

INTRODUCTION TO NUMERICAL ANALYSIS. NC GRA#-HILL. NEW VORK/ PQFB 420 

TORONTO/ LONDON. 1954. PP. 4T2-4T6.I PQFB 430 

PQFB 440 
,. . . ....PQFB 450 

POFB 440 



PQFB 500 
PQFB 510 
PQFB 520 

PQFB 530 
PQFB 540 
PQFB 550 
PQFB 540 
PQFB 570 
PQFB 5B0 
PQFB 590 
POFI 400 
PQFB 410 



Mathematics— Pol3Tiomials: Roots 195 



SUBROUTINE POf B (C. IC.Q.L IN, lEA I 



OIHENSION Cin.Qdl 

TEST ON LEADING ZERO COEFFICIENTS 

J-1C»1 

1 J^J-I 
IF(J-1K0.40.2 

2 IFIC<JII5tl.3 

NORMALIZATION OF REHAINING COEFFICIENTS 

3 A=C(JI 
IFIA-1.}'V.6.4 

4 00 S l>ltJ 
C(I}=C( I 1/A 
CALL OVERFLINI 
IFIN-ZK0t5,5 

5 CONTINUE 

TEST ON NECESSITY OF 6AIRSTQH ITERATION 

6 IFIJ-3Ml»3a,7 

PREPARE BAIRSTOW ITERATION 

7 e<»S=l.E-6 
£PSl=l.E-3 

L«0 

LL-0 

Ol=Q(t) 

Q2«=Q(2) 

001=0. 

002=0. 

AA=C(U 

BS=C<2> 

CB=ABS(AA) 

CA=AaSlBBl 

IF ICB-CAia,9,lO 

9 cc=ca*C8 

CB=C9/CA 

rA=i. 

GO TO 11 
9 CC=CA+CA 
ca=i. 
CB=1. 

GO TO 11 

10 CC=CA+CA 
CA=CA/Ce 
CR=1 . 

11 CO=CC*.l 

START BAIRSTOW ITtRATIQN 
PREPARE NfSTFD MULTIPLICATION 



Bl = A 

I=J 

Q0Ol=0I 

0002=02 

OQL=HH 

002=H 



START r4€5TEO MULI IPL ICAT I0^4 

13 H=-oi*e-026A*c( r I 

CALL DVERFL(N) 
IF(N-2I43. 1^,14 
U B=A 
A = H 
T=l-1 
IFM-niS, 15,16 

15 H:>0. 

16 l- = -0l*Sl-02*Al»H 
CALL OVtRfLIN) 
IF(N-2I42,17,17 

17 C1=P1 
81-Al 

fll=H 

GO Tn 13 

fNO DF NE5TE0 f" JL T IPL ICA T|ON 

TEST ON SATISFACTORY ACCURACY 

18 H=CA*ABS( a)+CB*Atl5( P) 
IF(LL) 19, 14,39 

1<) L = L*1 

]F(AeS(A)-tPS*AeSIC( 1)) 120,20,21 
20 IF(A6S(BI-EPSeABSIC( 2H )39, as.Zl 



•EMftlNOEP OF MINIMUM NOPM 



TEST ON LINEAR 
21 IF(H-CC)22,22,23 

8B = B 
CC=H 
001=01 

002=02 

TEST ON LAST ITERATION STEP 
23 1F(L-LIH W8.38,2'. 



ftlHSTOW I TESATI-'M 



TEST ON RESTART 
2^ IF(H-CD1A3,43,2S 
Z5 IF(0(lll27,2h,?T 

26 IF(0I2) 127. i^.?? 

27 01 11=0. 
OI2)-0. 
GO TG 7 

PERFORM ITEfiflTION STEP 
2 8 HH = AMAX1 (AaSIAU,ABS(Bll,ABS(CU i 
IF(HH)^2.'12,29 

29 A1=A1/HH 



INI HAL GUESS 



ei = 



l/M 



C1=C1/HH 

H=A1*CI-Bl*gi 
IF(H)30,'.Z, 30 
30 e=A/HH 
6=8/HH 

HH=(B»A1-A»61)/H 
H=( A*CI-B»Bn/H 
C1=01*HH 
02=02*H 

FNO OF ITERATION STEP 

TEST CN SATISFACTORY RELATIVE EBSQF OF ITERATED 
IF(ABS(HH)-EPS*AflS(01))31, 31.33 
3! IFfA6S<Hl-EPS»AesCg2n32.3Z,33 
32 LL=1 

GO TO 12 



POFB 6 70 
PQF6 600 
PQFB 690 
PQFB 700 
PQFB 710 
PQFB 720 
PQFB 730 
PQFB 7*0 
PQFB 7^0 
PQFB 760 
POFB 770 
PQFB 780 
POFB 7')0 
PQFB 800 
PQFB BIO 
POFB 820 
POFB 830 
PQFB 840 
POFB 850 

POFB 860 

POFB 870 
POFB 880 

PQFB 890 

PQFB <J00 
POFB 9 10 
PQFB 920 
POFB 930 
PQFB 940 
P0F6 960 
POFB 960 
PQFB 970 
PQFB 9qo 
POFB 990 
PQFB 1000 
PQFBIOIO 
P0FB102O 
POFBiOiO 

POfaiOAO 
P0F81050 
POFR1060 
PQFB1070 
P0FBIO8O 

PQF B1090 

pQFBi mo 

POF"! 110 
PQFBl 120 
PiJFPI 1 30 
PQF81 140 
P0F91 l-iO 
P OF « 11 60 
PyFBI 170 
POFDl IflO 
POFai 190 
P0FBt2O0 
PQFBl 210 
PQFbl?20 
POFBI23C1 
POFBI240 
PQFB1250 
PQFB1260 
P0FB127O 
POFB1280 
P0FB1290 
PQFBl 100 
PQFBl 310 
PQF61320 
PQFei330 
POFPl 140 
PQFBl 350 
POFB I 360 
PQF6n70 
PQFBl 380 
POFBl 390 
PQFBl 400 
P0F6141O 
P0Ffll470 
P0FB1430 
PQFBl'iAO 
PQFB14W 
POFB1460 
P0F61470 
PQFei480 
PQF61490 
00FB1500 
P OF 6 1 5 1 
PQFB1520 
PQFeibiO 
POFBI'i40 
PQFBlS'iO 
PQFB1560 
P0FE1570 
POFBl ^80 
POFBl 590 
PQFei6nO 
PQF61610 
P0FE1620 
P0FBI630 
PQFaife4'l 
PQFBlbSO 
P0FRI660 
P0F61670 
PQFdl6eO 
P0FB1690 
PQFB1700 
POF B17 10 
PQFBl 720 
PQF61730 
PQFB I 740 
PQFB1750 
P0FBI7&0 
POFBl 7 70 
PQFBl 783 

pQFfcieoo 
PQF eieio 

PQFBia20 
P0F61830 
P0F6ie40 
POFBlfiSO 
PQFB1860 
PQFBIBTO 
P0FBIB8O 
P0F81890 
P0FB1900 
PQFBI910 
PQFB1920 
PQFfll930 
PQFB194Q 
PQF 619^0 



TEST C!\ OfCPEASING RELATIVE fRHOaS 
lF(L-ni2,l?il4 

IFlABSIHMI-EPSl'Ae-^Oll ) J5,35, 12 
lF(ABStHl-EDSI*AfiS(C?M36,36,12 
IF (ABSIQ^iwl •HHI-ABSIQl'DQU) 37,44,4^ 
IF IA9S< 0QQ2«M)-A('S(Q2*0C2) 1 12.4^,^*. 

END ^F PAlOSTHh ITEIAFION 

EXIT IN CASE Of QUADRATIC POLYNOMIAL 

oui=c(n 

QI2I=C(2) 
0(3)=0. 
0(41=0. 
FETURN 

EHIT IN CASE OF SUFFICIENT ACCURACY 
Ot II =01 
Q(2I=02 
0(31=« 
0(41=6 
FETuRN 

FRROH EkIT in case OF I€RO OR CONSTANT POLYNOMIAL 
IfR=-l 
RETURN 

ERROR EXIT IN CASE OF LINEAR POLYNOMIAL 
IER=-2 

RETURN 

EPOQR EXIT IN CASE OF NONREFINEO QUADRATIC FACTOR 
IER=-3 
GO TO 44 

EPROP EXIT IN CASE OF UNSATISFACTORY ACCURACY 
I£R=l 
Q( U=QOI 
C( 21=002 
0(3J=AA 
0141=66 
RETURN 
END 



PQF8I960 
PQFB19T0 
PQFB19aO 
PQFBl 990 
P0F820OO 
PQFB2010 
P0FB2O20 
P0FB203O 
PQFB20A0 
P0Fe2050 
PQFB2060 
P0FB2070 
PaF620S0 
PQFB209O 
PQFB? 100 
PQF62110 
PQfBZlZO 
PQF62130 
PQFB2U0 
PQFB? I ^O 
PQF B2 160 
PQF82170 
PJFBZiaO 
PQFB2 190 
PQF92200 
PQFB22I0 
P0FB2220 
POFB2Z30 

P0Fe2 2'.0 

PQF622S0 
PQF62260 
PQFB2270 
PQF 82 2 80 
PQFB2Z90 
PQFB2 300 
P0F82310 
P0FB2 3 2O 
PQF B2 3 30 
POFB2340 
POF 82350 
POFB2360 
PQFB2 370 



SuqRCUTI^!e 0P0F6 

PURPOSE 

TO FI1JD AN APPROK IMA1 ION I X ) - L 1 *Q2* » » 
FACTOR OF A GIVEN POLYNOMIAL PU) hITH 



:*X TU A QUAORATIC 
REAL f,"rFF IC lENTS. 



DESCRIPTION OF PARAMEIERS 

C - DOUaLE PRECISION INPUT 

CntrFIC lENTS OF P(XI - 

(DIMENSION ICt 

IC - DI^'ENSICN riF C 

a - 00U3LF PRECISION VECTOR OF OIM6NSIQr4 

ND 0(21 CONTAIN INITIAL GUESSES FO 



VrCTOB CONTAIMfO thF 

CM I IS THE CLN;!ANI TE 



CO" 
DPQF 
OPQF 
OPQF 
DPQC 
OPOF 
DPOf 
OPQF 
OPOF 
OPOF 
OPOF 
OPQF 
nPQF 
OPOF 
OPQF 
DPOF 
DPOF 
- PN INPUT 0( 1 tOPQF 
(^NO 02 - ON DPOF 



RETURN Q(U AND 0(21 CONTAIN THE REFIMC COtFFICIENTS DPOF 
Ql AND Q2 OF QIXJ, WHILE Q(i) AND Q ( <i ) CONTAIN THE OPOF 

COEFFICIENTS A ANO B OF At6«X, WHICH IS THE REMAINDER OPQF 
OF THE QUOTIENT OF PtXI «*Y 0(Xl OOOF 

INP'JT VALUE SPECIFYING THE MAXIMUM NUMrifO Qp QPOF 

ITEHATIONS 10 BE PERFOR-^FO DPQF 

RESULTING ERROR PARAMETER (SEE REM»=kS» OPQF 

IER= - WO ERROR OOQF 

|FC= 1 - NO CONVERGENCE WITHIN LIM ITe-lAIIDNS OPQF 

l£R = -| - TiHE POLYNOMIAL P(XI IS C0!15mNI Ca UNDEFINED OPQF 
- OR OVERFLOW OCCURRED IN N'"*HAi.UING PIXI DPQF 

IER=-2 - THE POLYNCflAL P(X| IS OF 0(GB-f 1 DPUF 

IER = -3 - NO FURTHER REFINEMENT OF THE APOROX I MAT I ON TODPQF 
A QUADRATIC FACTOR IS FEASIBLE. "iUE TO EITMERDPOF 
DIVISION SY Oi '1VE3FL0W OH AN INITIAL GUESS DPOF 



THAT IS NOT SUFFICIENTLY CLQS^ 
P( X) 



FACTOR OFDPQF 
OPQF 
OPOF 
DPQF 

IAN THE OPQF 

OPQF 

IAN THE DPyF 

OPQF 



IF IER=-l THERE IS NO COMPUTATION OTHER 

POSSIBLE NORMALIZATION OF C. 

IF !ER=-2 THERF IS NO COMPUTATION OTHER 

NORMAL IZATION OF C. 

IF lER =-3 IT IS SUGGESTED THAT A NEW INITIAL GUESS BEDPOF 

MADE FOR A QUADRATIC FACTOR. 0. HOMCVEF^. WILL CONTAIN DPQF 

THE VALUES ASSOCIATED WITH THE ITERATION THAT YIELDED OPOF 

THE SMALLEST NORM OF THE MODIFIED LINEAR REMAINDER. OPQF 

IF IER-1. THEN, ALTHOUGH THE NUMBER CIF IieBAIIONS LiM DPQF 

WAS TOO SMALL TO INDICATE CONVERGENCE, NO OTHER PRQB- DPQF 

LEMS HAVE BEEN DETECTED, ANO WILL CONTAIN THE VALUES OPQF 

ASSOCIATED WITH THE ITERATION THAT VlELCtO THE SMftLLESTDPQF 

NOftM OF THE MOOIFTEO LlNtAR REMAINDER- 

FOR COMPLETE DETAIL SEE THE OOClJMENTAT I0^ fOR 

SUBFOUTINES PQFB ANO DPOFB. 



METHOD 

COMPUTATION IS BASED ON SAIRSTOU'S ITERATIVE METHOD. <SEE 
WILKINSON, J.N., THE EVALUATION OF THE ZCROS OF ILL-CON- 
DITIONED POLYNOMIALS (PART ONE ANO TwOI, NUMERISCHE MATH 

MAFfK, mA (1959), PP. 150-180, OK HliOEmm, fj., 



1 ^0 
14') 
1^0 

1 60 
170 
ISO 
190 
200 
210 
220 

2 30 
7<.0 

?^n 

260 
270 
280 
290 
300 
110 
320 
330 
340 
V>0 
3'>0 
370 

3 30 
390 
<.00 



DPOF 


^00 


OPOF 


510 


OPQF 


s?o 


OPQF 


•jio 


O^QF 


5*^0 


OPQF 


550 


DPQF 


560 


DPQF 


•jfO 


OPOF 


5B0 


OPOF 


S90 


OPQF 


600 


DPQF 


610 



MOf bifl 



INTRODUCTION TO NUMERICAL ANALYSIS, MC G«AW-H1LL. NEW YORK/ DPQF 630 

TORONTO/LONDON, 1956, PP. 472-476.) DPQF 640 

OPQF 650 

OPOF 660 

OPQF 670 

OPQF 6B0 

DPQF 690 

DPQF 700 

DPQF 710 

DPQF 7?0 

OPQF 7 30 

OPQF 740 

OPQF 750 

DPQF 760 

DPOF 7 70 

DPQF 780 



SUBROUTINE OPQFS (C, IC,Q .LIM. lERI 



DIMENSION C( It.Q(l) 

DOUBLE PRECISION A.B.AA.BB ,CA,C8,CC .CD, Ai , B 1 ,C 1 ,H,HH,Q1 ,02,001, 
I 0Q2.QQQl,QQQ2,0Ql,DQ2,EPStEPSl,C,a 

TEST ON LEADING ZERO COEFFICIENTS 
lER-O 
J=IC*l 
J»J-l 



196 Mathematics — Poiynomials: Roots 



hORHiLIJ ATION QF atMAINING COEff ICIENTS 
A=CIJI 

If (A-l.DOlA.ft.-i 
DO 5 I = l..t 

cdi-cn )/« 

CALL OVERFLfNl 
If (N-2)40.5,? 
CONtlNJf 

TtSr ON NErESSITY OF BAIRSIOM tTtRAIION 

IF ( J-)MI , 36, T 

PREPARe BAI-'STOh ITERATION 
EPS= I.D-IA 
EPSl=l.0-6 



Ql^OUl 

001=0. DO 

002=0. DO 

AA=C(l) 

Be=CI2» 

C8=DABS(AA) 

CA=0A8S(e6l 

IFICe-CAIS.I.IO 
3 f.C«CB»C8 

CB=CB/CA 

CA=1.D0 

GO TO U 
9 CC=CAtCA 

CA-l.DO 

C6=1.D0 

60 TO 11 

10 CC=CAtCA 

c*=CA/ce 

CB=1.00 

11 CO=CC».lDO 

START BAIRSTOW ITERATION 
PREPARE NESTfD MULTIPLICATION 

12 A=O.DO 



I=:J 

0001=01 
0002=02 
D01=HH 

D02=H 

START NESTED MULTIPLICATION 
13 H=-Ql»B-Q2*A+C(I I 

CALL OVERFLINI 

IF (N-ZI*2. l-i.lA 
I* B=A 

»=H 

1=1-1 

IFn*l)18,15,16 

15 H=O.DO 

16 H=*01*B1-02*A1*H 
CALL OVERFLINI 
IF(N-2IA2,17,17 

17 Cl=Bl 
Bl = Al 
Al-H 



GO 



TEST ON SATISFACTORV ACCURACY 

18 H=C(*0ABSIAI*CB«0fl6StS) 
IF(LL1 19, 19, 39 

19 L=L*1 

IF (DABS! A|-ePS»DABStCI U 1120,20,21 

20 IF(DAeSI6I-Et>S*D4BS(C(2n 139.39,21 

TEST ON LINEAR REMAINDER OF MINIMUM NORM 

21 IF (H-CC)22.22.23 



DPQF 790 
OPQF 800 
OPOF eio 
DPOF fl20 
DPQF B)0 
OPOF B<.0 
OPQF 6 50 
DPQf B60 
DPQf 670 
OPOF BRO 
OPQF 890 
OPOF 900 
DPOf 910 
DPQF 920 
DPQF 910 
DPOF SiO 
DPQF 950 
DPQF 960 
DPQF 970 
DPQF 980 
OPQF 990 
OPQF 1000 
DPQFIOIO 
0PQF1020 
DPOF 1030 
DPQFIOAO 
DPQF 1050 
OPQF 1060 
DPOF I 070 
DPQF 1080 
DPQF 1090 
DPQF I 100 
DPOF 11 10 
DPOFl 120 
DPOFl 130 
DPQFIUO 
DPQF 11 50 
DPOF 1160 
OPQFUTD 
DPQFllBO 
OPQFl 190 
0P0FI200 
0PQF12t0 
0P0F1220 
OP0F123O 
OPQF1240 
DPQF1250 
OPQF 1260 
DPQf 1270 
DPQF 1280 
DPQF 1290 
OPQFUOO 
DPQFL31!! 
DPQF1320 
DPOF 13 30 
DPQFl 340 
DPQF1350 
OPQFl 360 
OPQF 13 70 
DPQF 1380 
OPQF 1390 
DPQFl-tOO 
DPQFl^lO 
DP0FU20 
DPQF 14 30 
DPQFl^AO 
DPQFl*50 
DPOFl'tbO 
DPQF1470 
DPQF 1480 
OPQF I 490 
OPQF 1 500 
OP0F1510 
DPQF 1520 
DPQF1530 
DP0F154D 
DPQF1550 
DPQF1560 
DPQF 1 5 TO 
OPQF 15 80 
0PQF1590 



22 AA=A 

ee=8 

QQl^Ql 
QQ2"Q2 

TEST ON LAST ITERATION ilEP 

23 IF(L-LIM)26,2fl,?A 

TEST ON RESTART OF BAIRSTOW ITERATION WITH 1E.^\ 
2* IF(H-CDI43,43,25 

25 IFIOdI 127,26,27 

26 [F(0(2|]27,42,27 

27 Qdl'O.DO 
0( 21=0.00 
GO TO 7 

PERFOfiM ITERATinU STEP 
2 6 HH=DMAXl(OAeS( Al ) . DA8S( 6 1 1 , DAB S( CI tl 
IF(MH)42,42,29 

29 Al=Al/HH 

ei=fll/HH 

Cl=Cl/MH 

M=AI«C1-Bl*ei 

IFIHl3a.42.30 

30 A=A/HH 
B=e/HH 
HH=(8*AI-A*Bi »/H 

H=(A*ci-e*pn/H 

Ql=01*HH 
Q2=Q2*H 

END OF I TFRATICN STEP 

TEST ON SATISFACTORY RELATIVE ERROR OF ITERAFEO VALUES 
IF<OABS( HH)-EPS"OABS(Ql) 131, 31,3 3 

31 IF(OABS(HI-EPS»OA85(Q2l 13 2, 3 2,33 

32 LL=1 
GO TO 12 

TEST ON DECREASING RELATIVE ERRORS 

33 IF(L-II12, 12,3'i 

34 tF(OABS(HHl-€PSl*OAaS(Ql 113 5, 3 5, 12 

35 IF (DABS (HI -EPS l*DAeS(Q?M3', 36,12 

36 IF(OABS{QaQl*MH)-DABS(01«00 1) 1 3 7, <i4 , 'i'. 

37 IF<0ABS(Oa02*Hl-DaPS( 02*002) l 12,44.4'; 

END OF PAIBSIOW ITEKATION 

EXIT IN CASt GF OuaO^dTTC PPLYNGMIAL 
ifl Q( ll=C(ll 
0(2l=r(21 
0(3(^0.00 

0(41=0.10 
WFTURN 



CftSE CF SUFFIcn^MT 6CCURA 



EXIT IN 
Qt 11 ^31 
0( 21=02 
Q( 31=0 
0)4»=B 
RFTURS 

ERRO« EXIT IN CASE OF 

ieo=-i 

RETURN 



:V0 OR CONSTANT POLYNOMIAL 



ERHOK eXIT IN CASE OF LINEAR POLYNO'IIAL 
41 IER=-2 
KETURN 



EP'frR FriT IM tesp 
4? IER=-3 

GO Tn 44 



NCNREFINEU OUAORATIC FAC 



fRROfl 

i.? ICR^I 

^4 0(11=001 
0(21=002 
C(3I =aA 
GI4I=B6 
RETURN 
FND 



(IT !N CASE CF UNSAT I SFAC TOBV ACCUftACY 



OPQF 1600 
DPQF1610 
DPQF1620 
DPQF163Q 
X DPQF 1640 

0PQF1650 
DP0F1660 
DPQF 1670 
DP0F1680 
lAL GUESS DP0F1690 
DPOFl 700 
DPQF1710 
OPOf 1720 
DPQF 1 7 30 
OPQF 17*0 
OPQFl 750 
DPQFl 760 
DPQF1770 
DPQF178a 
OPQFl 790 
DPQFieOO 
OPQFIBIO 
0PQF1820 
DPQF1830 
DPQFia40 
DPQF1850 
OPQFl 860 
0PQF18T0 
DPQFieaO 
DpQFie9a 
OPQF1900 
DP0F1910 
DP0F1920 
DP0F1930 
0PQF1940 
DPQF 19 60 
0PQF1960 
DPQF 1970 
0PQF1980 
OPQF 1990 
OPQF2000 
DPQF2010 
DPQF2020 
DP0F2010 
0P0F2040 
OP0F2O5O 
DPQF 2060 
DPOF>070 
OPQF2080 
OP0F2090 
DPQF2100 
DP0F2110 
OPOF2120 
DPQF2130 
DPQF2140 
DP0F2150 
0P0F2160 
0PQF21T0 
0PQF2180 
OPOF 2 190 
0PQF2200 
DP0F2210 
DPOF2Z20 
DPOf 2230 
0PQF2240 
DPOF2250 
0P0F2260 
DP0F2270 
0PQF22B0 
0PQF2Z90 
DP0F2J00 
DPQF2310 
DPOF2320 
0PQF2330 
DPQF2340 
0P0F2350 
OPQF2360 
DPQF2370 
DP0F23BO 
0PQF2 390 
0PQF2400 



Mathematics— Polynomials: Roots 197 



Polynomials: Special Types 

Subroutines CNP and DCNP 

These subroutines compute the values of the 
Chebyshev polynomials for a given argument x and 
orders zero up to N. The Chebyshev polynomial 
Tjj(x) satisfies the recurrence equation 



Vi(x)=2x 



T^(x) 



n-1 



(X) 



with starting values Tq{x} = 1, T2(x) =x. From 
this equation it follows immediately that roundoff 
errors grow at worst linearly under the tacit as- 
sumption that the argument has an absolute value 
less than one. 

If en+2- is the error in Tn+r(x) due to a single 
roundoff error e in Tn(x): 



e ^ = 2 X . 

n+r+1 



with initial conditions e 



n 



n+r 



-n-1 



n+r-1 



= 0. 



The solution of this difference equation has its 
maximum for x =1: 



SUSROUriNE OCNP 

puftpose 

COMmiTE TH€ VALUES OF THE CHESYSHEV POLVWHIALS r( 
FOR AKCUNENT VALUE X AND OfloeRS UP ro N. 

USAGE 

CALL OCNP.r.X.NI 

OESCRtPTION Of PAItAHETEAS 

Y - RESULT VECTOR OF OINENSION H*l CONTAINING 

Of CHEBYSHEV fOLVNOHIALS OF OROEII UP TO 

FOA GIVEN ARGUMENT X. 

DOUBLE PRECISION VECTOR. 

VALUES ARE ORDERED FROM LOW TO HIGH ORDER 

V - RESULT VALUE 

OOUBLE PRECISION VARIABLE. 
X - ARGUMENT OF CHEBYSHEV POLVNOHIAL 

N - ORDER OF CHEBYSHEV POLYNOMIAL 



9 IS TREATED AS IF N MERE 

SUSftOUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION IS BASEO ON THE RECURRENCE EQUATION FOR 

CHEBYSHEV POLVNOniALS TtN.XI 

r<N*ltX|>2*X«T(N,XI-TIN-l«XI. 

WHERE THE FIRST TERN IN BRACKETS IS THE QROERt 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE TIO.X)-!. Tft.XI'X. 



N.K> 



SUBROUTINE OCNP(r,X«NI 



DIMENSION Vnt 

DOUBLE PRECISION Y, X«F 



YIll'1.00 
IFfNtl. 1,2 

RETURN 



OO « I-2,N 

YII*II»F*V(II-Y(|-1I 

RETURN 

END 



ONP 
DNP 
ONP 
ONP 
DNP 
DNP 
DNP 
ONP 
ONP 
ONP 
ONP 
ONP 
DNP 
THE VALUESONP 
N ONP 

DNP 
ONP 
ONP 
ONP 
ONP 
ONP 
ONP 
ONP 
ONP 
ONP 
DNP 
ONP 
ONP 
ONP 
DNP 
DNP 
ONP 
ONP 
DNP 
ONP 
ONP 
ONP 
ONP 
ONP 
DNP 
ONP 
ONP 
ONP 
ONP 
DNP 
DNP 
ONP 
DNP 
ONP 
DNP 
DNP 
ONP 
ONP 
DNP 
ONP 
ONP 
ONP 
ONP 



100 
IIQ 

120 
130 

140 
150 
160 
170 
IBO 
190 
ZOO 
219 
220 
2 JO 
240 
250 
260 
2 70 
2B0 
290 
300 
310 
320 
330 
3*0 
350 
360 
370 
3B0 
390 
400 
410 
420 
430 
440 
450 
460 
470 
4B0 
490 
503 
510 
520 
5 30 
540 
550 
560 
570 
580 



e ^ = 0, e = e, e 
n-1 n n+1 



= (r+l)e 



= 2 e. 



n+r 



The order is assumed to be zero for negative values 
of N. 



SUBROUTINE CNP 

PURPOSE 

COMPUTE THE VALUES OF THE CHEBYSHEV POLYNOMIALS TIN. XI 
FOR ARGUMENT VALUE X ANO ORDERS UP TO N. 

USAGE 

CALL CNPIYtX.Nl 

DESCRIPTION OF PARAMETERS 

Y - RESULT VECTOR OF DIMENSION N»l CONTAINING THE 

OF CHEBYSHEV POLYNOMIALS OF ORDER UP TO N 
FOR SIVEN ARGUMENT X. 

Y - RESULT VALUE 

VALUES ARE OROERED PROM LOW TO HIGH ORDER 
X - ARGUMENT OF CHEBYSHEV POLYNOMIAL 

N - ORDER OF CHEBYSHEV POLYNOMIAL 

REMARKS 

N LESS THAN IS TREATED AS IF N MERE 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION IS BASED ON THE RECURRENCE EQUATION FOR 

CHEBYSHEV POLYNOMIALS TIN*XI 

TtN*l,X1.2«X*T(N,XI-T(H-l,X), 

WHERE THE FIRST TERM IN BRACKETS IS THE ORDER, 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE TI0,X>"1» KltXt^X. 



SUBROUTINE CNP(Y,K,NI 

DIMENSION Ylll 
Y(ll»l. 
IFIN)!, 1,2 
1 RETURN 



DO 4 l«2iN 
4 YII*1I«F*Y( I l-Y<l-l t 
RETURN 

END 



CNP 


10 




?l) 


CNP 


30 


CNP 


*0 


CNP 


50 


CNP 


to 


CNP 


TO 


CNP 


60 


CNP 


90 


CNP 


100 


CNP 


110 


CNP 


120 


CNP 


110 


VALUESCNP 


1«0 


CNP 


150 


CNP 


ito 


CNP 


WO 


CNP 


100 


CNP 


190 


CNP 


ZOO 


CNP 


210 


CNP 


220 


CNP 


230 


CNP 


2*0 


CNP 


250 


CNP 


260 


CNP 


270 


CNP 


280 


CNP 


290 


CNP 


300 


CNP 


310 


CNP 


320 


CNP 


330 


CNP 


3»0 


CNP 


350 


CNP 


IkO 


CHP 


J 70 


CNP 


3B0 


CNP 


190 


CNP 


400 


CNP 


410 


CNP 


420 


CNP 


430 


CNP 


440 


CNP 


450 


CNP 


460 


CNP 


4 TO 


CNP 


400 


CNP 


490 


CNP 


900 


CNP 


510 


CNP 


520 


CNP 


5 30 


CNP 


540 



198 Mathematics — Polynomials: Special Types 



Subroutines CNPS and DCNPS 

These subroutines compute the value of a series 
expansion in Chebyshev polynomials. TheChebyshev 
polynomial Tji(x) satisfies the recurrence equation 

T (X) = 2 X • T (X) - T ^ (x> 
n+1' n^ ' n-1^ ' 

with starting values To(x) =1, Tj^(x) =x. 

An n-term expansion in Chebyshev polynomials 
with coefficient vector C = (ci, . . . , c^) is evaluated 
by means of a backward iteration scheme: 



Arg = 2 x, H^ = 0. H^ = 
«2^«1 



«1=«0 



Ho = ^^^ • «1 - «2 ^ '^n-i.l 
Y = (c^ - H^ + H^)/2. 



for i = 1 , . . . , n 



This gives result Y(x) = ^ ^-T. , (x). 

i=l ^ 
Calculation is bypassed in case of a nonpositive 
value of the dimension n. 



SUeftOUTlNE OCNPS 

PURPOSE \ 

COMPUTES THE VALUE OF AN N-TERff EXPANSION IN CHEOYSHCV 
POLVMMIALS rilTH COEFFICIENT VECTOR C FOR ARCUHENT VALUE 

USAGE 

CJU.L DCNPStV.X.C.NI 

OESCRfPTION OF RARANETERS 
y - RESULT VALUE 

OOUBLE PRECISION VARtAOLE 
K - ARGUMENT VALUE 

DOUBLE PRECISION VARIASLE 
C - COEFFICIENT VECTOR Of GIVEN EEPANSION 

COEFFICIENTS ARE ORDERED FRDH LOW TO HIGH 

DOUBLE PRECISION VECTOR 
N - OIHENSION OF COEFFICIENT VECTOR C 



IS BYPASSED IN CASE N LESS Than 1 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

NCTHOO 

OEFINITION 

Y-SUNICn }«T(I-1.I(1. SUNNED OVER I FROM 1 TO Nl. 

EVALUATION IS DONE BY NEANS OF BACKHAND RECURSION 

USING THE R6CURRENCE EQUATION FOR CHE»TSHEV POLYNONIALS 

T(N+l,XI>2«K«nN«K|-T(N-l«XI, 



SUBROUTINE OCNPSt Yt X.C.NI 

OINENStON GUI 

OOUetE PRECISION C t T.X tHO.HI * H2, ARO 

TEST OF OINENSION 
1F(N»1* 1.2 
RETURN 

; lFCN-2) 3,4,4 
Y"CIll 

RETURN 

INITIALIZATION 

ARG«X*X 
Hl-0.00 
HO-O.OO 



00 5 I-l,N 

R-N-1 

H2-HI 



>H0 

5 H0*ARG*Hl-H2*CIK«l| 
V-0.$00*(C<1I-H2«H01 
RETURN 
END 



JO 



60 



90 



ONPS 
..ONPS 
DNPS 
ONPS 
DNPS 
ONPS 
ONPS 

:. ONPS 
ONPS 
ONPS 100 
ONPS 110 
ONPS 120 
ONPS DO 
ONPS 140 
DMPS ISO 
ONPS 160 
ONPS 170 
ONPS IBO 
DNPS 190 
ONPS 200 
ONPS 210 
ONPS 220 
DNPS 230 
ONPS 240 
ONPS 250 
ONPS 260 
DNPS 2T0 
ONPS 280 
ONPS 290 
ONPS }D0 
ONPS 310 
ONPS 320 
ONPS }30 
DNPS 340 
DNPS 3S0 
..ONPS 3*0 
ONPS 370 
ONPS 380 
ONPS 390 
DNPS 400 
DNPS 410 
ONPS 420 
DNPS 430 
ONPS 440 
DNPS 4SD 
DNPS 460 
ONPS 470 
ONPS 410 
DNPS 490 
ONPS 500 
DNPS 510 
DNPS 520 
DNPS 5 30 
ONPS 5*0 
ONPS 550 
DNPS 560 
DNPS STO 
DNPS 560 
ONPS 590 
DNPS 600 
ONPS 610 
DNTS 620 
DNPS 6)0 



SUBROUTINE CNPS 

PURPOSE 

COMPUTES THE VALUE OF AN N-TERM EXPANSION IN CHEBYSHEV 
POLTNOHIALS VITH COEFFICIENT VECTOR C FOR ARGUMENT VALUE 



USAGE 

CALL CNPStY.: 



• C.NI 



DESCRIPTION OF PARAMETERS 
Y - RESULT VALUE 
K - ARGUN ENT VALUE 
C - COEFFICIENT VECTOR OF GIVEN EXPANSION 

COEFFICIENTS ARE ORDERED FROM LOW TO HIGH 
N - DIMENSION OF COEFFICIENT VECTOR C 

REMARKS 

OPERATION IS BYPASSED IN CASE N LESS THAN 1 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

NETHOO 

OEFINiriON 

Y-SUHICd )*r( l-l.XI, SLMNEO OVER I FROM 1 TO Nl . 

EVALUATION IS DONE BY NEANS OF BACKWARD RECURSION 

USING THE RECURRENCE EQUATION FOR CHEBYSHEV POLYNOMIALS 

TCN*l,XI«2*X*TIN,Xt-T(N-l.X». 



SUBROUTINE CNPS ( Y,X tCt N) 

DIMENSION CI II 

TEST OF DIMENSION 
IF(NII.1,2 
1 RETURN 



2 1F(N-2I3.4.4 

3 Y"C(l» 
RETURN 

INITIALIZATION 

4 ARG-X*X 

m-0. 

HO-0. 

DO 5 I-I«N 
K-N-I 
H2>H1 
HI -HO 

5 H0-ARG*HI-H2«-C(K4^1I 
V-0.5*fClll-H2tHOI 
RETURN 

END 



n 



60 



CNPS 
...CNPS 
CNPS 
CNPS 
CNPS 
CNPS 
CNPS 
X. CNPS 
CNPS 
CNPS 
CNPS tlO 
CNPS 120 
CNPS 130 
CNPS 140 
CNPS ISO 
CNPS 160 
CNPS 170 
CNPS 180 
CNPS 190 
CNPS 200 
CNPS 210 
CNPS 22C 
CNPS 230 
CNPS 240 
CNPS 250 
CNPS 260 
CNPS 2 70 
CNPS 280 
CNPS 290 
CNPS 3C0 
CNPS 310 
CNPS 320 
..CNPS 3 30 
CNPS 340 
CNPS 350 
CNPS 360 
CNPS 170 
CNPS 380 
CNPS 390 
CNPS 400 
CNPS 410 
CNPS 420 
CNPS 430 
CNPS 440 
CNPS *50 
CNPS 460 
CNPS 470 
CNPS 4B0 
CNPS 490 
CNPS 530 
CNPS 510 
CNPS 520 
CNPS 5 30 
CNPS 540 
CNPS 550 
CNPS 560 
CNPS 5 70 
CNPS 580 
CNPS 590 



Mathematics— Polynomials: Special Types 199 



Subroutines TCNP and DTCNP 

These subroutines transform a given series expan- 
sion in Chebyshev polynomials to a polynomial. The 
radependent variable x of the given expansion is 
thereby substituted by the independent variable z of 
the resulting polynomial using the linear transfor- 
mation x = A»z + B or z = (x- B)/A. 

N 
This means: y^ 
i =1 



C. » T. , (A#z + B) 
1 1-1 ^ 



POL • z 

1 



i-1 



N 

= L 

i = 1 

Calculation is bypassed in case of a nonpositive 
value of the dimension N. 

The range (-1, +1) in x is transformed to the 
range (zj^, z^) in z with zj^ = -(1+B)/A and z^ = 
(1-B)/A, or vice versa, A = 2/(zr-zi) and B = 



- (Zr + ^l)A2 



zi). 



The Chebyshev polynomial Tn (x) satisfies the 
recurrence equation 



T , (X) = 2 X • T (x) 
n+1^ ' n^ ' 



n-1 



(X) 



with startii^ values Tq(x) = 1, T2^(x) = x. The 
transformation is performed by means of a forward 
iteration scheme: 

1 . The coefficient vector of the Chebyshev poly- 
nomial Tj(x) is calculated from the coefficient 
vectors of Ti-i(x), Ti_2(x) using the recurrence 
equation, for i = 3, . . . , N. 

2. The resulting polynomial coefficient vector is 
obtained by summation of cj times coefficient vector 
of Ti-i(x) over i, for i = 1, .... N. 



SUBKOUTINE rCNP 



tCNf 10 

TCNP 20 

TCNP 30 
TCNP to 
TCNP 50 
PlDtPOSE 'CNP 60 

• SEHItS E«P»NSION IH CHEBYSHEV POLTNOBULS KITH INOEPEHOEHTTCHP TO 
VARIABLE X IS TRANSFOdNEO TO A POLYNONIAL MITH INDEPENDENT TCNP 80 
VARIAUE Z. 1(I«RE K.A»Z»«. 'CNP 90 

TCNP 100 
TCNP llO 
TCNP I JO 
TCNP L>0 
DESCRIPTION Of PARAN6TERS TCNP 1*0 

A - FACTOR Of tlNEAR TERN IN 6IVEN LINEAR TRANSFDRNATIONICNP 150 

B - CONSTANT TERN IN GIVEN LINEAR TRANSFORHATION TCNP 160 

POL - COEFFICIENT VECTOR OF POLVNONIAL IRESUlTANT VALUE) TCNP ITO 

COEFFICIENTS ARE ORDERED FRON LOU TO HIGH 
N - OIHENSION OF COEFFICIENT VECTORS POL AND C 

C - GIVEN COEFFICIENT VECTOR OF EXPANSION 

COEFFICIENTS ARE OROEAED FRON LOU TO HIGH 
POL AND C NAT BE lOENTICALLV LOCATED 
WORK - WORKING STORAGE OF OINENSION 2«N 



TCNP ISO 
TCNP 190 
TCNP 200 
TCNP 210 
TCNP 220 
TCNP 230 
TCNP 240 
TCNP 250 
TCNP 260 
TCNP 2T0 
TCNP 280 



RENARKS , „ . 

COEFFICIENT VECTOR C REHAINS UNCHANGED IF NOT COINCIDING 
WITH COEFFICIENT VECTOR POL. 

OPERATION IS BYPASSED IH CASE N LESS THAN I. 
THE LINEAR TRANSFORHATION X.A«2»B OR Z-Il/AKX-BI TRANSFORNSTCNP 290 
THE RANGE 1-1, til IN X TO THE RANGE I2L,2R1 IN t. WHERE TCNP 300 

2l--(l»»l/A AND 2R.<I-8I/A. TCNP 310 

FOR GIVEN 2L, ZR HE HAVE A-2/I2R-2LI ANO B—I/R42LI /(ZR-2L) TCNP J20 

TCNP 330 

SUBROUTINES *N0 FUNCTION SUOPROGRAHS REQUIRED 
NONE 



NETHOO 

THE TRANSFORttATION IS BASED ON THE RECURRENCE EOUATION 

FOR CHEBYSHEV POLVNOHIALS TlN.Kl 

TIN*1.XI-2*K*TIN.XI-T1N-1,XI . 

WHERE THE FIRST TERN IN BRACKETS IS THE INDEX. 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE TIO.KI-I. TI1.X)-X. 

THE TRANSFORHATION IS INPLICITIY DEFINEO BY HEANS OF 

X - A*2*a TOGETHER WITH 

SUNIP0LII)«Z«*1I-1I. SUNNED OVER I FROH I TO NI 

>SUH<C(II«riI-l.«l. SUNNED OVER I FRON 1 TO Nl. 



TCNP 3A0 
TCNP 3S3 
TCNP 360 
TCNP 370 
TCNP 380 
TCNP 390 
TCNP *00 
TCNP AlO 
TCNP 420 
TCNP 430 
TCNP 440 
TCNP 450 
TCNP 460 
TCNP 470 
TCNP 480 



SUBROUTINE TCNPIA.B.POl.N.CiHORK) 
DIMENSION POLIll.Clll.WORKIll 



c 




TEST OF OINENSION 


c 
c 




IFIN-1)2.1.3 




OINENSION LESS THAN 2 




1 


POLIll-CtU 




? 


RETURN 


c 








3 


f>QL(ll-C(ll«-C(21«B 
P0L(2)-C(2I*A 


c 
c 




IFIN-2I2,2,« 




INITIALlZAriON 




4 


WORKUI-l. 
HORKIZI-e 
MORKOl-O. 

HORKU>*A 

XO-A+A 

XO-Bt-B 



CALCULArC COEFFICIENT VECTOR OF NEXT CHEBVSHEV COLYNOKI AL 
ANO ADD HULTIPLE OF THIS VECTOR TO POLYNOHIAL POL 

DO 6 J-3*N 

P-0. 

00 5 K"2.J 

H-P-WaRK( 2*K-3 1 t-KO^WORKC 2*K-2) 

P>HORKt2*K-2) 

W0RK(2*K-2I«H 

W0RK*Z*K-5I«P 

POL I K- 1 1 • POL ( K- 1) ♦H •C ( J ) 

5 P-XO*P 
H0RK(2*J-1I«0. 
H0RKI2*JI-P 

6 PDL(J>-CIJJ*P 
RETURN 

END 



..TCNP htO 
TCNP 500 
TCNP 510 
TCNP 520 
TCNP 530 
TCNP 5*0 
TCNP 550 
TCNP S60 
TCNP 5T0 
TCNP 580 
TCNP 590 
TCNP 600 
TCNP 610 
TCNP 620 
TCNP 6 30 
TCNP 6^4 
TCNP 650 
TCNP 660 
TCNP 6T0 
TCNP 680 
TCNP 690 
TCNP 700 
TCNP 710 
TCNP T20 
TCNP 730 
TCNP T*0 
TCNP T50 
TCNP 760 
TCNP 7T0 
TCNP 780 
TCNP 190 
TCNP 800 
TCNP 810 
TCNP 820 
TCNP 8 30 
TCNP 8^0 
TCNP 850 
TCNP 860 
TCNP 870 
TCNP 880 
TCNP 890 
TCNP 900 



SUBROUTINE DTCNP 



OTCN 10 
OTCN 20 

DTCN 30 

OTCN «C 

OTCN 50 

PURPOSE OTCN 60 

A SERIES EXPANSION IN CHEBYSHEV POLVNOHIALS WITH INOEPENOENTOTCN TO 

VARIABLE X IS TRANSFORMED TO A POLYNOMIAL WITH INDEPENDENT OTCN 80 

VARIABLE It WHERE X-A*Z*^B. OTCN 90 

DTCN 100 

liSAGE OTCN LlO 

CALL DTCNPIAiBfPOLtN.CtWORK) DTCN IZO 

DTCN 130 

DESCRIPTION OF PARAMETERS OTCN 1*0 

A - FACTOR OF LINEAR TERN IN GIVEN LINEAR TRANSFORNATIONOTCN ISO 



DOUBLE PRECISION VARIABLE 

CONSTANT TERN It GIVEN LINEAR TRANSFORNATION 

DOUBLE PRECISION VARIABLE 

COEFFICIENT VECTOR OF POLYNOHIAL (RESULTANT VALUE) 

COEFFICIENTS ARE ORDERED FRON LOW TO HIGH 

DOUBLE PRECISION VECTOR 

DIMENSION OF COEFFICIENT VECTORS POL ANO C 

GIVEN COEFFICIENT VECTOR OF EXPANSION 

COEFFICIENTS ARE ORDERED FROH LOW TO HIGH 

POL ANO C HAY BE lOENTICALLV LOCATED 

DOUBLE PRECISION VECTOR 

H0RKII4G STORAGE OF DIMENSION 2*N 

DOUBLE PRECISION ARRAY 



NOT COINCIDING 



OTCN 160 
DTCN ITO 
OTCN IBO 
DTCN 190 
OTCN 200 
OTCN ZIQ 
OTCN 220 
DTCN 2 30 
OTCN 240 
DTCN 250 
OTCN 260 
OTCN 270 
OTCN 280 
DTCN 290 
OTCN 300 
DTCN 3L0 
OTCN 320 
OTCN 330 



REMARKS 

COEFFICIENT VECTOR C REMAINS UNCHANGED 
WITH COEFFICIENT VECTOR POL. 

OPERATION IS BYPASSED IN CASE N LESS THAN I. 
THE LINEAR TRANSFORMATION X>A*24-B OR Z-d/AMX-B) TRANSFORMSDTCN 340 
THE RANGE t-l.+l) IH X TO THE RANGE (ZL.ZRI IN Z, MHERE DTCN 350 
ZL--(L«^ai/A ANO ZR-ll-BI/A. OTCN 360 

FOR GIVEN ZLt ZR WE HAVE A-2/(ZR-ZL» ANO 8=-(ZR*Zil/(ZR-ZLI OTCN 370 

OTCN 380 

SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
NONE 



METHOD 

THE TRANSFORMATION IS BASED ON THE RECURRENCE EQUATION 

FDR CHEBYSHEV POLYNOMIALS TIN. XI 

TINi-l.X|32*X*r<N,Xl-T(N-ltX)t 

WHERE THE FIRST TERM IN BRACKETS IS THE INDEX, 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE TlOtXfU T(1*XI*X. 

THE TRANSFORMATION IS IMPLICITLY DEFINED BY MEANS OF 

X - A*Z*B TOGETHER HITH 

SUMtPOLd l*Z**(I-I), SUMMED OVER 1 FROM 1 TO Nl 

-SUMICII t*T(I-l,K), SUMMED OVER I FROM 1 TO N). 



SUBROUTINE OrCNP< A, B.POL tN, C. WORK! 

DIMENSION POLI I)bC( 1) .MORK< II 

DOUBLE PRECISION A. B.POL. C. WORK, H,P,KD,XO 

TEST OF DIMENSION 
IF(N-1)2,1,3 

DIMENSION LESS THA^i 2 
POL I 1I-C< 1) 
'. RETURN 

P0L(1I*CUUC(2)*B 

P0L(2)«C(21»A 

IF(M-2I2,2,« 

INITIALIZATION 

WORK( 11:^1.00 

H0RK(2)>B 

WORK)3I=0,DO 

W0RK(4»-A 

XD'A^A 

XO»B*B 



OTCN 390 
OTCN 400 
OTCN 410 
OTCN 620 
OTCN 430 
OTCN **0 
DTCN 650 
OTCN *60 
OTCN *70 
DTCN 480 
DTCN 490 
OTCN 500 
OTCN 5L0 
OTCN 520 
OTCN 530 
.. OTCN 5*.0 
OTCN 550 
OTCN 560 
OTCN 5 70 
OTCN 580 
OTCN 590 
OTCN 600 
DTCN 610 
OTCN 620 

orciu M 

DTCN 640 
OTCN 650 
OTCN 660 
OTCN 670 
OTCN 680 
DTCH 690 
OTCN 700 
DTCN 710 
DTCN 720 
DTCN 730 
DTCN 740 
DTCN 750 
OTCN 76C 
DTCN 770 
OTCN 790 
DTCN 790 



200 



Matliematics — Polynomials: Special Types 



CAtCULATE COEfFICI€NT VECTOR OF NEXT CHEBYSHEV POLYNOMIAL 
ANO AOD MULTIPLE OF THIS VCCTOR TO POLYNOMIAL POL 
00 6 J-3.M 

P«0.00 

OO 5 K-2.J 

H>P-UOAM2*K-3UX0*U0ftK(2*K-2) 

P=HOWtl2*K-2) . 

W0RKf2«K-2)-H 

U0R(C(Z*K-3I«P 

POL ( K- 1 1 " POL I H- 1 1 *N •C( J I 

P-)tO*P 

U0RK(2*J-1I*0.00 

WORKCZ^JWP 

POL! Jl'^Ct JI*P 

RETURN 

END 



OTCM aoo 

OTCN 810 
orcN BZO 
OTCN B3D 
orcN 8^0 

OrCN B50 
OTCN 8&0 
DTCN 8T0 
OTCN 880 
OTCN 890 
OrCN 900 
OTCN 9tO 
DTCN 920 
OTCN 930 
OTCN 940 
OTCN 950 
DTCN 960 



Subroutines CSP and DCSP 

These subroutines compute the values of the shifted 
Chebyshev poljmomials for a given argument x and 
orders zero up to N. The shifted Chebyshev poly- 
nomial satisfies the recurrence equation. 



n+1 



(X) = 2 (2 x-1) T^(x) - T^_^(x) 



s s 

with starting values To(x) = 1, Ti(x) =2 • x - 1. 

From this equation, it follows immediately that 
roundoff errors grow at worst linearly under the 
tacit assumption that the argument values are be- 
tween zero and one. 

g 

If Cn+r is the error in Tn+r(x) due to a single 
rounding error e in T^ (x): 



e ^ ^-, = 2 (2 x-1) e , 
n+r+1 ^ ' n+r 



n+r-1 



with initial conditions en = e, Cn-l = 0. 

The solution of this difference equation has its 
maximum for x = 1 or x = 0. 



e = 0, e = e, e ^, 
n-1 n n+1 



= 2e 



n+r 



= (1 + r) e. 

The order is assumed to be zero for negative values 
of N. 



SUBROUTINE CSP 

PURPOSE 

COMPUTE THe VALUES OF THE SHIFTED CHEerSMEV POLYNOMIAL 
TSfN.XI FOR ARGUMENT K ANO ORDERS UP TO N. 

USAGE 

CALL CSPIY.X.Nl 

DESCRIPTION OF PARAMETERS 

Y - RESULT VECTOR OF DIMENSION H*^! CONTAINING THE 

OF SHIFTED CHEBYSHEV POLYNOMIALS OF DROER UP 

FOA GIVEN ARGUMENT X. 

VALUES ARE OROEREO FROM LOW TO HIGH OftOER 
K - ARGUMENT OF SHIFTED CHEBYSHEV POLYNOMIAL 

H - ORDER OF SHIFTED CHEBYSHEV POLYNOMIAL 



REMARKS 

N LESS THAN IS TREATED AS IF 



METHOD 

EVALUATION IS BASED ON THE RECURRENCE EQUATION FOR 

SHIFTED CHEBYSHEV POLYNOMIALS TSIN.X) 

rSIN«I.l() = l4*X-2l*TS(N.Xt-TS(N-l,Xt. 

WHERE THE F!«ST TERM IN BRACKETS IS THE ORDER, 

THE SECOND IS THE ARGUMENT. 

STARTING VALJES ARE TSia,XI = t, TS ( I , X I =2*X-I . 



SUBROUTINE CSPIYtX,NI 

DIMENSION VU) 

TEST OF ORDER 
Vtli'l. 
IF(N)l,l,2 

L RETURN 

'. Yt2)-X*X-l. 
IF|N-n 1,1,3 

INiriALIZATION 
I F=Y(2I+Y(2> 

DO « 1=2, N 
Y(l*l».F*Y( I l-Y(I-l I 

RETURN 
END 



CSP 
CSP 

CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
VALUESCSP 
TO N CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 

CSP 

CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 
CSP 



103 
110 
120 
130 
140 
150 
160 
170 
IBO 
193 
200 
210 
220 
230 
240 
250 
260 
270 
280 
2-JO 
300 
310 
320 
330 
340 
350 
3iO 
3 70 
3B0 
J90 



430 
440 
450 
460 
470 
480 
490 
503 
510 
520 
5 30 
540 
550 



Mathematics — Polynomials: Special Types 201 



SUBROUTINE OCSP 

PURPOS€ 

COMPUTE THE VALUES OF THE SHIFTED CHEBYSHEV POLYNOMIALS 
rS(N.XI fOR ARGUMENT X AND ORDERS UP TO N. ^ 

USAGE 

CM-L OCSPIY.X.NI 



OSP 
05P 
DSP 
OSP 
OSP 
OSP 
DSP 
DSP 
OSP 
OSP 
DSP 
DSP 
OSP 



OESCRfPTION OF PARAMETERS 

r - RESULT VECTOR OF DIMENSION N*^! CONTAINING THE VALUESOSP 

OF SHIFTED CHEBYSHEV POLYNOMIALS OF OROEft UP TO N OSP 



FOR SIVEN ARGUMENT 

OIXJSLE PRECISION VECTOR. 

VALUES ARE ORDERED FROM LOU TO HIGH ORDER 

- ARGUMENT OF SHIFTED CHEBYSHEV POLYNOMIAL 
DOUBLE PRCCISIOM VARIABLE. 

- ORDER OF SHIFTED CHEBYSHEV POLYNOMIAL 



REMARKS 

N LESS THAN 



3 IS TREATED AS IF N HERE fl 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION IS BASED ON THE RECURRENCE EQUArlDN FOR 

SHIFTED CHEBYSHEV POLYNOMIALS TS(N.XI 

rSIN*l.Xl-l**X-2I*TS(N,X)-rSIN-|,Xl, 

WHERE THE FIRST TERM IN BRACKETS IS THE ORDER, 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE TSIOtXI-l, TS ( 1. X) *2*X-i . 



SUBROUTINE OCSPIY.X.NI 



DIMENSION Y( 11 

DOUBLE PRECISION V.X.F 



c 




TEST OF ORDER 






rUJ'l.DO 






lf=ir4lltl.2 




I 


RETURN 


c 








z 


Yt2I=X*X-1.00 
IF(N-1I1.I,3 


c 






t 




INITIALIZATION 




% 


F-Y(2)tY(ZI 


c 




DO 4 I<2,N 




4 


¥U + l|.F*V(II-Y(I-ll 
RETURN 

END 



DSP 
OSP 
DSP 
OSP 
OSP 
DSP 
DSP 
DSP 
OSP 
DSP 
DSP 
DSP 
OSP 
OSP 
DSP 
DSP 
DSP 
OSP 
DSP 
DSP 
OSP 
..OSP 
OSP 
OSP 

DSP 
DSP 
DSP 
OSP 
OSP 
OSP 
OSP 
OSP 
OSP 
DSP 
DSP 
DSP 
OSP 
DSP 
OSP 
OSP 
OSP 
OSP 
OSP 



100 

no 
120 
130 
140 
150 
160 
170 
ISO 
190 
200 
210 
220 
230 
240 
250 
260 

2 TO 
280 
290 
300 
310 
520 
330 
340 
550 
360 

3 70 

sao 

390 
«00 
410 
420 



460 
470 
490 
490 
SOD 
SIO 
520 
5 30 
540 
550 
560 
570 

sso 



Subroutines CSPS and DCSPS 

These subroutines compute the value of a series 
expansion in shifted Chebyshev polynomials .' The 
shifted Chebyshev polynomial Tg(x) satisfies the 
recurrence equation 

"' .(X) 



^n+l^""^ = 2 (2 x-1) T^(x) 



n-1' 



with starting values Tq (x) = 1, Tf (x) = 2x - 1. 

An n-term expansion in shifted Chebyshev poly- 
nomials with coefficient vector C = (ci, , . . , Cn) is 
evaluated by means of a backward iteration scheme: 



Arg = 4 X - 2, H = 0, H = 
«2=«1 



«1=«0 



H = Arg • H -H +c . 
^12 n-i+1 



for i = 1, 



Y = (c, 



«2 " «0>/2- 



This gives the result Y(x) =7^ c T^ rx) 

f-^ 1 i-1^ ' 
1=1 

Calculation is bypassed in case of a nonpositive 
value of the dimension n. 



SUBROUTINE CSPS 

PURPOSE 

COMPUTES THE VALUE OF AN N-TERM EXPANSION IN SHIFTED 
CHEBYSHEV POLYNOMIALS WITH COEFFICIENT VECTOR C 
FOR ARGUMENT VALUE X. 

USAGE 

CALL CSPStY,X,C,Nl 

OESCRIPriON OF PARAMETERS 
Y - RESULT VALUE 

K - ARGUHENT VALUE 

C - COEFFICIENT VECTOR OF GIVEN EXPANSION 

COEFFICIENTS ARE ORDERED FROM LOW TO HIGH 
N - DIMENSION OF COEFFICIENT VECTOR C 

REMARKS 

OPERATION IS BYPASSED IN CASE N LESS THAN I 



METHOD 

DEFINITION 

y=suM(Cc I i»rs(i-i,xi, sjmmed over i from i to m, 

EVALUATION IS DONE BY MEANS OF BACKWARD RECURSION 
USING THE RECURRENCE EQUATION FOR SHIFTED 
CHEBYSHEV POLYNOMIALS 
TS(N*1,X)=(4*X-2»*TS(N,X1-TS(N-1,XI. 



SUaRQUTlNE CSPS<ViXtC.NI 

DIMENSION CI I) 

TEST Of DIMENS13N 
IFINI I, 1.2 

1 RETURN 

2 IF(N-2I 3,4,4 

3 v=C( H 

RfrURN 

IMr lALIZATION 

4 ARG = X*^X-1. 
AKG=ARC*ARG 
H1=0. 
H0=0. 

00 5 1= 1,N 
X = N-I 
H2=H1 
HI^HO 

5 H0-*RG*Hl-H2*C(K»-l) 
Y=0.5"{CI II-H2+H0) 
RETURN 

END 



CSPS 10 
...CSPS 20 
CSPS 3D 
CSPS 40 
CSPS 50 
CSPS 60 
CSPS 70 
CSPS 80 
CSPS 90 
CSPS 100 
CSPS 110 
CSPS 120 
CSPS 130 
CSPS 140 
CSPS 150 
CSPS 160 
CSPS I/O 
CSPS 180 
CSPS 190 
CSPS 200 
CSPS 210 
CSPS 220 
CSPS 230 
CSPS 240 
CSPS 250 
CSPS 260 
CSPS 270 
CSPS 280 
CSPS 290 
CSPS 300 
CSPS 310 
CSPS 320 
CSPS 330 
CSPS 340 
..CSPS 350 
CSPS 360 
CSPS 3T0 
CSPS 3 80 
CSPS 390 
CSPS 400 
CSPS 410 
CSPS 420 
CSPS 433 
CSPS 440 
CSPS 450 
CSPS 460 

CSPS 47fl 
CSPS 480 
CSPS 490 
CSPS 500 
CSPS 510 
CSPS 520 
CSPS 530 
CSPS 540 
CSPS 550 
CSPS 560 
CSPS 570 
CSPS 580 
CSPS 590 
CSPS 500 
CSPS 610 
CSPS 620 



202 Mathematics— Polynomials: Special Types 



10 



COHPUTSS THt VALUcf OF AN N-TFRM EXPANSION IN SHlFfeO 
CHEflYSHEV PniYNlMIALS i^ITH COtfFICIENT VECTOR C '' 
f-lR A^OJMtNT VALUE X. 



CALL DC 



5< Y, XtCtN) 



jESC-tiPTIO-iJ OF PARiMETEHS 
f - ^tSULT VALUE 

JJU3Lt ;• .DECISION VArtlAbLE 
X - A^iU>lENr VALUE 

OGUgLt PRECISION VARMJLE 

c - cjirF iciEr4T vecroR oi: «iv£N expansion 

CItPFICIENTS A^E JRO-RtO FROM LOW TO H 
JJ'jaLE PRECISION Vt:CTOK 
-J - JIMENSIOM JF CO£ePICIENT VECTO** C 






av.»4SStD 1.^ CASt \ LESS THAN 1 

5j^-<qutincs and function suspkograms requireo 

^':thou 

tefjnitio.n 

Y=sjH(:n i*T>(i-i,xi , sjH'ii^D jVtk i from i ro m. 

EVALUAFIJ^ I) DON" ftY lEA-^S OF 6ACKHAR0 RECUWSIQN 
■JSING THc lECUR-^rNCe ^JUATig:* FOR SHIFTED 
CHEflYSHtV 'GLYN0*1IALS 
TS(Ntt,<I=(<.»X-J)»r5(N.X)-T$IN-l,XI. 



suasouTiNS aciPsi V, x.cM 

DIMLHSIOM CI U 

DUUdLE .>KECISI3N C, Y, X .HC , H I ,H2 , ARiJ 

TcST JF OIMENSiJN 
I F ( .N M . 1 . 2 

1 RETU?f4 

2 IFIf^-2t 3. '.,4 

3 Y=CU f 
RETJ--<:j 

[p-^1 r lALIZATIOfJ 

', APG=X*<-1.D0 
ARG--4R';*ARG 

HI- j.J-) 

03 5 £=1,N 
K^N-1 

H^ = ^l 
H1=H0 
5 HC'lKG'Hl-H^i-CtKtl) 
Y = 0.500*IC( ll-H2*H01 

RETURN 
END 



30 



60 



DSPS 
..DSPS 
OSPS 
USPS 
DSPS 
OSPS 
OSPS 
5SP$ 
OSPS 
DSPS ICC 
DSPS 110 
OSPS 120 
DSPS 13C 
USPS UC 
OSPS ISO 
OSPS 160 
OSPS 170 
OSPS uo 
OSPS k<iO 
OSPS JCO 
OSPS ZIC 
USPS Z2C 
USPS 230 
OSPS 2<t(? 
OSPS 2'iC 
DSPS 263 
OSPS 270 
OSPS 280 
DSPS 290 
OSPS 30C 
OSPS 31C 
DSPS 320 
OSPS 3JC 
QSPS 'i'rO 
OSPS 350 
OSPS 360 
OSPS 3T0 
..OSPS 3dC 
OSPS i-iO 
DSPS 40C 
OSPS <>iQ 
DSPS '•20 
DSPS *iO 
DSPS "r^O 
DSPS <.^0 
DSPS 'tftO 
OSPS 'tTO 
DSPS ^8C 
USPS 490 
OSPS 50C 
OSPS 510 
OSPS 520 
OSPS 530 
DSPS SiiO 
OSPS 550 
flSPS 560 
DSPS 570 
OSPS b80 
OSPS 590 
OSPS 600 
DSPS 610 
OSPS 62C 
OSPS 630 
OSPS 6^0 
OSPS 650 



Subroutines TCSP and DTCSP 

These subroutines transform a given series expan- 
sion in shifted Chebyshev polynomials to ^ poly- 
nomial. The independent variable x of the given 
expansion is thereby substituted by the independent 
variable z of the resulting polynomial using the 
linear transformation x = A»z + Borz=(x- B)/A. 



N 



,s 



This means: ^ C. * T (A» z + B) 
i = 1 



N 

y POL. ♦ z 



i-l 



Calculation is bypassed in case of a nonpositive 
value of the dimension N. 

The range (0, +1) in x is transformed to the 
range (zj, Zj.) in z with z^ = -B/A and Zj. = (1-B)/A 
or vice versa, A = l/(zr-zi) and B = -zi/(zj. - zj). 

The shifted Chebyshev polynomial Tg(x) satisfies 
the recurrence equation 



T^ , (X) = 4 X T^(x) - 2 T^(x) - T^ , (x) 
n+1^ ' n^ ' n^ ' n-1^ ' 



with starting values Tg(x) =1, Tf(x) = 2 x - 1. The 
transformation is performed by means of a forward 
iteration scheme: 

1 . The coefficient vector of the shifted Chebyshev 
polynomial T^ (x) is calculated from the coefficient 



.j_2(x) using the recurrence 

N. 



vectors of Tf_i(x), Tr 
equation, for i = 3, 

2. The resulting polynomial coefficient vector is 
obtained by summation of cj times T^_2^(x) over i, 
for i =1, .... N. 



SUBROUTINE TCSP 

PURPOSE 

A SERIES EXPANSION IN SHIFTED CHEBYSHEV POLYNOMIALS HITH 
INOEPENOENT VARIASLE X IS TRANSF3RME0 TO A POLYNOMIAL IIITi 
INOEPENOENT VARIABLE ly WHERE X=A*Z«^B. 



DESCRIPTION OF PARAMETERS 



TCSP 13 
•TCSP 20 
TCSP iO 
TCSP *0 
TCSP 
TCSP 
TCSP 
TCSP 
TCSP 
TCSP 100 
TCSP llO 
TCSP 120 
TCSP 130 
TCSP 1*0 



73 



- FACTOR OF LINEAR TERM IN GIVEN LINEAR IRANSFORMATIONTCSP 150 



WORK 



CQNSIANT TERN II GIVEN LINEAA TRANSFORNATl ON 
COeFFICIENT VECTOR DF POLYNOttlAL (RESULTA^JT VALUE) 
COEFFICIENTS ARE ORDERED FROM LDW TO HIGH 
OINE'^SION OF COEFFICIENT VECTORS POL AND C 
GIVE^ COEFFICIENT VECTOR OF CXPANSION 
COEFFICIENTS ARE OROERED FRtW LOM TO HIGH 
POL AND C HAY 6E IDENTICALLY LOCATED 
WORKING STORAGE OF DIMENSION 2«N 



TCSP 160 
TCSP 170 
TCSP 180 
TCSP 190 
TCSP 200 
TCSP 210 
TCSP 220 
TCSP 230 
TCSP 2A0 
TCSP 250 
TCSP Z60 



C REMARKS 

C COeFFIClENT VECTOR C REMAINS UNCHANBtO IF NOT COINCIDING 

c WITH caepfrcffNT vecTon poi. rcSP 37fl 

C OPERATION IS BYPASSED IN CASE N LESS THAN L. TCSP 280 

C THE LINEAR TRANSFORMAT [3N X-A«Z4^B OR 2=> ( 1/A I (X-BI TRANSFORHSTCSP 290 

C THE RANGE tO. 1) IN X TO THE RANGE (2L.ZRI IN Z. WHERE TCSP 300 

C Zt— B/A AND ZR-<l-BI/A. 

C FOR GIVEN ZL, Z« WE HAVE A = 1/IZR-ZLI AND B"-ZL/UR-ZLI 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

THE TRANSFORMATION IS BASED ON THE RECURRENCE EQUATION FOR 

SHIFTED CHEBYSHEV POLYNOMIALS rS(N,XI 

TS(N»l*XI>(4*X-2l*TS(N,X)-TSIN-ltXI, 

WHERE THE FIRST TERM IN BRACKETS IS THE INDEX. 

THE SECOND IS THE ARGUMENT. 



TCSP 313 
TCSP 320 
TCSP 330 
TCSP J*0 
TCSP 350 
TCSP 360 
TCSP 370 
TCSP 380 
TCSP 390 
TCSP *03 
TCSP *10 
TCSP 420 



Mathematics — Polynomials: Special Types 203 



STARTrNC V*Ljes ARE TS(3.X)-i, rS( U XI -2*K-1 . 

THE TRANSFORHAriQN IS MPLICITLf DEFINED 8f MEANS OF 

X-A*i+8 TOGETHER WITH 

SUM(POL(I)*Z»*U-n, SOWHEO OVER I FRDH 1 TO Nl 

-SUH(ClI)«TS(l-l,XI, SUMMED OVER I fROM I TO N>. 



sueROur INE rcspc a.b .pol.n.c.worki 

DIMENSION P01.(n*C(l).HORK(ll 

TEST OF DIMENSnN 
1F(N~112, 1,3 

DIMENSION LESS THAN Z 

1 POL( 1I-C[ 1) 

2 RETURN 

3 XD=A** 
XO'Sffi-l. 

PQL(l)>Cm*C(2)*X0 
P0L(2I-C( 2)*X0 

If IN-212,2.4 

INITIAL IZAT I QN 

4 UOftKID-l. 
WORK) 2 I -XO 
WORK! 31=0. 
WORKUI^XO 
XD-KOtKO 
X0=X0»KO 

CALCULATE COEFFICIENT VECTDR OF NEXT SHIFTED CHEBVSHEV 
POLVNOMIAL AND ADD MULTIPLE OF THIS VECTOR TO POLYNOMIAL POL 

00 6 J>3.N 

P-0. 

DO 5 K=2,J 

H-P-MOR(C(2*K-3»*-XO»i«a«K( 2*K-Z1 

P = UORIC( 2*iC-2» 

W0RK(2*K-2)=H 

WDRK(2*K-3I=P 

POL(K-l) = POL(tC-n*H*C( J) 

5 P=XD*P 
W0RK(2»J-ll-0. 
kORK(2«J»«P 

6 POLI Jt=C(J i*? 
RETURN 

ENO 



rcsp hio 
rcsp **o 
rcsp 450 

TCSP 440 
TCSP 470 
TCSP 480 
..TCSP 490 
TCSP 503 
TCSP 510 
TCSP 520 
TCSP 530 
TCSP 543 
TCSP 550 
TCSP 563 
TCSP 570 
TCSP 583 
TCSP 540 
TCSP 600 
TCSP ilO 
TCSP 620 
TCSP 430 
TCSP 440 
TCSP 650 
TCSP 660 
TCSP 6T0 
TCSP 680 
TCSP 6')0 
TCSP 700 
TCSP 710 
TCSP 720 
TCSP 730 
TCSP 740 
TCSP 753 
TCSP 750 
TCSP 770 
TCSP 780 
TCSP 790 
TCSP a03 
TCSP 810 
TCSP 820 
TCSP 830 
TCSP 843 
TCSP 850 
TCSP B50 
TCSP 870 
TCSP 880 
TCSP 893 
TCSP 900 

TCSP 910 

TCSP 920 



ores ID 
ores 20 

OICS 30 
OTCS 40 

ores 53 

OTCS 60 
DTCS 70 
DTCS 80 

ores 90 

OTCS 100 
OTCS 113 

ores 120 

ores 133 

nnF.I^S 2*" LINEAR TERM IN GIVEN LINEAR TRANSFORMATIONOTCS 150 
...- ^^^^ ^^^ 

CONSTANT TERM IH GIVEN LINEAR TRANSFORMATION OTCS 173 

DOUBLE PRECISION VARIABLE qtcs 180 

COEFFICIENT VECTOR OF POLYNOMIAL (RESULTANT VALUEI OTCS 193 



SUBROUTINE DTCSP 

PURPOSE 

A SERIES EXPANSION IN SHIFTED CHEBrSHEV PQlvnomialS WITH 
IWEPENOENT VARIABLE X IS TRANSFORMED TO A POLYNOMIAL HITM 
INOEPENDENT VARIABLE 2, WHERE X.A*Z«^e. 

USAGE 

CALL OTCSPIA.B.POL.N.C.MOHKI 

DESCRIPTION OF PARAMETERS 



COEFFICIENTS ARE ORDERED FROM LOW TO HI5H 
DOUBLE PRECISION VECTOR 

- DIMENSION OF COEFFICIENT VECTORS POL AND C 

- GIVEN COEFFICIEiir VECTOR OF EXPANSION 
POL ANO C MAY BE lOEMTICALLV LOCAfEo 
COEFFICIENTS ARE ORDERED FROM LOW TO HIGH 
DOUBLE PRECISION VECTOR 

- MORKING STORAGE OF DIMENSION 2*N 
OOUBLE PRECISION ARRAY 



REMARKS 

COEFFICIENT VECTOR C REMAINS UNCHANGED IF NOT COINCIDING 

MITH COEFFICIENT VECTOR POL. 

OPERATION IS BYPASSED IN CASE N LESS THAN 1. 

THE LINEAR TRANSFORMATION X*A*2*B OR I-(1/AHK-S) TRANSFORMSDTCS J40 

THE RANGE 10,11 IN X TO THE RANGE (ZL,2«) IN I. WHERE OTCS 350 

ZL"-B/A ANO ZR-U-6)/A. 

FOR GIVEN ZLi 2R WE HAVE A-1/tZR-ZL) AND B— ZL/(ZR-ILI 



ores 200 
OTCS 210 
OTCS 220 
OTCS 230 
ores 240 
ores 250 
DTCS 260 
OTCS 270 
OTCS 200 
OTCS 290 
DTCS 300 
DTCS 310 
ores 320 
OTCS 330 



METHOD 

THE TRANSF0R»(ATION IS BASED ON THE RECURRENCE EQUATION FOR 

SHIFTED CHEBYSHEV POLYNOMIALS TSIN.Kl 

rSlH*l,Xt-(4*X-2)*TS(N,Xt-TS(M-l,Xl, 

WHERE THE FIRST TERM IN BRACKETS IS THE INDEX, 

THE SECOND IS THE ARGUMENT. 

STARTING VALJE5 ARE TS(0,XI-l, T5 < I , X) "2*X-1 . 

THE TRANSFORMATION IS IMPLICITLY DEFINED BY MEANS OF 

X»A*Z*B TOGETHER WITH 

SUMfPOLI I t*Z«*II-ll, SUMMED OVER I FROM I TO Nl 

= SUM(Cm*TSl I-l,X) , SUMMED OVER I FROM 1 TO Nl. 



SUBROUTINE DTCSP (A, B.POL .NtC tWORK ) 

DIMENSION POLM),C( D.WORKI II 

DOUBLE PRECISION A. B«POL.C .WQRK,H. P, XO, XO 

YESr OF 0INENSI3N 
IFIN-tl2.1.3 

DIMENSION LESS THAN 2 
1 POLI 1»-C( I) 

? RETURN 

J XD-A*A 

XO=Bt6-1.00 

POL( lJ-CmtC12l*X0 

POLI2l-CI2)*XO 

IFIN-2I2«2,4 

INITIALIZATION 
> H0RKUI>1.D0 
W0RK(2I<^X0 

M0RK(3I«0.D0 
H0RKI4I>K0 
XD-XO+XD 
X0=XO*XO 

CALCULATE COEFFICIENT VECTOR OF NEXT SHIFTED CHEBYSHEV 
POLYNOMIAL AND ADD MULTIPLE OF THIS VECTOR TO POLYNOMIAL POL 

DO 6 J>3,N 

P'O.OO 

00 5 K*2tJ 

H-P-WORK( 2*K-3 I •X0*W0RKI 2*K-2) 

P-MORK(2*K-2) 

WORKI2*K-2l«H 

W0RtCC2*K-ll-P 

POL I K- X I « POL C X - 1 1 tH *C IJ 1 

P«XD»P 

WORKI2*J-tt-0.00 

W0RK(2*J1=P 

POL(JI>C(J)*P 

RETURN 

END 



ores 353 
ores 370 
DTCS 380 
DTCS 390 
DTCS 400 
DTCS 410 
ores 420 
OTCS 430 
ores 440 
OTCS 450 
OTCS 460 
DTCS 470 
DTCS 480 
DTCS 490 
OTCS 500 
OTCS 5 10 
DTCS 520 
OTCS 533 
..ores 540 

ores 550 
ores 560 
ores 570 
OTCS 580 
ores 590 
ores 530 
OTCS 510 
OTCS S23 
ores 630 
DTCS 540 
DTCS 650 
ores 660 
ores 570 
DTCS 680 
OTCS 490 

ores 700 

OICS 713 

OTCS 720 

ores 730 

OTCS 740 

DTCS 750 

DTCS 750 

DTCS 770 

OTCS 780 

DTCS 790 

ores 800 

OTCS 810 
DTCS 823 
ores 830 
OTCS 840 
OTCS 850 
ores 860 
DTCS 870 
ores 880 
OTCS 890 
DTCS 900 
OTCS 910 
ores 920 
OTCS 933 
ores 940 
DTCS 950 

ores 960 

OTCS 970 
DTCS 980 



204 Mathematics--Polynomials: fecial Types 



Subroutines HEP and DHEP 

These subroutines compute the values of the Hermite 
polynomials for a given argument x and orders zero 
up to N. The Hermite pol3Tiomial Hjj(x) satisfies the 
recurrence equation 



H ^, (X) 
n+1 



2 (X 



H (X) 
n 



n . H^_^(x)) 



with starting values Hq(x) =1, Hi(x) = 2 x. 

The order is assumed to be zero for negative 
values of N. 



SUeitOUTINE HEP 

PURPOSE 

COHPUTE THE tTALUES Of THE HeRHITE POLYNOMIALS H(N,X) 
FOR ARGUMENT VALUE X AND ORDERS UP TO N. 

USAGE 

CALL HEP(ViX.N} 

DESCRIPTION OF PARAMETERS 

Y - RESULT VECTOR OF DIMENSION N*l CONTAINING THE 

OF HERMITE POLYNOMIALS OF ORDER UP TO N 

FOR SIVEN ARGUMENT X. 

VALUES ARE ORDERED FROM LOW TO HIGH ORDER 
X - ARGUMENT OF HERMITE POLYNOMIAL 

N - ORDER OF HERMITE POLYNOMIAL 



REMARKS 
N LESS 



IS TREATED AS IF N WERE 



SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION IS BASED ON THE RECURRENCE EQUATION FOR 

HERMITE POLYNOMIALS H(N,XI 

H(N*lf Xl = Z*U*H(N,XI-N*H{N-l,Xn 

WHERE THE FIRST TERM IN BRACKETS IS THE INDEX, 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE H(0,XI=lt H(l,Xl=2*X. 



SUBROUTINE HEPIV.X.Nt 
DIMENSION Yl 1) 
TEST Of ORDER 

Y(H-1. 

IFINII. 1.2 

1 RETURN 

2 r(2»=xtx 

[F(N-llltlt3 

3 DO * 1=2, N 

f-x*Y(i )-FLOAr( i-i»*Yn-n 

* Y(I*1I=F+F 
RFTURN 

END 



HEP 
, HEP 

HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 

VALUESHEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 

HEP 

HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 
HEP 



130 
ILO 
120 
L3D 
UO 
150 
160 
170 

lao 

203 
210 
220 

2 30 
240 
250 
260 
270 
2B0 
290 
300 
310 
320 

3 30 
340 
150 
360 
370 
3S0 
390 
400 
410 
420 
430 
440 
450 
460 
470 
480 
490 
500 
510 
520 
530 



SUBROUTINE OHEP 

PURPOSE 

COMPUTE THE VALUES OF THE HERMITE POLYNOMIALS H(N 
FOK ARGUMENT VALUE X ANO OftOCRS UP TO N. 

USAGE 

CALL OHEPIY.K.N) 

DESCRIPTION OF PARAMETERS 

V - RESULT VECTOR OF DIMENSION N^^l CONTAINING 

OF HERMITE POLYNOMIALS OF OROER UP TO N 

FOR 51VEN ARGUMENT X. 

DOUBLE PRECISION VECTOR. 

VALUES ARE OROEREO FROM LOW TO HIGH OROER 
X - ARGUMENT OF HERMITE POLYNOMIAL 

DOUBLE PRECISION VARIABLE. 
N - ORDER OF HERHlTE POLYNOMIAL 



REMARKS 

N LESS THAN 



IS TREATED AS IF N WERE 



SUBROUriNES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION IS BASED ON THE RECURRENCE EQUATION FOR 

HERHlTE POLYNOMIALS HIN,XI 

KIN*1.X)*2*(X*H(N.XI-N*H(N-1, X)) 

WHERE THE FIRST TERM IN BRACKETS IS THE INDEX. 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE H(0,Xt=l. H(1,XI=2«X. 



SUBROUTINE DHEP(Y,X,NI 

DIMENSION Yd) 

DOUBLE PRECISION Y. X.F 

TEST OF ORDER 
Y(lt-I.DO 
IFINII. 1.2 
RETURN 

V(2I-X*X 
IF(N-1I1.1,3 

- 00 4 I»2tN 
F»X*Y(I )-DFLOATI l-l)*Y( 
VfI*I)=F»F 

RETURN 
END 



OHP 

OHP 

OHP 
OHP 
OHP 
OHP 
.XI OHP 

\ OHP 
OHP 
DHP 
OHP 
OHP 
OHP 
THE VALUESOHP 
OHP 
OHP 
OHP 
OHP 
OHP 
OHP 

DHP 

DHP 
OHP 
OHP 
DHP 
DHP 
DHP 
DHP 
OHP 
OHP 
OHP 
OHP 

OHP 

OHP 
OHP 
OHP 
. . . DHP 
OHP 
DHP 
OHP 
OHP 
OHP 
OHP 
DHP 
DHP 
OHP 
DHP 
DHP 
DHP 
DHP 
OHP 
DHP 
DHP 
DHP 
OHP 
DHP 



90 
100 
119 
120 
1)0 
l«0 
ISO 
l&O 
ITO 
180 
190 
200 
210 
220 
230 
240 
250 
260 
270 
280 
290 
300 
110 
320 
330 
340 
390 
960 
3T0 
3B0 
390 
400 
410 
420 
430 
440 
450 
460 
470 
480 
490 
530 
510 
520 
530 
540 
550 
560 



Mathematics- -Polynomials: Special Types 205 



Subroutines HEPS and DHEPS 

These subroutines compute the value of a series 
expansion in Hermite polynomials. The Hermite 
polynomial Hn(x) satisfies the recurrence equation 



n+1 ^ n ' n-1 



with starting values Hq(x) =1, H^(x) = 2 x. 

An n-term expansion in Hermite polynomials with 
coefficient vector C = (ci, . . ., Cn) is evaluated by 
means of a forward iteration scheme: 



Y = c^. H^=l, H^ =2 . X 
H2=x.H^-(i"l)H^ 



«0 = «1 



«1^«2^«2 



Y = Y + Ci • He 



for 1 = 2, 



This gives the result Y(x) =2 c. * H (x). 

i=l 
Calculation is bypassed in case of a nonpositive 
value of the dimension n. 



SUBROUTINE OKEPS 

PURPOSE 

COMPUTES THE VAtUE Of *N N-TERN EXPANSION IN HERHt TE 
POLVNOHIALS WITH COEFFICIENT VECTOR C FOR ARGUMENT VAUiE K. 

USAGE 

CALL DHEPSIVf X,C(NI 

DESCRIPTION OF PARAMETERS 
Y - RESULT VALUE 

0OU8LE PRECtSION VARIAaiE 
It - ARGUMENT VALUE 

OOJetE PRECISION VARIABLE 
C - COEFFICIENT VECTOR OF GIVEN EXPANSION 

COEFFICIENTS ARE ORDERED FROM LOU TO HIGH 

OOUeLE PRECISION VECTOR 
N - DIMENSION OF COEFFICIENT VECTOR C 

REMARKS 

OPERATION IS BTPASSEO IN CASE N LESS THAN 1 

sueROuriNES and function subprograms reouireo 

NONE 

METHOO 

DEFINITION 

Y^SUMtCd I»hC I-l,xt. SUMMED OVER I FftQM 1 TO Nl. 
EVALUATION IS DONE BY MEANS OF UPWARD RECURSION 
USING THE RECURRENCE EQUATION FOR HERNITE POLYNOMIALS 
H(N*l,XJ=2*(K*HfN,Xt-N«HIN-l.XI I. 



SUBROUTINE OHEPSI Vt X.C,N) 



20 



50 



DIMENSION C( II 

DOUBLE PRECISION C. V.X ,H0.HltM2 

TEST QF DIMENSION 
If (N)l,1.2 

1 RETURN 

2 Y'dll 

If (N-ZI It3t3 

INITIALIZATION 

3 HO=l,00 
Hl"X*X 

DO 4 I-2iN 

H2=X*H1-0FL0AT( l-l)*HO 
HO>HI 
Hl-M2*H2 
A V»Y*CI I 1*M0 
RETURN 
END 



OHPS 

.DHPS 
OHPS 
DHPS 
DHPS 
DHPS 
DHPS TO 
OHPS 90 
DHPS 90 
DHPS 103 
OHPS tlO 
DHPS 120 
OHPS 130 
DHPS 140 
OHPS ISO 
DHPS 160 
OHPS 173 
OHPS 180 
DHPS 190 
OHPS 200 
OHPS 2L0 
OHPS 220 
OHPS 230 
OHPS 240 
OHPS 250 
OHPS Z&O 
OHPS 270 
DHPS 289 
DHPS 293 
DHPS 900 
OHPS 310 
DHPS 320 
DHPS 330 
OHPS 3*0 
OHPS 350 

.OHPS 360 
DHPS 370 
DHPS 300 
DHPS 390 
OHPS ^30 
DHPS *10 
DHPS *20 
OHPS *30 
OHPS «40 
OHPS 450 
OHPS 460 
OHPS 473 
OHPS 480 
DHPS 490 
DHPS SOD 
OHPS 510 
DHPS 523 
OHPS 530 
DHPS 5*0 
OHPS 550 
OHPS 563 
DHPS 5 70 

OHPS sao 

OHPS 590 
DHPS 600 



SUBROUTINE HEPS 

PURPOSE 

COMPUTES THE VALUE OF AN N-TERM EXPANSION IN HERMITE 
POLYNOMIALS kITH COEFFICIENT VECTOR C FOR ARGUMENT VALUE 

USAGE 

CALL HEPSir.X.C.NI 

OESCRIPTtON OF PARAMETERS 
Y - RESULT VALUE 
X - ARGUMENT VALUE 
C - COEFFICIENT VECTOR OF GIVEN EXPANSION 

COEFFICIENTS *RE DROEREO FROM LOM TO HI3H 
N - DIMENSION OF COEFFICIENT VECTOR C 

REMARKS 

OPERATION IS BYPASSED IN CASE N LESS THAN 1 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

DEFINITION 

V«SUMIC(n*HU-l.XI, SUMMED OVER I FROM 1 TO Nt. 

EVALUATION IS DONE BY MEANS OF UPUARO RECURSION 

USING THE RECURRENCE EQUATION FOR HERMITE POLYWJMIALS 

H<N+1,XI=2*(X*HIN,X1-N*H(N-1,XI1. 



60 



SUBROUTINE HEPS I Y,X ,C t N} 

DIMENSION C(II 

TEST OF DIMENSION 
IFtNlia.Z 

1 RETURN 

2 V»Cll» 
IFIN-211.3,3 

INITIALIZATION 

3 HO-1. 
Hl-X«-X 

DO 4 I-2,N 

H2-X*Hl-FLOAT(l-l)»H0 

HO^Hl 

Hl«H2»H2 

4 Y"V*C( I )*H0 
RETURN 

ENO 



HEPS 10 
..HEPS 20 
HEPS 30 
HEPS 
HEPS 
HEPS 
HEPS 
. HEPS 

HEPS 90 
HEPS 100 
HEPS UO 
HEPS 120 
HEPS 130 
HEPS 140 
HEPS 150 
HEPS 160 
HEPS 170 
HEPS 180 
HEPS 190 
HEPS 203 
HEPS 210 
HEPS 220 
HEPS 230 
HEPS 240 
HEPS 250 
HEPS 260 
HEPS 270 
HEPS 200 
HEPS 290 
HEPS 300 
HEPS 310 
HEPS 320 
..HEPS 330 
HEPS 340 
HEPS 350 
HEPS 360 
HEPS 370 
HEPS 360 
HEPS 390 
HEPS 400 
HEPS *10 
HEPS 420 
HEPS 430 
HEPS 440 
HEPS 450 
HEPS 460 
HEPS 4 70 
HEPS 480 
HEPS 499 
HEPS 500 
HEPS 510 
HEPS 520 
HEPS 5 30 
HEPS 540 
HEPS 550 
HEPS 560 



206 Mathematics — Polynomials: Special T3^es 



Subroutines THEP and DTHEP 

These subroutines transform a given series expan- 
sion in Hermite polynomials to a polynomial. The 
independent variable x of the given expansion is 
thereby substituted by the independent variable z of 
the resulting polynomial using the linear treinsforma- 
tion x = A«z + Borz = (x-B)/A. 

N 

This means: Y] C. « H. , (A ♦ z + BV 
. , 1 1-1 
1=1 



N 

E 

i =1 



POL. » z 

1 



i-1 



Calculation is bypassed in case of a nonpositive 

value of the dimension N. 

The range (-c, + c) in x is transformed to the 
range (z^, Zj.) in z with z^ = - (c + B)/A and Zj. = 
(c-B)/A, or vice versa, A = 2 c/(Zr - zj^) and 
B = - c (Zj, + zi)/(Zj. - zi). 

The Hermite poljmomial Hjj(x) satisfies the re- 
currence equation 



H ^, (X) = 2 (x • H (x) - n ■ H . (x)) 
n+1 ^ n n-1' " 



with starting values Ho(x) = 1, Hi(x) = 2 x. 

The transformation is performed by means of a 
forward iteration scheme: 

1 . The coefficient vector of the Hermite poly- 
nomial Hi(x) is calculated from the coefficient 
vectors of Hi-i(x), Hi_2(x) using the recurrence 
equation, for i = 3, . . ., N. 

2, The resulting polynomial coefficient vector is 
obtained by sum.mation of c^ times coefficient vector 



SUS«0UT1NC THCP 



* SERIES EXPANSION IN HCRNITC KILrNfm|ALS WITH INOEPENOENT 
VWIUIE » IS ntNSFMMEII TO t POiniMUL WITH ■NMpiNOENT 



VMIAM.E I, NHEItE ■(■••2>g 



USAGE 

CAll THCPCA.S.PaL.N.CHOItKI 



DESCMMION or rMMETEIIS 



.THE* 
tHEf 
THEP 
TMEP 
THEP 
THEP 
THEP 
THEP 
THEP 150 
THEP 110 
THEP UO 
THEP 130 
THEP l« 



10 



10 

♦0 



iO 



90 



VOM 



- EACTH OF LINCA* TEM IN CKEII LINCAK TMNSFOmUTIONTHEP HO 

- CONSTANT TEH IN OIVEN LINEAIt TAANSFORNATION 

- COEFFICIENT »ECTO« OF POtTHOHUL HESUIIANT VAIUEI 
COEFFICIENTS ARE OROERCO FROM LOW TO HIGI 

- OINENSION OF COEFFICIENT MCT«R POl ANO C 

- COEFFICIENT VECTOR OF CtyEN EmNSION 
COEFFICIENTS ARE OROERCO FRO* LON TO HIG^ 
POL AND C NAT BE IOCNTICAi.LV LOCATED 

- NORKINS STORAGE OF OIHENSION fH 



•ENAMS 

COEFFICIENT VECTOR C KENAINS UNCHANOEO IF NOT COINCIOING 

KITH COEFFICIENT VECTOR POL. 

OPERiTION IS SVPASSEO IN CASE N LESS THAN 



TMEP 1*0 
THEP ITO 
THEP 183 
THEP 190 
THEP 200 
THEP 210 
THEP 220 
THEP 210 
THEP 2*0 
THEP 2S0 
THEP 2t0 
THEP 2T0 
THEP 260 



THE LINEAR TRANSFORHATION «-««2*S OR l>ll/AIIX-«l TRAHSFORHSTHEP 290 



of Hi_j^(x) over i, for 1=1, 



N. 



THE RANCE l-C.CI IN I TO THE RANCE IZL.ZRI IN < WHERE 
IL— IC*BI/« ANO IR'IC-BI/A. 

FOR GIVEN ZLt 2R ANO C HE HAVE A-2C/IIR-2LI ANO 
a— C(2R«ZLI/IZR-ZL1 

SURROuriNCS ANO FUNCTION SUBPROSRANS REOUIREO 
NOME 

HETHOO 

THE TRANSFORHATION IS BASED ON THE RECURRENCE EQUATION 

FOR HERMITE POLVWMIALS HIN.II 

H(N«ttXI-2«(XPH<N,xt-N«HIN-l,Xllt 

WHERE THE FIRST TERN IN BRACKETS IS THE INDEX 

THE SECONO IS THE ARGUHENT. 

STARTING VALUES ARE H(0,XI -IfHI 1* XI>2*R. 

THE TRANSFORHATION IS IHPLICITLV OEFINCO BV NEANS OF 

X-A*Z«B TOGETHER KITH 

SUH|P0LIII«2P«II-1I. SUHHEO OVER 1 FROII 1 TO Nl 

• SUWCIIIRHII-I.XI, SUHHEO OVER I FROH 1 TO N). 



SUBROUTINE THEPI4tB*P0LtN«C«H0RKI 

OINENSION POLUltCllliUORKIll 

TEST OF DIMENSION 
IF(N-II2.1.3 

OIHENSION LESS THAN 2 

1 POLIll-CIl) 

2 RETURN 
C 

3 ltO>A«A 
«0>l«B 

P0tllUC<l»*CI2IPXD 
PaL(2l>C(2l««D 
IFIN-2I2>2.« 

C 

C INITIALIZATION 

4 H0RK1II«I. 
H0RKI2I-X0 
HORRIll-O. 
HORKI4l>XO 
FI-2. 

C 

C CALCULATE COEFFICIENT VECTOR OF NEXT HERHITE POCVNOHIAL 

C ANO AOO NULTIPLE OF THIS VECTOR TO POLVNOmAL POL 

00 » J'ltN 

P»0. 
C 

00 1 R-2.J 

H-P*XO*HORKI2*K-2I*XO-FI*UO«K(2*K-3I 

P-WORlt(2««-21 

HORKI2PK-2I-H 

H0RR(2«K->I-P 
9 P0LIR-1I>P0LU-1I*H*CIJI 

HORK(2PJ-t)*0. 

HDRKf2PJI>P«XD 

FI.FI»2. 
* P0LIJI-CIJI«N0RKI2«JI 

RETURN 

EW> 



THEP 390 
THEP 310 
THEP 120 
THEP 330 
THEP 3*0 
THEP ISO 
THEP 360 
THEP 320 
THEP IBO 
THEP 390 
THEP 400 
THEP »10 
THEP 420 
THEP 410 
THCP 440 
THEP 450 
THEP 440 
THEP 470 
THEP 460 
THEP 490 
..THEP 300 
THEP 510 
THEP 520 
THEP 930 
THEP 540 
THEP 5S0 
THEP 5*0 
THEP 570 
THEP 5B0 
THEP 590 
THEP 600 
THEP 610 
THEP 420 
THEP 630 
THEP 6*0 
THCP *S0 
THEP ttO 
THEP 670 
THCP *•!> 
THCP 690 
THEP TOO 
THEP 710 
THCP 720 
THEP T30 
THEP 7*0 
THEP 710 
THEP 760 
THEP 770 

THEP rao 

THEP T90 
THEP aoo 
THEP (10 
THCP 820 
THCP 9 39 
THEP a*o 
THEP B50 
THCP B60 
THCP B70 
THCP BBO 
THCP B90 
THEP 900 
THCP 910 
THEP 920 



Mathematics — Polynomials: l^ecial Types 207 



SUMOUriNC OTHC^ 



20 



50 
«0 



DTHC 

orHC 

0T«« 

orHE 

OTHC 
PIMPOSC „^^ 

A SEftlES EXMNSIOM IN MEdflirC POLVNONULS yiTH INOCHNOEMT DTHC .. 

VMIMCE I IS TftANSFOKMO rO & POLVNOflUL MITH INOCKNOCNT DTHC SO 

VUIMtC Z. MHEKC R-A*Z«« > OTHE «0 

OTHE lOQ 

"S*eE OTHC 110 

CALL OrHE»fA.S,POL.N,C,W(MK| OTHC 120 

DCSCRIMIOM OF PMAMCTCRS OTHC 1«0 

rACTOft OF LINCAR TEAN Id CIVCN LINCAft TAANSFOANATIIMOrHC ISO 



MMMlf PffCCISION VAKIAUE 
■ - CONSTANT TCRH IN 6IVEH LIHCAR TMNSFOKHATION 

aOMLC PMCISION VAItlAALC 
rO. - COCFFICICNT VCCTOA OF FOLTNONUL (ftCSULTANT VUUEI 

COCFFICIENTS AAC OROERCO F«OM LOW TO HIG»1 

OOUSLC FRCCISION VECTOR 
H - OINENSION OF COEFFICIENT VECTOR FOL ANO C 

C - COCFFICIENT VECTOR OF 6IVCH EXFANSION 

COCFFICIENTS ARE OROEREO FROM LM TO HICH 

POL ANO C HAY P£ lOCNTICALLT LOCATED 

OOIMLC FRCCISION VECTOR 
UQRK - HORKINC STQItACE OF OINENSION 2*N 

DOIMLE PRECISION ARRAY 

REMARKS 

COEFFICIENT VECTOR C RCNAINS UNCHANGED If NOT COINCIDING 

MITH COEFFICIENT VCCTOR POL. 

OPCMTION IS IVPASSCO IN CASE N LESS THAN 1. 



THE RANGE (-C«CI IN It TO THE RANGE IZL.ZR) IN Z HHCRE 

ZL«-(C«S1/A ANO Zt>|C-BI/A. 

FOR GIVEN ZLt ZR AND C «E HAVE A-2C/UR-ZL) ANO 

■— CI ZA*2Ll/( 2R-ZL I 

SUBROUTINES ANO FUNCTION SURFROGRANS RCOUIREO 
NONE 

HETHOO 

THE TRANSFDRNATION IS BASED ON THE RECURRENCE EQUATION 

FOR HERNITE POLYNONIALS H(N*KI 

HIN«l*XI«Z*IX«HfNtJ(l-N*HIN-|»Xllt 

WHERE THE FIRST TCRN IN BRACKETS IS THE INDEX 

THE SECOND [S THE ARGUNENT. 

STARTING VALUES ARE HIO.XI -1,H( 1* )<)-Z*X. 

THE TRANSFORNATION tS INPLICITLV DEFINED BY NEANS OF 

X-A«Z*B TOGETHER WITH 

SUHlFOLtl l*Z*«tI-lf . SUNNED OVER I FRON 1 TO Nl 

>SUN(CII)*Hn-UX). SUNNED OVER I FRON 1 TO Nl. 



SUBROUTINE DTHCPI A, B»POL»N,C »MORK) 

OINENSION PaL(l)*C(ll.WMK(l) 

DOUBLE PRECISION A. a«POL*C«HORK«HtP.FI«KDt XO 

TEST OF OINENSION 
IFIN-1I2.1(3 

OINENSION LESS THAN 2 

1 POLIll-Ctll 

2 RETURN 

3 X0-A4-A 
XO«B«S 

PQLU)>C11I+C(2>«X0 
F0L<2I-C(2I«X0 
lF(N-2t2.2.4 

INiriALIZATIOH 

4 UORRUI-l.OO 
UORK(2I>XO 
UORKOI-0.00 
U0IIK(41-X0 
FI>Z.DO 

CALCULATE COEFFICIENT VECTOR OF NEXT HERNITE POLYNOMIAL 
AND AOD MULTIPLE OF THIS VECTOR TO POLYNONtAL POL 

DO A J-3»N 

P-0.00 

00 5 K-2«J 

H-P*X0»H0RK(2«K-2t*XO-FI«WORM2«K-3l 

P-W0RKt2*K-2l 

U0RR(2*K-2I-H 

WORKI2««-3l'f 

5 POL(K-ll-POL(R-ll*M*CIJI 
WDRK(2*^1I-0.D0 
Wa«KI2«Jl-P*X0 
FI-FI»2.00 

A POLf JI-C(JI«WORKf 2*JI 
RETURN 
ENO 



DTHC ISO 

OTHE 360 
OTHC 570 
OTHE 3 BO 
OTHC 390 
OTHC «00 
OTHC «10 
OTHE A20 
DTMC 430 
DTHC 4^A0 
OTHE MO 
DTHC 4*0 
OTHE ATO 
OTHE ABO 
OTHE A«0 
OTHE 500 
OTHE 510 
DTHE 520 
OTHC S30 
OTHE 540 
..DTHE $50 
OTHE 5*0 
OTHC $70 
DTHE S«0 
OTHE 590 
DTHC AOO 
OTHE fclO 
OTHE 620 
OTHC $30 
DTHC AAO 
OTHE 450 
DTHE **0 
DTHE ATO 
OTHE &B0 
DTHE b9D 
DTHE 700 

OTHE no 

OTHE 720 
OTHC 7 30 
OTHE 740 
OTHC 750 
OTHE 7*0 
OTHE 770 
OTHC 7*0 
DTHE 790 
OTW BOO 
DTHC BID 
DTHE B20 
DTHE B30 
OTHE 440 
OTHE BfO 
DTHC B*0 
DTHC B70 
OTHC BBO 
DTHC B90 
DTHE 900 
DTHC 910 
DTHE 420 
OTHE 430 
OTHE 940 
DTHE «$0 
OTHE 960 
OTHE 970 
OTHC 960 



Subroutines LAP and DLAP 

These subroutines compute the values of the nor- 
malized Laguerre polynomials for a given argument 
X and orders zero up to N, The polynomial Ln(x)/n: , 
termed Lj^(x) below, satisfies the recurrence equation 

^n+1 ^""^ = [(2 n + 1 - X) L^ (x) - n L^_^ (x)J /(n+1) 

with starting values Lq(x) =1, L^ (x) = 1 - x. 

For reasons of economy and numerical stability 
the recurrence equation is used in the form 

L ^, (X) = L (x> - L , (X) + L (X) 
n+1 ^ ' n^ ' n-1 ^ ' ^^ 

'[{1^} L^(x>-L^_^(x>] /(n+1). 

For large values of n the last term is negligible, 
giving the approximation 



L ^^ (x> = 2 L (X) - L ^ (x>. 

n+1 n n-1 



This form shows that roundoff errors grow at worst 
linearly as long as x is small compared to n. 

If en+r is the error in Ln4.r(x) due to a single 
rounding error e in Ln(x), the approximation is: 



n+r+1 n+r n+r-1 



with initial conditions e^ = e, Cn-i = 0. This 
implies: 



e , = 2e, e „ = 3 . e, . . . , e , = (r + l)e 

n+1 n+2 n+r ^ ' 



The order is assumed to be zero for negative 

values of N. 



SUBKOUTINE LAP 

PURPOSE 

CDMPUrE THE VALUES OF THE LAGUERRE POLVHOMIALS L(N,X) 
FOR ARGUMENT VALUE X ANO ORDERS UP TO N. 



CALL LAPI Y,X. N) 

DESCRIPTION OF PARAMETERS 

f - RESULT VECTOR OF OlMENSION N*l CONTAINING THE VA 

OF LAGUERRE POLYNOMIALS OF JROER UP TO N 

FOR 5IVEN ARGUMENT X. 

VALUES ARE ORDERED FROM LOW TO HIGH OROgR 
X - ARGUMENT OF LAGUERRE POLVNOKIAL 
N - ORDER OF LAGUERRE POLVNOMIAL 

REMARKS 

N LESS THAN IS TREATED AS IF N WERE 

SUBROUTINES AMD FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION IS BASED ON THE RECURRENCE EQUATION FO^ 

LAGUERRE POLrNOMIALS L(V.XI 

LfN4^1,X) = 2*L(N.XI-L(N-l.X}'((l<^X)*LIN.Xt-L(N-UX) t/(N4^L}. 

WHERE THE FIRST TERM [N BRACKETS IS THE ORDER, 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE LfO.Xt^l, LU.KI = l.-X. 



LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LUESLAP 
LAP 
LAP 

LAP 



LAP 
LAP 
LAP 

LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
LAP 
.LAP 
LAP 



103 
110 
120 
I JO 

140 

150 
160 
170 
183 
190 
£00 

210 
220 
233 

240 
250 
260 
270 
2S0 
290 
300 
310 
320 
330 
3«0 
350 
360 



208 Mathematics — Polynomials: Special Types 



SUBROUTINE L*P(V,XtN) 

DIMENSION V( I) 

TEST Of ORDER 
Y(l)-l. 
If INIL,1,2 

RETURN 

! Y(2>-l.-X 
IF(N-1)1,1,3 

INITIALIZATION 
. T'l.^X 

00 4 I-2.N 

Yii*i»=Y(ii-r(i-ii*Y«n-(T*Y(n-Yii-ni/Fio*T(ii 

RETURN 
END 



LAP 


3 TO 


LAP 


i«n 


LAP 


39D 


LAP 


*00 


LAP 


410 


LAP 


«20 


LAP 


430 


lAP 


*40 


LAP 


450 


LAP 


4*0 


LAP 


470 


LAP 


*80 


LAP 


490 


LAP 


500 


LAP 


510 


I AP 


S?0 


LAP 


530 


LAP 


5*0 


LAP 


550 



Subroutines LAPS and DLAPS 

These subroutines compute the value of a series 
expansion in normalized Laguerre polynomials. 
The polynomial Ljj(x)/n'. , termed Ljj(x) below, 
satisfies the recurrence equation 

L (X) = 2 • L (X) - L , (X) - 
n+1 * ' n^ ' n-1 ^ ' 



[(I + X) • L^(x) - L^_^ (x)] /(n+1) 



SUBROUTINE OLAP 

PURPOSE 

CONPUTE THE VALUES OF THE LAGUERRE POLYNOMIALS LIN, XI 
FOR ARGUMENT VALUE X AND ORDERS UP TO N. 

USAGE 

CALL DLAPIY.XfNI 

DESCRIPTION OF PARAMETERS 

Y - RESULT VECTOR OF DIMENSION N+t CONTAINING THE 

OF LAGUERRE POLYNOMIALS OF 3RDER UP TO N 

FOR 3IVEN ARGUMENT X. 

DOUBLE PRECISION VECTOR. 

VALUES ARE ORDERED FROM LOW TO HIGH ORDER 
X - ARGUMENT OF LAGUERRE POLYNOMIAL 

DOUBLE PRECISION VARIABLE. 
N - ORDER OF LAGUERRE POLYNOMIAL 

REMARKS 

N LESS THAN IS TREATED AS IF N WERE 



METHOD 

EVALUATION IS fiASEO ON THE RECURRENCE EQUATION FOR 

LAGUERRE POLYNOMIALS LINfX) 

L(N+1,XI«Z*L( N,X)-L(N-l.X)-(!l*XI*L(N.XI-L(N-l,XI 1/(N* 

WHERE THE FIRST TERM IN BRACKETS IS THE OROERt 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE L(O.Xt=L. LI1,K)=I.-X. 



SUSROUTINE OLAPIY,X,NI 

DIMENSItM Y( II 

DOUBLE PRECISION Y, X.T 

TEST tM= ORDER 
Yll)=l.DO 
IF^INIl. 1,2 

1 RETURN 

2 Y(2l=l.O0-X 
IF<N-1I1,1,3 

INITIALIZATION 

3 T=1,00*X 

00 4 I>2.N 

4 YII*1»»Y1I1-YII-U*YI1 |-(T«Y( II-YI I-ll l/DFLOATI I 1 

RETURN 
END 



DAP 


10 


DAP 


20 


DAP 


33 


DAP 


40 


DAP 


50 


DAP 


60 


DAP 


TO 


DAP 


80 


OAP 


90 


DAP 


LOO 


OAP 


110 


OAP 


120 


OAP 


130 


VALUESOAP 


1*0 


DAP 


150 


DAP 


160 


OAP 


170 


DAP 


180 


DAP 


190 


OAP 


200 


OAP 


210 


OAP 


220 


OAP 


230 


OAP 


240 


OAP 


250 


DAP 


260 


OAP 


?70 


OAP 


280 


DAP 


290 


OAP 


300 


OAP 


310 


1). DAP 


320 


OAP 


130 


DAP 


340 


OAP 


360 


OAP 


360 






DAP 


380 


OAP 


390 


DAP 


400 


OAP 


410 


DAP 


420 


DAP 


430 


DAP 


440 


OAP 


450 


DAP 


*60 


DAP 


470 


OAP 


480 


OAP 


*90 


DAP 


500 


OAP 


510 


DAP 


520 


OAP 


S30 


OAP 


5*0 


DAP 


550 


OAP 


560 


OAP 


5 TO 


OAP 


580 



with starting values Lo(x) = 1, Lj-(x) = 1 - x. 

An n-term expansion in Laguerre polynomials with 
coefficient vector C = (ci, . . . , Cq) is evaluated by 
means of a forward iteration scheme: 

Y = Cj^, Hq = 1, Hj^ = 1 - X, T = 1 - X 



«2 = «l-«0^«l-<^-«l-«0>/^ 



for i = 2, 

. . .. n 



«0 = «1 

«1=«2 

Y = Y + c. • H„ 
1 



This gives the result Y(x) = ^^ c 

i-1 '' 

Calculation is bypassed in case of a nonpositive 
value of the dimension n. 



i-1 



(X). 



SUBROUTINE LAPS 

PURPOSE 

COMPUTES THE VALUE OF AN N-TERM EXPANSION IN LAGUERRE 
POLYNOMIALS WITH COEFFICIENT VECTOR C FOR ARGUMENT VALUE 

USAGE 

CALL LAPS(Y,X,CtN) 

DESCRIPTION OF PARAMETERS 
Y - RESULT VALUE 
X - ARGUMENT VALUE 
C - COEFFICIENT VECTOR OF GIVEN EXPANSION 

COEFFICIENTS ARE ORDERED FROM LOW TO HIGH 
N - DIMENSION OF COEFFICIENT VECTOR C 

REMARKS 

OPERATION IS BYPASSED IN CASE N LESS THAN 1 



METHOD 

DEFINITION 

Y=SOM(C(I )*LI I-I,X) , SUMMED OVER I FROM 1 TO N). 

EVALUATION IS DONE BY MEANS OF UPMARO RECURSION 

USING THE RECURRENCE EQUATION FOR LAGUERRE POLYNOMIALS 

LIN*l.X» = 2»L(N.X)-L(N-l,XI-( ( 1»X) *L(N.XI-L IN-l .XH /( N+H 



to 

20 
30 



6C 



SUBROUTINE LAPS { Y,X ,C.NI 

DIMENSION C(ll 

TEST OF DIMENSION 
IFINI 1,1,2 

1 RETURN 

2 Y«C(1I 
IFIN-211,3,3 

INITIALIZATION 

3 H0=1. 
Hl"l.-X 
T«1.»X 

DO 4 1 = 2, N 

H2=Hl-H0*Hl-(r*Hl-H0)/FL0AT{| I 
MO'Hl 
Hl»H2 
4 Y»Y+C1 I )«H0 
RETURN 
END 



LAPS 
LAPS 
LAPS 
LAPS 
LAPS 

X. LAPS SO 
LAPS 90 
LAPS 100 
LAPS 119 
LAPS 120 
LAPS 130 
LAPS 1*0 
LAPS L50 
LAPS 160 
LAPS L70 
LAPS IflO 
LAPS 190 
LAPS 200 
LAPS 210 
LAPS 220 
LAP£ 23C 
LAPS 240 
LAPS 250 
LAPS 260 
LAPS 270 
LAPS 280 
LAPS 290 
LAPS 300 
LAPS 310 
LAPS 320 

...LAPS 330 
LAPS 340 
LAPS 350 
LAPS 360 
LAPS 370 
LAPS 393 
LAPS 390 
LAPS *00 
LAPS 410 

LAPS 420 
LAPS 430 
LAPS 4*0 
LAPS 450 
LAPS *60 
LAPS *70 
LAPS 483 
LAPS 490 
LAPS 500 
LAPS 510 
LAPS 520 
LAPS 530 
LAPS 540 
LAPS 550 
LAPS 560 
LAPS 570 



Mathematics—Polynomials: Special Types 209 



SUBROUTINE DLAPS 

PURPOSE 

COMPUTES THE VALUE OF AN N-TERH EXPANSION IN LAGUERAE. 
POLYNOniALS MITH CDEFFICtENT VECTOR C FOR ARGUMENT VALUE 

USAGE 

CALL OLAPS(YtX,CtNI 

DESCRIPTION Of PARAMETERS 

Y - RESULT VALUE 

OOUSLE PRECISION VARIABLE 
X - AHGUNENT VALUE 

DOUBLE PRECISION VAAIASLE 
C - COEFFICIENT VECTOR OF GIVEN EXPANSION 

COEFFICIENTS ARE ORDERED FROM LOM TO HIGH 

DOUBLE PRECISION VECTOR 
N - DIMENSION OF COEFFICIENT VECTOR C 

REMARKS 

OPERATION IS BYPASSED IN CASE N LESS THAN 1 

SUBROUTINES ANO FUNCTION SUBPROGRAMS REgUIRED 
NONE 

METHOD 

OEFlNirtON 

V = SUM<C(n*L(I-I.X), SUMMED OVER I FROM I TO N). 
EVALUATION IS DONE BY MEANS OF UPWARD RECURSION 
USING THE (tECURREtCE EQUATION FOR LAGUERRE POLYNOMIALS 
LIN+l,X)"2»HNtXI-L(N-l.XI-l ( I + XI *L(N t X ]-L< N-1 tXl } /I N*l ) . 



SUBROUTINE OLAPSf Y, X,C t Nl 

DIMENSION C(l> 

DOUBLE PRECISION C, V, X tHO, H1,H2. T 

TEST OF DIHENSI3N 
IFINU.l.Z 

1 RETURN 

2 Y«C(H 
IF(N-2) Ii3»3 

INITIALIZATION 

3 H0=1.00 

HI=1.00-X 

T=1.D0*X 
DO 4 I=2*N 

H2-Hl-H0*HI-(T*H1-H0)/DFL0AT( I) 
HO'HI 
Hl"H2 
* Y=Y»C( I l*HO 
RETURN 
END 



20 



70 



DAPS 
..DAPS 

DAPS 
DAPS 
DAPS 
DAPS 
DAPS 
. DAPS 80 
OAPS 90 
OAPS LOO 
DAPS 110 
OAPS 120 
OAPS L33 
OAPS UO 
OAPS ISO 
DAPS 160 
DAPS 170 
DAPS 180 
DAPS 190 
OAPS 200 
OAPS 210 
DAPS 220 
OAPS 230 
DAPS 2«0 
OAPS 250 
OAPS 260 
OAPS 2T0 
OAPS 2B0 
OAPS 290 
OAPS 300 
DAPS 310 
OAPS 320 
DAPS 330 
DAPS 340 
OAPS 3S0 
.DAPS 360 
OAPS 3 TO 
OAPS 3B0 
DAPS 390 
OAPS *00 
OAPS 410 
DAPS 42Q 
DAPS 430 
OAPS 443 
DAPS 450 
DAPS 460 
DAPS 4 70 
DAPS 480 
DAPS 490 
DAPS 500 
OAPS 510 
DAPS 520 
DAPS 530 
DAPS 540 
OAPS 550 
OAPS 560 
OAPS 570 
OAPS 5BD 
DAPS 590 
OAPS 600 



Subroutines TLAP and DTLAP 

These subroutines transform a given series expan- 
sion in Laguerre polynomials to a polynomial. The 
independent variable x of the given expansion is 
thereby substituted by the independent variable z of 
the resultii^ polynomial using the linear transfor- 
mation x = A#z + Borz = (x-B)/A. 

N 

This means: V* C, * L, (A * z + B> 
.^-'^ 11-1^ ' 

1 = 1 



N 



E POL 
i = 1 



i-1 



Calculation is b5rpassed in case of a nonpositive 
value of the dimension N. 

The range (0, c) in x is transformed to the range 
(zj^, Zj.) in z with Z]^ = - B/A and Zj. = (c - B)/A, or 
vice versa, A -= c/(Zj, - z^) and B = - c * zi/(Zr ~ ^l)- 

The Laguerre polynomial Lq(x) satisfies the re- 
currence equation 

L^^^(x)=x/(n+l)- L^(x)+ [^2-l/(n+l)l L^(x) - 

[l - l/(n+l)] L^_^(x) 

with starting values Lq(x) =1, L^ (x) = 1 - x. 

The transformation is performed by means of a 
forward iteration scheme: 

1 . The coefficient vector of the Laguerre poly- 
nomial Li(x) is calculated from, the coefficient 
vectors of Ijx-1(x), Lx-2(x) using the recurrence 
equation, for i = 3 N. 

2. The resultii^ polynomial coefficient vector 
is obtained by summation of Cj times L^_i(x) over i, 
for i = 1, ., ., N. 



210 Mathematics — Polynomials: Special Types 



Tt*P 13 

rLAP zo 

TLAP 30 

TLAP *0 

TLAP 53 

PURPOSE TLAP (,0 

A SeRIES EXPANSION IN LAGUERRE POLYNOHEALS wrTH INOE^ENOENT TLAP 70 

VARIABLE K IS TAANSFOftMED TO A POLYNOMIAL WITH MDCPENOENT TLAP 80 

VARIABLE Z, iJHERE K = A*Z*B TLAP 90 

TLAP lOD 
TLAP 110 
TLAP 120 
TLAP 130 

DESCRIPTION OF PARAMETERS TLAP t-iO 

A - FACTSR OF LINEAR TERM IN GIVEN LINEAR TRANSFORHATIONTLAP 153 

B ~ CONSTANT TERM IV GIVEN LINEAR TRANSFORMATION TLAP 160 

POL - COEFFICIENT VECIOH OF POLYNOMIAL (RESULTANT VALUE I TLAP ITO 

COEFFICIENTS ARE ORDERED FROM LOW TO HIGH 
N - DIMENSION OF COEFFICIENT VECTORS POL AND C 

C - CIVEV COEFflCtENT VECTOtl OF EXPANSION 

COEfFlCfENTS ARE OftOERED FR01 LOH TO HIGH 
POL ANO C MAY 8€ IDENTICALLY LOCATED 
- WORKING STORAGE OF OIHENSION 2*N 



SUBROUTINE TLAP 



USAGE 

CALL TLAPIA.B. POL. N.C. WORK) 



UOAK 

REMARKS 

COEFFICIENT VECTOR C REMAINS UNCHANGED IF NOT COINCIOINC 

WITH COeFFICIENT VECTOR POL. 

OPERATION IS BYPASSED IN CASE N LESS THAN I, 



TLAP 180 
TLAP 190 
TLAP ZOO 
TLAP 210 
TLAP ZZO 
TLAP 230 
TLAP 240 
TLAP 250 
TLAP 260 
TLAP 270 
TLAP 260 



THE LINEAR TRANSF0RHATI3N X=A*Z*6 OR Z-ll/AtlX-B) TRANSFORMSTL AP 290 



THE RANGE (0,CI IN X TO THE RANGE (2L.ZR1 IN 2, MHERE 

lL'-6/A ANO 2R«<C-e)/A. 

FOR GIVEN ZL, ZR ANO C WE HAVE A=C/(ZB-2Lt AND 

8=-C*ZL/(ZR-ZL) 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOO 

THE TRAMSFORHATION IS SASEO ON THE RECURRENCE EQUATION 

FOR LA&UERRE POLYNOMIALS LIN.Xl 

L(N*l,K»»2*L(N,K)-L(N-l,X|-{(l*X»*L(N,XI-L(N-l,XH/(N»l), 

WHERE THE FIRST TERM IN BRACKETS IS THE INDEX, 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE LfO.Xl=l. L(l,XI=l-X. 

THE TRANSFORMATION IS IMPLICITLY DEFINED BY MEANS OF 

X=A*i+B TOGETHER WITH 

SUHIPQLC I I*Z**(I-n, SUMMED OVER I FROM 1 TO Nl 

-SUM|C(l)*LII-l.X)t SUMMED OVER I FROM 1 TO Nt. 



SUBROUTINE TLAP I A.6 .POL .N,C ,HORK ) 

DIMENSION POLU).C( 1) tWQRK( I) 

TEST OF DIMENSION 
IF(N-1)2.U3 

DIMENSION LESS THAN 2 

p0Lm"cm 

' RETURN 

i POL(ll=C{ll+CI21-B»CI2l 
POU 2I»-CIZ)*A 
IF<N-2)2,2.4 

INITIALIZATION 
. WOflK(L)=l. 

W0flKt2t»I.DO-B 
M0RKO)=0. 
MaftKI4)=-A 
Fl = l, 

CALCULATE COEFFICIENT VECT3R OF NEXT LAGUERRE POLYNOMIAL 
ANO ADD MULTIPLE OF THIS VECTOR TO POLYNOMIAL POL 

DO 6 J=3,N 

FI=FI*1. 

Q-l./FI 

Ol»Q-l. 

C12"U-Q1-B*Q 

Q*Q»A 

P=0. 

00 5 K"2,J 

H=-p*Q+wORK(2*K-2l*Q2+WO«KI2«K-3)*0l 
P=WORKl2*K-2) 
W0RK(2*K-2|=H 
W0RK(2*K-3I«P 
I P0LU-1I»P0L1K-1)+H*C( Jl 
W0RKI2*J-1I-C. 
WaR(C(Z*J)"-0*P 
POL IJ » «CI J I *WORK I 2* J 1 
RETURN 
END 



TLAP J30 
TLAP 310 
TLAP 320 
TLAP 330 
TLAP 340 
TLAP 350 
TLAP 360 
TLAP 370 
TLAP 380 
TLAP 390 
TLAP *00 
TLAP 410 
TLAP 420 
TLAP 430 
TLAP 440 
TLAP 450 
TLAP 460 
TLAP 470 
TLAP 480 
TLAP ^^O 
.TLAP 500 
TLAP 510 
TLAP 520 
TLAP 530 
TLAP 540 
TLAP 550 
TLAP 560 
TLAP 570 
TLAP 580 
TLAP 590 
TLAP 600 
TLAP 610 
TLAP 620 
TLAP 630 
TLAP 640 
TLAP 650 
TLAP 660 
TLAP 670 
TLAP 6B0 
TLAP 690 
TLAP 700 
TLAP 710 
TLAP 720 
TLAP 730 
TLAP T40 
TLAP 750 
TLAP 760 
TLAP 770 
TLAP 780 
TLAP 790 
TLAP 800 
TLAP 8L0 
TLAP 820 
TLAP 830 
TLAP 840 
TLAP 850 
TLAP 860 
TLAP 870 
TLAP 880 
TLAP 890 
TLAP 900 
TLAP 910 
TLAP 920 
TLAP 930 
TLAP 940 



SUBROUTINE DTLAP 



DTLA 10 
DTLA 20 

DTLA 30 

OTL> 40 

OTlA 50 

A SERIES EXPANSION IN LAGUERRE POLYNOMIALS WITH INOEPENOENT OTLA 73 
VARIABLE X IS TRANSFORMED TO A POLYNOHIAL MITH INDEPENDENT OTLA 69 
VARIABLE I, WHERE X>A*Z*S qth 90 

,,_,-, DTLA 103 

"^**'^ DTLA 110 

CALL OTLAPf A. B.POL.N.CMORKI Qj^f^ j^O 

DESCRIPTION OF PARAMETERS ox,^^ j^q 

- FACTOR OF LINEAR TERM IN GIVEN LINEAR TRANSFORMATl ONOTL A 150 
DOUBLE PRECISION VARIABLE DTLA 160 

- CONSTANT TERM IN GIVEN LINEAR TRANSFORMATION DTLA 170 
DOUBLE PRECISION VARIABLE DTLA 180 

- COEFFICIENT VECTOR OF POLYNOMIAL (RESULTANT VALUE) DTLA 190 
COEFFICIENTS ARE ORDERED FROM tOW TO HISH 
DOUBLE PRECISION VECTOR 

- DIMENSION OF COEFFICIENT VECTORS POL ANO C 

- GIVEN COEFFICIENT VECTOR 3F EXPANSION 
COEFFICIENTS ARE ORDERED FROM lOW TO HIGH 
POL ANO C MAY BE IDENTICALLY LOCATED 
DOUBLE PRECISION VECTOR 

- WORKING STORAGE OF DIMENSION 2*N 
DOUBLE PRECISION ARRAY 



POL 



WORK 



REMARKS 

COEFFICIENT VECTOR C RENAINS UNCHANGED IF NOT COINCIDING 

WITH COEFFICIENT VECTOR POL. 

OPERATION IS BYPASSED IN CASE N LESS THAN 1. 



DTLA 200 
OTLA 2t0 
DTLA 220 
OTLA 230 
DTLA 240 
OTLA 250 
DTLA 260 
OTlA 270 
OTLA 280 
DTLA 290 
OTLA 300 
OTLA 310 
DTLA 323 
OTLA 330 



THE LINEAR TRANSFORMATION K>A*Z*B OR Z>(l/AnX-B) TRANSFORMSOTLA 340 

THE RANGE (O.C) IN X TO THE RANGE IZL.ZR) IN Z, WHERE 

ZL— B/A AND ZR-(C-6I/A. 

FOR GIVEN ZL, ZR ANO C WE HAVE A=C/(ZR-ZL) AND 

B=-C*ZL/IZR-ZLI 



SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

THE TRANSFORSATION IS BASED ON THE RECURRENCE EQUATION 

FOR LAGUERRE POLYNOMIALS LlN,X) 

LtN4^L.Xl=:2*L(N.X)-LIN-l.XI-(<l*^X1*L(NtX}-L(N-l,X))/<N*-l}, 

WHERE THE FIRST TEAM IN BRACKETS IS THE INDEX. 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE L(0,X)=L, LIL,X)=t-X. 

THE TRANSFORMATION IS IMPLICITLY DEFINED BY MEANS OF 

X=A*Z*8 TOGETHER WITH 

SUM{PaL(n*Z**(l-LI. SUMMED OVER I FROM 1 TO Nl 

-SUM(C( I l*LlI-ltX) . SUMMED OVER I FROM 1 TO Nl. 



SUBROUTINE OTL API A, BtPOLiN, C. WORK I 

OIHENSION POLUI.CUI.WORKd) 

DOUBLE PRECISION A. B,POL*C,WORK«H,P, 0,31,02, FI 

TEST OF OIHENSION 
IFIN-It2,l,3 

DIMENSION LESS THAN 2 
L P0LI1)-C(1I 
I RETURN 

I P0LI1)-C( lt«^CI2)-B*C(2l 
P0L(2»=-C(2I*A 
IF(N-2I2,2.4 

INITIALIZATION 
t H0RKI1)>L.D0 
H0RK(2)>L.D0-B 

WORKOl-O.DO 

W0RK(4)=-A 

FI-I.DO 

CALCULATE COEFFICIENT VECT3R OF NEXT LAGUERRE POLYNOMIAL 
AND ADO MULTIPLE OF THIS VECTOR TO P0LYN0H1AL POL 

DO 6 J>3.N 

FI-FI*1.00 

Q-l.DO/FI 

OtsQ-l.DO 

Q2-l.00-Ql-fl*Q 

0-Q*A 

P=0.00 

DO 5 K-2.J 

H>-P*Q«^H0RK(2*K-2)*02*^W0RK(2«K-3l«Ql 

P»WORK(2*K-2l 

waRK(2*K-2)-H 

WaRKI2*K-31»P 

PDLIK-1 l«POLIK-l)*H*CIJI 

W0RK{2*J-l)-0.00 

W0RK<2*J)=-Q*P 

POL ( J I =C( J t •WORKC 2* J I 

RETURN 

END 



DT'-A 350 
OTLA 363 
DTLA 370 
DTLA 380 
OTLA 390 
OTLA 400 
DTLA 410 
OTLA 420 
DTLA 430 
OTLA 440 
OTLA 450 
OTLA 460 
OTLA 470 
OTLA 480 
DTLA 490 
OTLA 500 
DTLA 510 
DTLA 520 
OTLA 530 
DTLA 540 
..DTLA 550 
OTLA 560 
DTLA 570 
OTLA 590 
OTLA 590 
OTLA 600 
DTLA 610 
OTLA 620 
OTLA 630 
OTLA 640 
DTLA 650 
DTLA 660 
OTLA 670 
OTLA 680 
OTLA 690 
DTLA 700 
DTLA 710 
OTLA 720 
OTLA 730 
DTLA 740 
DTLA 753 
OTLA 769 
OTLA 770 
OTLA 780 
OTLA 790 
DTLA 800 
OTLA SIO 
DTLA 820 
DTLA 830 
OTLA 840 
DTLA 850 
OTLA 860 
DTLA 870 
OTLA S60 
DTLA 893 
OTLA 900 
OTLA 910 
OTLA 920 
OTLA 930 
DTLA 940 
OTLA 950 
OTLA 963 
DTLA 970 
OTLA 980 
DTLA 990 
OTLAIOOO 



Matheraatics--Pol3momials: Special Types 211 



Subroutines LEP and DLEP 

These subroutines compute the values of the 
Legendre polynomials for a given argument x and 
orders zero up to N. The Legendre polynomial 
Pji(x) satisfies the recurrence equation 

P ^^ (X) = ((2n + l) - X . P (x) -n • P (x))/(n+l) 
n+i n n-i 

with starting values Po(x) =1, Pi (x) = x. 

For reasons of economy and numerical stability 
the recurrence equation is used in the form: 



Vi<")="- V)-Vi<'')""- V) 



(X • P^(x) - P^^{x))/(n+l) 



For large values of n the last term is negligible, 
giving the approximation: 



Vl<^>^2.x.P^(x)-P^_^(x) 



This form shows that roundoff errors grow at worst 
linearly, assuming that the argument x is absolutely 
less than one. 

If Cn+r is the error in Pn+r {^} due to a single 
rounding error e in Pn(x), the approximation is 



e ,=2x-e, -e, . 

n+r+1 n+r n+r-1 



with initial conditions e,. 



e, e 



. «n-l 



0. The solution 



of this difference equation has its maximum for 
|x| = 1: 



e ^ = 0, e = e, e 
n-1 n n+1 



= 2 e. ..., le 



n+r 



= (r + l)e 

The order is assumed to be zero for negative 
values of N. 



SUBROUTINE LEP 

PJRPOSE 

COMPUTE THE VALUES OF THE LE&ENOHE POLYNOMIALS P(N.. 
FOR AftCUMENT VALUE X AND OROEftS UP TO N. 



CALL LEP(V,I,NI 

OeSCRIPTIDN OF PARAMETERS 

Y - RCSUir VECTOR OF DIMENSION U*l CONTAINING THE 

OF tEG£NOR£ POLYNOMIALS OF 3RDER C UP TO N 

FOR CIVEN ARGUMENT X. 

VALUES ARE OROEREO FROM LOW TO HIGH ORDER 
X - ARGUMENT OF LEGENORE POLYNOMIAL 
N - ORDER OF LEGENDRE POLYNOMIAL 

REMARKS 

N LESS THAN IS TREATED AS If N HERE 

SUSROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION !S BASED ON THE RECURRENCE EQUATION F0% 

LEGENDRE POLYNOMIAL^ PCW.X) 

P(N*l,X)"2*X*P(N,X»-P(N-l.XI-(X»*'IN,K)-P<N-l,XM/(N*l 

WHERE THE FIRST TERM IN BRACKETS IS THE ORDER, 

THE SECOND !S THE ARGUMENT. 

STARTING VALUES ARE P(O.X) = U PU.XI=X. 



SUBROUTINE LEP<Y,X.N1 

DIME MS I ON Yd) 

TEST OF ORDER 
V( IJ = I. 
IFINII, 1,2 

RETURN 

Y(2)=X 
IFIN-ll It t ,3 

I 00 * 1=2. N 
G=X»V( I 1 
Y(I*1)=G-Y( I-11*G-(C-Y( 1-1 t I /FLOAT! n 

RETURN 
END 



LEP 


10 






LEP 


30 


LEP 


■*0 


LEP 


■iO 


LEP 


63 


LEP 


TO 


LEP 


93 


LEP 


90 


LEP 


100 


LEP 


llO 


LEP 


120 


LEP 


133 


VALUESLEP 


uo 


LEP 


150 


LEP 


160 


LEP 


170 


LEP 


183 


LEP 


190 


LEP 


POO 


LEP 


2i:i 


LEP 


220 


LEP 


2J0 


LEP 


2*0 


LEP 


f'in 


LEP 


260 


LEP 


270 


LEP 


7B0 


LEP 


290 


LEP 


300 


LEP 


113 


LEP 


320 


LEP 


330 


LEP 


5*0 






LEP 


3b0 


LEP 


370 


LEP 


380 


LEP 


390 


LEP 


400 


LEP 


<tl3 


LEP 


AZO 


LEP 


430 


LEP 


■*40 


LEP 


*53 


LEP 


460 


LEP 


*70 


LEP 


*ao 


LEP 


*<J0 


LEP 


500 


LEP 


■in 


LEP 


520 


LEP 


530 



SUBROUTINE DLEP 

PURPOSE 

COMPUTE THE VALUES OF THE LEGENDRE POLYNOMIALS PIN.X) 
FOR ARGUMENT VALUE X AND ORDERS UP TO N. 

USAGE 

CALL DLEP(Y,X,N) 

DESCRIPTION OF PARAMETERS 

Y - RESULT VECTOR OF DIMENSION N»l CONTAINING THE 

OF LEGENDRE POLYNOMIALS OF ORDER UP TO N 

FOR GIVEN ARGUMENT X. 

DOUBLE PRECISION VECTOR. 

VALUES ARE OROEREO FROM LOW TO HIGH ORDER 
X - ARGUMENT OF LEGENDRE POLYNOMIAL 

DOUBLE PRECISION VARIABLE. 
N - ORDER OF LEGENDRE POLYNOMIAL 

REMARKS 

N LESS THAN IS TREATED AS IF N WERE 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 

METHOD 

EVALUATION IS BASED ON THE RECURRENCE EQUATION FOR 

LEGENORE POLYNOMIALS ^l^ltXt 

P(N*l,XI=2*X«P<NfXI-P(N-l, XJ-IX*PIN,X|-P(N-1,XI1/IN*1 I 

MHERE THE FIRST TERM IN BRACKETS IS THE ORDER. 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE P(0.X):l. PlliX)-X. 



SUBROUTINE OLEP(Y,X,Nt 

DIMENSION Y( 1) 

DOUBLE PRECISION Y.X.G 

TEST OF ORDER 
Y C 1 1 = I . 00 
IF(N1 1.1.2 
RETURN 



IF(N-1I 1, 1,3 

I 00 * l32,N 
G"X*Y( I I 

Y{I#1>=G-Yn-1I*G-(G-Y( I-in/DFLOATU) 
RETURN 
END 



OEP 


10 






OEP 


33 


OEP 


*0 


OEP 


SO 


DEP 


6C 


OEP 


ro 


DEP 


90 


OEP 


90 


OEP 


103 


DEP 


113 


DEP 


1?0 


DEP 


130 


VALUESOEP 


140 


OEP 


150 


DEP 


160 


OEP 


170 


OEP 


180 


OEP 


190 


OEP 


203 


DEP 


210 


OEP 


??0 


DEP 


Z30 


DEP 


240 


OEP 


750 


OEP 


260 


OEP 


2 70 


OEP 


280 


OEP 


290 


DEP 


300 


DEP 


310 


OEP 


320 


DEP 


330 


DEP 


340 


OEP 


350 


DEP 


360 


DEP 


370 


DEP 


380 


OEP 


390 


OEP 


«f00 


DEP 


*10 


DEP 


420 


OEP 


*30 


DEP 


«.40 


DEP 


450 


DEP 


*6D 


OEP 


470 


OEP 


490 


OEP 


490 


OEP 


500 


DEP 


5 10 


DEP 


520 


OEP 


530 


OEP 


540 


OEP 


550 


DEP 


560 



212 Mathematics — Poljmomials: %)ecial Types 



Subroutines LEPS and DLEPS 

These subroutines compute the value of a series 
expansion in Legendre polynomials. The^Legendre 
polynomial Pn(x) satisfies the recurrence equation 



P ^ fx) = 2 X ■ P (X) - P rx) - (X . P (X) 

n+1 n n-1 n 



- Pjj_i(x))/(n+l) 

with starting values Po(x) = 1, Pi(x) =x. 

An n-term expansion in Legendre pol3momials 
with coefficient vector C = (cj^, . . . , Cn) is evaluated 
by means of a forward iteration scheme: 



Y = c^, H^=l. H^=x 



H2=x.H^ 



«2 = «2 - ^^0 " «2 - («2 - «0)/^ 



«0 = «1 



for i = 2, . . . , n 



SUBROJTINE LEPS 

PURPOSE 

COMPUTES THE VALUE OF A^ N-TERH EXPANSION IN LEG&NORE 
POLYNOMIALS rflTH COEf=FICIENT VECTOR C FOR KRGUHENT ViLUE 

USAGE 

CALL LEPSfV.XrC.NI 

DESCRIPTION OF PARAMETERS 
V - RESULr VALUE 

X - ARGUMENT VALUE 

C - COEFFICIENT VECTOR OF GIVEN EXPANSION 

COEFFICIENTS AAE ORDERED FROM LOW TO HIGH 
N - DIMENSION OF COEFFICIENT VECTOR C 



REMARKS 

OPERAriON IS arPASSED IN CASE 



LESS THAN I 



SUSROUTINES AND FUNCTION SUBPftOGRA'IS REQUIRED 
NONE 

METHOD 

DEFINITION 

V=SUM(C( 1 )«PI I-L.X) , SUMMED OVER I FROM 1 TO Nl. 

EVALUATION IS ODNE BY MEANS OF UPWARD RECURSION 

USING THE RECURRENCE EQUATION FOR LEGENDRE POLYNOMIALS 

P(N+l,X> = 2»X*P(N,KI-P(N-l, XI-(X*P(N,X»-P(N-1.XI t/(N4-ll. 



SUBROUTINE LEPS ( Y .K ,C. N I 

DIMENSION CI II 

TEST OF DIMENSIDN 
IF|N)t,1.2 
I RETURN 



«1=«2 



INITIALIZATION 
3 HO=l. 



DO 4 1-2, N 

H2=X»H1 

H2=H2-H0*H2-{H2-H0) /FLOAT! II 

HO = Hl 

Hl = H2 
4 Y=Y+C) I )*H0 
RETURN 
END 



LEPS 13 

..LEPS 20 

LEPS J3 

LEPS *0 

LEPS 50 

(.EPS 60 

LEPS 70 

. LEPS ao 

LEPS 90 

LEPS 100 

LEPS MO 

LEPS 120 

LEPS 130 

LEPS U3 

LEPS 150 

LEPS 160 

LEPS 170 
LEPS 190 
LEPS 190 
LEPS 200 
LEPS 210 
LEPS 22^ 
LEPS 230 
LEPS 2*0 
LEPS 250 
LEPS 260 
LfPS 270 
LEPS 280 
LEPS 290 
LEPS 500 
LEPS 310 
LEPS 320 
,.LEPS 330 
LEPS 3*0 
LEPS 350 
LEPS 360 
LEPS 370 
LEPS 380 
LEPS 390 
LEPS 400 
LEPS «10 
LEPS ♦ZO 
LCPS 430 
LEPS 440 
LEPS 453 
LEPS 460 
LEPS 470 
LEPS 480 
LEPS 490 
LEPS 500 
LEPS 510 
LEPS 52D 
LEPS 533 
LEPS 540 
LEPS 550 
LEPS 5bO 
LEPS 570 



Y = Y + c. ■ H 
1 



This gives the result Y(x) = ^ c. • P. (x). 

i=l 



Calculation is bypassed in case of a nonpositive 
value of the dimension N. 



SUBROUTINE DLEPS 

PURPOSE 

COMPUTES THE VALUE OF AN N-TERM EXPANSION IN LEGENDRE 
POLYNOMIALS WITH COEFFICIENT VECTOR C FOR ARGUMENT VALUE 

USAGE 

call olepsiy. x.c.ni 

description of parameters 
y - result value 

double precision variable 
x - argument value 

double precision -variable 
c - coefficient vector of given expansion 

coefftcients are ordered from low to high 

double precision vector 
n - dimension of coefficient vector c 

remarxs 

operation is bypassed in case n less than i 



METHOD 

DEFINITION 

Y»SUM1C(I t»P(I-I,K), SUMMED OVER I FROM I TO Nl. 

EVALUATION IS DONE BY MEANS OF UPWARD RECURSION 

USING THe RECURRENCE EQUATION FOR LEGENDRE POLYNOMIALS 

P(N*l,X)=2*X*P(N,X)-P(N-|,Xl-IX*PfN,X)-P(N-I»Xl l/tN«lt. 



SuaROUTlNE OLEPSI Y. X.CtN) 



DIMENSION C<n 

DOUBLE PRECISION C t Y , K ,HC t Hl,H2 



c 


1 


TEST Of DIMENSION 
IFINIlf 1.2 
RETURN 


f. 








2 


Y-C( 11 
IFIN-2I 1,3,3 


C 






c 




imruLiZiTiou 




3 


HP=1.00 

H1 = X 


c 




00 4 1=2. N 

H2=K«Hl 

H2=H2-HO*HZ-(H2-HO)/OFLOAT( II 
H0=H1 
H|=H2 




4 


Y=Y*CIII*HO 

RETURN 

END 



OEPS 10 
..D6PS 20 
DEPS 30 
DEPS 40 
DEPS 50 
DEPS 60 
DEPS TO 
:. OEPS 80 
DEPS 93 
OEPS 100 
OEPS 110 
DEPS 120 
OEPS 130 
DEPS 140 
DEPS 150 
DEPS 160 
DEPS 170 

OEPS lao 

DEPS 190 
DEPS 200 
DEPS 210 
OEPS 220 

OEPS 230 
OEPS 240 
DFPS 253 
DEPS 260 
DEPS 270 
DEPS 280 
DEPS 290 
OEPS 300 
DEPS 310 
DEPS 320 
OEPS 330 
OEPS 340 
OEPS 353 
..OEPS 360 
OEPS 3T0 
OEPS 3B0 
OEPS 390 
OEPS 400 
DEPS 410 
OEPS 420 
DEPS 430 
DEPS 443 
DEPS 450 
DEPS 460 
OEPS 470 
DFPS *S0 
0£P5 ♦^O 

DEPS 500 
OEPS 510 
OEPS 520 
DEPS 530 
DEPS 540 
OEPS 550 
DEPS 560 
DEPS 5 70 
DEPS 583 
DEPS 590 
OEPS 600 
OEPS 610 



Mathematics— Polynomials: %)ecial Types 213 



Subroutines TLEP and DTLEP 

These subroutines transform a given series expan- 
sion in Legendre polynomials to a polynomial. The 
independent variable x of the given expansion is 
thereby substituted by the independent variable z. of 
the resulting polynomial using the linear transfor- 
mation x = A«z + Borz = (x- B)/A. 

N 

This means: V C*P (A«z + By 
. ■^-'^ 1 i-1 
1 = 1 



N 



i-1 



y^ POL. ♦ z 
i=l 



Calculation is bypassed in case of a nonpositive 
value of the dimension N. 

The range (-1, +1) in x is transformed to the 
range (zi, zr) in z with zi = - (1 + B)/A and Zj. = 
(1 - B)/A, or vice versa, A = 2/(zr - ziJ and 
B = - (zj. + zi)/(Zi. - zi). 

The Legendre polynomial P^M satisfies the 
recurrence equation 

Vl^""^ =x[2-l/(n+l)] P^(x) - [l-l/(n+l)] 



n-1 



with starting values Po(x) = 1, Pl(x) =x. 

The transformation is performed by means of a 
forward iteration scheme: 

1. The coefficient vector of the Legendre poly- 
nomial Pi(x) is calculated from the coefficient 
vectors of Pi-i(x), Pi_2(x) using the recurrence 
equation, for i = 3, . . . , N. 

2. The resulting polynomial coefficient vector 
is obtained by summation of ci times coefficient 
vector of Pi-i(x) over i, for i = 1, . . . , N. 



TLEP 10 

TL£f 20 

TLEP SO 
TLEP tfO 
TltP 50 

PURPOSE TLEP 50 

* SERIES EXPANSION IN LEGENORE POLVNOHIALS WITH IMOEPENOENT TLEP 70 
VARIABLE K IS TRANSFORMED TO A POLYNOHIAL WITH INOEPENOfNT TLEP 80 
VARIABLE Z, HHERE X«A*Z*-e TLEP 90 

TLEP 100 
TLEP 110 
TLEP 120 
TLEP 130 

DESCRIPTION OF PARAMETERS TLEP 140 

A - PACTOH Of LINEAR TERM IN GIVEN LINEAR TRANSf ORHATl DNTLEP ISO 
B - CONSTANT TERM IN GIVEN LINEAR TRAMSFORHATION TLEP UO 

- COEFFICIENT VECTOR OF POLYNOMIAL IRESULTANT VALUEI TLEP ITO 
COEFFICIENTS ARE ORDERED FROM LOW TO HIGH 

- OIMENSION OF COEFFICIENT VECTORS POL AND C 

- GlVe^l COEFFICIENT VECTOR OF EXPANSION 
COEFFICIENTS ARE OROERED FROM LOU TO HIGH 
POL AND C HAY BE IDENTICALLY LOCArCO 

- MORKIMG STORAGE OF DIMENSION Z*H 



SUBROUTINE TLEP 



USAGE 

CALL TLEP(A.B.P0L,N.C.W3RKI 



POL 



WORK 



TLEP L80 
TLEP 190 
TLEP 200 
TLEP 210 
TLEP 220 
TLEP 233 
TLEP 2*0 
TLEP 250 
TLEP 260 
TLEP 2T0 
TLEP 280 



REMARKS 

COEFFICIENT VECTOR C REMAINS UNCHANSEO IF NOT COINCIDING 
UITH COEFFICIENT VECTOR POL. 

OPERATION IS BYPASSED IS CASE N LESS THAN I. 

THE LINEAR TR ANSF0RMATI]<4 X>A*Z*S OR Z-(1/A}(X-«| TRANSFORMSTLEP 293 
THE RANGE (-l.»l) IN X TO THE RANGE I2L,2RI IN 2, HHERE TLEP 300 

ZL"-|M6I/A AND 2R = I1-BI/A. TLEP 310 

FOR GIVEN 2L, Z« WE HAVE ^'^/^lR-^Lt AND B— ( ZR+ZL I /I ZR-ZL I TLEP 320 

TLEP 330 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 



METHOD 

THE TRANSFORMATION IS BASED ON THE RECURRENCE EQUATION 

FOR LEGENORE POLYNOMIALS PIN, XI 

P1N*1,XI=2*X»PIN.XJ-P<N-1, K)-(X*P|N,X|-P(N-I.XI l/(N*lt, 

WHERE THE FIRST TERM IN BRACKETS IS THE INDEX. 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE PI0*X]=1, P<ltX}>X. 

THE TRANSFORMATION IS IMPLICITLY OEFINEO BY MEANS OF 

X=A»Z*8 TOGETHER WITH 

SUMfPOLI I l*Z**l l-ll t SUMMED OVER I FROM I TO Nl 

= $UMIC(I l*Pn -I,X), SUMMED OVER I FROM I TO N». 



SUBROUTINE TLEP) ArB ,POL .NtCi WORK I 
OIMENSION PGLUI,CUl,yQRK( 1) 



OIMENSION LESS THAN 2 

1 POHl) = Cni 

2 RETURN 

3 P0L<lt=C(l)*8*C(2) 
POLI2l=A«C(2I 
IF(N-2»2,2t4 

INI T [ALIZAT ION 
!, W0RK(1)*1. 
W0RK(2I=B 
WORK< 31 =0. 
WORtCf^l =A 
FI«1. 

CALCULATE COEFFICIENT VECTOR OF NEXT LEGENORE POLYNOMIAL 
AND AOO MULTIPLE OF THIS VECTOR TO POLYNOMIAL POL 

DO b J = 3,N 

FI=FI*l. 

0=1./Ft-I. 

01 = 1. -q 

P=0. 

DO 5 K-2,J 

H = {A*P*B*WOHKI2*K-2n*QU0*MORK(2*K-3) 

P=WQ«K( 2*K-2I 

WORKI 2*«C-2)=H 

WORK(2«K-3)=P 

POL(K-l I^POLtK-n*H*C( Jl 

W0RK(2*J-l)-O. 

WDRK(^»J)=A*P«OI 

POL)JI=C( J)*WORK( 2*JI 

RETURN 

END 



TLEP 3*0 
TLEP 350 

TLEP 360 
TLEP 370 
TLEP 380 
TLEP 390 
TLEP *00 
TLEP *10 
TLEP 420 
TLEP *30 
TLEP **0 
TLEP 450 
TLEP 460 
TLEP 470 
TLEP 480 
.. TLEP 490 
TLEP 500 
TLEP 510 
TLEP 520 
TLEP 530 
TLEP 540 
TLEP 550 
TLEP 560 
TLEP 570 
TLEP 580 
TLEP 590 
TLEP 600 
TLEP 610 
TLEP 620 
TLEP 630 
TLEP 640 
TLEP 650 
TLEP 660 
TLEP 670 
TLEP 680 
TLEP 690 
TLEP 7C0 
TLEP 710 
TLEP 720 
TLEP 730 
TLEP 740 
TLEP 750 
TLEP 740 
TLEP 770 
TLEP 780 
TLEP 790 
TLEP BOO 
TLEP 810 
TLEP 820 
TLEP 830 
TLEP 840 
TLEP 850 
TLEP 860 
TLEP 870 
TLEP 880 
TLEP 890 
TLEP 900 
TLEP 910 



214 Mathematics-- Polimomials: Special Types 



SUSROUriNE oruEP 



one 10 

OTlE 20 

OTLE 30 

OTLE 49 

one 50 

PURPOSE OTLE 60 

A SEfttES EXPANSION IN LEGENORE ^OLVNOHIALS WITH INOEPENOENT OTLE TO 

VARIABLE X IS rRANSfORHEO TO A POLYNOHIAL WITH INOEyPENOENT OTLE B3 

VARIABLE Z. WHERE X*A«2«-B OTLE 90 

DFLE 100 

USAGE OfLE 110 

CALL OrLEPI A.B.POL.N.C.WaRICI OTLE 120 

OTLE 130 

OeSCRIPTION OF PARAMETERS OTLE UO 

A - FACT3R OF LINEAR TERK IN GIVEN LINEAR TRANSFORHATIONOTLE 15C 



DOUBLE PRECISION VARIABLE 

- CONSTANT TERH M GIVEN LINEAR rRANSFORHATION 
D9U6LE PRECISION VARIABLE 

- COEFFICIENT VECTOR OF POLYNOMIAL (RESULTANT VALUE) 
COEFFICIENTS ARE ORDERED FROM LOW Tu HIGH 
DOUBLE PRECISION VECTOR 

- OtNENSION OF COEFFICIENT VECTORS POL AND C 

- GIVE^ COEFFICIENT VECTOR OF EXPANSION 
COEFFICIENTS ARE ORDERED FR3f4 LOW TO HIGH 
POL AND C MAY BE IDENTICALLY LOCATED 
DOUBLE PRECISION VECTOR 

- UORKING STORAGE OF DIMENSION 2*N 
OOUSLE PRECISION ARRAY 



OTLE 160 
DTLE ITO 
OTLE ISO 
OTLE 190 
DTLE 200 
OTLE 210 
OTLE 220 
DTLE 230 
OTLE 2*0 
DTLE 2» 
DTLE 260 
DTLE 2T0 
OTLE 280 
OTLE 290 
OTLE 330 
DTLE 310 
DTLE 320 
OTLE 330 



REMARKS 

COEFFICIENT VECTOR C REMAINS UNCHANSEO IF NOT COINCIDING 
WITH COEFFICIENT VECTOR POL. 

OPERATION IS BYPASSED IN CASE N LESS THAN 1. 
THE LINEAR TRANSF0RNATI3N X*A*2te OR /«U/AHX-6) TRANSFORMSOTLE 3*0 
THE RANGE <-lt*^ll IN X TO THE RANGE (ZLtZR> IN 2, WHERE OTLE 350 

2L--(l*fl)/A AND 2R-II-BI/A. OTLE 360 

FOR GIVEN 2L, IR ME HAVE A»2/1ZR-ZLI AND B«-(ZR*2L )/l2R-2LI OTLE 370 

DTLE 380 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 
NONE 



METHOD 

THE TRANSFORMATION IS BASED ON THE RECURRENCE EQUATION 

FOR LEGENORE POLYNOMIALS PIN, XI 

P(N+l.Xl-2*X*P(N,Xl-P(N-l,X»-(X*P(N,X)-P(N-l,K)l/<N»n, 

WHERE THE. FIRST TERM IN BRACKETS IS THE INDEX, 

THE SECOND IS THE ARGUMENT. 

STARTING VALUES ARE P(0,XI>1, PIl.XI-X. 

THE TRANSFORMATION IS IMPLICITLY DEFINED BY MEANS OF 

K'A^Z+S TOGETHER WITH 

SUNIPOLl I)*Z**(I-U, SUMMED OVER 1 FROM L TO N> 

= SUH(CIII*PU-I.X>f SUMMED OVER I FROM I TO Nl. 



SUBROUTINE OrLEP<A« B. POL . N, C* WORK) 

DIMENSION POLlll.Cin.WORKin 

DOUBLE PRECISION A. B,POL>C tWORK ,H, P.Q,Q l.F I 

TEST OF DIMENSI3N 
IF(N-1I2.1.3 

DIMENSION LESS THAN 2 
I P0L(1>-C( 1) 
! RETURN 

I P0Lni-Clll*B»C(2t 
POL(2l-A«C(2) 
IF(N-2l2t2.4 

INITIALIZATION 
. WORK(LI<^1.00 
H0RK(2)*B 
WORK! 31 >0. 00 
U0RK(4)>A 
Fl-l.DO 

CALCULATE COEFFICIENT VECTOR OF NEXT LEGENORE POLYNOMIAL 
AND AOO MULTIPLE OF THIS VECTOR TO POLYNOMIAL POL 

00 6 J*^3tN 

F I -F 1*1. DO 

a«l-DO/FI-l.D0 

01-l.DO-Q 

P=O.DO 

DO S K>2,J 

H"(A*P*B*HORK(2*K-2>)*Ql*Q*WORK(2*K-3l 

P*H0RK(2*K-21 

H0RKI2*K-2I*H 

MORK(2*K-3)-P 

P0LlK-l|»POLlK-ll*H*C(Jl 

WORK12*J-1)-0.00 

W0RK(2*JJ«A*P*Q1 

POLUI-C(J)*«ORK(Z»JI 

RETURN 

END 



OTLE 390 
DTLE 400 
OTLE 410 
OTLE 420 
OTLE 430 
OTLE 440 
OTLE 450 
DTLE 46.0 
DTLE 470 
OTLE 480 
OILF 490 
OTLE 500 
DTLE 510 
OTLE 520 
DTLE 530 
..DTLE 540 
OTLE 590 
OTLE 560 
DTLE 570 
OTLE 580 
DTLE 590 
OTLE 600 
DTLE 610 
DTLE 620 
OTLE 630 
DTLE 640 
OTLE 690 
OTLE 660 
DTLE 670 
OTLE 660 
OTLE 690 
OTLE 700 
OTLE 710 
OTLE 720 
OTLE 730 
DTLE 740 
DTLE 750 
OTLE 760 
DTLE 770 
OTLE 780 
OTLE 790 
OTLE 800 
OTLE ata 
OTLE 820 
OTLE 630 
OTLE 840 
OTLE B50 
DTLE B60 
DTLE 870 
DTLE 8B0 
OTLE 890 
OTLE 900 
DTLE 910 
DTLE 920 
DTLE 9 30 
DTLE 940 
DTLE 950 
OTLE 960 
DTLE 970 



Roots of Nonlinear Eqiiatlons 

Subroutines RTWI and DRTWI 

These subroutines refine the initial guess x^ of a 
root of the general nonlinear equation x = f(x). 
Wegstein's iteration scheme is used in order to get 
accelerated convergence in case of a function f (x), 
which has at least continuous first derivative in the 
range in which iteration moves. 

Following Figure 14, set x = y„ = ^^^n^ ^'^^ ^i ~ 

f(Xj). 

Refinement of xi is done by determination of the 
intersection of the linear function y = x and the 
secant through the points (x , y ) and (x , y^), thus 
getting: 



"2=^l'"' 



^-^0 






-1 



and y^ = f(X2) 



The next step is done by starting at (x , y ) and 



setting: 



'^3=^2"'- 



''e-^ 






y3=f(x3) 



y = f(x) 




Figure 14. Wegstein's iterative method 



Mathematics — Roots of Nonlinear Equations 215 



It is easily seen that this determines the intersec- 
tion between y = x and the secant through the points 
(XI, yi) and (X2, y2). Therefore Wegstein's itera- 
tion scheme is often called the secant modification 

of the normal iteration scheme x = f(x ). 

i+1 ^ i' 

Repeating these steps, the result is the iteration 
scheme: 



2. xi = xi-i and xj ?^ yi = f(xi). This case is 
possible due to roundoff errors or to a very steep 
slope of the secant. 

For reference see G.N. Lance, Numeric'al 
Methods for High Speed Computers . Uiffe, London, 
1960, pp. 134 - 138. 



X. , =x. + 
i+1 i 



x.-x. 
1 1-1 



"i-i-yi-i 



-1 \(i = 1.2,...) (1) 



yi+i = ^(Vi) 



Each step requires one evaluation of f(x). 

This iterative procedure is terminated if the 
following two conditions are satisfied: 



^ and j ^10 ■ e 



with 



i+1 i 



^i+1 



in case of |x. J > 1 



i+1' 



i+1 il in case of |x. | £ 1, V/gx 



«2=^ 



^+1 - ^i+l 



'^i+l 



X. 



i+1 ^i+1 



in case of |x. i > i 



in case of l^-.-il ^ 1 



and tolerance 6 given by input. 

The procedure described above may not converge 
within a specified number of iteration steps. Rea- 
sons for this behavior, which is indicated by an 
error message may be: 

1. Too few iteration steps are specified. 

2. The initial guess xq is too far away from any 
root. 

3. The tolerance £ is too small with respect to 
roundoff errors. 

4. The root to be determined is of muitipiicity 
greater than one. 

Furthermore, the procedure fails if at any iteration 
step the denominator of equation (1) becomes zero. 
This is also indicated by an error message. This 
failure may have two reasons: 

1. The secant has the slope 1, either exactly or 
due to roundoff errors. In both cases it is probable 
that there is at least one point f in the range in 
which iteration moves with ^'( { ) = 1. 



suenouTiNE htmi 

PURPOSE 

TO SOLVE GENERAL N0W.1NEAA EQUATIONS OF THE FORM X>FCT(X} 
8V MEANS OF UEGSTElH-S ITERATION HETHOO. 

USAGE 

CALL RTUI IX. VAL, FCT.XSr.EPS, (END. lERI 
PARAHCTfR FCT REOUIRES AN EXTERNAL STATEWNT. 

OESCRlPTtON OF PARAMETERS 

- RESULTANT ROOT OF EOUAT[ON X«FCT(XI. 

- RESULTANT VALUE OF X-FCTCX) AT R30T X. 

- NAME OF THE EXTERNAL FUNCTION SUBPROGRAM USED. 

- INPUT VALUE WHICH SPECIFIES THE INITIAL GUESS OF 
THE ROOT X. 

- INPUT VALUE UHICH SPECIFIES THE UPPER BOUND OF THE 
ERROR OF RESULT X, 

- KAXtHUM NUMBER OF ITERATION STEPS SPECIFIED. 

- RESULTANT ERROR PARAMETER COOEO AS FOLLOWS 
IEK-0 - NO ERRORt 

lER-l - NO COUVERGENCE AFTER lENO ITERATION STEPS 
lER-2 - AT ANV ITERATION STEP THE DENOMINATOR OF 

ITERATION FORMULA HAS EQUAL TO ZERO. 



10 



40 



TO 



90 
100 



VAL 
FCT 
XST 

EPS 

lENO 
lER 



REMARKS 

The PROCEDURE IS BYPASSED AND GIVES THE ERROR MESSAGE IER-2 
IF AT ANV ITERATION STEP THE DENOMINATOR OF ITERATION 
FORMULA HAS EQUAL TO 2ER0. THAT MEANS THAT THERE IS AT 
LEAST ONE POINT IN THE RANGE IN WHICH ITERATION MOVES WITH 
DERIVATIVE OF FCTCXI EQUAL TO 1. 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

THE EXTERNAL FUNCTION SUBPROGRAM FCTIXI MUST BE FURNISHED 
8Y THE USER. 

NETHOO 

SOLUTION OF EQUATION X«FCT(XJ IS DONE BY NEANS OF 

WEGSTEIN-S ITERATION METHOD, WHICH STARTS AT THE INITIAL 

GUESS XST OF A ROOT X. ONE ITERATION STEP REQUIRES ONE 

EVALUATION OF FCTIXI. F3R TEST ON SATISFACTORY ACCURACY SEE 

FORMULAE 121 OF MATHEMATICAL DESCRIPTION. 

FOR REFERENCE* SEE 

111 G. N. LANCE. NUMERICAL METHODS FOR HlfiH SPEED COMPUTERSi 

ILIFFE, LONDON, 1460* PP. 134-138, 
(2) J. WEGSTEIN, ALGORITHM 2» CACH, V0L.3f [SS.2 (19601, 

PP.74. 
131 H.C. THACHER* ALGORITHM IS, CACN, VOL.3, ISS.8 119601, 

PP.4T5, 
141 J.G. HERRIDT, ALGORITHM 26. CACM, VOL.3, ISS.Ll (19601, 

PP.603. 



SUBROUTINE RTHM X«V AL.FCT, XST.EPSt lENO* lER) 



PREPARE ITERATION 

IER-0 

rOL-XST 

X«FCT(TOLI 

A-X-XST 

e"-A 

TOL-X 
VAL*X-FCT(TOLI 



START ITERATION LOOP 
00 6 I-l.IENO 
IFIVALI i,r.i 

EQUATION IS NOT SATISFIED BY X 
L e-B/VAL-1. 
IFfB)2.8.2 

ITERATION IS POSSIBLE 

X-X'tA 
B*VAL 
TOL-X 
VAL'X-FCTITOLI 

TEST ON SATISFACTORY ACCURACY 
TOL-EPS 
0>AaS(XI 
IFfO-1. 14,4,3 
TOL«TaL*0 

IflABSt Al-TaLI5*S,6 
. IF(ABS(VAL)-tO.«rOL)7,T,6 
CONTINUE 
END OF ITERATION LOOP 



NO CONVERGENCE AFTER lEND ITERATION STEPS. ERROR RETURN. 
' RETURN 

ERROR RETURN IN CASE OF ZERO DIVISOR 

IER-2 

RETURN 

END 



RTHI 
.RTWI 
RTWI 
RTWI 
RTHI 
RTHI 
RTWI 
RTHI 
RTHI 
RTW 

RTHI 110 
RTHI 120 
RTWI 130 
RTHI 140 
RTHI ISO 
RTHI 140 
RTHI 170 
RTHI 180 
RTHI 190 
RTWI 290 
RTWI 210 
RTWI 220 
RTWI 230 
RTHI 240 
.RTHI 250 
RTHI 2&0 
RTHI 270 
RTWI 280 
RTWI 290 
RTWI 330 
RTHI 310 
RTHI 320 
RTHI 330 
RTWI 340 
RTHI 350 
RTHI 340 
RTHI 370 
RTHI 380 
RTHI 390 
RTWI 400 
RTHI 410 
RTHI 420 
RTHI 430 
RTHI 440 
RTHI 450 
RTHI 460 
RTHI 470 
RTWI 480 
RTWI 490 
RTWI SOO 
RTHI 510 
RTHI 520 
RTWI «30 
RTWI 549 
RTHI 550 
..RTWI 540 
RTWI 570 
RTHI 580 
RTWI 590 
RTWI 600 
RTWI 610 
RTWI 620 
RTHI 630 
RTWI 640 
RTWI 650 
RTWI 660 
RTWI 670 
RTWI 680 
RTHI 690 
RTWI. TOO 
RTWI TlO 
RTHI T20 
RTHI 730 
RTWI 740 
RTWI 750 
RTHI 760 
RTWI 770 
RTWI 780 
RTWI 790 
RTHI BOO 
RTHI 810 
RTHI 829 
RTHI 830 
RTHI 840 
RTWI 850 
RTWI 860 
RTWI 870 
RTHI 880 
RTHI 890 
RTWI 900 
RTHI 910 
RTWI 920 
RTWI 930 
RTWI 940 
RTWI 950 

m m 

RTWI 910 
ftrwl 9B0 
RTm 910 
RTUIIOOO 
KTUllOll) 
RTHI1320 
«TIII11)30 

«riiil3to 



216 Mathematics — Roots of Nonlinear Equations 



suenouTiNE omtwi 

TO $0L« C£NE»AL NONLINEAK EQUATIONS OF THE FORM lt-F^T<KI 
BY «*NS OF MEGSTCIN-S ITERATION METHOD. 

USAGE 

CAtL ORTHI U,VAL.FCT,XST,EPS.1EN0,1ER1 
PARAMETER FCT REQUIRES AN EXTERNAL STAT&HENT. 

DESCRIPTION OF PAAAMCTERS 

X - DOUBLE PRECISION RESULTANT ROOT OF EQUATION 

X-FCT(X>. 

- DOUBLE PRECISIDN RESULTANT VALUE OF X-FCTU) 
AT ROOT X. 

- NAME OF THE EXTERNAL DOU&LE PRECISION FUNCTION 
SUBPROGRAM USED. 

- DOUBLE fRECISION INPUT VALUE MHICH SPECIFIES THE 
INITIAL GUESS OF THE ROOT X. 

• SINGLE PRECISION INPUT VALUE WHICH SPECIFIES THE 
UPPER SOUND OF THE ERROR OF RESULT X. 

- MAXIMUM NUMBER 3F ITERATION STEPS SPECIFIED. 

- RESULTANT ERROR PARAMETER COOED AS FOLLOWS 
IER-0 - NO ERROR* 

|ER«t - NO CONVERGENCE AFTER lEND ITERATION STEPS 

IER*2 - AT ANY ITERATION STEP THE OENDHtHATOR OF 

ITERATION FORMULA HAS EQUAL TO ZERO. 



LO 



30 

♦ 
SO 



BO 



VAL 



FCT 



XST 
EPS 



I END 
lER 



C REMARKS 

C THE PROCEDURE IS BYPASSED AND GIVES THE ERROR MESSAGE ICR-2 

C IF AT ANY ITERATION STEP THE DENOMINATOR OF ITERATION 

C FORMULA HAS EQUAL TO ZERO, THAT BEAMS THAT THERE IS AT 

C LEAST ONE POINT IN THE RANGE IN WHICH ITERATION MOVES WITH 

C DERIVATIVE OF FCTIX) EQUAL TO 1. 

C 

C SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

C THE EXTERNAL D0J8LE PRECISION FUMCTION SUBPROGRAM FCT(X» 

C MUST BE FURNISHED BY THE USER. 

C 

C METHOD 

C SOLUTION OF EQUATION X-FCTIXI IS DONE BY MEANS OF 

C W6GSTEIN-S ITERATION METHOD. WHICH STARTS AT THE INITIAL 

C GUESS XST Of A ROOT X. ONE ITERATION STEP REQUIRES ONE 

C EVALUATION OF FCTfXI, FOR TEST ON SATISFACTORY ACCURACY SEE 

C FORMULAE (21 OF MATHEMATICAL DESCRIPTION. 

C FOR REFERENCE, SEE 

C m G. N. LANCE. NUMERICAL METHODS FOR HISH SPEED COMPUTERS 

C ILIFFE. LONDON, i960. PP. 134-138. 

C (21 J. WEGSTEIN, ALGORITHM 2, CACM« VOL. 3. ISS.2 (H6DI. 

C (3» H.C. THACHCR. ALGORITHM 15, CACM. VOL.3, ISS.B 11«0>, 
C PP.*T5, 

C (4» J.G, HERRIOT, ALGORITHM 26, CACM, VOL.3. ISS.Il (19601, 
C PP.601. 



SUBROUTINE DRTWMX, VAL.FCT, XST,EPS,IENO,IER) 



DOUBLE PRECISION X, VAL,FCT,KST. A, B, D, TOL 

PREPARE ITERATION 

IER>0 

TOL>XST 

X-FCTITOLl 

A-X-XST 

B— A 

TOL-X 

VAL-X-FCTITOLI 



START ITERATION L03P 
DO 6 I-1,IEN0 
IFIVAlll.r.t 

EQUATION IS NOT SATISFIED BY X 

1 B-B/VAL-l.OO 
|F(BI2.B,2 

ITERATION IS POSSIBLE 

2 A-A/S 
X-X+A 

B-VAL 
TOL-X 
VAL-X-FCT(TOLl 

TEST ON SATISFACTORY ACCURACY 

T(H.-EPS 

0>OABSIXl 

|F(0-1. 0014*6,9 

3 TOL" TOL •O 

6 IF(0ABS(At-T0L)9,9,6 

5 IFt0ABS(VALl-1.01*T0tl7,7,6 

6 CONTINUE 

END OF ITERATION LOOP 



NO CONVERGENCE AFTER I END 
IER«1 
r RETURN 

ERROR RETURN IN CASE OF lERO DIVISOR 
! IER-2 
RETURN 
END 



ITERATION STEPS. ERROR RETURN. 



DRTW 

,DRTW 
DRTH 
ORTW 
DRTH 
DRTH 
DRTH 
DRTU 
DRTW 
ORTW 100 
DRTH ilO 
DRTH LZO 
ORTW ISO 
DRTW 1*0 
ORTM 150 
DRTU 160 
DRTW 170 
DRTH ISO 
DRTW 190 
DRTH 200 
ORTW 2t0 
DRTH 220 
DRTH 230 
DRTH 240 
DRTH 250 
DRTH 260 
DRTW 2T0 

,DRTH 210 
DRTW 290 
DRTW 300 
DRTH 310 
DRTH 320 
DRTH 330 
DRTH 340 
DRTW 390 
DRTW 360 
DRTW 370 
DRTH 360 
DRTU 390 
DRTW 400 
ORTU 610 
DRTH 420 
DRTH 430 
DRTH 440 
DRTU 450 
DRTH 460 
ORTW 470 
DRTH 4a0 
DRTU 490 

.DRTW SOO 
DRTH 910 
ORTW S20 
ORTH 530 
DRTH 540 
DRTH 990 
DRTH 560 
DRTH 970 
ORTW 580 
ORTW 590 
DRTU 600 
DRTH 610 
DRTH 620 
DRTH 630 
ORTH 640 
DRTH 650 
ORTH 660 
ORTH 679 
DftTH 6S0 
DRTU 690 
DRTH 700 
ORTU 710 
DRTH 720 
DRTH 730 
DRTH 740 
DRTH 790 
ORTH 760 
DRTH 770 
ORTU 780 
ORTH 790 
DRTU 800 
ORTU 610 
ORTM 120 
DRTU 630 
DRTH B40 
ORTU BSD 
ORTU 860 
DRTH 8T0 
ORTH BBO 
ORTH 890 
DRTH 900 
ORTH 910 
DRTW 920 
ORTH 930 
DRTH 940 
ORTU 990 
ORTH 960 
DRTH 970 
ORTU 980 
DRTW 990 
DRTHIOOO 
DRTHtOIO 
ORTH 10 20 
DRTHI0 30 
ORTH1040 
ORTH1090 
ORTUL060 
ORTHIOTO 
ORTH 1080 
ORTHI 090 



Subroutines RTMI and DRTMI 

These subroutines determine a root of the general 
nonlinear equation f(x) = in the range of x from 
xli up to xri (xli, xri given by injnit) by means of 
Mueller's iteration scheme of successive bisection 
and inverse parabolic interpolation. The procedure 
assumes f(xii) . f(Xj-i) < 0. 

Starting with xi = xn and x^ = Xj-i and following 
Fig. 15, one iteration step is described. 

First, the middle of the interval x, . . .Xj. is 
computed: 

^ (X, +xj. 



m 



1 



In case t(x^) . f(x^) < 0, x^ and x^ are interchanged 
to ensure that i(K^) ■ f(Xr> > 0. 



In case 

Xj. is replaced by x^^ and the bisection step is re- 
peated. If, after a specified number of successive 
bisections, inequality (1) is still satisfied, the 
procedure is bypassed and an error message is 
given. 

In Fig. 15, the second bisection step leads to a 
configuration which does not satisfy inequality (1). 
Thus by inverse parabolic interpolation: 

X -X, 
m 1 



^''-^(^l) f(x )-f(x,) 
^ m' ^ I 



1 + f (X ) 
^ m 



f (x^) - 2 f(x J+f(Xj) , 

[f(x^)-f(x^)] Lf(V^<''l^^' 
and X = X - Ax 

and X is sure to be situated between x, and x^. 



/ inverse quodraHc 
/ parabola 



(2) 



f<x ){2. step) '^ 



f(x_.){4.step) 



y = f(x) 



f(x,) ^ 




Figure 15. Mueller's Iterative method 



Mathematics — Roots of Nonlinear Equations 217 



Now, for the next iteration step, x becomes Xj 
and XjQ becomes x^ if f(x) • f(xj) > 0, or x becomes 
xr if f(x) •f(Xj)< 0. 

■ Convergence is either quadratic or linear if the 
multiplicity of the root to be determined is equal to 
one or greater than one respectively, and if f(x) can 
be differentiated continuously at least twice in the 
range x^^ - . . x^^. Each iteration step requires two 
evaluations of f(x). 

This iterative procedure is terminated if either 
the two conditions (checked in bisection loop) 



and 



|x^ - Xji < e.max (1, \xj ) 
|f(xp - f(x )l< 100 -e 



(3) 



or the two conditions (checked after inverse para- 
bolic interpolation) 



and 



Axl < e . max (1, |x| ) 

< ,„. c- ( (4) 



If (x)l 



100 •£ 



are satisfied, where tolerance e is given by input. 

The procedure described above may not converge 
within a specified number of iteration steps followed 
by the same number of successive bisections. Rea- 
sons for this behaviour, which is indicated by an 
error naessage, may be: 

1. Too few iteration steps are specified. 

2. The initial interval xn-- x^j is too long. 

3. The tolerance e is too small with respect to 
roundoff errors . 

Furthermore, the procedure is bypassed, also 
giving an error message, if the basic assumption 
f(x^) . f(Xj.j) <0 is not satisfied. 

For reference see G. K. Kristiansen, "Zero of 
Arbitrary Function", BIT, vol. 3 (1963), pp, 205- 
206. 



SUSROUTINE ftTNl 

PMPOSe 

ro SOL« GEN6KAL WNLlHCAII EQUAriONS OF THE FOTN FCTCXI 
BV MEANS OF NUELLEK-S ITEKATION NCTHOO. 

USAGE 

CALL ftTNI U.F.FCT.XLt.Xltl.EPS.IEND.IEKI 
l>AMMErCK FCr REOUlRES AN EXTEftNAL STATEMENT. 



RTNt 

.KTMI 
ATM I 
RTHI 

Arm 

RTMI 
RTHI 



TO 
«t) 



RTHf 

RTHI 100 

RTHt 110 

RTMI 120 

RTMI IJO 

RTMl lO 

RTMI 150 

RTMI 160 

RTMI 170 



OESCRIRTION OF PARAMETERS 

I - RESULTANT ROOT OF EQUATION FCT(Kt-0. 

F - RESULTANT FUNCTION VALUE AT ROOT «. 

FCT - NAME OF THE EXTERNAL FUNCTION SUBRROGRAM USED. 

XII - INFUT VALUE MHICH SPECIFIES THE INITIAL LEFT eOUMO RTMI 183 

OF rue AooT X. rtmi im 

IRI - INPUT VALUE MHICN SRECIFICS THE INITIAL AIGHT SOUNORfHI 200 

OF rw ROOT X. njm ^iq 

€FS - INCUT VALUE WHICH SPECIFIES THE UPFER ROUND OF THE AFMI 2Z0 

ERROR OF RESULT I. 
lENO - MAXIMUM MUN0ER 3F ITERATION STERS SP£CtFieO 
rCR - RESULTAWr ERROR RARAMETER COOEO AS FOLLOWS 
"■■-" NO ERROR, 

NO COIVERGEMCE AFTER lENO ITERATION STEPS RTMI 2fD 



IER-0 
lEN-t 



FOLLOWED RT lENO StKCESSIVE STEPS OF 
BISECTION, 
lER-Z - BASIC ASSUMPTION FCT! XLI l«FCTIXRI I LESS 
THAN 3R EQUAL TO ZERO IS MOT SATISFIED. 
MARKS 

IIl^-«°Sf?"" RSSOMES THAT FUNCTION VALUES AT INITIAL 
BOUNDS XLI ANO XRI HAVE NOT THE SAME SIGN. IF THIS BASIC 
ASSUMRFION IS NOT SRTISFIEO .V INPUT viCois XLI ANO xi!^ 



PROCEDURE IS BVPASSEO H^O CIvES THE ERROR MESSAGE IEft*2. 

FUNCTION SUBPROCKAMS REQUIRfO 

FUNCTION SUBPROGRAM FCT(Xl MUST BE FURNISHED 



SUBROUTINES AND 
THE EXTERNAL 
BY THE USER. 

METHOD 

SOLUTION OF E 
ITERATION MET 
PARABOLIC INT 
XLI ANO XRI 
FCT(X» AT ROa 
REQUIRES TMQ 
ACCURACY SEE 
FOR REFERENCE 
FUNCTIONt BIT 



RTMI 3T0 
RTMI }eo 
RTMI 390 
RTMI 400 
RTNl 419 
RTHI t,za 

QUATION FCTIX)"0 IS DONE Br MEANS OF MUELLER-S RTMI *40 
HOO OF SUCCESSIVE BISECTIONS ANO INVERSE RTMI *50 
ERPOIATION, WHICH STARTS AT THE INITIAL BOUNDS RTMI *60 
CONVERGENCE IS QUADRATIC IF THE DERIVATIVE Of RTHI *73 
T X IS NOT EQUAL TO ZERO. ONE ITERATION STEP RTMI *e0 
EVALURTIONS OF FCTIXl. FOR TEST ON SATI SFACTORYRTMI 490 
FORMULAE |3,4I OF MATHEMATICAL DESCRIPTION. RTHI 500 
SEE G. R. KRISTIANSEN, ZERO OF ARBITRARY RTMI 510 
VOL. 3 (19631, PP,2C5-206. rthI 520 

RTMI 533 



SUBROUTINE RTHI CX,F .FCT , XL I , XRI ,EPS. lEND, lERI 



PREPARE ITERATION 

IER=0 

XL«XLI 

XR=XRI 

X'XL 

TOL«X 

F=FCT{TOLI 

IF|F|l,16,l 

1 FL-F 
XiXR 
TOL»X 
F-FCF(TOL) 
IF<F12,16,2 

2 FR-F 

IFI$|GN(I.,f'Ll*SIG'4< I. .FR) 125,3.25 

BASIC ASSUMPTION FL*FR LESS THAN IS SATISFIED. 
GENERATE TOLERANCE FOR FUNCTION VALUES. 

3 1=0 
TOLF=100.*EPS 



START irERATION L03P 

4 I«l*l 

START BISECTION LOOP 

00 13 K=1,IEN0 

X=.5*(XL*XRI 

TOL"X 

F»FCHTOL» 

IF(F)5, 16,5 

5 IF(S[GNII.,FI«'S IGNI l.,FRI ) 7,6, 7 

INTERCHANGE Xl'AND XR IN ORDER TO GET THE SANE SIGN IN F AND FR 

6 T0L=XL 
XL = XR 
XR=rOL 
rOL=FL 
FL=FR 
FR= TOL 

7 TOL-F-FL 
A=F*TOL 
A = A«-A 
IFIA-FR*(FR-FL J 18,9,9 

fl IF(I-I£N0I17,I7,9 

9 KR = K 
FR»F 

TEST ON SATISFACTORY ACCURACY IN BISECTION LOOP 

TOL*EPS 

A-ABSI XR} 

If( A- 1. J 11, 11, 10 

10 rOL=TOL*A 

11 IF(ABS(XR-XL»-T0LI12,12.13 

12 IP ( ABS( FR-FLt-TOLFl U. 1*, 13 

13 CONTINUE 
ENO OF BISECTION LOOP 

NO CONVERGENCE AFTER (ENO ITERATION STEPS FOLLOWED BY lENO 
SUCCESSIVE STEPS OF BISECTION OR STEADILY INCREASING FUNCTION 
VALUES AT RIGHT 80JN0S. ERROR RETURN. 
IER=1 

14 IFIABSI FR)~ABS(FL I I 16, 16, 15 

15 X=XL 



COMPUTATION OF ITERATED X-VALUE BY INVERSE PARABOLIC INTERPOLATI 
IT A=FR-F 

DK=|X-XLI*FL*(l.tF*(A-TOL)/(A*(FR-FLUl/TOL 

KH-X 
FM = F 
X=XL-OX 
TOL'X 

F=Fcr(roLi 
iF(F)i8a6,ia 

TEST ON SATISFACTORY ACCURACY IN ITERATION LOOP 

18 rOL=EPS 
A^ABSI X] 
IF(A-l. 120.20,19 

19 TOL = rOL«A 

20 IF( ABS(DXI-TOL (21,21,22 
2! IFIAaS{F)-TaLF) 16.16,22 

PREPARATION OF NEXT BISECTION LOOP 

22 IF(SIGN(l..Ft*SISN( I. . FL H 24,2 3, 24 

23 XR=x 



RTMI 219 






GO TO 4 


RTHI 2*0 




24 


Xl'X 


RTMI 250 






FL = F 


RTMI ZfrO 






XR = XM 


EPS RTMI 2fD 






FRsFM 


RTMI 280 






GO TO 4 


RTMI 290 


C 




END OF ITERATION LOOP 


S RTMI 300 


C 






RTMI JIO 


c 






RTMI 320 


c 




ERROR RETURN IN CASE OF WRONG INPUT 


RTMI 333 




25 


IER = 2 


RTMI 340 






RETURN 


RTMI «0 






END 


THERTMI 160 









..RTMI 540 

RTMI 553 

RTHI 560 

RTMI 570 

RTHI sao 

RTMI 590 
RTHI 600 
RTMI 610 
. RTHI 620 
RTHI 633 
RTMI 540 
RTMI 650 
RTMI 660 
RTHI 670 
RTMI 680 
RTHI 690 
RTMI 700 

RTMI no 

RTHI 720 
RTMI 730 
RTHI 740 
RTHI 750 
RTMI 760 
RTMI T70 
RTHI 780 
RTMI 790 
RTMI 800 
RTHI 810 
RTMI 820 
RTMI 630 
RTMI B40 
RTHI 850 
RTMI 860 
RTMI 870 
RTMI 880 
RTHI 890 
RTMI 900 
RTHt 910 
RTMI 920 
RTMI 930 
RTMI 940 
RTMI 950 
RTMI 960 
RTMI 970 
RTHI 980 
RTMI 993 
RTMUOOO 
RTMUOIO 
RTNIIOZO 
RTMI1030 
RTMIL040 
RrMIl050 
RTMllOftO 
RTMI1070 
RTMI1080 
RTHa090 
RTMHIOO 
RTMIlllO 
RTMILIZO 
RTMU130 
RTHItUO 
RTMIUSO 
RTKI1160 
RTHII170 
RTMI1180 
RTMItI90 
RTMI12D0 
RTMI1210 
RTMI1220 
RrNI1233 
RTMI 1240 
RTMI1250 
DNRTMI1260 
RTMI1270 
RTMI 1280 
RTMI1290 
RrMll300 
RTMU310 
RTMI 1320 
RTHI1330 
RTHI 1343 
RTHII350 
RTMn360 
RTMI1370 
RTMIt380 
RTMI1390 
RrMI1400 
RrMI1410 
RrMI1420 
RTMI 1433 
RTHI 1440 
RTHI1450 
RTMI 1460 
RTMI1470 

RTMiueo 

mum 

RTHIISOO 
RTMI 1510 
RTMI1520 
RTHI1530 
RTHIlS^O 
RrMI1550 
RTHn56D 
RTMIISTO 
RrMI1580 
RTHI1590 
RTHIIftOO 



218 Mathematics— Roots of Nonlinear Equations 



SUBROUTINE ORTKI 

PURPOSE 

ro SOLVE GENERAL NONLINEAR EQUATIONS OF THE fORM FCr(XI=0 
BY MEANS OF MUELLER-5 ITtKATION METHOD. ^ 

USAGE 

CALL ORTMI (X,F,FCTi XLItXRI.EPS. lEND) lER) 
PARAMETER FCT REQUIRES AN EXTERNAL STATEMENT. 

OE&CRIPTION OF PARAMETERS 

X - DOUBLE PfiECISI3N RESULTANT ROOT OF EQUATION 

FCT( K)"0. 
F - DOUBLE PRECISnN HESULTANf FUNCTION VALUE 

AT ROOT K. 

- NAME OF THE EXTEHNAL OOUBLE PRECISION FUNCTION 
SU8PR0GRAM USED. 

- IX]U9L£ PRECISION INPUT VALUE WHICH SPECIFIES THE 
INITIAL LEFT SOUND OF THE ROOT X. 

- DOUBLE PRECISION INPUT VALUE WHICH SPECIFIES THE 
INITIAL RIGHT BDUNO OF THE ROOT X. 

- SINGLE PRECISIDN INPJT VALUE WHICH SPECIFIES THE 
UPPER BOUND OF THE ERROR OF RESULT X. 

- HAKIMUN NUMBER OF ITERATION STEPS SPECIFIED. 

- RESULTANT ERROR PARAMETER COOED AS FOLLOWS 
NO ERROR. 



13 



70 



FCT 



XLI 



KR] 



EPS 



lENO 
lER 



ORTM 

,.ORTM 
DRTM 
DRTH 
ORTM 
DRTM 
ORTM 
DRTM 
ORT^ 90 
DRTM IOC 
ORTM UO 
ORTM 120 
ORTM 130 
ORTM L40 
ORTM 150 
DRTH 160 
ORTM I TO 
ORTH 180 
DRTM 190 
ORTM 200 
ORTM 210 
DRTM 220 
DRTM 230 
ORTM 2'VO 
DRTM 250 
ORTM 260 
ORTM 270 
ORTM 280 
DRTH 290 



IER=l - NO CONVERGENCE AFTER lENO ITERATION STEPS ORTH JOD 



FOLLOMEO Br IEND SUCCESSIVE STEPS OF 
BISECTION, 
IER=2 - BASIC ASSUMPTION FCTI XL 1 1 •FCTIXRM LESS 
THAN 3R EQUAL TO ZERO IS NOT SATISFIED. 

REMARKS 

THE PROCEDURE ASSUMES THAT FUNCTION VALUES AT INITIAL 
BOUNDS XLI AND XRI HAVE NOT THE SAME SIGN. IF THIS BASIC 
ASSUMPTION IS NOT SATISFIED BY INPUT VALUES XLI AND XRI, 
PROCEOUHE IS BYPASSED AND GIVES THE ERROR MESSAGE IER=2. 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

THE EXTERNAL DOUBLE PRECISION FUNCTION SUBPROGRA-l F C T 1 X 1 
MUST BE FURNISHED BY THE JSER. 



ORTM 310 
DRTM 320 
DRTM J30 
ORTM 340 
DRTM }50 
ORTM 360 
DRTM 370 
DRTM 380 
THEORTH 390 
DRTM 400 
DRTM 410 
ORTM 420 
ORTM 4 30 
ORTM 440 
DRTM 450 
ORTM 4&0 
DRTM 470 
DRTM 490 



METHOD 

SOLUTION OF EQUATION FCT(XI=0 IS DONE BY MEANS OF MUELLER-S 
ITERATION METHOD OF SUCCESSIVE BISECTIONS AND INVERSE 
PARABOLIC INTERPOLATION, WHICH STARTS AT THE INITIAL BOUNDS ORTM 49C 
XLI AND XRI. CONVERGENCE IS QUADRATIC IF THE DERIVATIVE OF DRTM 500 
FCTIXJ AT ROOT X IS NOT EQUAL TO ^ERO. ONE ITERATION STEP DRTM 51Q 
REQUIRES TWO EVALUATIONS OF FCTfX). FOR TEST ON SAT I SFACTDRYDRTM S2C 
ACCURACY SEE FORMULAE (3,41 OF MATHEMATICAL OESCrt 1 PT I DN. DRTM 530 
F(W REFERENCE, SEE G. K. KRISTIANSEN, ZERO OF ARBITRARY ORTM 540 
FUNCTION, BIT, VOL. 3 n")63), PP. 205-206. DRTM 550 

ORTM 5!.0 
ORTM sro 

ORTH sao 

DRTM 590 
ORTM SOO 
ORTM 61C 
ORTM 620 
DRTM 630 
ORTM 640 
DRTM 650 
DRTM 660 
ORTM 670 
ORTM 680 
DRTM 690 
DRTM 700 
ORTM TIO 
ORTM 720 
DRTM 730 
ORTM 740 
ORTM 7S0 
DRTM 753 
DRTM T70 
ORTM TBO 
ORTM 790 
DRTM 800 
ORTM 910 
DRTM 820 
DRTM 830 
DRTM 840 
ORTM 850 
ORTM 860 
DRTM 870 
DRTM 88C 
DRTM S90 
DRTM 900 
ORTM -310 
DRTM 920 
ORTM 930 
ORTM 940 
DRTM 950 
DRTM 960 
DRTM 970 
DRTM 980 
ORTM 990 

drtmiooo 
drtmioio 

0RTM1D20 
DRTM1330 
DRrM1040 
ORTM1050 
DRTMt060 
ORTMU70 
DRTM1380 
0flTMI09C 
ORTMUOO 
ORTMlllO 
ORTM1I20 
ORTMU30 
OfirMII43 
OflfMIISO 
DRTMU60 
ORTMII 70 
DRTM1180 
ORTM1190 
DRTM1200 
DRTMI2I0 
DRTMI22D 
ORTM1230 
DRTMI240 
ORTM1250 
DRTM1260 
ORTMI270 
DRTM1280 
DRTM1290 



SUBRQUT INE DRTM UK, F, FCT, XL I, XRI, EPS, IE NO, lER) 



DOUBLE PRECISION X, F, FCT , XL I , XRI , XL , XR , FL , FR , TOL , TOLF, A.OX . XMtFM 

PREPARE ITERATION 

1ER = 

XL^KLI 

XR'XRI 

X = XL 

TOL = X 

F=FCT(TOLI 

IFiFll, 16, I 

1 FL = F 
X = XR 
TOL = x 
F = FCT{TQLI 
IFIFI2.l5t2 

2 FR = F 
IFIOSIGNI i.D0,FL)tDSIGNU.DO,FRM25, 3,25 

BASIC ASSUMPTION FL«FR LESS THAN IS SATISFIED. 
GENERATE TOLERANCE FOR FUNCTION VALUES. 

3 1=0 
TOLF=100.«EPS 



START ITERATION LOOP 

4 I=l»l 

START BISECTION LOOP 

DO 13 K=1.IEN0 

X=.500*(XL+XR) 

TOL-X 

F=FCTITOLt 

IF(F)5, 16,5 

5 IFIOSIGNU.DO.F t*OSIGN( I.OO,FRI» 7,6.7 

INTERCHANGE XL AMD XR IN ORDER TO GET THE SAME SIGN IN F AND FR 

6 TOL -XL 
XL = XR 
XR=rOL 
rOL=FL 

fl=fr 

FR=TOL 

7 TOL=F-FL 
A'F*rOL 
A^Af-A 
IFI A-FR*tFR-FLl (9,9 ,9 

a IFI I-IENOUT, 17,9 
9 XR = K 
FR = F 

TEST ON SATISFACTORY ACCURACY IN BISECTION LOOP 
TOL = EPS 

il = 04aS( XRI 

IF(A-l.O0m. 11,10 

10 rOL=T0L»A 

11 IF<0A6S(XR-XLt-r0LI 12, 12,13 

12 IFIOABSIFR-fLI-TOLF 114, 14, 13 

13 CONTINUE 
END OF BISECTION LOOP 

NO CONVERGENCE AFTER IEND ITERATION STEPS FOLLOWED BY IEND 
SUCCESSIVE STEPS OP BISECTION OR STEADILY INCREASING FUNCTION 
VALUES AT RIGHT BOUNDS. ERROR RETURN. 

ieR=i 

14 IF(OABS(FRI-OAaS{FL II 16, 16. 15 

15 K«XL 
F = FL 

16 RETURN 



COHPUTATION OF ITERArEO X-VALUE BY INVERSE PARABOLIC 

17 A-FR-F 
0X>(X-XLl*FL*(1.00*F«(A-rOLl/lA*lFR-FLIll/rOL 

XM«X 
FM-F 
X-XL-OX 

roL<x 

F-FCriTOLI 
IF(Flia*16,LB 

TEST ON SATISFACTORY ACCURACY IN ITEAATION LOOP 

18 rOL-EPS 
A>DAeS(XI 
[F(A-1.00)20,20,19 

19 TO(.>rOL*A 

20 IF(0A8S(0K|-TQLI21, 21.22 

21 IF(0AeSIF)-T0LFU6. 16,22 

PREPARATION Of NEXT BISECTION LOOP 

22 IFIDS1GN4 1.00.F1»DSIGNI 1. 00. FL t I 24.23.2 4 

23 XR>X 
FR»F 

GO TO 4 

24 XL-X 

FL-F 

xn*XM 

FR"FM 

GO TO 4 

ENO OF ITERATION L30P 



ERROR RETURN IN CASE OF WRONG INPUT DATA 
25 lER-2 
RETURN 

ENO 



ORTNDOO 
INTERPOLATIONOATNISIO 
DRTM1320 
DftTHLS}} 
0flTH1340 
DRTH13S0 
DRTHi360 
^ ORTHISTO 
DHTM1380 
ORTH1390 
0RTH1400 
ORTM14L0 
ORTHl^ZO 
ORTNIOO 
ORTH1440 
ORTHUSO 
ORTni460 
DRTK1470 
ORTHUSO 
DRTH1490 
ORTML500 
ORTHlflO 
ORTM1520 
DRTMISSO 
ORTH 1540 
DRTHISSO 
DRTHlSbO 
DRTHISTO 
ORTNlSaO 
0RTN1590 
0RTH1600 
0RTN1610 
ORTN1620 
ORTHU30 
ORTH1640 
ORTHUSO 



Matheniatics--Roots of Nonlinear Equations 219 



Subroutines RTNI and DRTNI 

These subroutines refine the initial guess xq of a 
root of the general nonlinear equation f(x) =' 0. 
Newton's iteration scheme is used in the following 
form: 



1 



(i = 0.1,2, ...) 



(1) 



Convergence is quadratic or linear if the multiplicity 
of the root to be determined is equal to one or 
greater than one respectively, and if f(x) can be 
differentiated continuously at least twice in the 
range in which iteration moves. Each iteration 
step requires one evaluation of f(x) and one evalua- 
tion of f'(x). 

This iterative procedure is terminated if the 
following two conditions are satisfied: 

5 ^e and |f (x ) | 4 100-£ 



with 



X. ,-x. 
1+1 i 



i+1 



in case of Ix. I > 1 
1+1 



(2) 



K+1 ^i I ^^ '^^se of jxj+j^ 1 4 



^ 1 



and tolerance e given by input. 

The procedure described above may not converge 
within a specified number of iteration steps. Rea- 
sons for this behaviour, which is indicated by an 
error message, may be: 

1. Too few iteration steps are specified. 

2. The initial guess xq is too far away from any 
root. 

3. The tolerance e is too small with respect to 
roundoff errors . 

4. The root to be determined is of multiplicity 
greater than one. 

Furthermore, the procedure fails and is by- 
passed if at any iteration step the derivative f(xi) 
becomes zero. This is also indicated by an error 
message. 

For reference see: 

(1) F. B. Hildebrand, Introduction to Numerical 
Analysis , McGraw-Hill, New York/Toronto/ 
London, 1956, pp. 447 - 450. 

(2) R. Zurmiihl, Praktische Mathematik fur 
Ingenieure und Physiker , Springer, Berlin/ 
Gottingen/Heidelberg, 1963, pp. 12 - 17. 



SUBROUriME RTNI 

PURPOSE 

TO SOLVE GENERAL NONLINEAR EQUATIONS OF THE FORM FiXLD 
aw — i.ur «r .., _ iTE^^riON METMOO. 



BY MEANS OF HEwrON-; 



20 



eo 



USAGE 

CALL RTMl (X,F,OERF.FCr.XST,El>S,l£NO.IER| 
PARAMETER FCT REQUIRES AN EXTERNAL STATEMENT. 



RTNI 
RTHI 
RTNI 
RTNI 
RTNI 
RTNI 
RTNI 
RTNI 
RTNI 
RTNI 100 
RTNI LIO 
RTNI 120 
RTNI 130 
RTNI 1^0 
RTNt tSO 
RTNI 160 
RTNI ITO 



DESCRIPTION Of PARAMETERS 

« - RESULTANT ROOT OF EQUATION FIX)-0. 
f - RESULTANT FUNCTION VALUE AT ROOT X. 

OERF - RESULTANT VALUE OF DERIVATIVE AT ROOT X. 

" I??"! ^^ ^"^ EXTERNAL SUflROUTINE USED. IT COMPUTES RTNI 180 
TO *1VEN ARGUNENT X FUNCTION VAtUt F AND OER I VATI VtRTNi 190 
OERF. ITS PARAMETER LIST MUST BE K.F.OERF. rtN 200 

" JlJc^Inn*'-"^ '"^'^" SPECIFIES THE INITIAL 3UESS OF RTNI 210 
THE ROOT X. RlHl 770 

" Vtlil It^^^ """^"^ SPECIFIES THE UPPER BOUND OF THE RTNI 230 
ERROR Or RESULT X. RTMr 3*fl 

- MAXIMUM NUMBER OF ITERATION STEPS SPECIFIED. RTNI 750 

- RESULTANT ERROR PARAMETER COOEO AS FOLLOUS rtNI 260 
IER-0 - NO ERROR, „fjjj f^" 
IER"1 - NO CONVERGENCE AFTER lENO ITERATION STEPS. RTNI 280 
IEa»Z - AT ANY ITERATION STEP DERIVATIVE OERF MAS RTNI Z90 

EQUAL TO ZERO. «rHI WO 

RTNI 310 

THE PROCEDURE IS BYPASSED AND GIVES THE ERROR MESSAGE IER-2 RrHl \M 

IF AT ANY ITERATION STEP DERIVATIVE OF t^(Kl IS EQUAL TO 0, RTNI 3*0 

POSSIBLr THE PROCEDURE ^QULO BE SUCCESSFUL IF IT IS STARTED RTNI 350 

ONCE MORE MITH ANOTHER INITIAL GUESS XST. »iAKito KTNI 350 

SUBROUTINES ANO FUNCTION SUBPROGRAMS REQUIRED 

THE EXTERNAL SUBROUTINE FCT ( X,F,0€RF I MUST BE FURNISHED 
BY THE USER. 



EPS 



REMARKS 



OF 



SOLUTION Of EQUATION F(KI=0 IS DONE BY MEANS OF NEWTON-S 
ITERATION METHOD, WHICH STARTS AT THE INITIAL GUESS XST I 
A ROOT X. CONVERGENCE IS QUADRATIC IF THE DERIVATIVE OF 
F(XI AT ROOT X IS NOT EQUAL TO ZERO. ONE ITERATION STEP 
REQUIRES ONE EVALUATION OF F<X» ANO ONE EVALUATION OF THE 
DERIVATIVE OF F(X1. FOR TEST ON SATISFACTORY ACCURACY SEE 
FORMULAE (21 Of MATHEMATICAL DESCRIPTION. 

FOR REFERENCE, SEE R. ZURIUEHL, PRAKTISCHE MATHEMATIK FUER 
INGENIEURE U»JO PHYSIKER, SPRINGER, BERLI N/GOETTINSEN/ 
HEIOELBERGf 1963, PP. 12-17. 



SUSROUriNE RTNr(x,F,OERF,FCr,XST,EPS,IENO,IER| 



PREPARE ITERATION 

IER>0 

X = XST 

TOL»K 

CALL FCTITOL«F,OERF I 

TOLF"I00.*EPS 



START ITERATION LOOP 
00 6 I*l. I END 
IFIF)l,7,l 

EQUATION IS NOT SATISFIED BY X 

1 IF{OERFI2t6,2 

ITERATION IS POSSIBLE 

2 DX«F/OERF 
X'X-OK 

TOL = X 

CALL FCT(TOL.FtOERFI 

TEST ON SATISfACrraiY ACCURACY 

T0L=EPS 

A-ABS(XI 

IF(A'1.)4,4,3 

3 rOL"TOL*A 

4 IF(AaS(DXI-TOLlS,S.6 

5 IF{A8S(F)-T0LF17.7,6 

6 CONTINUE 

END OF ITERATION LOOP 



NO CONVERGENCE AFTER lENO 
IER=l 

7 RETURN 



TERATION STEPS. ERROR RETURN, 



ERROR RETURN IN CASE OF ZERO DIVISOR 
: I£R=2 
RETURN 
END 



RTNI 360 
RTNI 370 
RTNI 3B0 
RTNI 390 
RTNI 400 
RTNI 410 
RTNI 420 
RTNI 430 
RTNI 440 
RTNI 450 
RTNI 460 
RTNI 4T0 
RTNI 4B0 
RTNI 490 
RTNI 500 
RTNI 510 
RTNI 520 
RTNI 53") 
..RTNI 540 
RTNI 550 
RTNI 560 
RTNI 5T0 
RTNI 580 
RTNI 590 
RTNI &00 
RTNI 610 
RTNI 620 
RTNI 630 
RTNI 640 
RTNI 650 
RTNI 660 
RTNI 670 
RTNI 680 
RTNI 690 
RTNI TOO 
RTNI 710 
RTNI 720 
RTNI 7 30 
RTNI 740 
RTNI 750 
RTNI 760 
RTNI 7T0 
RTNI TBO 
RTNI 790 
RTNI BOO 
RTNI 813 
RTNI B20 
RTNI 830 
RTNI 840 
RTNI 850 
RTNI 860 
RTNI 870 
RTNI 880 
RTNI 890 
RTNI 900 
RTNI 910 
RTNI 920 
RTNI 930 
RTNI 940 
RTNI 950 
RTNI 960 
RTNI 970 
RTNI 9B0 



220 Mathematics—Roots of Nonlinear Equations 



sueROuriNE ortni 

PURPOSE 

TO SOLVE GENERAL NONLINCAft EQUATIONS OF THE FORM FIK)- 
BY HEANS OF NEWTON-5 ITERATION HETHOO. '' 

USAGE 

CALL ORTNI (X ,F(OERF,FCT, XST tEPSt lENO. lER) 

PARAMETER FCT REQUIRES AN EXTERNAL STATEMENT. 



DESCRIPTION OF PARAMETERS 



ORTN 
.DRTN 
ORTN 
ORTN 
ORTN 
ORTN 
ORTN 
ORTN 
ORTN 
DRTN 100 
ORTN L13 
ORTN 120 
DRTN 130 
DRTN 140 



69 



DOUBLE PRECISION RESULTANT ROOT OF EQUATION F(X)>0.ORTN 153 



OERF 



FCT 



XST 



EPS 



- 00U8LE PRECISION RESULTANT FUNCTION VALUE AT 
ROOT X. 

- DOUBLE PRECISnN RESULTANT VALUE OF DERIVATIVE 
AT ROOT X. 

- NAME OF THE EXTERNAL SUBROUTINE USED. IT COMPUTES 
TO GIVEN ARGUMENT X FUNCTION VALUE F AND DERI VATI VEORTN 210 
DERF. ITS PARAMETER LIST MUST BE X.F,OEitF, WHERE DRTN 220 
ALL PARAMETERS ARE DOUBLE PRECISION. 

- DOUBLE PRECISION INPUT VALUE WHICH SPECIFIES THE 
INITIAL GUESS OF THE ROOT X. 

- SINGLE PRECISION INPUT VALUE WHICH SPECIFIES THE 
UPPER SOUND OF THE ERROR OF RESULT X. 

lEND - MAXIMUM NUMBER OF ITERATION STEPS SPECIFIED. 
lER - RESULTANT ERROR PARAMETER COOED AS FOLLOWS 

I£R*D - NO ERROR, 

IER"1 - NO COMVErGENCE AFTER lEND ITERATION SIEPStDRTN 310 

IER-2 - AT ANY ITERATION STEP DERIVATIVE OERF WAS ORTN 320 

EQUAL TO ZERO- DRTN 930 

ORTN 340 

MARKS ORTN 353 

THE PROCEDURE IS BYPASSED AND GIVES THE ERROR MESSAGE 1ER»2 ORTN 360 

IF AT ANY ITERATION STEP DERIVATIVE Of FIXl IS EQUAL TO 0. ORTN 370 

POSSIBLY THE PROCEDURE WOULD BE SUCCESSFUL IF IT IS STARTED DRTN 380 



DRTN 160 
ORTN ITO 
DRTN 160 
ORTN 190 
DRTN 200 



ORTN 230 
DRTN 240 
ORTN Z50 
DRTN 260 
ORTN 270 
ORTN 280 
DRTN 290 
ORTN 300 



ONCE MORE WITH ANDTHEft INITIAL GUESS XST. 

SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED 

THE EXTERNAL SUBROUTINE FCTI X,F,DERF) MUST BE FURNISHED 
BY THE USER. 

METHOD 

SOLUTION OF EQUATION FIX)"0 IS DONE BY MEANS OF NEWTON-S 
ITERATION METHOD, WHICH STARTS AT THE INITIAL GUESS XST OF 
A ROOT X. CONVERGENCE IS QUADRATIC IF THE DERIVATIVE OF 
FIXl AT ROOT X IS NOT E3UAL TO ZERO. ONE ITERATION STEP 
REQUIRES ONE EVALUATION OF F(KI AND ONE EVALUATION OF THE 
DERIVATIVE OF F(X). FOR TEST ON SATISFACT3RY ACCURACY SEE 
FORMULAE (21 OF MATHEMATICAL DESCRIPTION. 

FDR REFERENCE, SEE R. 2URHUEHL, PRAKTISCHE MATHEHATIK FUEH 
INGENIEURE UHD PHYSIKER* SPRINGER, BERL IN/GOETTINSEN/ 
HEIDELBERG. 1963. PP.12-'ir. 



SUBROUTINE DRTNKX, F.DERF,FCT. XSr,EPS, lENO.IER) 



DOUBLE PRECISION X. F,OERF*XST, TOL*TOLF,OX,A 

PREPARE ITERATION 

1ER«0 

X'XST 

TOL-X 

CALL FCT(TOL,F,DERFI 

T0LF-100.*EPS 



START ITERATION LOOP 
00 6 I =1,1 END 
IF{F)1,7,1 

EQUATION JS NOT SATISFIED BY X 

1 tF(OERFI2,B,2 

ITERATION IS POSSIBLE 

2 OX-F/OERF 

X=X-OX 

TOL = X 

CALL FCT(TOL.F,0£RF) 

TEST ON SATISFACTORY ACCURACY 

TOL=EPS 

A-OABSIXl 

EFIA-1. 0014,4, 3 

3 TOL=TOL*A 

4 IF{0A6S(0XI-T0L)5.5.6 

5 IF(DABS(F1-T0LF)7,7,6 

6 CONTINUE 

END OF ITERATION LOOP 



NO CONVERGENCE AFTER lENO ITERATION STEPS. ERROR RETURN. 

IER-1 

RETURN 

ERROR RETURN IN CASE OF ZERO OIVISOR 

lER-2 

RETURN 

END 



ORTN 390 
DRTN 400 
ORTN 410 
ORTN 420 
DRTN 430 
ORTM 4*0 
DRTN 450 
DRTN 460- 
DRTN 470 
ORTN 480 
DRTN <t90 
ORTN 500 
ORTN 510 
ORTN 520 
ORTN 530 
ORTN 540 
DRTN 550 
ORTN 560 
..DRTN 570 
ORTN 580 
DRTN 593 
ORTN 600 
DRTN 610 
DRTN 620 
ORTN 630 
DRTN 640 
ORTN 650 
DRTN 660 
ORTN 670 
ORTN 660 
ORTN 690 
ORTN 700 
ORTN 710 
DRTN 720 
DRTN 730 
DRTN 740 
DRTN 750 
DRTN 760 
DRTN 770 
ORTN 780 
ORTN 790 
DRTN 800 
DRTN StO 
ORTN 820 
ORTN B3Q 
DRTN 840 
ORTN 850 
DRTN 860 
DRTN 870 
DRTN 680 
DRTN 890 
DRTN 900 
DRTN 910 
ORTN 920 
DRTN 930 
ORTN 940 
ORTN 950 
DRTN 960 
ORTN 970 
DRTN 980 
ORTN 990 
DRTNIOOO 
ORTNIOIO 
DRTNI02C 
DRTN1030 



Extremum of Functions 

Subroutines FMFP and DFMFP 

These subroutines perform the calculation of an un- 
constrained minimum of a function of several vari- 
ables using a method proposed by Davldon. The 
underlying method is described in the article by 
R, Fletcher and M.J. D. Powell, "A Rapidly Con- 
vergent Descent Method for Minimization", Compu - 
ter Journal , vol. 6, iss. 2, 1963, pp. 163 - 168. 



It is assumed that the functicm f of the n variables 
XI, . . . , Xjj (abbreviated as argument vector x) may 
be computed together with its gradient vegtor g(x) 
for any point x. The generalized Taylor expansion 
for functions of several variables is 



f (x+u) = f (X) + g(x) 



1 T 
u + - u G(x)u + higher terms 



where g is the gradient vector and G the matrix of 
second order partial derivatives. Vectors are as- 
sumed to be colimin vectors; u^means transpose of 
vector u. It is assumed that in the neighborhood of 
the required minimum x^j^^ the function is approxi- 
mated closely by the first three terms of its Taylor 
expansion, giving 

f(x) = f(xjnin) +1 (X - Xmin)^G(^in) <^ " ^in) 
since gCXj^^i^) = 0. Then the gradient is seen to be 
approximately g(x) = G(xniin) (x - Xmin)- 

Assume now that the symmetric matrix G is 
positive definite. Then the following equation holds 
true: 



G ^ (X. 



) • g(x) 



^"■min ^ ^'^min' 

which would allow x^^^^ to be calculated in one step 
if G"-*- (Xjj^jj) were available. 

To approach G~ (Xj^^^j^), a method of successive 
linear searches in G-conjugate directions is used. 
Starting with the identity matrix G^^) = I, a sequence 
of symmetric matrices g(^) is generated which tends 
to G"^. At the (i+1)^^ iteration step a linear search 
is made in direction hW = -oWgW , where g'^^ is 
an abbreviation for g(xW). By means of the linear 
search the minimum of y (t) = f (x(^) + t • h(^) is deter- 
mined, giving ai"gument x(i^l) = x(^) + ti • li(^), 

The argument of the minimum. x(i+l) on the line 
through x^^) in direction h^^^ is determined by the 
relation that scalar product (g^^"^^) , hW) = 0. 



Now: 



and: 



M) 



= x«). 



t. h 

1 



(i) 



Therefore: 



n-1 



n-1 



scalar product (g^"\ h^^^^ =53*. (Gh^^^ h^-'^ 

i=j+l 

Suppose now that the vectors h(*^) , h(^) , ..., 
h^'^-l) are G-conjugate, satisfying (Gh<^), h^J)) =0 
for i ^U Then (g(n) , h(J)) = 0, and since hW, hW, 
. . . , h<° ) form a basis , g^*^) = and x^'^) = Xmin- 
This shows that the minimum is located at the nth 
iteration for a quadratic function when using succes- 
sive linear searches for G-conjugate directions. 



Mathematics—Extremum of Functions 221 



For the generation of G-conjugate directions, 
start with h(0) = -g(0) and calculate successive 
directions h(^) by means of h''^) = -G^^'g^^', where 
G(i) is modified to G^^"*"^) so that h^^' is an eigen- 
vector of the matrix g'^"'"-'-) G with eigenvalue 1. 
This ensures that g(^) approaches G"-*^ as x(^) 
approaches Xjjjjjj. An easy calculation shows: 

r^fi + l) _ c<^> , dx • dx"^ G^^^dg • dg'^G^^^ 
dx^ • dg dg'^G^^^dg 
with dg = g(i+l) - g(i) 
dx=x(i+l) -x(i) 

where all vectors are regarded as column vectors, 
and superscript T means transpose of column 
vector — that is, row vector. 

The strategy adopted for termination of the suc- 
cessive linear searches is as follows: 

1. If the fvinction value has not decreased in the 
last iteration step, the search for the minimum is 
terminated provided the gradient is already suffi- 
ciently small; otherwise, the next step is in the 
direction of steepest descent. 

2. If the argument vector and the direction vec- 
tor change by very small amounts , and at least n 
iterations are performed, the minimization is ter- 
minated again. 

3. If the number of iterations exceeds an upper 
bound furnished by the user , further calculation is 
bypassed, and an error code is set to 1 indicating 
poor convergence. 

4. If one of the successive linear searches indi- 
cates that no constrained minimum exists, further 
calculation is bypassed again , and the error code is 
set to 2 indicating that it is likely that no minimum 
exists. 

The i*^ term G(i) is reset to the identity matrix if 
there is indication that the current g(i) is not posi- 
tive definite, or if the formula for G(i + ^) breaks 
down due to zero divisors. 

The linear search technique used in subroutines 
FMFP and DFMFP is as follows. For a given argu- 
ment vector X and vector h, defining a direction 
through X, a local minimum of the function y(t) = 
f(x+th) must be found. This means that a value t^^ 
must be determined for which 

y' (tm) = scalar product (g(x+tjnh),h) = 

From y'(0) = (g(x),h) < it is evident that a mini- 
mum y (tjji) < y(0) should be found for positive 
values of t. 

The calculation of the minimum is in three stages. 
The first estimates the magnitude of tj^^ , the second 
determines an interval containing tj^ , and the third 
interpolates the value of t^^. 



An estimate of the step-size may be obtained , 
assuming that the true value of the constrained 
minimum is equal to the estimated value EST of the 
imconstrained minimum and that y (t) is closely 
represented by a quadratic polynomial passing 
through (x, y(0)) with derivative y'(0): 
step =2 (EST -y(0))/y'(0). 

This equation tends to overestimate the step-size, 
since the unconstrained minimum will normally not 
lie on the line through x with direction h. Therefore, 
step is taken as step-size s only if it is positive and 
less than one. Otherwise, s = 1 is taken as step- 
size. 

At the second stage y(t) and y'(t) are examined at 
the points t = s, 2s, 4s,..., sj^, S2, where succes- 
sive values are obtained by doubling the step-size. 

This search is terminated at t = s, if: 

y'(s2) = 0, or y^sg) > 0, or y(s2) ^ y(si) 
n 

orifs2-( E |l^i|) > 10^°- 
i= 1 

The last case (search argument runs out of range) 
is interpreted as an indication that no local minimum 
exists on the given line. In this case, the error 
indicator is set to (2) and further calculation is 
bypassed. 

In case y'(s2) = 0, tm is set to S2 and x^^ = x = S2h 
is used as the argument of a constrained minimum on 
the line through x with direction h. 

In the second and third case (y'(S2)>0 and/or y(S2) 
>y(si) a minimum lies necessarily between si and S2. 
Its argument value gets approximated using cubic 
interpolation. 

The extrema of the cubic interpolation passing 
through (Sj^, yj^ =y(s^), y\ =y'(sj)) and (83, y2 = 
y(S2)> y'2 "^ y'(^2)) ^^^ given by solvi