LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN 510.84- U6r no. 403-^08 Cop.Z —-^^r^,^^^^.. The person charging this material is re- sponsible for its return to the library from which it was withdrawn on or before the Latest Date stamped below. Theft, mutilation, and underlining of books are reasons for disciplinary action and may result in dismissal from the University. To renew call Telephone Center, 333-8400 UNIVERSITY OF ILLINOIS LIBRARY AT URBANA-CHAMPAIGN DK 3 KB* L161— O-1096 Digitized by the Internet Archive in 2013 http://archive.org/details/sporrtsimplified405west I* for ^Report No. k05 ' V SPORRT: SIMPLIFIED POLYNOMIAL ROOT FINDING AT A REMOTE TERMINAL June, 1970 by Marilyn Dolores West JHEUBRARYOFTHE NOV 9 1972 UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN URBANA, ILLINOIS SPORRT : SIMPLIFIED ^ POLYNOMIAL ROOT FINDING AT A REMOTE TERMINAL BY MARILYN DOLORES WEST B.S., University of Illinois, 1969 THESIS Submitted in partial fulfillment of the requirements for the degree of Masters of Science in Computer Science in the Graduate College of the University of Illinois, 1970 Urbana, Illinois This work was supported in part by the National Science Foundation under Grant No. US NSF GP-9665 and was submitted in partial fulfillment for the degree of Master of Science in Computer Science, June, 1970* Ill ACKNOWLEDGMENT I wish to express my appreciation to Professor Lloyd Fosdick for his guidance in this project and to Dick Isler and Bruce Leasure for their beneficial discussions and suggestions. I also wish to thank my roommate Mary for her patience and encouragement throughout the writing of the program SPORRT and the preparation of this manuscript. IV TABLE OF CONTENTS Page I . INTRODUCTION 1 II . COMMANDS AND THEIR USE 3 Blanks 3 Errors 3 Illegal Commands k Entering Polynomials k Finding Roots 7 End of Commands 8 III . RESULTS 9 IV. ORGANIZATION OF THE FILES 11 POLOUT/File 10 11 FORTOUT Ik INITIAL/File ll/ANSWERS lk V. PROCESSING THE COMMAND LANGUAGE 15 NOERR 15 TRIM 16 SQUEEZE 16 FILECARD 16 POLHEAD 16 VALINT IT GETPOLY IT VALID 19 SIGN 20 DECPNT 20 INT 21 Main Program 21 NEXTLINE ' 21 INPUT 22 SETUP 2k VI . FINDING THE ROOTS 26 CALLER 26 FINDP 2T VII . GETTING THE ANSWERS (ROOTS ) 29 APPENDIX A. LISTING OF SPORRT 30 B. SAMPLE USER/SPORRT COMMUNICATION (COMMAND PROCESSING) 1+3 C . SAMPLE RESULTS H5 I. INTRODUCTION The program called SPORRT is a quasi-interactive system to allow a user, having no special knowledge of mathematics or programming, to find the roots of polynomials from a time-sharing terminal. The user must enter all the polynomials he wishes to be solved "before any of the roots are found. The accuracy of the roots found depends on the particular numerical routine used. Originally, SPORRT used RSSR, a root-solving routine which could work only on polynomials with real coefficients. To overcome this restriction, SPORRT currently uses TRAUBZ, a root-solving routine that can work on polynomials with com- plex coefficients. SPORRT can handle a maximum of ninety-nine polynomials , and the degree of each polynomial must be between one and fifty. The RSSR routine had a set limit of fifty. When the change to TRAUBZ was made, the same limit on the degree was retained because of error considerations The accuracy of the k-th root found depends on the accuracy of the previous k-1 roots found if the k-th root is solved from P . ,-,(x), n-k+1 the reduced polynomial derived from the n-th degree polynomial P (x) by dividing out the k-1 factors (x - root.) for i = 1,2,..., k-1. As the degree of the polynomial increases, the error induced by such a reduction scheme usually increases. With this approach, one should probably not attempt to find roots of polynomials greater than degree twenty. Although the user is allowed to enter polynomials of degree greater than twenty, he should be aware that the error may be large for such large polynomials. 2 SPORRT consists mainly of three separate though interrelated parts: a PL/1 program to process a simplified command language to request the finding of the roots of certain polynomials and to obtain further in- formation concerning these polynomials; a FORTRAN program to find the roots; a PL/1 program to print out the results of the root-finding routine. In order that these three separate routines may communicate "with each other, three files are necessary. First of all, the polynomials are stored on a polynomial file in a semi -linked list and identified by what is called a polynomial number or name (this will be described later). As the commands are being processed by the first PL/1 routine, a main FORTRAN program is generated on a second file. This main pro- gram later calls the necessary subroutines to locate the polynomials on the first file, to find their roots, and to store the answers on the third file. The last PL/1 routine simply reads and prints out the contents of this answer file. Appendix C contains a listing of the program SPORRT, with the exception of the TRAUBZ routine. II. COMMANDS AND THEIR USE There are three kinds of commands given by the user. All other information is requested by SPORRT; the order and manner of such requests will be described under the topic of the specific commands which initiate these requests. Appendix B contains a sample of the communication between SPORRT and the user during the processing of the user's commands. Blanks . Blanks are not important in any of the commands or answers to requests — indeed, they are completely ignored. They may be added or deleted at will by the user. Errors . If the user makes an error in typing either a command or an answer to a request, he should type the characters ERR on the same line and then type the correct commend or answer. Anything to the left of ERR (and including it) is ignored; therefore, the whole command or answer must be printed to the right of ERR. If there is not enough room remaining on that line, he should not print anything on that line, or else that segment will be interpreted as a complete command or answer. Such a segment may or may not be caught as an illegal command or incorrect answer. The error indication, ERR, may be used any number of times on a line. On any line not having enough room for the correct version of k an answer or command, the last non-blank characters should he ERR. In the case of a command, the user should simply print the entire correct command on the next line. For an answer, there will be a specific request for repetition of the answer until one of the correct format is given; such requests are described under the appropriate section below. Illegal Commands . When a command supplied by the user is not of the correct format for any one of the three allowable types, then the message ILLEGAL COMMAND, PLEASE REPEAT is printed out. In that case, the user should type the command in the correct format on the next line. Sometimes a command is partially processed, but then an error is detected, in which case a specific error message is printed out. Such messages are described below. Entering Polynomials . To enter a polynomial, the user should type the command ENTER POLY Pk where k is an integer, 1 ^ Is. 4. 99. This integer, called a polynomial number (or name), is used from then on to identify the specific poly- nomial about to be entered. If the number is not in the range from one to ninety-nine or if character other than a digit appears where this integer is expected, the message 5 Pw IS NOT A LEGAL POLYNOMIAL NAME is printed out, where w is the character string appearing in the command in place of a correct integer. Since any number of polynomials (up to ninety-nine) may "be entered, this polynomial number must be unique; if a polynomial has already been entered with the same integer k,the message Pk HAS ALREADY BEEN ENTERED is printed out. In this case, the user should re-type the command, using a new (and distinct) polynomial number. Once an acceptable ENTER POLY Pn command has been processed, a small routine will re- quest the degree of the polynomial by printing DEGREE OF POLYNOMIAL - The user should then type the degree n, where 1 < n < 50. If a blank answer is received (or an answer followed by ERR), the message DID NOT RECEIVE DEGREE OF POLYNOMIAL, PLEASE REPEAT is printed, followed by a repeat of the request for the degree. If an erroneous degree is received (n is too small or too' large or the answer is a character string w with non-numeric characters) the message w IS NOT A LEGAL DEGREE OF POLYNOMIAL is printed. If, however, n is a legal polynomial degree, the n+1 coefficients of this polynomial are then requested. If all the n+1 coefficients are real, asking for the real and imaginary parts of each coefficient would be wasteful. Therefore, the request ARE ALL COEFFICIENTS REAL? is printed. The user then prints his answer, either YES or NO. If the answer is YES, then the coefficients are requested by n+1 uses of the request COEFF( J )= where j is the subscript of the coefficient being requested. If not all coefficients are real (that is, if the answer was NO), then the real and imaginary parts of each coefficient are requested separately by the requests REAL COEFF( j )= and IMAG COEFF( J )= Regardless of the type of coefficient requests used, the j-th coefficient is that number multiplied by x , i.e., the polynomial is n , n-1 , c.x + C_X + +CX + C ,_ 12 n n+1 ollowing the coefficient request, the user must type the j-th coefficient in one of the acceptable formats. An example will be used to explain the acceptable forms. The number -237.0 may be typed in any one of the following forms and be correctly interpreted: -237 -237D00 -23.7D1 -23700D-2 r. -237- DO -2.370D02 -23700. D-2 . -237-OODO -2.237D3 etc . where aDm means that the number c is c = a(lO) m If the command representing the j-th coefficient consists of only blanks, or if the right-most non-blank characters are ERR, then DID NOT RECEIVE COEFF( j ), PLEASE REPEAT is printed, and the coefficient request is repeated. If a number is typed but is not one of the acceptable forms, then COEFF( J ) IS NOT A LEGAL COEFFICIENT NUMBER, PLEASE REPEAT is printed, and the coefficient request is repeated. It is important to note that until the degree and all the n+1 coefficients are received, no other command is accepted, but is in- terpreted as an incorrect response to the degree or coefficient request. Also, once a coefficient has been accepted, it cannot be corrected. If the user has made such an error, he should answer the remaining coefficient requests for that polynomial. He may then enter a new polynomial (with a new polynomial number) having the coefficients he originally intended. He need not request the solving of the roots of the polynomial whose coefficients he incorrectly entered. Finding Roots . In order to request the computation of the roots of a specific polynomial, the user must type the command SOLVE Pk = where k is the polynomial number of one of the polynomials already entered. 8 If k is not an integer of the correct form or magnitude as described above, then the message Pw IS NOT A LEGAL POLYNOMIAL NAME is printed, where w is the character string given in place of a correct integer. The command is then treated as an illegal command (the message for illegal commands is printed, etc.). If n is a legal polynomial number, a check is made to determine whether this polynomial has already been entered. If not, the message Pk HAS NOT BEEN ENTERED is printed, and the command is ignored. SPORRT does not check whether or not anything follows the SOLVE Pk = command. If anything is to the right of the "=0 M , it is ignored; the command would not be illegal, but the remainder has no bearing on the interpretation of the command. End of Commands . When all the necessary polynomials have been entered and all the necessary solve commands have been accepted, the user should type the command END Until this command is typed, the program cannot continue. Once this :ommand is accepted by SPORRT, no more polynomials can be entered, and no more solve commands can be typed. III. RESULTS For every polynomial whose roots are to be found, the statement SOLVE Pi = is printed, where i is the polynomial number identifying the poly- nomial in question. If the root-finding routine is able to find all n roots, the statement ALL n ROOTS HAVE BEER FOUND. Then all n roots are printed in the form ROOT ( j ) = ( a , b ) where a is the real part and b the imaginary part of the j-th root, for 1 < j < n. If not all n roots were found, different statements are printed. For example, if m roots are found, then k = n - m roots have not been found, and there is a k-th degree "unresolved polynomial factor" whose roots are the k unfound roots. In this case, the statements DEGREE OF UNRESOLVED POLYNOMIAL FACTOR = k ITS COEFFICIENTS ARE are printed. Then the k+1 coefficients of this unresolved polynomial factor are printed in the form A(j) = ( c, b ) for 1 < j < k + 1, where c is the real part and b the imaginary part n-j+1 of the j-th coefficient, the number multiplied by x ; i.e., the unresolved factor is 10 k k-1 a, x + a^x + . . . + \ X + \+l The the message ONLY m ROOTS HAVE BEEN FOUND, is printed, followed by the found roots printed in the form described above, but in this case for (k+l) < j < n. Appendix C contains a sample of the output from the ANSWER file. 11 IV. ORGANIZATION OF THE FILES Since the program called SPORRT actually consists of three separate, though, interrelated, parts (a large PL/1 program, a FORTRAN program, and a short PL/l program), three files are necessary to provide communication among the separate routines. POLOUT/File 10 This file, called P0L0UT by the first PL/1 program and File 10 "by the FORTRAN program, contains all the polynomials entered by the user stored in a semi-linked list and identified by what is called a polynomial number or name (an integer between one and ninety-nine). Each record has a length of twenty-three bytes. A polynomial of degree n takes up 2n+3 records: one for a header record, and the rest for the n+1 coefficients of the polynomial (since the real and imaginary parts of each coefficient are stored on separate records). The header record contains three items of information: an integer number identifying the polynomial, an integer pointer to the header of the next polynomial header, and the integer degree of this polynomial. These numbers are right- justified in the following characters of the header record (the remaining characters are blank): characters information 1 - 2 polynomial number 3 - 7 the pointer 22 - 23 the degree In the coefficient records, the double precision floating point numbers (in D exponential form) are right-justified, with blanks in the remaining characters. 12 I call POLOUT a semi-linked list because each header record contains a pointer (link) to the next header record, and yet this pointer is not used directly as a link in searching the file. At first, I used a direct access organization, utilizing a relative track address, via a file pointer. With this direct access method, I could have only one record per block, and therefore a separate direct access to the file was required for each record read. To decrease the number of direct accesses without drastically changing my whole file organization, I changed to what I call a semi-linked list. Though it is essentially a sequential file, I still utilize the old links between header records to skip past the records containing coefficients of a polynomial to be by-passed in the search for the desired polynomial. In this new organization, a whole block of 7268 bytes, or 3l6 records (23 bytes per record), is stored in core at one time, and then these records are read from core, thus decreasing the time involved in searching through the file and in reading the coefficients. In order to by-pass certain records, SPORRT reads them with an (Al) format, thus reading one character only from a record while avoiding any time-consuming conversion. would like to suggest improvements over my file organization, ^uld have been simpler to store the header records separate from 'icient records. Then the relatively short list of header ■ Ld be searched sequentially in order to find the location of •.oefficients of the desired polynomial. 13 One method would be to have two separate files , one with the polynomial coefficients, and the other with the header records, each containing a link to the first coefficient of that polynomial. How- ever, if a direct access organization is used, fixed blocks of more than one record cannot be used. And a separate direct access for each record could be time-consuming. Therefore, with this method, a sequential file of the coefficients should be used (rather than the direct access), where the necessary number of records are by-passed until the desired polynomial is reached. Another possibility would be to store the polynomials in separate blocks of variable length, with the file of header records containing pointers to the required block of coefficients. However, if would be even better to store the coefficients and the header records on the same file, but separately. The file could contain blocks of variable length. The first block could be reserved for the header records — this would necessitate reserving a block of some specified length. One possibility would be to require the user initially to specify the maximum number of polynomials he wishes to solve. However, this may be an undesirable restriction. If the user entered an incorrect coefficient, without realizing his error in time to correct it, he might wish also to enter the correct polynomial, thus increasing the number of polynomials to be stored on file. A solution to this problem would be to reserve a block for header records with a number of records equal to the maximum number of polynomials that could 11+ "be stored (for SPORRT, this would be 99)- After all polynomials are stored on the file, the list of header records would be stored in that first block. Each of the polynomials would be stored in a separate block of only the necessary number of records to store the coefficients (thus, the true desirability of variable-length blocks). FORTOUT This file contains the main FORTRAN program which is generated by the first PL/l program and is used in the FORTRAN program to call the necessary root-finding routines. The records, which have a length of eighty characters, each represent one card containing a FORTRAN statement. INITIAL/FILE 11/ANSWERS Called INITIAL by the first PL/l program, File 11 by the FORTRAN program, and ANSWERS by the second PL/l program, this file contains the answers (roots, and reduced polynomial factor, if appropriate) from the RTRAN root-finding routines. The first PL/l routine blanks out the necessary number of records so that the end-of-file marker will not be encountered by the FORTRAN program before all the answers are stored in file. The second PL/l program simply reads and prints out all of this file. When the program SPORRT is added to the system or use at the remote terminals, the record length of this file (as i as the number of characters in the character string BLANKS in first PL/l program) will have to be adjusted to the width of a page on the remote terminal. his sequential file consists of fixed blocks of 7280 bytes, or 91 '-•s per record). 15 V. PROCESSING THE COMMAND LANGUAGE The first PL/l program processes the simplified command language from the remote terminal. Certain routines are necessary to perform specific tasks. Each will be discussed by its name before the main program itself is discussed. NOERR The character string called ORDER is the only argument to this routine. NOERR checks for the occurrence of the characters ERR in ORDER; if these characters do appear, then everything to the left of (and including) the letters ERR is ignored — that is, ORDER is set equal to the remainder (what appeared to the right of ERR). This process is repeated until ERR no longer appears in ORDER. As a result, since ORDER represented a command from the remote terminal, only that part of the original command following the right- most occurrence of ERR is retained in the string ORDER. And since ERR indicates an error in the previous part of ORDER, NOERR performs the corrections on ORDER indicated by the user. Since PL/l has the INDEX, LENGTH, and SUBSTR (substring) functions it is much more straight-forward to check for ERR from left to right. INDEX tells us immediately whether the letters E, R, and R appear consecutively in ORDER. Without INDEX, all the characters of ORDER would have to be compared separately (from right to left) to R; if a character of ORDER does equal R, then the next two characters (to the left) would have to be compared to R and E, etc. This process would be at least as involved and time-consuming as the method used by NOERR. 16 TRIM This routine removes trailing blanks from the string ORDER. Then a check is made on the length of the remaining string. TRIM returns a value of 1 if the string has heen reduced to a null character string, which would happen only if ORDER had originally consisted only of blanks. If the string has characters remaining (naturally, they are non-blank), TRIM returns a value of 0. SQUEEZE This routine removes all initial and intermediate blanks from the string ORDER. First all initial blanks are removed, and then all intermediate blanks. FILECARD This is used in generating the main FORTRAN program on the file F0RT0UT. FILECARD generates an 80-character long character structure representing the contents of a card having a FORTRAN statement. 'Columns" 1-6 and 73-80 are always blank. The FORTRAN statement part, called FORTSTMT, is provided as an argument to this routine. Once this "card" is generated, it is stored on the file F0RT0UT. Then the 80-character structure representing the card is re-set to blanks. .HEAD This routine sets up a header record for a polynomial and writes LOUT file. Arguments to this routine are PNUM, the ication number for this polynomial, NXTPOL, a pointer for the , the degree of this polynomial. NXTPOL is used to 17 point to the record in POLOUT to hold the header for the next poly- nomial, so it is incremented by 2*N+3 (since each N-th degree poly- nomial requires a header record plus 2*(N+l) records for its coefficients). The organization of the header record is described in the section on organization of the files. VALINT Given the arguments STRING, and character string, and MAX, an integer, this routine checks whether STRING represents a valid integer NDEG, where 1 .< NDEG ^ MAX. First , each character of STRING is checked to be a numerical digit. If all characters are digits, then the numerical value of this string is checked. If the number is valid (all digits and value within the desired limits) then a value (via the variable FLAG) of is returned; otherwise, a value (FLAG) of 1 is returned. This routine is used for two purposes. If MAX equals 50, VALINT is checking whether STRING represents a valid degree of a polynomial. If MAX is 99, VALINT is checking whether STRING represents a valid polynomial number. The appropriate error messages are printed out by the sections of the main program calling this routine. GETPOLY This routine requests (and stores in the file POLOUT) the N+l coefficients of a polynomial, where N is provided as an argument to this routine. The real and imaginary parts of each coefficient are stored in separate records of the POLOUT file. 18 If all coefficients of a polynomial are real, then their imaginary parts are all zero, and it would be time-consuming and annoying for the user to have to answer requests for the zero imaginary part of N+l coefficients. Therefore, there are two sets of polynomial coefficient requests: one for polynomials with all real coefficients and one for polynomials with complex coefficients. In order to determine which requests should he used, the question ARE ALL COEFFICIENTS REAL? is printed. The user's answer must he either YES or NO. If the answer is blank, the message DID NOT RECEIVE ANSWER, PLEASE REPEAT is printed. If a non-blank but incorrect answer w is received, the message w IS NOT A LEGAL ANSWER, PLEASE REPEAT is printed. In either case, the question is repeated. If an answer YES is received, then only the real part of each coefficient is requested by COEFF( j ) = where j is the appropriate subscript (see the section on entering polynomials in Chapter II for the correct order of coefficients). The user's reply is stored in the character string ORDER. /t, NOERR and TRIM are called. If the result is a null string, •3 sage 19 DID NOT RECEIVE COEFFICIENT ( J ), PLEASE REPEAT is printed, followed by the same coefficient request. If the resulting string is not null, SQUEEZE is called, and the result is stored in NUMB, another character string. Next, the validity of the coefficient represented by NUMB is checked by calling VALID. If it is invalid, the message COEFF( j ) IS NOT A LEGAL COEFFICIENT NUMBER is printed, followed by the same coefficient request. If NUMB is valid, it is written (right-justified) onto the next record of the POLOUT file. Then the number 0.D0 is automatically stored onto the next record of POLOUT (representing the imaginary part of the j-th coefficient) . If not all coefficients of the polynomial are real (that is, an answer of NO was received for the question), then the real and imaginary parts of each polynomial are requested by REAL COEFF( J ) = and IMAG COEFF( j ) = where j is the appropriate subscript. The same checks and error messages apply to these requests as to the requests for only real coefficients. VALID VALID determines whether a coefficient, stored in a character string NUMBER, is a valid form of a double precision floating point number. If necessary, attempts are made to correct NUMBER (if, indeed, 20 it is possible to do so). Finally, LFLAG is set to one if NUMBER represents an invalid coefficient (after attempts are made at correction); otherwise, LFLAG is set to zero. NUMBER and LFLAG are the arguments to this routine. NPT, a pointer, and CHR, a one-character string, are used to check each character of NUMBER individually. PTFLAG is used to determine whether a decimal point has been encountered (if so, this bit is set to one by the DECPNT routine; otherwise, it is zero). The SIGN routine checks the first character of NUMBER for a plus or a minus. The D (for double precision) exponential form is allowed. In fact, if this form is not used, a DO is added to the end of NUMBER. If a decimal point was not encountered, one is inserted immediately before the D. SIGN This is a short routine to check whether a particular character in a character string, NUMBER, is either a plus (+) or a minus (-) sign. NUMBER and NPT, which serves as a pointer to a particular character in NUMBER, are both provided as arguments to the routine. If this particular character, called CHR, is a plus or a minus sign, then NPT is incremented by one. :PHT . checks whether a particular character, CHR, in a character is a decimal point. NUMBER, NPT, which is used as a , and PTFLAG, are all arguments to this routine. 21 PTFLAG is a bit string of length one bit: when DECPNT is called, PTFLAG has the value zero. If CHR is a decimal point, then two operations are performed: PTFLAG is set to a one, and NPT is increased by one. INT INT checks for the occurrence of one or more integers in a certain part of a character string NUMBER. NUMBER, NPT, a pointer to a specific character (CHR) in NUMBER, and ERROR are arguments to this routine. ERROR, a one-character string, is originally set to a blank. CHR is always set equal to the character in NUMBER pointed to by the current value of NPT. If, in this portion of NUMBER there is no integer at all, then ERROR is set equal to CHR and this routine returns. If, however, there are one or more integers in this portion of NUMBER, NPT is reset to point to the first non-integer character following this portion of NUMBER, and this routine returns. Main Program The main program consists of three important sections, which will be referred to by the label beginning that section. NEXTLINE This section serves to read commands from the console and to choose the appropriate section of code to process the command. It reads one line from the console, stores it in the character string ORDER, calls NOERR to eliminate all but the intended portion of the command, and calls TRIM and SQUEEZE to remove all blanks. If the remainder is null, the next line is read. 22 If the remainder is non-null, it is compared to the legal commands. If the first ten characters are ENTERPOLYP indicating a desire to enter a polynomial, the program transfers to the section called INPUT. If the first six characters are SOLVEP indicating a desire to find the roots of a particular polynomial, then the program transfers to the section called SETUP. If the first three characters are END indicating that the user is finished, the FORTRAN instructions STOP END are generated onto the FORTOUT file, and this first PL/1 program terminates. If, however, none of these three commands match what was read into ORDER, the message ILLEGAL COMMAND, PLEASE CORRECT : printed, and control is transferred to the beginning of NEXTLINE. INPUT section is used to handle the entering of a polynomial after rid beginning with ENTERPOLYP is read. PTOT, which serves as ount of the number of polynomials entered, is incremented by one. M, 1 character string for the identifying polynomial number (or 23 name) is extracted from the remainder of ORDER (after ENTERPOLYP), and checks are made to determine whether it is a valid polynomial number and if it has already been used for entering a previous poly- nomial. VALINT is called to check whether PNUM is an integer between one and ninety-nine; if not, then the message Pw IS NOT A LEGAL POLYNOMIAL NAME is printed, where w was the invalid polynomial name provided by the user. If PNUM was used previously, the message Pk HAS ALREADY BEEN ENTERED is printed, where k was the polynomial number. In either case, PTOT is decreased by one, and the program transfers to the section NEXTLINE. If PNUM is a correct new number, the degree of the polynomial is next requested by DEGREE OF POLYNOMIAL = The answer, read from the console and stored in ORDER, is checked ("by calling VALINT) to determine whether it is a number between one and fifty. If ORDER is null, the message DID NOT RECEIVE DEGREE OF POLYNOMIAL, PLEASE REPEAT is printed, and the request for the degree is repeated. If ORDER is non-null, but not of the correct form, the message w IS NOT A LEGAL DEGREE OF POLYNOMIAL is printed, where w was the invalid degree provided by the user, and the request for the degree is repeated. 2k If a valid degree was given, then the POLHEAD and GETPOLY routines are called for setting up a polynomial header on POLOUT and for re- questing the coefficients and storing them on POLOUT. PREC, which serves as the count of records used on file POLOUT, in increased by 2n+3, where n is the polynomial degree. Then control is transferred to NEXTLINE. SETUP This routine serves to generate the necessary calling statements for the main FORTRAN program on FORTOUT. ORDER is known to have begun with SOLVEP. The occurrence of '=0' in ORDER is checked. If it does not occur, or if there are fewer than two characters between the P and the = then the message for illegal commands is printed. PNUM is set equal to those characters between the P and the =. VALINT is called to check whether PNUM is an integer between one and ninety-nine. If not, the message Pw IS NOT A LEGAL POLYNOMIAL NAME is printed, where w is the invalid polynomial name, followed by the message for illegal commands. Then a check is made to see that the polynomial with this number has already been entered. If not, the message Pk HAS NOT BEEN ENTERED is printed, where k is the polynomial name, and control is transferred to NEXTLi:. If there are no errors, then the FORTRAN statement CALL CALLER ( J , n , k ) 25 is generated onto FORTOUT, where j is the polynomial number PNUM, n is the degree of this polynomial, and k is PREC, the number, so far, of records used on the POLOUT file. Then the necessary number of blank records (n+6 to allow for extra messages) are added to the ANSWER /INITIAL file. (This was found to be necessary to avoid encountering the end-of-file mark on this file when storing answers on it in the FORTRAN Program). Finally, control is transferred to NEXTLINE. 26 VI. FINDING THE ROOTS The main FORTRAN program is generated by the first PL/1 program and is stored on file. It consists of one call statement per poly- nomial to be solved. Each is of the form CALL CALLER ( k , n , J ) where k is the identification number, n the degree of the polynomial, and j is the maximum number of records on the polynomial file after polynomial k was entered. While the numerical root-solving routine, TRAUBZ , will not be discussed, two important subroutines, CALLER and FINDP, will now be described. CALLER This subroutine is called by the main FORTRAN program (which was generated onto a file) and is given PNUM (the identification number for a polynomial), N(the degree of the polynomial), and PREC (the maximum number of records on the polynomial file after PNUM was entered) CALLER calls FINDP to reach the correct part of the polynomial file. On return from FINDP, if NOPOL has a value of one, the polynomial PNUM could not be found on the polynomial file, so the error message UNABLE TO LOCATE POLYNOMIAL Pk printed, where k is PNUM, and CALLER returns control to the main program. If, however, NOPOL has the value zero, the polynomial has been found, and CALLER reads the real and imaginary parts of the N+l B separately, stores them in a complex* l6 array and calls ine to solve for the roots. 27 On return from TRAUBZ, NRTFND has the total number of roots actually found. If NRTFND equals N, then the message • ALL n ROOTS HAVE BEEN FOUND: is printed, followed by the list of N roots printed in the form ROOT( J ) = ( a , b ) where a is the real part and b the imaginary part of the j-th root. If NRTFND does not equal N, then the message ONLY k ROOTS HAVE BEEN FOUND: is printed, where k is NRTFND, followed by the list of NRTFND roots. Next, the message DEGREE OF UNRESOLVED POLYNOMIAL FACTOR = m is printed, where m = N - NRTFND. Then the coefficients of this polynomial are printed in the form C( j ) = ( d, e ) where d is the real part and e the imaginary part of the j-th coefficient FINDP The subroutine FINDP searches through the polynomial file for the header record for the polynomial with the identification number PNUM. The search is completed successfully when the correct header record is found. An unsuccessful search is stopped when either PREC records have been searched (where PREC is the maximum number of records on the file after polynomial PNUM was entered) or when the whole file has been searched. In the first case, where polynomial PNUM has been found, FINDP has read the header record and hence the next record to be read 28 contains the (real part of the) first coefficient of the required polynomial. Then NOPOL is set to zero to indicate a successful search. If, on the other hand, the search is unsuccessful, NOPOL is set to one. In performing the search, FINDP first rewinds the polynomial file. Then the file is simply read sequentially. If a header record for polynomial PN of degree N is read, but PN is not equal to PNUM, then the next 2*(N+l) records are read with an (Al) field. This avoids a time-consuming conversion and yet by-passes the necessary records. This method of reading from the file was found to be faster than using a pointer in a linked list. 29 VII. GETTING THE ANSWERS (ROOTS) The last PL/1 program simply reads and prints out the answers (roots and, if appropriate, the reduced polynomial factor) from the ANSWERS file. Appendix A contains the listing of this routine. For a sample output from this routine, see Appendix B. 30 APPENDIX A LISTING OF SPORRT ^FORMAT PR,DDNAME=SYSMSG,TRAIN=PL1 FXEC PL1LKG0,TIME.G0=(3,00) /PL1.SYSIN OD * POLROOT: PROCEDURE OPTIONS (MAIN) 31 DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL MSG1 MSG2 MSG3 MSG4 MSG5 PNUM CHAR(5) VAR, NXTPOL BIN FIXED INIT ( 1 ) ; TEMP CHAR(15) VAR ; CHAR(66) VA FILF OUTPUT FILE OUTPUT FILF OUTPUT INIT ( 'P' ) ; •STOP' ) ; l't , 2S , 3S , 4 , , , 5 , t , 6 , , l 7 l , , 8 , , , 9 , , , l )i T (1) ; T (0) ; (2) VAR; FTSTMT POLOUT INITIAL FORTOUT CHAR( 1 ) CHAR ( 15) CHAR( 16) CHAR (21 ) CHAR(21 ) r; environment environment (F(7268,23) ) ; (F(7280,80) ) ; I'LL nj«J 1/HHiMti / DCL MSG6 CHAR(15) DCL MSG7 CHAR(16) DCL MSG8 CHAR(7) DCL MSG9 CHAR(4) DCL DCL DCL DCL INIT INIT INIT INIT INIT INIT INIT INIT ( • ( ' ( • ( • ( • ( ' ■ IS PO DE HA , P DI COE NOT A LEGAL' ) ; LYNOMIAL NAME 1 ) ; GREE OF POLYNOMIAL ' ) ; S NOT BEEN ENTERED 1 ) ; LFASE REPEAT' ) ; D NOT RECEIVE* ) ; FF( ' ) ; • ); AS ALRFADY BEEN ENTERED'); COEFFICIENT NUMBER' ) ; RE ALL COEFFICIENTS REAL?'); SWER • ) ; UlL KtLUKU LMAK I DCL 1 INIT ( (5 INIT ( • INIT ( DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DCL DC DCL ANS(2) FORTCARD, 2 ST# CHAR(5) 2 CONT CHAR( 1 ) 2 STMT CHAR(66) 2 SEQ# CHAR(6) INIT ( ( GFTPOLY ENTRY (BIN FIXE TRIM ENTRY (CHAR(*) VAR SQUEEZE ENTRY (CHAR(*) FILFCARD ENTRY (CHAR(*) NOERR ENTRY (CHAR(*) VA POLHEAD ENTRY (CHAR(*) ENTRY (CHAR(23) FIXED, IT ( (80) ' • ) ; IT ( • REAL ' t ' IMAG ' ) ; CHAR(3) VAR INIT ( ' Y ES • , ' NO • ) ; V VALID SIGN ENTRY (BIN INT ENTRY (CHAR(23) VAR DECPNT ENTRY (CHAR(23) VALINT ENTRY (CHAR(*) V ) ' • ) (66 6) • D) ; ) R VAR VA R) ; VAR AR, CHA » B VAR AR, ' ), ) ' ' ) , • >; ETURMS ) ; R) ; (BIN FIXED) ,BIN FIXED, CHAR(*) VAR) ; BIN FIXED) ; R(23) VAR); IN FIXED, CHAR( 1 ) ) ; , BIN FIXED, BIT (1 ) ) ; BIN FIXED) RETURNS (BIN FIXED); /* GETPOLY REQUESTS (AND STORES IN FILE POLOUT) 32 THE (DEGREE + 1) GETPOLY: PROCEDURE (DEGREE) DCL DEGREE BIN FIXED; DCL NUMB CHAR(23) VAR; DCL j»k; KIND: PUT GET PUT PUT CALL COEFFICIENTS OF THE POLYNOMIAL. */ EDIT (MSG12) EDIT (ORDER) EDIT (ORDER) SKIP; NOERR(ORDER) ; (A) ; ( A(80) ) (A) ; DO; / IF TRIM(ORDER) = 1 THEN NO ANSWER AT ALL. */ PUT EDIT (MSG7,MSG13,MSG6) PUT SKIP; GO TO KIND; ( A, A, A ) END; J = 1 ORDER THEN GO TO SET KIND; /* /* SFT COFFF DO J = 1 TO 2; IF ORDER = ANS(J) END; NON-BLANK ANSWER NEITHER 'YES' NOR 'NO'. #/ PUT EDIT (ORDFRtMSG2 t MSG13,MSG6) (A, A, A, A); PUT SKIP; GO TO KIND; ITYP = 1 IF ALL COEFF'S REAL; OTHERWISE, ITYP = KIND: ITYP = J; DO J = 1 TO DEGREE + 1; K = l; */ REPEAT: GET PUT PUT CALL IF IF ITYP = 1 THEN PUT EDIT ( MSG8 , J » MSG9 ) (A,F(2),A); ELSE PUT EDIT ( TYP E ( K ) , MSG8 , J , MSG9 ) ( A , A , F ( 2 ) , A ) ; EDIT (ORDER) (A(80)); EDIT (ORDER) (A); SKIP; NOERR(ORDER) ; TRIM(ORDER) = 1 THEN DO; PUT EDIT (MSG7,MSG8, J,' ) ' ,MSG6) ( A , A , F ( 2 ) t A , A ) ; PUT SKIP; GO TO REPEAT; END; CALL SQUFFZE(ORDFR) ; NUMB = ORDER; CALL VALID ( NUMB , L FLAG ) ; IF LFLAG = 1 THEN DO; PUT FDIT (MSGStJ, • ) • »MSG2,MSG11»MSG6) ( A , F ( 2 ) , A , A , A ) ; PUT SKIP; GO TO RFPFAT; END; NOW. LEN = LENGTH (NUMB) ; I ) = (23) ' ' ; ;UBSTR(REC0RD t 24-LEN f LEN) = NUMB; WPITF- FILF (POI.OUT) FROM (RECORD); h-ih I ( 'COEFF i SKIP; ? THEN GO K 2 : : 2 Tl now; ON POLOUT: •, RECORD) ( A ( 1 7 ) , A ( 2 3 ) ) TO FC; GO TO RFPEAT; EC: END COEFF; END GETPOLY; 33 /* NQERR REMOVES THE INCORRECT ENTRIES LINE FROM THE CONSOLE. NOERR: PROCEDURE (ORDER); DCL ORDER CHAR (*) VAR ; FINDERR: IR = I NDEX ( ORDER , • ERR ' ) ; IF IR = THEN RETURN; ORDER = SUBSTR(ORDER, IR + 3); END NOERR; FROM GO TO findfrr; /* TRIM REMOVES TRAILING BLANKS FROM ORDER (FROM CONSOLE). ON RETURN FROM TRIM, FLAG = 1 IF ORDER HAS BEEN REDUCED TO A NULL CHAR STRING (IT HAD CONSISTED ONLY OF BLANKS). */ TRIM: PROCEDURE (ORDER) BIN FIXED; DCL ORDER CHAR (*) VAR, FLAG BIN FIXED; FLAG = l; LEN = LENGTH ( ORDER ) ; TRAILING: DO I = LEN TO 1 BY -1 ; IF SUBSTR (ORDER, I , 1 ) -.= • ' THEN DO; FLAG = 0; GO TO SHORTEN; END; END TRAILING; SHORTEN: IF FLAG = THEN ORDER = SUBSTR ( ORDER , 1 , I ) ; RETURN (FLAG); END TRIM; /* SQUEEZE REMOVES INITIAL AND INTERMEDIATE BLANKS FROM ORDER (FROM CONSOLE). */ SQUEEZE: PROCEDURF (ORDER); END SQUEEZE; 3k FILECARD: PROC (FORTSTMT); DCL FORTSTMT CHAR(*) VAR; SUB STR(STMT,1, LENGTH (FORT STMT) ) = FORTSTMT; PUT FILF (FORTOUT) PUT EDIT (FORTCARD) ST# = (5 ) • ' ; CONT = • • ; STMT = (66) ' • SE(0# = (6) • • ; RETURN; END FILECARD? EDIT (FORTCARD) ( A ( 5 ) , A ( 1 ) , A ( 66 ) t A ( 8 ) ) ; (A(5) ,A( 1) ,A(66) ,A(8) ) ; PUT SKIP; /* SET UP HEADER RECORD FOR A POLYNOMIAL AND WRITE IT THE POLOUT FILE. */ POLHEAD: PROC ( PNUM , NXTPOL ,N ) ; DCL NXTPOL5 DCL PNUM CHAR(*) VAR; DCL N CHAR(*) VAR; DCL PTR CHAR( 15) VAR; DCL (LPNUM,LPTR,LN) BIN FIXED; NXTPOL = NXTPOL + 2*N + 3; PTR = CHAR(NXTPOL ) ; CALL SQUFEZE(PTR) ; LPNUM = LENGTH(PNUM) ; LPTR = LENGTH(PTR) ; LN = LENGTH(M) ; RECORD = (23 ) • ' ; SUBSTR (RECORD, 3-LPNUM, LPNUM) = PNUM; SUBSTR(RECORD,8-LPTR,LPTR ) = PTR; SUBSTR (RECORD, 24-LN,LN) = N; WRITE FILE (POLOUT) FROM (RFCORD); ON PUT EDIT PUT SKIP; RECORD = RETURN; FND POLHEAD; (•POLHEAD: ', RECORD) (A(9),A(23)) (23 ) • • /* DETERMINE WHFTHER COEFFICIENT READ IN IS A VALID FORM OF A REAL NUMBER. PATCH UP IF NECESSARY AND POSSIBLF. LFLAG=1 IF INVALID. LFLAG=0 IF VALID REAL NUMBER. * / VALID: PROC (NUMBER, LFLAG) ; DCL CHR CHAR ( 1 ) ; FRROR CHAR ( 1 ) ; PTFLAG BIT( 1 ) INIT ( »0'B) ; DCL DCL DCL NkT = I LFLA',; NUMBER CHAk(?3) VAR; NPT; LNMht' ; MG fH(NUMBf-R ) ; 0? /* NPT IS A STRING POINTER */ IN (NPT ,NUMBFR ) 35 REALNO QPTD ERRMSG ADDDO END CALL CALL IE ER IE PT CALL IE PT CALL IE ER IF NP CHR = IE CH IE PT NUMB NPT END; NPT = CALL CALL IE ER IF NP RETUR PUT E PUT S LFLAG RETUR IF PT NUMBE RETUR VALID; DECPNT(NUM8ER,NPT,PTFLAG) ; INK NUMBER, NPT, ERROR) ; ROR ~i= ' ' THEN GO TO ERRMSG; FLAG = «1'B THEN GO TO OPTD; D EC PNT ( NUMBE R, NPT, PTF LAG) ; FLAG = •O'B THEN GO TO OPTD; INKNUMBER, NPT, ERROR) ; ROR -»= • • THEN DO; IF ERROR = «D» THEN GO TO OPTD ELSE GO TO ERRMSG; END; T > LNMBR THEN GO TO ADDDO; SUBSTR(NUM3ER,NPT,1); R -,= id* THEN GO TO ERRMSG; FLAG = 'O'B THEN DO; ER = SUBSTR(NUMBER,1,NPT-1) | | • . • = NPT + 1; SUBSTR(NUMBER,NPT) NP SIG INT ROR T < n; DIT KIP; = l ; n; FLA R = n; T + l; M( NPT, NUMBER) ; (NUMBER, NPT, ERROR) ; -,= • i THEN GO TO ERRMSG; = LNMBR THEN GO TO ERRMSG; (NUMBER,' IS NOT A VALID NUMBER') (A, A); G = 'O'B THEN NUMBER NUMBER I I 'DO' ; = NUMBER II '. ' SIGN: PROC(NPT, NUMBER) ; DCL NPT; DCL NUMBER CHAR(23) VAR DCL CHR CHAR( 1 ) ; CHR = SUBSTR(NUM3ER,NPT, 1 ) ; IF CHR = '+• | CHR = •-• THEM RETURN; END SIGN; NPT = NPT + l; INT: PROC (NUMBER, NPT, ERROR ) ; DCL ERROR CHAR ( 1 ) ; DCL (NPT, I , LNMBR) ; DCL NUMBER CHAR(23) VAR; DCL CHR CHAR( 1 ) ; LNMBR = LENGTH(NUMBER) ; ERROR = ' • ; IF NPT > LNMBR THEN RETURN; CHR = SUBSTR(NUMBER,NPT,1 ) ; 36 FIRST: DO I = 1 TO 10; IF CHR = DIGIT(I) THEN GO TO ADVANCE; END FIRST; ERROR = CHR; RETURN; NPT = NPT + l; IF NPT > LNMBR THEN RETURN; CHR = SUBSTR(NUMBER,NPT, 1 ) ; DO I = 1 TO 10; IF CHR = DIGIT(I) THEN GO TO NEXTCHR; end later; return; MPT = NPT + l; GO TO REST; END INT; ADVANCE REST LATER NEXTCHR DECPNT: PROC (NUMBER, NPT, PTFL AG) ; DCL NUMBER CHAR (23) VAR; DCL NPT; DCL PTFLAG BIT ( 1) ; DCL CHR CHAR( 1 ) ; CHR = SUBSTR(NUMBER,NPT, 1 ) ; IF CHR = • .• THEN DO; PTFLAG = ' 1' B; NPT = NPT + l; end; return; END DECPNT; VALINT: PROC( STRING, MAX) BIN FIXED; DCL STRING CHAR(«) VAR; DCL (FLAG, NDEG, MAX, LEN) BIN FIXED; DCL C CHAR( 1 ) ; FLAG = 1 ; LFN = LFNGTH(STRING) ; IF LEN > 2 THEN RETURN ( FLAG ) ; CHOOSE: DO I = 1 TO LEN; C = SUBSTR( STRING, 1,1); COMPARE: DO K = 1 TO 10; IF C = DIGIT(K) THEN GO TO NFXT; END COMPARE; ILLEGAL: RETURN ( FLAG ) ; ' I : FND CHOOSF; NDFG = STRING; IF NDFG < 1 I NDFG > MAX THEN RETURN ( FLAG ) J FLAG = OS I IRN( FLAG ) ; v/.i I NT ; /* 'MA IN PROGRAM' . */ 37 ON ENDFILE (SYSIN) GO TO FINIS; /* READ ONE LINE FROM CONSOLE. */ NEXTLINE: GET EDIT (ORDER) (A(80))J PUT EDIT (ORDER) (A); PUT SKIP; CALL NOERR( ORDER) ; I = TRIM(ORDER); = 1 THEN GO TO PUT LI IF I — i men wu CALL SOUEEZE(ORDER) ; PUT EDIT (ORDER) (A); = INDEX(ORDER, 'END' ) ; TC LI -•= THEN DO; CALL FILECARD( ' STOP' ) ; CALL FILECARD( 'END* ) ; GO TO FINIS; p M n * NEXTLINE; SKIP IF EASE CORRECT' ) ; PUT SKIP; INPUT: PTOT = PTOT + 1; PNUM = SUBSTR(ORDFRtLI + 10) ; LFLAG = VAL INT ( PNUM, 99 ) ; IF LFLAG = 1 THEN DO; PUT EDIT (MSG1,PNUM,MSG2,MSG3 ) (A, A, A, A); PUT SKIP; /* P IS NOT A LEGAL POLYNOMIAL NAME */ PTOT = PTOT - l; GO TO NEXTLINE; END; P#(PTOT) = PNUM; /* HAS P ALREADY BEEN ENTERED? */ CHKREP: DO I = 1 TO PTOT - 1; IF PU( I ) = P#(PTOT) THEN DO; PUT EDIT(MSGl,P#(PTOT) ,MSG10 ) (A, A, A); PUT SKIP; /* P HAS ALREADY BEEN ENTERED */ PTOT = PTOT - 1; GO TO NEXTLINE; END; END CHKREP; GETDEGR: PUT EDIT (MSG4,'=') (A, A); PUT SKIP; /* GFT DEGREE OF POLYNOMIAL */ GET EDIT (ORDER) (A(80)); PUT EDIT (ORDER) (A); PUT SKIP; CALL NOERR (ORDER) ; NFLAG = TRIM(ORDER) ; IF NFLAG = 1 THEN DO; PUT EDIT (MSG7,MSG4,MSG6) (A, A, A); PUT SKIP; GO TO GETDEGR; END; 38 CALL SQUEEZE(ORDER) ; NFLAG = VALINT(0RDER,50) ; IF NFLAG = 1 THEN DO; PUT EDIT (ORDER»MSG2tMSGA) (A, A, A) PUT SKIP; /* NOT A LEGAL POLYNOMIAL DEGREE */ GO TO getdegr; end; deg(ptot) = order; call polhead ( p# ( ptot ) , nxtpol t deg ( ptot ) ) ; n = deg(ptot ) ; call getpoly(n) ; prec = prec + 2*deg(ptot) + 3; go to nextline; SETUP: K = INDEX(ORDER, '=0* ) ; IF K = I K < (LI + 6) THEN GO TO ILLEGAL; PNUM = SUBSTR(0RDER»LI+6»K-LI-6) ; PUT EDIT (•PNUM = »,PNUM) (A, A); PUT SKIP; NFLAG = VALINT (PNUM, 99) ; IF NFLAG = 1 THEN DO; PUT EDIT (MSG1,PNUM,MSG2,MSG3) (A, A, A, A); PUT SKIP; GO TO illegal; END; CHKDFF: DO I = 1 TO PTOT; LI = I ; IF P#(I) = PNUM THEN GO TO DEFN; END CHKDEF; /* P NOT ENTERED YET */ PUT EDIT (MSGl t PNUM,MSG5) (A, A, A); PUT SKIP; GO TO nfxtline; DEFN: TEMP = PREC; CALL SOUEEZE(TEMP) ; FTSTMT = 'CALL C ALLER ( • I I PNUM | | • , • | | DEG ( L I ) I I ' » ' I CALL FILECARD(FTSTMT) ; N = DFG(LI ) ; DO J = 1 TO (N + 6) ; WRITE FILE (INITIAL) FROM (BLANKS); END; TO NFXTLINE; FINIS: TEMP 39 = 1,2) IMAG*C0EFF(2) // EXEC FORTLKGO,TIME.GO=(6,00) //FORT.SYSIN DD DSNAME = &F TGEN , DI SP= ( OLD , DELETE ) // OD * SUBROUTINE CALLER ( PNUM ,N ,PR EC ) INTEGER PNUM»PREC COMPLEX* 16 C(51),ZCAL(50) ,UNRES(50) ,DUM3(50) ,DUM4(49) ,DUM5(49) , *DUM6(49) ,REAL/( 1.000,0.000)/, I MAG / ( O.ODO , 1 . ODO ) / REAL*8 DUM1 (50) ,COEFF( 2) C SEARCH FILE FOR HEADER FOR POLY PNUM. CALL FINDP( PNUM,N,NOPOL,PREC) IF (NOPOL.EO.l ) GO TO 99 IT1 = ITIMEZ(O) WRITE( 11,110)PNUM C READ COEFFICIENTS FROM FILE. Nl = N + 1 DO 3 I = 1,N1 READ(10,104) (COEFF( J) ,, C( I ) = REAL*COEFF( 1 ) + WRITF(6,101 ) I,C(I ) 3 CONTINUE ITZ = ITIMEZ ( IT1 ) WRITE(6,111 ) ITZ WRITE(6,102 ) IT1 = ITIMEZ(O) CALL TRAUBZ ( N , C , ZC AL , DUM 1 , UNRES , DUM3 , DUM4, DUM5 , DUM6 , NRTFND ) ITZ = ITIMFZ(ITl) WRITF(6,111 ) ITZ IT1 = ITIMEZ(O) WRITE(6,103) IF (NRTFND. NF.N) GO TO 500 WRITF(6,108 )N WRITE ( 11,108)N DO 310 I=1,N WRITE(6,109) I ,ZCAL( I ) WRITEdl ,109) I ,ZCAL ( I ) 310 CONTINUE GO TO 600 500 WRITE ( 11 ,107 )NRTFND WRITE(6, 107)MRTFND DO 400 1=1, NRTFND WRITE(6,109) I,ZCAL( I ) WRITEdl ,109) I ,ZCAL( I ) 400 CONTINUE N = N - NRTFND Nl = N + 1 WRITE ( 11 ,105)N WRITE (6, 105 )N WRITE ( 11,106) WRITF(6, 106) DO 450 1=1, Nl WRITE(6,101 ) I,UNRES( I ) WRITE( 11 ,101 ) I ,UNRES( I ) 450 CONTINUE 600 ITZ = ITIMEZ( IT1 ) WRITE(6,111 ) ITZ RETURN C UNABLE TO FIND POLYNOMIAL HEADER FOR POLY PNUM. 1+0 99 101 102 103 104 105 106 107 108 109 110 111 200 WRITE(llt200)PIMUM WRITE(6,200)PNUM RETURN FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT FORMAT END (D23.16) ( C(',I2,') = ( ' ,023.16,' ,' ,023.16, • ) • CALLING TRAUBZ' ) TRAUBZ RETURNED 1 ) DEGREE OF UNRESOLVED POLYNOMIAL ITS COEFFICIENTS ARE: 1 ) FACTOR = ',12) ONLY ALL ■ ROOT( SOLVE ,12,' ROOTS HAVE BEEN FOUND:') 12, • ROOTS HAVE BEEN FOUND: 1 ) ,12, ' ) = ( • ,D23.16, • ,',D23.16, P« ,12, • = 0' ) ) ' ) •'CLOCK ON THE WALL'' ELAPSED TIME = «,I6) UNABLE TO LOCATE POLYNOMIAL P',I2) Ui su SEARC NOPOL IN II RE NO RE WR IF IF NO RE IP IF RE II on FO FO Fn EN //GO .SYS //GO.FT1 //GO.FT1 100 101 103 BROUTI H FILE = I = 1 I TEGER = 1 WIND 1 POL = AD( 10, ITE(6, ( PNUM ( PNTR POL = TURN 1110 = NTR = ( PNTR A0( 10, = PN TO 3 RMAT ( RMAT ( RMAT ( D LMOD 0F001 1F001 NE FINDP(PNUM,N, NOPOL, PREC) TO FIND HEADER FOR POLYNOMIAL PNUM F POLY PNUM IS FOUND. F POLY PNUM NOT FOUND. PNUM, PREC, PNTR ,PN 100)PN,PNTR,N 101 )PN,N,PNTR .EO.PN) RETURN .LT.PRFC) GO TO 5 1 110 + 1 PNTR - 1 .EO.II 10) GO TO 7 10 3, END =6) (LL, 1=1 110, I PNTR) TR I2,I5,14X,I2) 2X, 12, 2X, 15, 5X, 12) Al ) DD DISP=(OLD, DELETE) DD DSNAME = SPL OUT, D I SP=( OLD, DELETE) DD DSN AMB=£RE SU LT f DISP=( MOD t PASS ) 1+2 // EXEC //PL1.SYSIN ROOTS: NEXT ON LINE: FINIS PL1LKGO DD * procedure options (main); dcl answers file input; dcl line char(80); put page; put edit ('answers (roots) from •FILE 11) • ) (A, A) ; ENDFILE (ANSWERS) GO TO FINIS; READ FILE (ANSWERS) INTO (LINE); PUT EDIT (LINE) (A(80))J PUT SKIP; GO TO NEXT_LINE; END ROOTS; FORTRAN PROGRAM (FROM ' /* //GO. ANSWERS DD DSNAME = £RE SULT , D I SP= ( OLD , DEL ET E ) U3 APPENDIX B SAMPLE USER/SPORRT COMMUNICATION (COMMAND PROCESSING) kk solz P23 HAS N ENTER P P4 2 6 IS N ENTER POL PA2 IS NO SOLVE M ILLEGAL C SOLVE PI PI HAS NO SOLVE PA PAA IS NO ILLEGAL C ENTER POL DEGREE OF ARE ALL C COEFE( 1) COEEF ( CDEFF( COEFF ( COEFF( ENTER 2) 3 ) 4) 5) POL FRR OT BE OLY OT A Y PA T A L ERR OMMAN = T BEE A = T A L OMMAN Y POLY OEFFI = .3 DEGREE OF ARE ALL C kFAL I^AG KFAL IMAG REAL IMAG KEAL COE COE COE COE COE COF COE ENTERPOLY COEFF( 4) REAL REAL REAL R p AL COE COF COE COF COF COF COE COE 1 VF = 2 Y P7 POLY OEFFI FF( 1 FF ( FF( FF( EF( FF( FF( Pin IS FF ( FF( FF( FF( FF( FE( EF ( FF( FF( FF ( P 7 =0 SOLVE P23=0.0 EN ENTERED P426 LFGAL POLYNOMIAL NAME 2 EGAL POLYNOMIAL NAME SOLZ FRR SOLVE P19 Dt PLEASF CORRECT N ENTERED EGAL POLYNOMIAL NAME D, PLEASE CORRECT P 1 9 NOMIAL= 4 CIENTS REAL? YES 1.0 -1.0D1 5 D 2 -50.0 4. MOM CIE ) = ) = ) = ) = ) = ) = ) = S N OT ) = ) = ) = ) = ) = ) = ) = ) = ) = 19 IAL = 7 NTS R 1.0 0.0 1 -5.0 125.9 80. ENTF OT A A LEG 419 -511. (SO 1^43 5.28 -27 872.8 2249 62 -655 = EAL7N0 8.0009 099 9 7444 163448991 R POLY P10 VALID NUMBER AL COEFFICIENT NUMBER, PLEASE REPEAT .52873302709 029545873001 2.254676327078 .0678563312 32935004301 65.13207842085 88757408 .527118477848 FRR611. 938542347744 .22700766981 1*5 APPENDIX C SAMPLE RESULTS ANSWERS (ROOTS) FROM FORTRAN PROGRAM (FROM FILE 11) k6 SOLVF ALL 4 ROOT( ROOT ( ROOT ( ROOT( SOLVE ALL KOOT( ROOT( ROOT( ROOT( ROOT( ROOT( ROf.T ( P19 = ROOTS HAVE BEEN 1 ) = ( 0.9999999 2) = ( 0.2000000 3) = ( 0.2999999 4) = ( 0.4000000 P 7 = 7 ROOTS HAVE BEEN = ( 0.3756298 = ( 0.6646894 = ( = ( 1 ) 2 ) 3) 4) 5) 6) 7) (-0 (-0 5872787 3115035 2608374 2224452 = (-0.1680835 FOUND: 999999999D 0000022150 999995571D 0000022140 FOUND: 594140273D- 371941906D 277487688D 555659952D- 713017014D 282671182D 643246713D 00, 0. 20976728028758470-17) 01 , -0.2 1508892 5 580966 5 D-l 2 ) 01, 0.42926605938437690-12) 01,-0.2141792 314762132 0-12) 01, 0.34437603709983100 00) 00, 0.1112156986819764D 01) 00,-0. 8646981707251440D 00) 02,-0.21686010748608510 01) 00, 0.4554188433162110D 01) 01,-0.92727752424128870 01) 02, 0.11305343030917180 02) ,^ •# *tf MAY 17 197A