MATALG is opening the file output MATALG Version 1.42, 01 May 2000 MATALG can interpret and evaluate formulas involving constants, vectors and matrices. Matrices may have up to 12 rows and columns. It was developed by Charles Cullen and John Burkardt. All rights reserved by the authors. This program may not be reproduced without written permission. Send suggestions and complaints to burkardt@psc.edu. Enter command (H for menu or ? for full help) # # Display the help screen. # h Enter command (H for menu or ? for full help) # # Enter a 3 by 3 matrix A, # estimate its reciprocal condition number, # change the 2,3 entry to 6, # estimate the reciprocal condition number again, # and compute B=A*transpose(A). # e a 3,3 Added the variable a Enter entries (1,1) through (1,3) 1, 2, 3 Enter entries (2,1) through (2,3) 4, 5, 10 Enter entries (3,1) through (3,3) 7, 8, 9 a 1 2 3 4 5 10 7 8 9 Enter command (H for menu or ? for full help) = rcond(a) Formula = 0.18181819E-01 Enter command (H for menu or ? for full help) a(2,3) = 6 a(2,3)= 6 Enter command (H for menu or ? for full help) = rcond(a) Formula = 0 Enter command (H for menu or ? for full help) b = a * trans(a) Implicit definition of b b= 14 32 50 32 77 122 50 122 194 Enter command (H for menu or ? for full help) # # Now compute the singular value decomposition of A, # and save the factors as U, S and V. # m Enter PLU or QR or SVD for factorization desired. svd Enter matrix to factor. a U Factor -0.21483725 -0.88723093 0.40824798 -0.52058738 -0.24964365 -0.81649673 -0.82633764 0.38794267 0.40824834 Singular Values 16.848101 0 0 0 1.0683697 0 0 0 0.15814163E-06 V Factor -0.47967109 0.77669138 -0.40824789 -0.57236773 0.75686097E-01 0.81649667 -0.66506445 -0.62531787 -0.40824863 Enter matrix to save U in, or return u Added the variable u Enter matrix to save S in, or return s Added the variable s Enter matrix to save V in, or return v Added the variable v Enter command (H for menu or ? for full help) # # Now make sure that the singular value decomposition # can reproduce the original matrix A. # w = u * s * trans(v) Implicit definition of w w= 0.99999875 1.9999999 3 3.9999988 4.9999986 5.9999990 6.9999986 7.9999981 9 Enter command (H for menu or ? for full help) # # Now discard the variables U, S, V and W to save space. # k u s v w Removed the variable u The amount of free memory is now 2607 Removed the variable s The amount of free memory is now 2616 Removed the variable v The amount of free memory is now 2625 Removed the variable w The amount of free memory is now 2634 Enter command (H for menu or ? for full help) # # Now compute the QR factorization of A # m qr a Q Factor 0.12309150 0.90453410 -0.40824813 0.49236599 0.30151120 0.81649667 0.86164045 -0.30151129 -0.40824836 R Factor 8.1240387 9.6011362 11.078235 0 0.90453398 1.8090682 0 0 0.35762787E-06 Enter matrix to save Q in, or return q Added the variable q Enter matrix to save R in, or return r Added the variable r Enter command (H for menu or ? for full help) # # And now verify that A=Q*R # = q * r Formula = 1.0000001 2 3.0000002 4.0000005 5 6.0000010 7.0000005 8 9 Enter command (H for menu or ? for full help) # # Now let's compute the PLU factorization of A # m plu a L Factor 1 0 0 0.14285715 1 0 0.57142860 0.49999979 1 U Factor 7 8 9 0 0.85714281 1.7142856 0 0 0 P Factor 0 1 0 0 0 1 1 0 0 Enter matrix to save L in, or return l Added the variable l Enter matrix to save U in, or return u Added the variable u Enter matrix to save P in or return p Added the variable p Enter command (H for menu or ? for full help) # # And let's verify that P*A=L*U, that is, A = P*L*U # = p * l * u Formula = 1 2 3 4 5 6 7 8 9 Enter command (H for menu or ? for full help) # # Now let's decide to save the value of the formula we # just calculated in a matrix C. And then let's print C # to show that it's been saved. # s c Added the variable c Enter command (H for menu or ? for full help) t c c 1 2 3 4 5 6 7 8 9 Enter command (H for menu or ? for full help) # # Now let's compute the characteristic polynomial of A, # and save the coefficients in CVEC. # p a Enter variable to save polynomial in, or RETURN to discard. cvec Added the variable cvec Polynomial coefficients saved in cvec Enter command (H for menu or ? for full help) # # Let's see what symbols are now stored in the program. # t all Predefined symbols: ABS KRYLOV SIND ACOS LCM SINH ALOG LN SQRT ALOG10 LOG STEP ASIN LOG10 TAN ATAN LOG2 TAND ATAN2 MAX TANH COS MIN TRACE COSD NEG TRANS COSH NINT ZEROS DET NORM0 ** DIAG NORM1 ^ E NORM2 + EPS NORME - EVAL NORMF / EVEC NORMS * EXP PI \ GCD POLY ( HILBERT RAN ) HILBINV RCOND = HOUSE ROUND , ID RTOL ! INT RVAL INDEX1 INV SEED INDEX2 IVAL SIN $ User-defined variables: a 1 2 3 4 5 6 7 8 9 "2 2 "3 3 "6 6 b 14 32 50 32 77 122 50 122 194 q 0.12309150 0.90453410 -0.40824813 0.49236599 0.30151120 0.81649667 0.86164045 -0.30151129 -0.40824836 r 8.1240387 9.6011362 11.078235 0 0.90453398 1.8090682 0 0 0.35762787E-06 l 1 0 0 0.14285715 1 0 0.57142860 0.49999979 1 u 7 8 9 0 0.85714281 1.7142856 0 0 0 p 0 1 0 0 0 1 1 0 0 c 1 2 3 4 5 6 7 8 9 cvec Transposed -5 -7.5000000 -15 1 User RPN formulas: p l * u * $ Most recent user infix formula: p * l * u $ Enter command (H for menu or ? for full help) # # Now clear out ALL user defined variables. # i Enter "YES" to confirm you want to re-initialize. yes Enter command (H for menu or ? for full help) # # Enter a matrix A, # # Enter a vector V (in this case, the first row of A), # # Compute B, the Householder matrix which will, # for each column of A, reflect the portion perpendicular to V. # # Compute B*A. # e a 3,3 Added the variable a Enter entries (1,1) through (1,3) 1, 3, -4 Enter entries (2,1) through (2,3) 4, 1, 1 Enter entries (3,1) through (3,3) 7, -1, 0 a 1 3 -4 4 1 1 7 -1 0 Enter command (H for menu or ? for full help) e v 3, 1 Added the variable v Enter entries 1 through 3 1, 4, 7 v Transposed 1 4 7 Enter command (H for menu or ? for full help) b = house(v) Implicit definition of b b= 0.96969700 -0.12121212 -0.21212122 -0.12121212 0.51515150 -0.84848487 -0.21212122 -0.84848487 -0.48484850 Enter command (H for menu or ? for full help) c = b*a Implicit definition of c c= -1 3.0000002 -4 -4 1 1 -7 -1 0 Enter command (H for menu or ? for full help) # # Compute the polynomial with roots 1, 2 and 3. # Store its coefficients in w. # Evaluate the polynomial at evenly spaced points # using the L command. # i Enter "YES" to confirm you want to re-initialize. yes Enter command (H for menu or ? for full help) e v 3 1 Added the variable v Enter entries 1 through 3 1,2,3 v Transposed 1 2 3 Enter command (H for menu or ? for full help) p v Enter variable to save polynomial in, or RETURN to discard. w Added the variable w Polynomial coefficients saved in w Enter command (H for menu or ? for full help) x = 0 Implicit definition of x x= 0 Enter command (H for menu or ? for full help) = poly(w,x) Formula = -6 Enter command (H for menu or ? for full help) l x, 0, 4, 8 Table of X, F(X) 0.0000000 -6.0000000 0.50000000 -1.8750000 1.0000000 0.0000000 1.5000000 0.37500000 2.0000000 0.0000000 2.5000000 -0.37500000 3.0000000 0.0000000 3.5000000 1.8750000 4.0000000 6.0000000 Enter command (H for menu or ? for full help) # # Compute the eigenvalues and eigenvectors of a matrix A. # i Enter "YES" to confirm you want to re-initialize. yes Enter command (H for menu or ? for full help) e a,4,4 Added the variable a Enter entries (1,1) through (1,4) Enter entries (1,1) through (1,4) 17, -8, -12, 14 Enter entries (2,1) through (2,4) 46, -22, -35, 41 Enter entries (3,1) through (3,4) -2, 1, 5, -4 Enter entries (4,1) through (4,4) 4, -2, -2, 3 a 17 -8 -12 14 46 -22 -35 41 -2 1 5 -4 4 -2 -2 3 Enter command (H for menu or ? for full help) l = eval(a) Implicit definition of l l= 3.6319828 0 -0.81599557 1.1231403 -0.81599557 -1.1231403 1.0000108 0 Enter command (H for menu or ? for full help) p = evec(a) Implicit definition of p p= 0.29746425 -0.21301502 0.25610971 0.44721362 0.90527523 -0.57198352 0.73047531 0.89442718 -0.30220461 -0.67444913E-01 0.15178223E-02 0.14774229E-05 -0.25768440E-01 -0.13412718 0.75708754E-01 0.17745582E-05 Enter command (H for menu or ? for full help) b = inv(p)*a*p Implicit definition of b Warning! The matrix may be nearly singular! The results may be unreliable! The determinant= 0.0000000 Warning! The matrix may be nearly singular! The results may be unreliable! The determinant= 0.0000000 b= -22.557840 -6.9987335 -58.845177 26.111912 217.25111 -17.808853 -43.108429 42.873104 234.43811 -26.409698 -53.417480 77.282890 -7.2583470 0.33045912 -0.27898288 -0.11872726E-05 Enter command (H for menu or ? for full help) # # Now let's show how we could save the 2 x 2 central block # of B using the "U" (partition) command. # u b Enter rows to keep, 0 to end. 2 3 0 Enter columns to keep, 0 to end. 2 3 0 Enter matrix to save submatrix, or return. d Added the variable d d -17.808853 -43.108429 -26.409698 -53.417480 Enter "YES" to see other pieces of matrix. no Enter command (H for menu or ? for full help) # # Show how repeated evaluation works. # i Enter "YES" to confirm you want to re-initialize. yes Enter command (H for menu or ? for full help) x = 0.734 Implicit definition of x x= 0.73400003 Enter command (H for menu or ? for full help) x = 4*x*(1-x) x= 0.78097594 Enter command (H for menu or ? for full help) r 10 I= 1 0.68421006 I= 2 0.86426663 I= 3 0.46923926 I= 4 0.99621516 I= 5 0.15082042E-01 I= 6 0.59418295E-01 I= 7 0.22355103 I= 8 0.69430387 I= 9 0.84898400 I= 10 0.51284069 Enter command (H for menu or ? for full help) # # Check how MATALG will handle the inverse of a singular # matrix. # i Enter "YES" to confirm you want to re-initialize. yes Enter command (H for menu or ? for full help) e a 2,2 Added the variable a Enter entries (1,1) through (1,2) 5,10 Enter entries (2,1) through (2,2) 1,2 a 5 10 1 2 Enter command (H for menu or ? for full help) = inv(a) Error! The matrix is numerically singular! RPNVAL - Warning! Evaluation of this formula is abandoned. COMRPN - Error! The formula could not be evaluated! MATALG noticed an error or mistake. Your command was not carried out. We are back at the main command menu. Enter command (H for menu or ? for full help) # # Make some other simple checks. # i Enter "YES" to confirm you want to re-initialize. yes Enter command (H for menu or ? for full help) b = id(2) Implicit definition of b b= 1 0 0 1 Enter command (H for menu or ? for full help) c = zeros(3) Implicit definition of c c= 0 0 0 0 0 0 0 0 0 Enter command (H for menu or ? for full help) d = ran(c) Implicit definition of d d= 0.29170376 0.97478253 0.52346694 0.13132721 0.43135566 0.69429517E-01 0.97340405E-01 0.13788342E-02 0.14299154E-02 Enter command (H for menu or ? for full help) # # Check the matrix norms. # e d 3,3 Added the variable d Enter entries (1,1) through (1,3) 1, 2, 3 Enter entries (2,1) through (2,3) 4, 5, 6 Enter entries (3,1) through (3,3) 7, 8, 9 d 1 2 3 4 5 6 7 8 9 Enter command (H for menu or ? for full help) = norm0(d) Formula = 24 Enter command (H for menu or ? for full help) = norm1(d) Formula = 18 Enter command (H for menu or ? for full help) = norm2(d) Formula = 16.848104 Enter command (H for menu or ? for full help) # # Load the 5 by 5 Hilbert matrix, H, # have MATALG compute the inverse, G, # compute H*G. # Load the 5 by 5 Inverse Hilbert matrix, F, # compute H*F, notice that even now we don't get I! # compute F-G. # h = hilbert(5) Implicit definition of h h= Columns 1 to 4 1 0.50000000 0.33333334 0.25000000 0.50000000 0.33333334 0.25000000 0.20000000 0.33333334 0.25000000 0.20000000 0.16666667 0.25000000 0.20000000 0.16666667 0.14285715 0.20000000 0.16666667 0.14285715 0.12500000 Column 5 0.20000000 0.16666667 0.14285715 0.12500000 0.11111111 Enter command (H for menu or ? for full help) g = inv(h) Implicit definition of g Warning! The matrix may be nearly singular! The results may be unreliable! The determinant= 0.0000000 Warning! The matrix may be nearly singular! The results may be unreliable! The determinant= 0.0000000 g= Columns 1 to 4 -8571960.0 41968332. -55752080. 24687292. 41968332. 9257729.0 -0.19996688E+09 98749168. -55752080. -16663908. -3291637.5 0.23041438E+09 24687292. 8229098.0 2194426.0 -104495.34 0 0 -88167.453 51431.004 Column 5 0 0 -9257569.0 -0.12343646E+09 44084.215 Enter command (H for menu or ? for full help) = h*g Formula = Columns 1 to 4 1 43099836. -0.15630176E+09 0.15085083E+09 702902.50 21549920. -94930384. 0.10285130E+09 598895.75 14342610. -68880928. 78989192. 485419.25 10741896. -54177536. 64315556. 401658.50 8584701.0 -44683956. 54304652. Column 5 -33936156. -26994336. -22417960. -19171198. -16747169. Enter command (H for menu or ? for full help) f = hilbinv(5) Implicit definition of f f= Columns 1 to 4 25 -300 1050 -1400 -300 4800 -18900 26880 1050 -18900 79380 -117600 -1400 26880 -117600 179200 630 -12600 56700 -88200 Column 5 630 -12600 56700 -88200 44100 Enter command (H for menu or ? for full help) = h*f Formula = Columns 1 to 4 1 0 0 0 0 1 0 0 0.76293945E-05 -0.12207031E-03 1.0004883 0.97656250E-03 -0.15258789E-04 0.24414062E-03 0 1.0019531 0 0 0.97656250E-03 0 Column 5 0 0 0.48828125E-03 -0.97656250E-03 1.0004883 Enter command (H for menu or ? for full help) = f-g Formula = Columns 1 to 4 8571985.0 -41968632. 55753128. -24688692. -41968632. -9252929.0 0.19994798E+09 -98722288. 55753128. 16645008. 3371017.5 -0.23053198E+09 -24688692. -8202218.0 -2312026.0 283695.34 630 -12600 144867.45 -139631 Column 5 630 -12600 9314269.0 0.12334826E+09 15.785156 Enter command (H for menu or ? for full help) # # Check out the GCF and LCM functions. # = gcd(20,12) Formula = 4 Enter command (H for menu or ? for full help) = gcd(20,17) Formula = 1 Enter command (H for menu or ? for full help) = gcd(20,-12) Formula = 4 Enter command (H for menu or ? for full help) = gcd(20,0) Formula = 20 Enter command (H for menu or ? for full help) = lcm(12,4) Formula = 12 Enter command (H for menu or ? for full help) = lcm(12,5) Formula = 60 Enter command (H for menu or ? for full help) = lcm(12,12) Formula = 12 Enter command (H for menu or ? for full help) = lcm(12,0) Formula = 0 Enter command (H for menu or ? for full help) = lcm(12,-6) Formula = 12 Enter command (H for menu or ? for full help) # # Try out the HELP facility. # ? MATALG version 1.40 15 October 1996 MATALG is an interactive matrix algebra program. This help file includes information on the commands MATALG will accept; the operators and functions MATALG allows in a formula; how to install and run MATALG on different computers. Help is available on: Background Acknowledgements Purpose Commands Operators Functions DOS PC version Macintosh version UNIX version VMS version Double precision version RETURN to back up, ? to redisplay. Enter topic you want help on, or RETURN or ?. Commands Commands A command to MATALG is usually a single letter. Most commands must be followed by "arguments", which tell MATALG what object it is to operate on, how large it is, and so forth. If a command has arguments, these are including in the list, with symbolic names. Command and arguments Short definition --------------------- ---------------- D filename Open a transcript file. E name, rows, cols, values Enter variable. I Initialize. K name Kill variable(s). L name, lo, hi, nstep Tabulate formula. M LU/QR/SVD, name Matrix factors. P name Characteristic polynomial. Q Quit. R nstep Repeated evaluation (x=f(x)). S name Save formula value. T name/ALL/blank Type variable. U name Partition a matrix. V Re-evaluate formula W filename, name Write variable to file. X filename Read variable from file. # Begin a comment. $, % Turn paging on or off. < file Get input from file. ? Extensive help. variable = formula Set variable to value of formula. For instance, the entry E name, row, col, values means that when you issue the "E" command, you will also be required to specify: the name of the variable to be entered, the number of rows in the variable, the number of columns in the variable, the value to be assigned to that entry. So a "real" ENTER command, to declare an array "Stanley" containing two rows and three columns of data, might look like: E Stanley 2, 3 1.1 2.4 3.7 4 4.3 9 Here, we have separated the arguments by spaces and extra blank lines. We could just as easily have typed: E Stanley 2, 3 1.1, 2.4, 3.7 4, 4.3, 9 In the listing above, if the arguments of a command are separated by slashes, you have a choice of which one to choose. If the argument is in capital letters, it doesn't represent the name of something, then you should type exactly those letters. So for instance to get the LU factorization of a matrix named "DAVE", you could type: M LU DAVE MATALG doesn't notice whether you type capital letters or not, so you could also type this command as m lu dave or m LU Dave The program will prompt you for the next argument it needs if you don't supply it. Thus, E A 2, 2 is the concise way to enter a matrix named A which has 2 rows and 2 columns. But if you just type E the program will ask you for the name of the variable, and then the number of rows and columns. You can give as much of this information at a time as you like. Variable names may be up to 10 characters long, and may only consist of letters and numbers. The first character of a variable name should be a letter, not a number. You should not try to use a variable name like "SQRT" or "COS" that MATALG has already permanently assigned a meaning to. The values of all variables are stored as real numbers inside the program, and the usual roundoff problems can occur. When you are entering a number into the program, you may use a variety of forms, including integer, rational, decimal and scientific forms: 2 (an integer) 7/4 (a rational value, equals 1.75) 17.23 (a decimal value) 1.5E+2 (a scientific form. "E+2" means multiply by 10**2, so the result equals 150.) Help is available on: Disk file transcript Enter a variable Help Initialize Kill a variable List a table of values Matrix factorization Polynomial Quit Repeated evaluation Save a variable Type a variable Partition a matrix Value of a formula Write example to file Read example from file # Comments Stop paging ($) Start paging (%) Input from file (<) Extensive help (?) Formula evaluation RETURN to back up, ? to redisplay. Enter topic you want help on, or RETURN or ?. Enter a variable Enter a variable E (variable, rows, columns) The "E" command sets up a variable of the given name and size. You should use this command first, to set up variables, before using them in a formula. In some cases, where MATALG can figure out the dimensions of a variable, you can skip the "E" command. For instance, you can type "X=1" and MATALG will realize that X is a scalar. This is called an "implicit declaration". The number of rows and columns must be no more than 12. The program will immediately request that you set the value of the variable. If the variable is a scalar (1 row and 1 column), then its value may be included on the same line. E SQUARE 5,4 would declare a matrix named SQUARE of five rows and four columns. The program will now ask you for 20 values to enter into SQUARE. Similarly, the command E FRED 1,1, 17 would declare a scalar named FRED whose value was 17. Because FRED is a scalar, you may also enter it by typing FRED=17 When you have completed the "E" command, MATALG will print out the variable name and its values so that you may check it. MATALG only uses real valued variables. You cannot assign complex values to any MATALG variable. RETURN to back up, ? to redisplay. Enter RETURN or ?. Commands Help is available on: Disk file transcript Enter a variable Help Initialize Kill a variable List a table of values Matrix factorization Polynomial Quit Repeated evaluation Save a variable Type a variable Partition a matrix Value of a formula Write example to file Read example from file # Comments Stop paging ($) Start paging (%) Input from file (<) Extensive help (?) Formula evaluation RETURN to back up, ? to redisplay. Enter topic you want help on, or RETURN or ?. MATALG version 1.40 15 October 1996 Help is available on: Background Acknowledgements Purpose Commands Operators Functions DOS PC version Macintosh version UNIX version VMS version Double precision version RETURN to back up, ? to redisplay. Enter topic you want help on, or RETURN or ?. Enter command (H for menu or ? for full help) # # Try lots of scalar functions. # x = 1.0 Implicit definition of x x= 1 Enter command (H for menu or ? for full help) y = abs(-1) Implicit definition of y y= 1 Enter command (H for menu or ? for full help) y = acos(0) y= 1.5707964 Enter command (H for menu or ? for full help) y = asin(1) y= 1.5707964 Enter command (H for menu or ? for full help) y = atan(1) y= 0.78539819 Enter command (H for menu or ? for full help) y = atan2(10,10) y= 0.78539819 Enter command (H for menu or ? for full help) y = cos(pi) y= -1 Enter command (H for menu or ? for full help) y = cosd(45) y= 0.70710677 Enter command (H for menu or ? for full help) y = cosh(1) y= 1.5430807 Enter command (H for menu or ? for full help) y = e y= 2.7182817 Enter command (H for menu or ? for full help) y = eps y= 0.11920929E-06 Enter command (H for menu or ? for full help) y = exp(1) y= 2.7182817 Enter command (H for menu or ? for full help) y = int(pi) y= 3 Enter command (H for menu or ? for full help) y = log(10) y= 2.3025851 Enter command (H for menu or ? for full help) y = log2(1000) y= 9.9657841 Enter command (H for menu or ? for full help) y = log10(100) y= 2 Enter command (H for menu or ? for full help) y = max(1,10) y= 10 Enter command (H for menu or ? for full help) y = min(1,10) y= 1 Enter command (H for menu or ? for full help) y = neg(10) y= -10 Enter command (H for menu or ? for full help) y = nint(1.9) y= 2 Enter command (H for menu or ? for full help) y = pi y= 3.1415927 Enter command (H for menu or ? for full help) y = ran(x) y= 0.79398137 Enter command (H for menu or ? for full help) y = round(1) y= 1 Enter command (H for menu or ? for full help) y = round(eps) y= 0.11920929E-06 Enter command (H for menu or ? for full help) y = round(0.00000001) y= 0 Enter command (H for menu or ? for full help) rtol = 0.0001 rtol= 0.99999997E-04 Enter command (H for menu or ? for full help) y = round(eps) y= 0 Enter command (H for menu or ? for full help) y = seed y= 0 Enter command (H for menu or ? for full help) y = sin(pi) y= -0.87422777E-07 Enter command (H for menu or ? for full help) y = sind(45) y= 0.70710677 Enter command (H for menu or ? for full help) y = sinh(1) y= 1.1752012 Enter command (H for menu or ? for full help) y = sqrt(100) y= 10 Enter command (H for menu or ? for full help) y = step(10) y= 1 Enter command (H for menu or ? for full help) y = tan(pi) y= 0.87422777E-07 Enter command (H for menu or ? for full help) y = tand(45) y= 1.0000001 Enter command (H for menu or ? for full help) y = tanh(1) y= 0.76159418 Enter command (H for menu or ? for full help) y = 10! y= 3628800 Enter command (H for menu or ? for full help) # # Quit # quit MATALG is stopping now. MATALG is closing the file output