Home

SandMatrix Manual

image

Contents

1. Function Description Input 1 ABSP Alpha Back Space Text in Alpha 2 AIP Appends integer part x in X 3 ASWAP Alpha Swap A B in Alpha 4 CLAC CLA from Comma Text in Alpha 5 ST lt gt A Exchanges Alpha and Stack Values in Stack and Alpha registers Note that already in revision M all these functions weren moved to the secondary FAT and therefore you need to use the V or EV launchers to execute them or to enter them in a FOCAL program See the sub function table at the introduction section for details on their reference indexes e ABSP deletes the rightmost character in ALPHA equivalent to back space in manual mode e AIP was HP s answer to the need to append just the integer part of the number in X to Alpha not changing the FIX and radix settings Note also that AIP appends the absolute value of the number which is not the case with ARCLI or AINT from the CCD and AMC_OS X modules e ASWAP handles comma separated strings exchanging the strings placed left and right of the first comma found in Alpha Very handy to manage all those operations that have an input and output matrix names defined in ALPHA separated by comma e CLAC deletes the contents of ALPHA located to the right of a comma i e after the comma but not including it It is adapted from CLA in the CCD Module e ST lt gt A simply exchanges the contents of the stack and the four Alpha registers M N O P Used in 3D vector
2. Particular case Symmetric Matrices JACOBI For symmetric matrices the Jacobi algorithm provides a faster method JACOBI was written by Valentin Albillo and published in PPC TN V1N3 October 1980 I ve only slightly adapted it to the SandMatrix but basically remains the same as originally written The paragraphs below are directly taken from the above reference to explain its workings This program computes all eigenvalues of a real symmetric matrix up to 22 x 22 It uses the Jacobi method which annihilates in turn selected off diagonal elements of the given matrix A using elementary orthogonal transformations in an iterative fashion until all off diagonal elements are zero when rounded to a given number of decimal places Then the diagonal values are the eigenvalues of the final matrix The method explained The Jacobi method does not attempt to solve the characteristic equation for its roots It is based in the fact that a n x n symmetric matrix has exactly n real eigenvalues Given A another matrix S can be found so that S A S D is a diagonal matrix whose elements are the eigenvalues of A The Jacobi method starts from the original matrix A and keeps on annihilating selected off diagonal elements performing elementary rotations Let s single out an off diagonal element say apq and annihilate it using an elementary rotation The transformation R is defined as follows Rpp cosz Rpq sinz Rqp sinz Rqq
3. c Angel M Martin December 2014 Page 52 of 124 SandMatrix_4 Manual Revision N Program listing for MPWR M 2 and M 1 X 1 LBL MPWR MNAME in Alpha 1 LBL M42 MNAME in Alpha 2 SQR square 2 SQR Square 3 LU yes but LU 3 LU yes but LU 4 ADV MATRX not square show error 4 ADV MATRX not square show error 5 CCD MATRX no show RUNNING 5 CCD MATRX no show Running 6 X lt gt Y power index to X reg 6 ASTOL 7 INT make integer 7 DIM dimension to X reg 8 X 0 is it zero 8 a ad 9 GTO 01 no skip over 9 ARCLL 10 MIDN yes make identity 10 J P M M P 11 RTN done 11 ASWAP M P M 12 LBL 01 12 ASWAP P M M 13 X lt 0 is it negative 13 MATDIM auxiliary P 14 MINV yes invert matrix 14 ASWAP M M P 15 ABS 15 M M matrix product 16 E 16 CLAC M M 17 n 1 17 CLAC M 18 X 0 was n 1 18 1p M P 19 RTN yes we re done 19 ASWAP PRM 20 STO 00 store in ROO 20 MAT result to M 21 ASTO 01 store Mname in R01 21 PURFL purge P 22 at er 22 MNAME MNAME to Alpha 23 MAT copy to aux matrix 23 END done 24 DIM get dimansion 25 p 26 MATDIM auxiliary matrix P 27 tBLOO lt _ prepare alpha string 1 LBL MM X MINAME in Alpha 28 4 2 1 X 29 ARCL 01 MNAME 3 STO 05 store in ROS 30 I P MNAME P 4 MLN matrix logarithm 31 M M matrix product 5 RCL 05 32 VIEW 00 show current index 6 at ie prepare Alpha string 33 P 7 ASWAP sw
4. 1 Introduction the SandMatrix 4 Preamble to revisions M amp N Introduction Logical next chapter after the SandMath The many names of Dr Who What isn t included Function index at a glance Subfinctions in the Auxiliary FAT 2 Lower Page Functions in Detail 2 1 SandMatrix 4 Group Alpha String Manipulation Function Launcher and Matrix keyboards Functions in the header section The main MATRX program 2 2 Matrix 101 Setting up a matrix How a matrix is stored Matrix Editors How to Specify a matrix Storing and Recalling Martrix Elements Updated Matrix Editor 2 3 Matrix Functions Matrix Arithmetic Major Matrix Operations LU Decomposition Working with Complex Matrices Using Functions with Complex Matrices Other Matrix Functions Utilities Moving and Exchanging sections Maxima and minima Norms and Sums Matrix Reductions Appendix Pascal and Random Matrices e O COONNDO 14 16 16 20 22 24 25 26 27 28 29 30 34 34 35 35 36 38 c ngel M Martin December 2014 Page 3 of 124 SandMatrix_4 Manual Revision N 3 Upper Page Functions in Detail 3 1 Advanced Matrix The Enhanced Matrix Editor s 39 New Matrix Utilities housekeeping 42 Finding elements Driver for M M 45 Exponential of a Matrix 46 Logarithm of a Matrix 47 Square Root of a Matrix 49 Appendix Square root of a 2x2 matrix 51 Matrix Integer Powers and Roots 52 Lie Prod
5. 0 9 x2 22 1 for which you must determine the values of x1 and x2 These equations can be expressed in matrix form as AX B where A is the coefficient matrix for the system B is the column or constant matrix and X is the solution or result matrix For such a matrix system the MATRX program creates dimensions a square real and complex matrix A and a column matrix B You can then Enter change edit or just view elements in A and B Invert A Transpose A if A is real Find the determinant of A if A is real Solve the system of simultaneous equations by finding the solution to AX B The size of your matrix is limited only by available memory each real matrix requires one register plus one register for each element If you want to store more than one matrix you will need to use the matrix function MATDIM described in the next chapter The MATRX program does not store or recall matrices it works with a single square matrix A and a single column matrix B When you enter new elements into A you destroy its old elements c Angel M Martin December 2014 Page 16 of 124 SandMatrix_4 Manual Revision N Instructions MATRX has two menus to show you which key corresponds to which function The initial menu you see is to select a real ox complex matrix picture on the left below vIE Ta Dalt Q t f t al e LIE LIC LJ C C After you make this selection input the order of the matrix
6. 19 x4 20 x 7x7 7x 10 2x x4 1 x 2 Keystrokes Display Result XEQ PFE DEN Input number of factors 2 R S NUM inputs degree of numerator 5 R S Z aK XAK Reminder of convention a5 coefficients data entry 6 R S a4 19 CHS R S a3 20 R S a2 7 CHS R S al 7 R S a 10 R S Q1 Input degree of Q1 in den 2 R S Z aK X K Reminder of convention a2 2 R S al 1 R S a0 1 R S Q2 1 R S Z aK X K Reminder of convention al 1 R S a0 2 CHS R S APA time to enter the multiplicities now al exponent of first factor 1 R S ad exponent of second factor 2 R S flying goose beep sounds E informs that E x follws lt r akK X K Reminder of convention al 3 R S a0 1 end of data output There are three control words placed registers R05 R06 and R15 upon completion as follows 1 The cnt l word stored in R15 is for the Quotient polynomial E x 2 The cnt l word in RO5 gives the entire register range for the coefficients of all the pi x polynomials the numerators of the expanded fractions It needs to be interpreted depending on the denominators qi x are polynomials of degree 1 or polynomials pf degree 2 with negative discriminant c Angel M Martin December 2014 Page 95 of 124 SandMatrix_4 Manual Revision N
7. and END 121 Note Make sure that revision N or higher of the Library 4 module is installed c Angel M Martin December 2014 Page 5 of 124 SandMatrix_4 Manual Revision N SandMatrix_4 Module Revision N Matrix Extensions for the HP 41 System 0 Preamble to revisions M amp N The latest revision of the SandMatrix rounds up the module with subtle architectural enhancements as well as a few more new functions to complete the pack Notable are the all MCODE versions of polynomial evaluation and its derivatives and the addition of the FOCAL examples from the manual now available to the user in the function set Simplification of the code allowed for optimal allocation of the routines freeing up space for the new additions Revision M of the SandMatrix included significant additions to its predecessor both in contents as well as in what relates to its internal architecture Short on the heels of revisions K and L the author figured out a way to enhance the original bank switching implementation based on HP s Advantage Module adding support for the Hepax based model to it and thereby enabling the This freed up a substantial amount of room that now hosts the 3D Vector Calculator ROM almost in its entirety using a secondary FAT and auxiliary function launchers like those present in the SandMath module The benefits are obvious all 3D Vector functions ar
8. n 4 pi pj pk pl a n 6 n 5 amp amp pi pj pk pl pm in general the n th coefficient would require the calculation of n dimensional product sums However the program POLZER is limited to expressions up to 7 poles max resulting in 6 zeroes Example To study the stability of the transfer function below calculate its roots G s 1 s 1 s 1 1 s 2 1 s 3 1 s 4 Keystrokes Display XEQ POLZER POL 5 R S P 1 0 R S P 2 1 R S P 3 2 R S P 4 3 R S P 5 4 R S E e 25 a EIS DLEE EELEE CFS Y N y a 4 5 00000 R S a 3 40 00000 R S a 2 105 00000 R S a 1 100 00000 R S a 0 24 00000 Therefore the natural polynomial form is as follows G s 5 s 4 40 s 3 105 s 2 100s 24 c Angel M Martin December 2014 Page 93 of 124 SandMatrix_4 Manual Revision N Next the execution is transferred to RTSN which will calculate the roots following the iterative process explained in section 4 3 1 Remember that the accuracy is dictated by the number of decimals places set R S RUNNING R S Z 0 35557 R S Z 1 45609 R S Z 2 54395 R S Z 3 64442 POLZER is also rather long and dates back to the days the author attended EE School many moons ago so I m somehow attached to it 4 4 7 Partial Fraction Decomposition In algebra the partial fraction d
9. 3 The contents of these registers are to be read e by groups of 1 number if deg qj 1 the numerators are constants e by groups of 2 numbers if deg qj 2 the numerators are polynomials of degree 1 e by groups of 3 numbers if deg qj 3 the numerators are polynomials of degree 2 and so on 4 The third in RO6 is for an alternative solution using a new reminder p x Thus in this case registers R16 and R17 contain the coefficients for E x 3x 1 And registers R33 R36 for the denominator polynomials which must be three of them pi1 1 x 2x 3 p2 1 x 4 9 p2 2 x 5 Thus the final result is as follows R x E x p1 1 x 2x42 x 1 p2 1 x x 2 42 p2 2 x x 2 Or alternatively using the data in registers R18 R21 cnt l word in Z p x 12 x43 12x 2 5x 6 and thefore R x E x p x Q x Example 2 Calculate the partial fraction decomposition for R x below R x P x Q x x45 3x42 1 2 The three control words returned are Z 18 021 with R18 2 3 R19 0 R10 1 9 R21 0 Ne 28 031 with R29 1 9 R29 0 R30 2 9 and R31 0 X 16 017 with R16 1 9and R17 0 The range in Y must be split as p1 2 x 9 x 0 and p2 2 2x 9 0 Therefore R x E x p1 2 x 3x 2 1 2 p2 2 x 3x 2 1 All in all a powerful program which flexibility requires some careful attention to the details involved Note you can check another Partial Fraction expansio
10. RE2 2 0 2369 Displays x22 i Y2 R S IM2 2 0 0225 R S or J A I DT BSE Exits the editor Other more advanced examples are available in the next sections of the manual during the description of the individual matrix functions Note that if any of the element registers currently contains alpha data you ll get an ALPHA DATA error message during data entry Simply clear the X register using tha back arrow key and continue with R S c Angel M Martin December 2014 Page 19 of 124 SandMatrix_4 Manual Revision N ee a a 2 2 1 Setting up a matrix Name Storage and Dimension The first group of matrix functions are used to create populate and store the matrices Function Description Inputs l 1 MATDIM Dimensions a Matrix Name in Alpha dimensions in X 2 MNAME Returns name of current Matrix to Alpha none 3 DIM Returns the dimension of Matrix Name in Alpha 4 MEDIT Matrix Editor Name in Alpha 5 CMEDIT Complex Matrix Editor Name in Alpha You can create manipulate and store real and complex matrices The size and number of matrices is limited only by the amount of memory available in the calculator If you have extended memory you can also store matrices there To create a matrix you must provide its name and dimensions The function MATDIM uses the text in the Alpha register as its name and the dimensions mmm nnn in
11. write itin display Re allow comma writing Disable PER enable RAM ENCPOO put F28 to F9 comma or period overflows if COMMA cf28 comma CF 28 Enable Display not cleared ENLCD read right comma or period should replace the last chr with the same one w radix Jappends oT fOe so an E no need return Jappends MO2E oouo 5 Page 123 of 124 SandMatrix_4 Manual Revision N go ahead and write a few more functions on your own A few suggestions 1 Program to calculate Eigenvectors from Eigenvalues General purpose p th root of a matrix Extended memory support for Polynomial files General purpose Logarithm of a matrix Anything else you feel like going for This concludes the SandMatrix Manual Hope you have found it useful and interesting enough to keep as a reference Better yet are The End ee Oe Oa as o OS SF SSR TTT a a e d a fr Oo a aSa ewe amp 9 8 ts eo e a Oe i Lod eet S sie oss8 S a i o Ooo amp eoe o e amp a Q am 3 Do SV 1 bmd L Add 22S zz A e e200 eoeo ae ee OS EGE a T a v Pw w Ce Ge e Te Me C e o a Cs oe eK e gt ae i a e a A A a te te te t vw 9 QAQ See Seecrnee a gt on Daa Oaar no aaa A aa L Da aa e e e G ee e e e Y ee s ee e es s s58 2 Sbn et
12. ya me s Ww ae amp saa Ara e T s s S Trepe Or ae e eoe ea a r rT eT T mi aa a a T enn gt s gt s e pemr Ea peee em Geren en r Er P em Ead Se S 8e 84 S2 amp 2 gt oog saa asaeag SS 8S TET aS O O O Page 124 of 124 December 2014 z c Angel M Martin
13. 0 where I is the n x n identity matrix It is a fundamental result of linear algebra that an equation M v O has a non zero solution v if and only if the determinant det M of the matrix M is zero It follows that the eigenvalues of A are precisely the real numbers that satisfy the equation det A AI 0 The left hand side of this equation can be seen to be a polynomial function of the variable A The degree of this polynomial is n the order of the matrix Its coefficients depend on the entries of A except that its term of degree n is always 1 A This polynomial is called the characteristic polynomial of A and the above equation is called the characteristic equation or less often the secular equation of A c Angel M Martin December 2014 Page 62 of 124 SandMatrix_4 Manual Revision N SOLVE based Implementation EIGEN There are three Programs in the SandMatrix that calculate eigenvalues The first one is aptly named EIGEN and is a brute force approach using the direct definition of the eigenvalue given above What makes it interesting is the direct application of SOLVE of FROOT in the SandMath plus the combination of matrix functions to calculate the secular equation to solve for EIGEN can be used in manual mode with guided prompts and data entry or in a subroutine In manual mode it creates a matrix named EV in X mem and will prompt for the
14. 4 E 4 PURFL purge file 5 plus one 5 FC C 25 was in main mem 6 X gt Y is it larger 6 GTO 01 jump over 7 PSIZE yes adjust size 7 MATDIM re create file 8 sR prepare Alpha string 8 RTN done 9 MAT make matrix RO equal 10 MSZE its size again ANUM get first reg from title 11 E3 E prepare control word 11 ENTER copy in Y reg 12 RGSORT sort registers 12 MSZE get matrix size 13 ASWAP swap alpha 13 add to first reg 14 CLST prepare pointers 14 E3 3 i prepare index format 15 MMOVE move all elements 15 add to first reg 16 MNAME recall original name 16 CLRGX clear registers 17 END done 17 END done MSZE has a new MCODE implementation in this revision directly reading the matrix header register Its functionality is equivalent to FLSIZE for matrices stored in X mem but not so for matrices stored in main memory 1 MSZE Header OBF 2 MSZE Header 005 Matrix Size 3 MSZE Header 01A 4 MSZE Header 013 5 MSZE Header 00D ngel Martin 6 MSZE PORT DEP Jumps to Bank_2 7 MSZE XQ adds 4 to XS 8 gt A5D9 LNCHO 9 valid for main and X mem lt parameter gt B788 aaa 10 the proper way to do it JNC 01 11 ENROM1 restore bank 1 12 MSZE C N ALL header register 13 MSZE A C S amp X 14 MSZE BIN BCD plus RCL 15 MSZE ATOX20 PMAT is nothing more than a user friendly driver program to automate the complete matrix product procedure without any need to dimension the re
15. 5 CF05 2 AXV 14 VADST 16 X 0 63 RCL 13 15 EXSCR 48 GTO 05 7 GTOOO 4 FC 01 16 V A 18 SFOS 5 CHS 17 LBL 02 19 STO 13 6 SIN 18 ay Po sT 7 xv 9 ARCL X 21 E 8 50 AVIEW H2 Xoz 9 sSTO12 51 EXSCR wo s wa ie k 23 GTOJ 25 VUNIT 72 RCL13 E k 24 LBL c 26 VSTO 73 cos Bs ARON TR 070 74 ST 12 O e ho moa e aw ma 30 SF27 7 VSTO Ze Eee 31 2 SF 21 73 53 23 BVAS B2 FOI T9 VRCL 30 GTO 02 33 AN AQ NEW 30 r 31 LBL F 54 PROMPT 1 VRCL 32 V lt gt A 65 EXSCR B5 GTOO00 B2 AV 33 GTOJ 6 2 IV B3 ST 12 7 GTO02 37 XROM 3VC Ba VoA 68 END B35 RCL12 39 SF01 B6 xv 40o GTOO03 B7 VRCL B83 53 B9 AV o FS 01 44 XROM CT O01 46 VIEWV 93 VRCL 47 GTO 00 cy n O5 AAV 96 END c ngel M Martin December 2014 Page 114 of 124 SandMatrix_4 Manual Revision N Calculating 2D and 3D Distances The Launcher A few example programs in the module illustrate the convenience of using an abstraction layer to handle vector expressions without having to worry about their individual components The net result is shorter neater programs with higher level structure devoid of all those multiple STOnn RCLnn statements so common otherwise and therefore much easier to understand and debug The functions included are as follows 3D 2D Point Point VADST PP2 DOTN Point Line PL3 PL2 Point Plane PPL3 Line Line LL3
16. When you use functions that produce an LU decomposed form there are several things that you need to be aware of e You cannot edit an LU decomposed matrix unless you edit every element Also care must be exercised when viewing an LU decomposed matrix Certain operations can alter elements without your knowledge refer to Editing and Viewing an LU Decomposed Matrix below for more details e You cannot perform any operation that will modify the matrix other than MINV because the LU status of the matrix will be cleared and it will become unrecognizable Operations that have this effect are R lt gt R C lt gt C MS MSR MSR MSC MSC MMOVE intramatrix MSWAP and TRNPS e LU decomposition destroys the original form of the matrix So if you perform MSYS or MDET and then try to look at your input matrix A in the MATRX program you will find only the altered decomposed form You cannot calculate the transpose TRNPS SHIFT B in MATRX program of a matrix in LU decomposed form LU decomposition does not hinder the correct calculation of the inverse determinant or solution matrix since these operations require the LU decomposition anyway Reversing the LU Decomposition To restore a matrix to its original form from its decomposed form simply invert it twice in effect find the inverse and then re invert to the original Naturally for this to work the matrix must be invertible non singular The result can differ slightly
17. Z0 Y0 X0 NEW and then return to step 2 10 To use vector operations switch to the Vector C DP CP A MUV Calculator All the functions described in the USER must be Vector Operations chapter are then available on to you 11 To return to the TR program from VC Bc Z0 Y0 X0 12 To transform a vector result Vs from VC by pass the initial prompts and call up the main menu assuming a transformed system is al ready defined tN t0 NEW c ngel M Martin December 2014 Page 111 of 124 SandMatrix_4 Manual Revision N Remarks This program uses local Alpha labels as explained in the owner s manual for the HP 41 assigned to keys A B E C and J These local assignments are overridden by any User key assignments you might have made to these same keys thereby defeating this program Therefore be sure to clear any existing User key assignments of these keys before using this program and avoid redefining these keys in the future However these local Alpha labels are active only while the USER annunciator is on This allows you to use the arithmetic functions in the top two rows while the USER annunciator is off As long as USER is on the keys mentioned above are redefined and will not execute their Normal functions Data Storage The vector or point you want to transform is stored in ROO RO1 R02 which is vector storage register 0 initially from the X Y and Z registers The rotation
18. a0 150 R S STO Y N prompts for storage option y RUNNING At this point the different precision factors are shown which shoud be decreasing as the iterations converge towards the solutions and this repeated as many times at quadratic factors are needed c ngel M Martin December 2014 Page 82 of 124 SandMatrix_4 Manual Revision N The solutions are shown below in FIX 5 Z 2 00000 J1 00000 and its conjugate not shown Z 1 00000 J3 00000 and its conjugate not shown Z 1 50000 And the matrix ROOTS is left in X Mem with 5 rows and two columns as follows ROOTS To be sure it isn t the fastest method in town typically 5 6 iterations are needed each iteration takes a bout one full minute at normal speeds but it s applicable to any degree and stores the results in a matrix which makes it very useful as a general purpose approach Bairstow Method A faster program is BAIRS which also uses a factorization method but does not utilize any of the matrix functions Therefore the solutions are just prompted to the display but not saved into an X Mem file BAIRS expects the coefficients already stored in main memory and the polynomial control word in X Note that they will be overwritten during the execution of the program It uses registers ROO to RO8 internally thus cannot be used to store your data For both programs the a
19. cos z Ru 1 Rpk Riq Rik 0 for 1 p q and k p q Let s now denote B R AR which elements are as follows bip dip cos z aiq sin z biq aip sin z dig cos z bik adik where i k p q bpp app cos z aqq sin z 2 apq Sin Z cos Z bqq app sin z aqq cos z 2 apq sinz cos z bpq 0 and the remaining elements are symmetric where sin z w sqrt 2 1 sqrt 1 w 2 and cos z sqrt 1 sin Z with L apq M app aqq 2 and w Lsign M sqrt ML This is iterated using a strategy for selecting each non diagonal element in turn until all non diagonal elements are zero when rounded to a specific number of decimal places When this is so the diagonal contains the eigenvalues Program remarks The accuracy and running times are display settings dependent however the computed eigenvalues are very often more accurate that it d appear for instance usinf FIX 5 it s quite possible to have eigenvalues accurate to 8 decimal digits The program is written to be as fast as possible and to occupy the minumim amount of program memory the matrix is stored taking into account its symmetry so that all elements are stored only once as aji aij For a nxn matrix minimum size is 2 n 2 n 7 25 41 10 6 Example Find the eigenvalues for the 4x4 matrix A 41 68 17 10 10 17 5 3 6 10 3 2 c ngel M Martin December 2014 Page 69 of 124 SandMatrix_4 Manual Revision N P
20. is a peculiar function in that the irreducibility is tested by brute force using a sequence of integers looking for a prime number result If found the polynomial is irreducible but if not found within the range of the calculator then there s no conclusive determination So this is a glorified example of the trial and errortechnique so to speak 1 LBL COHN bhb ecce in X Using functions from the SandMath makes 2 STOM ipenn programming this criterium a simple affair see 3 RGMAX get maximum coefficient the program listing on the left with functions 4 X lt 0 should be gt 0 RGMAX and PVAL doing all the heavy lifting 5 LN DATA ERRROR if not for you and of course function PRIME 6 STON save maximum finally testing the results for primality 7 8 next integer 9 get control word A restriction of this method is that all coefficients get test point must be positive and obviously the independent evaluate term a0 not null is it prime yes clear X found it no loop back yes recall integer done Example1 p x 2x 4 3x 4 5x41 COHN returns n 6 which result p 6 2731 is a prime Example2 p x 2x Sx 44x 45x 42x41 COHN returns n 8 which result p 8 624977 is a prime c Angel M Martin December 2014 Page 78 of 124 SandMatrix_4 Manual Revision N 4 3 Polynomial Root Finders Once upon a time there was a program called POLYN available in H
21. 0000 prompts for new origin components in stack prompts for angle of rotation prompts for the rotation vector ready for P1 components in stack A N X 9 2622 shows new components Y 17 0649 in automated sequence Z 0 0000 R S optional AN O NEW ready for P2 0 ENTER 4 CHS ENTER 5 CHS 5 0000 components in stack A N X 10 6921 shows new components Y 5 4479 in automated sequence Z 0 0000 R S optional AN O NEW ready for P3 0 ENTER 3 6 CHS ENTER 2 7 2 7000 components in stack B 0 X 11 0401 shows old components Y 5 9818 in automated sequence Z 0 0000 Example 2 A three dimensional coordinate system is translated to 2 45 4 00 4 25 After the translation a 62 5 degree rotation occurs about the 0 1 1 axis In the original system a point had the coordinates 3 9 2 1 7 0 What are the coordinates of the point in the translated rotated sytem Keystrokes Display Action J AN O NEW retrieves menu if USER is on E NEW Z0 Y0 X0 prompts for new origin 4 25 ENTERS 4 ENTER 2 45 2 4500 components in stack R S 62 5 R S ROT lt c b a pr prompts for angle of rotation prompts for the rotation vector 1 CHS ENTER ENTER 0 0 0000 components in stack R S AN O NEW ready for P 7 ENTER 2 1 ENTER 3 9 3 90000 components in stack A N X 3 5861 shows old components Y 0 2609 in automated sequence Z 0 5891 Pro
22. 10 CLA initial sum 11 STOM set pointer to 1 1 12 LBL 00 13 RCLM k 00 n 1 recall element 14 E end of row 15 E3 E 1 001 yes juom out 16 k 1 00n no increase row 17 STON recall element 18 LBL 01 multiply 19 RCLM k 00 n 1 add to partial sum 20 INT k end of matrix 21 RCLN k 1 00n no do next row 22 INT k 1 23 I lt gt J does E3 for integers FC 00 order gt 3 24 k 1 00 n k 1 24 RDN yes get result to X reg 25 MSU sel pointer 25 FC C 00 order gt 3 26 MR recall element 26 RTN yes done 27 X lt gt Y 27 0 28 I lt gt J does E3 for integers 28 MSU set pointer to 1 1 29 MSIJ set pointer 29 RDN ann to X reg 30 RDN 30 MR aoo 31 MR recall element 31 a00 ann 32 ba multiply them 32 add to the sum 33 ST O add to partial sum END done 34 ISG N increase row 35 GTO 01 next element in row 36 ISG M increase colum 37 GTO 00 next colum 38 RCL O partial sum to X reg 39 MNAME recall mname to Alpha 40 END done c Angel M Martin December 2014 Page 58 of 124 SandMatrix_4 Manual Revision N Matrix Polynomial MPOL MPOL was a last minute addition to the ROM which somehow combines both matrix and polynomial algebra Use it to calculate a matrix polynomial P A not to be confused with a polynomial matrix based on an existing square matrix A and a polynomial P x P A is the result matrix calculated replacing the real variable x with A using the polynomial coefficients to multiply the diffe
23. 124 SandMatrix_4 Manual Revision N The last two functions are not operating on a matrix but are auxiliary for the FOCAL programs Function Description Input Output 20 AIP Appends the absolute value of the Value in X integer part of the number in X to the contents of the Alpha register 21 MPT Appends a matrix prompt rrr ccc to rrr ccc in X reg the contents of the Alpha register dropping leading zeros in each part Note that AIP and AINT in the SandMath are very similar but AINT won t take the absolute value This fact is useful to append integer values to alpha without decimal numbers but respecting the sign Note that MPT in the SandMatrix is an enhanced version written in MCODE that replaces the mini FOCAL program used in the Advantage Example Calculate the Row Column and Frobenius norms for the matrix 35 7 A 2 6 4 Alle 02 8 m IA li max 5 ai jl which is simply the maximum absolute column sum of the matrix 1l lt jen i n IA ig meax 9 ai jl which is simply the maximum absolute row sum of the matrix Sismi The results are Row Norm 19 Column Norm 15 Frobenius Norm 14 38749457 The Frobenius norm will come very handy for some programs in Chapter 3 as convergence criteria and to determine whether two matrices are equivalent in reduction algorithms c ngel M Martin December 2014 Page 37 of 124 SandMatrix_4
24. 5 OMC Output Matrix by Column Matrix name in Alpha 6 OXC Output Column k Matrix name in Alpha kkk in X reg 7 OXR Output Row k Matrix name in Alpha kkk in X reg Of all these the most remarkable one is of course PMTM which expedites element data entry to the maximum possible on the 41 platform almost as if it were a full fledge editor in a graphical screen The idea is to use the Alpha register as repository for all the elements separating the individual values by spaces entered using the ENTER key The data input is terminated by pressing R S The back arrow key is always active to correct a wrong entry and will terminate the function if Alpha is completely cleared PMTM allows for negative and decimal numbers to be entered thus the CHS and RADIX keys are also active during the data entry prompt Furthermore the logic will only allow one occurrence of these per each element within the prompt string PMTM knows how many rows should be input it is part of the matrix dimension thus the prompts will continue to appear until the last row is completed A row counter is added to the prompt to indicate the current row being edited If you enter fewer elements in the prompt than existing columns the remaining elements will be left unchanged and the execution will end Conversely if you enter more elements in the prompt than existing columns those exceeding the quota the extra ones will simply be ignored The two limitations of P
25. A V adds L1 L2 L3 64 559 166 885 0 VENTER pushes it to V2 0 ENTER 175 ENTER 1 line polar coordinates P R rectangular 0 996 0 087 0 VSTO 02 saves unit vector A V calculates projection 78 859 Note that you need to execute VENTER at the end of each intermediate vector calculation so the result is placed in the V2 level in registers M N O and doesn t get overwritten by the new vector components being entered When the load L3 is doubled since the sum L1 L2 L3 is still in the level 2 we type Keys Action Result V lt gt A brings L1 L2 L3 back to level 1 VRCL 01 pushes V1 into V2 and recalls L3 to V1 At V adds L3 to the previous sum VRCL 02 pushes V1 into V2 and recalls the line unit vector A V calculates the projection 85 834 There s nothing surprising about the utilization of the vector functions which use the same logic to separate vector arguments as the complex numbers in the 41Z module using ZENTER that you may already be familiar with c Angel M Martin December 2014 Page 108 of 124 SandMatrix_4 Manual Revision N Coordinate transformations The TR program performs three dimensional translation of coordinates with or without rotation This program uses parts of the VC program for vector operations You can access TR either directly or from VC The program prompts you for the coordinates of the origin of the new system x0 yO z0 the angle of rotation of this system rel
26. For further convenience these functions are grouped together in its own launcher ZDST which is accessed pressing XEQ at the V or P prompts You can toggle the 2D and 3D cases with the key whereby changing the display accordingly Note also the usage of the user flags SHIFT annunciators 2 3 to denote the corresponding case where the Shifted screen is for the 2D case Pee el ee Note that VCT and TR are shortcuts for the Advantage s Vector Calculator and Coordinate Transformation programs described before The formulas used are as follows d p q y p 41 pe 2 2D Point to Point distance Where the points are given by P p1 p2 and Q q1 q2 Enter q2 q1 p2 p1 in the stack then execute PP2 The result is left in the X register Example The distance between points M 1 2 and N 3 4 is 4 ENTER 3 ENTER 2 ENTER 1 2V PP2 gt d 2 828427125 _ may y k d m 1 2D Point to Line distance where the line is given by the equation Y mx k and the point is P x1 y1 Enter m p y1 x1 in the stack then execute PL2 The result is left in the X register Example The distance from the point M 2 5 and the line y 3x 4 is 3 ENTER 4 ENTER 5 ENTERS 2 2V PL2 gt d 1 581138830 c ngel M Martin December 2014 Page 115 of 124 SandMatrix_4 Manual Revision N d p q y pi 41 P2 G2 p3 q3 3D
27. I DT BSE displays the solution matrix Exits the editor c ngel M Martin December 2014 Page 18 of 124 SandMatrix_4 Manual Revision N Example 2 Find the inverse of the complex matrix CFA 3 3t 44 5i 647i Note that the original MATRX has been slightly edited in the SandMatrix so that the program sets the required SIZE if not enough registers are currently available to store the matrices so you don t need to worry about that mundane detail This example is also interesting because also shows how to make corrections to the data entered by mistake Keystrokes Display Comments XEQ MATRX RL CX Starts the MTRX program B CX ORDER Selects a complex Matrix 2 R S A I DT BSE Dimensions a 2x2 complex matrix A R S RE1 1 x11 Enters the editor and displays old value 1 R S IM1 1 y11 ditto for the imaginary part 2 R S RE1 2 x12 3 R S IM1 2 y12 4 R S RE 2 1 x21 Wrong entry Should be 3 not 4 1 002 A RE1 2 3 000 Moves editor back to X12 R S IM1 2 4 000 The wrong imaginary part 3 R S RE2 1 x21 Correct value is entered for y 2 Proceed 4 R S IM2 1 y21 5 R S RE2 2 x22 6 R S IM2 2 y22 7 R S A I DT BSE Enters last element and returns main menu B I A I DT B SE Inverts A SHIFT A RE1 1 0 9663 Viewing A 1 R S IM 1 1 0 1461 R S RE 1 2 0 4382 2 002 A
28. JM Baillard and published at http hp41programs yolasite com part frac expan php Given a rational function R x P x Q x with Q x qi x J eenn q x J and gcd qi qj 1 foralli j this program returns the partial fraction expansion R x E x Pra aux J pr EAX JPT eee Pipi q x Fo E S Pana EAn J Pn EAK JPE oeiee Daun X Gn x c ngel M Martin December 2014 Page 94 of 124 SandMatrix_4 Manual Revision N where deg pi lt deg qj and E x is the quotient in the Euclidean division P x E x Q x p x and p x is the remainder Data entry is a complicated affair but it has been automated just follow the process carefully It makes extensive use of the polynomial arithmetic routines PPRD and PDIV Also the polynomial entry routine PEDIT is called several times The program prompts for the number of factors in the denominator as well as for their degrees and multiplicities It also prompts for the coefficients of the numerator polynomial and of each factor polynomial in the denominator so you don t need to store those values manually prior to executing PFE Data output is not automated therefore you d need to interpret the control words returned in stack registers Some guidelines will follow in the examples Examplei Calculate the partial fraction decomposition for R x below R x P xVQ x 6 x
29. JO Ooo O oS SSS OSOS O OEk 35 ALIST 36 AUST gt 44FO 1030 __ CON _ ____ 37 ALIST 38 AUST 2 MFC HOD ENEE 39 ALIST digits input already 40 ALIST ANCHOR1 ONE PROMPT 41 ALIST CLRF 10 clear CHS flag 42 ALIST CLRF 11 allow RADIX 43 ALIST CLRF12 __ setSPACEflag J 44 ALIST add space to LCD 45 ALIST me EET EL OREN 2 ees eee a6 ALIST add to Alpha 7 47 ALIST i i 48 ALIST 49 ALIST PAHC S amp X terminate digit entry 50 ALIST 7B __JNC 15d WAYOUT nnn 51 ALIST 52 ALIST 30 CON 53 ALIST PA C S amp X 54 AUST OO O 023 _ JNC 04 _ DR E a ccssctr oe cnchenck ete chccamnee otk ct cia 55 ALIST Blink Display pass 2 56 ALUST BLINK1 57 AUST EZL lone PROMPT mo 58 ALIST FSET 10 Ha been used already 1 59 ALIST 3F7 JC 02 ONE PROMPT 60 ALIST OS TE O o E first time o 61 ALIST 130 LDI S amp X 62 ALIST 02D mD appends 63 ALIST WRIT 15 e E 9 bit LCD write 64 ALIST 03 ___INC 32d__ TOALPH n 65 ALIST WAYOUT NC XQ Left justify LCD meos gt 2BF7 LEFTJ 9 ngel M Martin December 2014 Page 122 of 124 SandMatrix_4 Manual Revision N 67 ALIST 450F PIF NC XQ 68 ALIST 4510 PZ gt 4958 69 ALIST 4511 FPE NC XQ 70 ALIST 4512 EEE gt 455D 71 ALIST 4513 31D PNC GO 72 ALIST 4514 002 gt 00C7 73 ALIST DELCHR 4515 READ 14 d 74 ALIST 4516 M C ALL 75 ALIST 4517 76 ALIST 4518 77 ALIST 4519 READ 5 M 78 ALIST 451A 2EE C O ALL 79 ALI
30. MNAME yes recall Mname RTN done LBL 06 X lt gt F set case lags SF 25 prepare test LU is LU decomposed NOP will clear F25 if so FC C 25 was it LU SF 04 yes flag this fact END and return Other pointer utilities included are listed in the table below they are used in many of the FOCAL programs described in the following sections Function Description Input Output 8 MROW Prompts the list and controls input Element values as Alpha List 9 I lt gt J Swaps iii and jjj in X iii jjj in X reg also does E3 for integers Index swapped to jjj iii 10 I J Tests whether iii is different from jjj iii jjj in X YES NO do if true 11 SQR Tests for Square Matrices MNAME in Alpha YES NO do if True 12 MFIND Finds an element in a given matrix Element value in X reg and sets element pointer to it Outputs the pointer iii jjj to X reg TJ has been removed in revision M c ngel M Martin December 2014 Page 41 of 124 SandMatrix_4 Manual Revision N 3 2 New Matrix Math functions 3 3 1 Utility housekeeping functions rounding the capabilities This group comes very handy for the handling and management of intermediate steps required as part of more complex algorithms As a rule the functions work for matrices stored either in main memory or in X memory Only MATP and MAT create new matric
31. Manual Revision N Appendix Pascal and Random matrices In mathematics particularly matrix theory and combinatory the Pascal matrix is an infinite matrix containing the binomial coefficients as its elements There are three ways to achieve this as either an upper triangular matrix a lower triangular matrix or a symmetric matrix The 5x5 truncation of these is shown below 11 ks 1 12 3 4 5 Ss 1 3 6 10 15 1 4 10 20 35 1 5 15 35 70 The elements of the symmetric Pascal matrix are the binomial coefficients i e n n Saa l Sij E rin r wheren i r t r l n r in other words see the relationships for the general term and the matrix trace below _ cats y n 5 gt 2k ig Ss L GDP Gar a i k 0 _ bo 7 Random matrices are implemented in the SandMatrix using a time based seed applying a pseudo random algorithm on it and then summing the digits of the mantissa to come up with an integer number It is furthermore rounded to the current display settings thus you can limit the values as required Functions SEEDT RAND and DGT in the SandMath are used See the program listings below For the Pascal matrix function NCR in the SandMath calculates each element value Note how the subindices are tweaked to return ones in the first row and column a nice trick courtesy of JM Baillard 1 LBL PSCAL MNAME in Alpha 1 LBL MRND MNAME in Alpha 2 0 2 0 3 MSIJA set po
32. Page 12 of 124 SandMatrix_4 Manual Revision N The function groups are distributed in both lower and upper pages as follows e The lower page contains the general intro section plus the CCD Matrix set Very much like the lower page of Advantage Pac minus the digital functions It also hosts the auxiliary FAT a necessity in order to have the subfunctions available to the FOCAL programs within the ROM e The second bank in the lower page contains the 3D Vector calculator functions the execution tables for the three launchers and the code for the EQT function Also the return snippets to support the Advantage style bank switching calls to the upper page e The upper page has the Advanced Matrix and Polynomial sections Basically all new and additional to the Advantage Pac e The second bank in the upper page is practically identical to that in the Advantage with a few changes made after removing the Digital functions as well It mostly contains the MCODE for the CCD Matrix functions and the major matrix calculations MSYS MINV MDET TRNPS The SandMatrix checks for the presence of its dependencies i e The Library 4 and the SandMath Note that if the SandMath module is not plugged in the calculator a warning message is shown every time the calculator is switched on but not halting the polling points process whereas if the Library 4 is missing or the machine is not a CX the errors will halt it to avoid likely proble
33. Point to Point distance Where the points components are P p1 p2 p3 and Q qi q2 q3 Use VENTER to separate v1 and v2 in the vector stack then use VADST Example verify that the distance between points P 1 2 3 and Q 1 2 3 is the double of the magnitude of any of them 3 ENTER 2 ENTER 1 VENTER VCHS VADST gt d 7 483314774 3 ENTER 2 ENTER 1 VMOD 2 gt 7 483314774 3D point to line distance d I UxAM II II U I Where the point is M x y z and the line is determined by its anchor point A a b c and unit vector U u v w The program PL3 will prompt for the components of A M and U Example L is defined by the point A 2 3 4 amp the vector U 1 4 9 and M 2 5 3 XEQ PL3 aM 3 ENTER 5 ENTER 2 R S AA 4 ENTER 3 ENTER 2 R S AU 9 ENTER 4 ENTER 1 R S d 2 233785110 3D Point to Plane distance For a plane given by ax by cz d 0 anda point x1 y1 z1 not necessarily lying on the plane the shortest distance from to the plane is jax by cz d va b e The program PPL3 will prompt for the components leaving the result in the X register p Example P 2x 3y 5z 9 and M 4 6 1 XEQ PPL3 APL 9 ENTER 5 ENTER 3 ENTER 2 R S M 7 1 ENTER 6 ENTER 4 R S d 3 568871265 3D Line to Line distance d UxU AA UxU I For a line L determined by one point A a b c and one
34. Revision N So we see that unfortunately the logarithm is not a trivial exercise The programs are listed below note the combination of both exponential and logarithm into a single program with flag 01 controlling the case 44 LBL02 2 SF 01 exp flag 45 VIEW 00 3 GTO 00 46 oP 4 LBL MEXP 47 ARCL 01 5 CF 01 LN flag 48 ay p 6 49 M M 7 SQR square 50 PH 8 LU yes but LU 51 CLST 9 ADV MATRX not square show error 52 MMOVE 10 ASTO 01 53 RCL 02 11 vje An 54 FC 01 exp 12 MAT safekeeping copy 55 FACT to be used as divisor 13 DIM get dimension 56 FC 01 exp 14 p 57 GTO 04 15 MATDIM auxiliary matrix 58 ENTER 16 4 59 ENTER 17 MATDIM auxiliary matrix 60 E to be used as divisor 18 MIDN 61 19 ARCL 01 62 CHSYX 20 FS 01 LN 63 LBL 04 21 ASWAP yes swap names 64 P X 22 fa At 65 MAT divide by scalar 23 FS 01 LN 66 ABSP remove X 24 MAT 67 JA An prepare new string 25 FC 01 exp 68 MAT safekeeping copy 26 MAT 69 E 27 KAN 70 ST 02 increase term index 28 FNRM initial norm 71 ar 29 STO 00 store in ROO 72 FNRM new frobenius norm 30 FC 01 exp 73 X lt gt 00 swao with old norm 31 CLA 74 RCL 00 recall new again 32 ARCL 01 75 X Y are the different 33 FC 01 exp 76 GTO 02 yes keep at it 34 GTO 04 77 ARCL 01 no we re done 35 MAT 78 MAT 36 CLAC 79 PURFL purges 37 ABSP 80 P 38 LBL 04 81 PURFL purges P 39 82 ASWAP 40 CLST 83 PURFL purges 41 MMOVE 84 MNAME recalls name to Al
35. all these functions perhaps MRDIM needs further explanation Contrary to MATDIM a proper re dimensioning should respect the elements in the re dimensioned matrix that held the same position in the original one MRDIM does this deleting the discarded elements when the redimensioned sub matrix is smaller than the original and completing the new one with zeroes when it is bigger super matrix It always starts with a11 no random origin is possible MNAME in Alpha 16 X lt gt Y min j1 j2 2 DIM get dimension 17 RCLZ 3 X lt gt Y new dimension to X 18 INT min I 4 ASTO T temporary safekeep 19 min I min j 5 Tar add tilde 20 0 6 MATDIM create new matrix 21 STOZ prepare pointers 7 CLA 22 ASTO T temporary safekeep 8 ARCL T MNAME 23 ts 9 X gt Y 24 ARCL T MNAME 10 X lt gt Y min i1i2 25 ter prepare Alpha string 11 STOZ keep inZ 26 MMOVE copy elements 12 FRC 27 PURFL purge original file 13 X lt gt Y 28 MNAME recall name to Alpha 14 FRC 29 END done 15 X gt Y A logical enhancement to this routine would be to change the matrix name back to its original one removing the tilde This can be done in two ways 1 creating a new matrix file and copying it over once again or preferable 2 using RENMEL in the AMC_OS X module to rename the X mem file c Angel M Martin December 2014 Page 44 of 124 SandMatrix_4 Manual Revision N Finding an element within a Matrix MFIND pl
36. are the eigenvalues of A listed according to their algebraic multiplicities then tr A XA det A X Another powerful property relates the trace to the determinant of the exponential of a matrix as follows Jacobi s formula det e eA MTRACE uses a single element approach basically adding all the elements in the principal diagonal For small to mid size matrices this is faster than a block approach redimensioning and transposing the matrix such as the one sketched below courtesy of Thomas Klemm DIM n n 1 at DIM i n DET l I 2 2 i ia sf SS ye occ SS fs CO SS fF weeny SS TL OS EA 1 0 0 OF l Ol 11 l Ol Here s the sweet and short SandMatrix program listing compared side by side to a block approach alternative implementation which also requires a scratch matrix if one wishes to keep the original matrix unchanged as well as some additional steps for Alpha housekeeping c Angel M Martin December 2014 Page 56 of 124 SandMatrix_4 Manual Revision N Note how in the alternative approach function SUM is used which removes the need to calculate the last step of the sketch Regardless it s bigger and takes longer execution time even without the test for square matrix condition 1 LBL MTRACE MNAME in Alpha 1 LBL TRACE2 2 SQR square 2 prepare Alpha string 3 LU yes but LU 3 MAT make scratch 4 ADV MATRX not square show error 4 AS
37. at x 2 7 011 XEQ PMTP 25 ENTER 16 ENTER 9 ENTER 4 ENTER 1 R S 2 XEQ PVAL gt 573 0000000 RDN 2 V DPL gt 1 032 000000 c Angel M Martin December 2014 Page 76 of 124 SandMatrix_4 Manual Revision N And finally closing the circle of derivatives we enter P x in memory 12 015 XEQ PMTP 100 ENTER 48 ENTER 18 ENTER 4 R S 2 XEQ PVAL gt 1 032 000000 But wait there s more PVAL can also evaluate the primitive polynomial i e calculating the integral between zero and the evaluation point of the original polynomial Simply change the sign of the control word in Y so it s negative to trigger this mode Example Calculate the integral of Q x x 2 3x 7 in the interval 0 2 First we enter the coefficients in registers R09 R11 using PMTP as usual then we type 9 011 CHS 2 PVAL gt 5 333333334 obtained in a blazing fast short time that sure beats the heck out of INTEG FINTG approach There s much to be said about simple functions like these that when implemented in MCODE provide maximum speed and convenience As an exercise you re encouraged to write a polynomial real root finder routine using Newton s left or Halley s right methods for the successive approximations to the roots Programming them for polynomials should become a near trivial task using the functions desc
38. elements data In subroutine mode it ll take the matrix name from Alpha The function is aware of whether it s being run in RUN or PROGRAM mode The data entry is omitted during a program execution There s no need to remember to set user flags or clear it for manual mode saving one FAT entry for a subroutine as well The program checks that the matrix is square and not in LU decomposed form presenting error and warning messages respectively For LU decomposed matrices you can double invert them on the spot assuming they re invertible and keep going just pressing R S The selection of the interval a b plays an important role in finding the solution obviously the closer to the actual value the faster it ll find it Remember also that the accuracy is determined by the display settings on the calculator so FIX 9 will provide for both the most accurate and longest execution time Example Find one eigenvalue for the matrix A below using the subroutine mode 315 As 3 3i 464 Keystrokes Display Result ALPHA EV3 ALPHA X reg contents MNAME is in Alpha 3 003 XEQ MATDIM 3 003 Creates matrix in X Mem XEQ PMTM R1 _ Prompts for the first row 3 ENTER 1 ENTER 5 R S R2 second row 3 ENTER 3 ENTER 1 R S R3 _ third row 4 ENTER 6 ENTER 4 R S 6 0000 XEQ EIGEN LO V Prompts for lower bound 5 R S HI V Higher bound 15 R S flyi
39. for ALPHA FACTORS LINKS ALPHA XEQ MSYS Week 1 Week 2 Week 3 Cabbage Weight kg 186 141 215 Broccoli Weight kg 88 92 116 Note using OMR or OMC to output the elements of the matrix B you can see how the results are all integer values which speaks of the accuracy of the internal operations taking advantage of the 13 digit math routines available in the OS for MCODE Note also that with these programs the integer results are shown without any zeros after the decimal point regardless of the current display settings FIX or otherwise OMR and OMC are extension functions pretty much like PMTM is and will be described in detail in chapter 3 c Angel M Martin December 2014 Page 33 of 124 SandMatrix_4 Manual Revision N 2 3 3 Other Matrix Functions Utilities The remaining matrix functions also called utilities are those for copying and exchanging parts of matrices and miscellaneous extra arithmetic functions finding sums norms maxima and minima and matrix reduction Moving and Exchanging Matrix Sections Function Description Input 1 C lt gt C Exchange columns k and in a matrix Name in Alpha kkk Ill in X reg 2 R lt gt R Exchange Rows k and in a matrix Name in Alpha kkk Ill in X reg 3 MMOVE Matrix Move Names in Alpha Pointers in stack 4 MSWAP Matrix Swap Names in Alpha Pointers
40. functions just a single keystroke doing the same as all those intricate FOCAL programs did using Gaussian algorithms element pivoting and row simplification simply amazing back then It was the ultimate Matrix function set pretty much surpassing the HP 15C implementation in this area If you re reading this now I suspect you probably had a similar experience too but enough reminiscing and let s get on with the manual The output of these operations always replaces the original matrix with the result Moreover for MDET and MSYS the result matrix is placed in its LU decomposed form which makes it not suitable for some direct subsequent operations Note You cannot transpose or change any element of a matrix A that has had its determinant found or has had its solution matrix found because MDET and MSYS transform the input matrix A into its LU decomposed form Refer to LU Decomposition for more information However you can retrieve the original form of A from its decomposed form by inverting it twice execute MINV twice The LU decomposition does not interfere with the calculations for MINV MSYS or MDET Example 1 6 3 2 Find the determinant of the inverse of the transpose of the matrix Storing it in Main Memory starting in Register RO 2 ia 1 First make sure that the calculator SIZE is set at least to 10 to accommodate the elements plus the header register typing XEQ SIZE 010 Next we begin by creating the matrix in
41. g r 51 END done r 26 AIP append index c Angel M Martin December 2014 Page 72 of 124 SandMatrix_4 Manual Revision N 4 2 2 Polynomial Arithmetic PSUM PPRD PDIV The arithmetic functions provide convenient functionality for the basic operations addition subtraction multiplication and eucliedean division A distinction is made between the three base routines PSUM PPRD and PDIV written by JM Baillard and the four user friendly drivers that automate the element data entry and work out all the details behind the scenes For the first group beside the element data entry the control words for each operand polynomial and the result are typically input in the X Y and Z registers of the stack As follows Operation Addition Subtraction Euclidean Division Copy Multiplication bbb eee1 in Z bbb eee of dividend in Y bbb eee of source in Y anpe Bobo ee in Y bbb eee of divisor in Y bbb or destination in X 1st Reg of result in X bbb eee of reminder in Y Output bbb eee of result in X bbb eee of quotient in X bbb eee or result in X Because registers ROO to RO3 are used internally they cannot be used to hold the polynomial coefficients ie all control words must start at bbb 4 at least Note also that none of the register ranges should overlap In addition for the Euclidean Division the original polynomials are overwritten with the results quot
42. is left unchanged A V Calculates the DOT product of V1 and v2 Result is left in X reg X component of v1 is saved in LastX all other registers are unchanged AXV Calculates the CROSS product of V1 and V2 Result vector v2 x v1 is placed in V1 with v1 saved in LastV V2 is left unchanged A V Calculates V2 x 1 V1 Same result and LastV conventions apply EXSCR Exchanges Vector in Alpha v2 with registers L T a LASTV Recalls last vector to level 1 and pushes V1 into V2 X V Scales the vector with components in T Z Y by the factor in X Result is left in level V1 V lt gt __ Exchanges vector in Vi with the vector register nn Supports INDirect addressing V lt gt A Exchanges vectors in levels V1 and V2 VADST Calculates the distance between V1 and V2 Result is left in X reg with X component of vi saved in LastX VANG Calculates the angle between V1 and V2 Result is left in X reg with X component of vi saved in LastX VCHS Changes sign of all components of v1 Original v1 is saved in LastV VO VENTER Pushes v1 in X Y Z regs into the V2 level M N O regs VIEWV Sequentially shows the three components of vector v1 VINV Replaces v1 with the inverse of its components Original v1 is saved in VO VMOD Calculates the modulus of vi SQRT Vx 2 Vy 2 Vz 2 Result is placed in X reg with the x component saved in LastX VNORM Calculates the norm of v1 Vx42 Vy 24 Vz 2 Result is placed in X reg with the x component saved i
43. mmm nnn as twice the number of rows and twice the number of columns Refer to Working with Complex Matrices A zero part defaults to a 1 so 0 is equivalent to 1 001 3 to 3 00 1 and 023 to 1 023 LS a 1 1 243 amp 8 6 4 51 6 7 mmm nnn 2 003 mmmnnn 4 004 c ngel M Martin December 2014 Page 20 of 124 SandMatrix_4 Manual Revision N e MATDIM Dimensions a new matrix or redimensions an existing one to the given dimensions e MNAME Returns the name of the current matrix to the Alpha register e IDIM Returns the dimensions mmm nnn of the matrix specified in the Alpha register to the X register A blank Alpha register specifies the current matrix How a Matrix Is Stored The elements of a matrix are stored in memory in order from left to right along each row from the first row to the last Each element occupies one data storage register A complex number requires four registers to store its parts Memory Space A matrix in main memory occupies m x n 1 data storage registers one register being used as a status header A complex matrix uses 2m x 2n 1 registers where m is the number of rows in the complex matrix and n is the number of columns in the complex matrix A matrix in extended memory has a file length of m x n 2m x 2n for a complex matrix Its file type is unique to matrices Do not use the function CLFL with a matrix in extended memory this
44. n rows and n columns by such a vector v the result will be another vector w A v also with n rows and one column That is Vy Wy Ait Arin vj W2 A21 Aon v2 is mapped toj Un Wh A nl Ann Un c ngel M Martin December 2014 Page 61 of 124 SandMatrix_4 Manual Revision N where for each index i n wi Aji Ait Aintn D Ai i j 1 In general if v is not all zeros the vectors v and A v will not be parallel When they are parallel that is when there is some real number such that A v A v we say that v is an eigenvector of A In that case the scale factor A is said to be the eigenvalue corresponding to that eigenvector In particular multiplication by a 3x3 matrix A may change both the direction and the magnitude of an arrow v in three dimensional space However if v is an eigenvector of A with eigenvalue the operation may only change its length and either keep its direction or flip it make the arrow point in the exact opposite direction Specifically the length of the arrow will increase if A gt 1 remain the same if A 1 and decrease it if A lt 1 Moreover the direction will be precisely the same if A gt 0 and flipped if lt 0 If 0 then the length of the arrow becomes zero 4 4 4 Eigenvalues and eigenvectors of matrices Characteristic Polynomial The eigenvalue equation for a matrix A is Av Av 0 which is equivalent to A AI v
45. nybbles 0 1 2 and the number of columns field nybbles 6 7 8 whereby Number of rows File size Number of Columns Lastly the pointer field stores the information on the current element as a counter starting from the first element 1 to the last nxm Given the length of this field it follows that a maximum of 4 096 elements FFF can be tracked equivalent to a square matrix of dimensions 64 x 64 or any equivalent m x n combination You can use the function LU to check whether a matrix is in its LU decomposed form It ll return YES NO in Run mode but in a program will halt the execution if true i e it s decomposed Working with Complex Matrices When working with complex matrices it is most important to remember that in the calculator a complex matrix is simply a real matrix with four times as many elements Only the MATRX program and the complex matrix editor CMEDIT recognize a matrix as complex and treat its elements accordingly All other functions treat the real and imaginary parts of the complex elements as separate real elements How Complex Elements are represented In its internal representation a complex matrix has twice as many columns and twice as many rows as it normally would 100 200 The complex number 100 200i is stored as 200 100 lL 2 l 2i 2 A The 2 x 1 complex matrix T is stored as i 4 3 There is one important exception to this scheme for the column matrix a v
46. operations where one of the operands is stored in Alpha c Angel M Martin December 2014 Page 14 of 124 SandMatrix_4 Manual Revision N 2 2 The Matrix function launcher and Keyboards It has become customary in the author s modules to always use function launchers to enhance the user interface as the most convenient way to save key assignments As expected there is a function launcher in the SandMatrix that groups many of the most frequently used matrix functions plus a few others thrown to the mix All functions can be accessed from the M _ prompt there is no need to make any key assignment other that for the main launcher itself This becomes active when you execute XML the function launcher in run mode When executed it presents the M prompts and awaits your next selection Pressing A in turn activates the Vector prompt V _ and pressing it a second time the Polynomial prompt P _ The following pictures of the Matrix and Polynomial Overlays show the available functions in the dedicated keyboards Note that those with blue names on the keys are called using the main keys ie unshifted and those in green above the keys require pressing the key in the corresponding prompt It also shows the M launcher assigned to the key as usual hp 41 SandMATRIX hp 41 PolynROM c Angel M Martin December 2014 Page 15 of 124 SandMatrix_4 Manual Revision N 2 3
47. sets pointer to 1 1 80 SF 10 fake condition 27 RDN argument to x 81 LBL 01 PF Completed 28 CF 00 default not prime 82 E 1 29 INT condition x 83 FC 10 end of matrix 30 ABS to avoid errors 84 MSR store it as last exp 31 PRIME is it prime 85 STO 00 initial value 32 SF 00 FIRST PF found 86 MSIJA sets pointer to 1 1 33 MSR Store this PF 87 CLA Clean Slate 34 X 1 is PF 1 88 Rebuild the number 35 GTO 01 yes leave the boat get prime factor 36 FS C 00 Was it Prime if not totient case 37 GTO01 if Prime we re done add it to Alpha 38 STO 01 Store PF for comparisons get multiplicity 39 ST L divide number by PF if not totient and 40 LASTX Reduced number or if it is one 41 LBL 05 skip adding to Alpha 42 E reset counter otherwise put symbol 43 STO 00 and add it to the string 44 RDN 98 45 LBL 00 PFAExp 46 RCL 01 recall PF Rebuilding the number 47 X lt gt Y Reduced number End of Array 48 PRIME is it prime yes leave the boat 49 SF 00 PF found if not totient case 50 X Y Compare this and old PF s append symbol 51 GTO 02 skip over if different next PF 52 ISG 00 Same One 106 53 NOP Increase counter 107 RCL 00 final result 54 FS C 00 Was it Prime 108 FC 04 if not totient case 109 AVIEW Show the construct 110 END done c Angel M Martin December 2014 Page 88 of 124 SandMatrix_4 Manual Revision N 4 4 4 Polynomial Fitting POLFIT The next program is taken from Valent in Albillo article
48. stored vectors e Be sure to give each vector three dimensions If it has only two dimensions then enter a zero for Vz e Enter the vector s dimensions as rectangular coordinates If you have polar coordinates magnitude and angle for a two dimensional vector convert them using the function P R polar to rectangular e For those operations involving angles the units will match the current angular mode setting Degrees Radians or Grads e The view function E is very useful for reviewing the components of V2 in the stack e Vi refers to the top vector the one in M N and O Alpha registers V2 refers to the bottom vector the one in X Y and Z stack registers c Angel M Martin December 2014 Page 103 of 124 SandMatrix_4 Manual Revision N This menu will show you which key corresponds to which function in VC Press J to recall this menu to the display at any time VXY VS VA MENU F H j J ti EP USER i To clear the menu at any time press This shows you the contents of the X register but does not end the program You can perform calculations then recall the menu by pressing J However you do not need to clear the program s display before performing calculations The Vector Calculator provides two methods for entering a vector into the vector stack The vector enter function VENTER is analogous to the ENTER key A shortcut method o
49. taken from the next line in a program Zero is not explicitly required and INDirect is done by adding 128 to the address 80 Hex They operate on 3 register blocks and their indexes are logical and not related to the actual underlying data registers Compatibility with Alpha messages Scratch The choice of Alpha for the second vector level V2 requires some work around when the use of Alpha prompting or displaying is also needed in a FOCAL program like VC or TR This has been accomplished with EXSCR a simple register swapping function to be called both before and after the PROMPT or AVIEW actions effectively preserving V2 in a scratch area registers L T and a during the process This requires that no more than 2 pending subroutine returns are used before calling VC not perfect but clever enough to work in practicality LASTV functionality Level 0 ina dynamic scheme The natural choices for a temporary storage of the LastV VO components are the still unused registers L T and P Using L is a given since it already works like a LastX in the real case T is a safe choice but P becomes unusable in all practical cases due to the OS demand for it as data entry scratch We chose register Q instead as a better fit despite also being very volatile In reality both P and Q are used to hold the third coordinate in sequence it is first stored in P when the function execution commences where it remains during the calc
50. the accuracy 0 999999999 0 499999999 0 333333333 Sqr A 2 0 500000000 0 333333333 0 250000000 0 333333333 0 249999999 0 200000000 which isn t bad at all for a 33 years old calculator indeed c Angel M Martin December 2014 Page 49 of 124 SandMatrix_4 Manual Revision N Example 2 Find a square root of the 4 x 4 matrix below and check the accuracy by squaring it back 56 97 17 89 33 68 42 5 206 48 34 104 39 92 27 30 Using FIX 4 and PMTM for the data input nice integer values the result is as follows 8 0000 6 0000 1 0000 7 0000 7 0000 1 0001 8 0000 3 0000 8 0001 6 0000 8 0000 6 0000 6 0000 7 0000 7 0000 3 0000 SQRT A which is exact to 4 decimal places save a couple of u ps here and there The program listing is shown below Note the relatively short program but here too the data requirements are equally hefty as three auxiliary matrices are required for a total of 4 x dim A registers needed either in main or X memory including the original matrix 30 X YR are they equal gt 2 SQR square 31 SF 00 yes flag this fact 3 LU yes but LU 32 X YRP are they equal gt 4 ADV MATRX not square show error 33 GTO 02 yes jump over 5 CF 00 34 CLA no keep at it 6 FNRM initial norm 35 ARCL 01 7 STO 00 store it in ROO 36 prepare Alpha string 8 ASTO 01 matrix name to R01 37 MINV invert matrix 9 DIM dimension to X reg 38 MAT copy in auxiliary 10 pr 39 MINV undo
51. the user to enter N 04 1 add 1 to get the number of data points 05 N 1 06 1 001 the required multiplier 07 forms the matrix dimensions N 1 00 N 1 08 MX specifies matrix MX to be created in X Mem 09 MATDIM creates and dimensions matrix MX in X MEM 10 0 specifies first row first column and 11 MSI resets the row column indexes 12 LBL 00 loop to ask for data amp compute MX elements 13 MRIJ recalls the current value of the indexes 14 x forms the prompt to ask the user to enter xi 15 AIP appends the index to the prompt 16 appends to the prompt 17 PROMPT prompts to enter xi and resume execution 18 ENTER fills the stack with the value of xi 19 ENTER in order to compute all powers of xi 20 ENTER from 1 to xi n and store them in MX 21 1 initializes the value of xi 0 i e 1 22 MSR stores it in MX and updates the indexes c Angel M Martin December 2014 Page 89 of 124 SandMatrix_4 Manual Revision N Notes 23 LBL 01 loop to compute the powers of xi 24 computes xi4j 25 MSR stores it in MX and updates the indexes 26 FC 09 are we done with this row 27 GTO 01 not yet go back for the next xi power 28 FC 10 row done Are we done with all rows 29 GTO 00 not yet go back to ask for the next xi 30 CLA all rows done MX complete Make it current 31 DIM get its dimensions N 1 00 N 1 32 INT get N 1 avoid usin
52. then checked to see if we re done with all the rows e Once the system matrix has been populated lines 30 45 do likewise dimension and populate the MY matrix prompting the user for the required yi values Then once all the data have been input and both matrices are allocated and populated lines 46 47 solve the system for the coefficients of the polynomial using MSYS e Finally lines 48 59 establish a loop that labels and outputs all the coefficients Example Rumor has it that the seemingly trigonometric function y cos 5 arccos x is actually a 5th degree polynomial in disguise Attempt to retrieve its true form If it is indeed a 5th degree polynomial we can retrieve its true form by fitting a 5th degree polynomial to a set of 6 arbitrary data points x y Any set with different x values 1 0 lt x lt 1 0 will do but for simplicity s sake we ll use x 0 0 2 0 4 0 6 0 8 and 1 Proceed like this set Rad mode 4 decimals XEQ RAD FIX 4 start the program XEQ POLFIT N specify degree 5 5 R S X1 enter ist x value 0 R S X2 enter 2nd x value 0 2 R S X3 enter 3rd x value 0 4 R S X4 enter 4th x value 0 6 R S X5 enter 5th x value 0 8 R S X6 enter 6th x value 1 R S Y1 enter 1st y value 0 ACOS 5 COS R S Y2 enter 2nd y value 0 2 ACOS 5 COS R S Y3 enter 3rd y value 0 4 ACOS 5 C
53. to square a matrix i e n 2 The first requires the matrix name in Alpha and the exponent in the X register whereas for the second only the matrix name in Alpha is needed The exponent may also be a negative integer For that case the inverse matrix is calculated first and the positive integer power is used for it Lastly for n 0 the result is the identity matrix of course A feeble attempt is also made for the integer roots calculation the function M 1 X will attempt to calculate the x th root of a matrix using the general expression A exp 1 x Ln A which is only valid when abs IIA IIl lt 1 Despite the inherent limitations of these programs they are interesting examples of extension of the native matrix function set and therefore their inclusion in the SandMatrix Examplei Calculate the 7 th power of the matrix below Type XEQ MPWR and the result is 7851276 8652584 31076204 A 8911228 9823060 35267932 5829472 6422156 23076808 Example 2 Calculate the 5 root of matrix A below then compare its 5 power to the original matrix 1 2 0 1 0 3 A 01 08 0 1 0 1 0 2 0 9 The results are as follows 1 034632528 0 015156701 0 057916477 A gt 0 019601835 0 953558110 0 020490861 0 017823781 0 045426856 0 974937998 1 199999994 0 100000000 0 300000000 A1 0 100000000 0 800000000 0 100000000 0 100000000 0 200000000 0 900000000
54. 000E0 a3 2 000000E0 a4 1 000000E0 n 4 R4 1 000000E0 E4 0 000000E0 D4 1 000000E0 Original author OPFIT was written by Eugenio Ubeda and published in the UPLE The version in the SandMatrix only had minimal changes made to it It was by far the longest program in the module and unfortunately had to be removed to make room for the Vector Functions c Angel M Martin December 2014 Page 92 of 124 SandMatrix_4 Manual Revision N 4 4 6 From Poles to Zeros and back POLZER PFE These two programs complete the applications section The first one calculates the zeros of a polynomial expressed as a partial expansion of factors as would typically be the case when working with transfer functions in control theory The second program builds the partial fraction expansion for a polynomial given it its standard or natural form Function Description Input Output 1 POLZER Zeros of transfer functions Under program control 2 PFE Partial Fraction Expansion Under program control This program calculates the polynomial coefficients and roots of expressions such as P x 1 x pi i 1 2 n Which will be transformed into P x aix4i i 0 1 n 1 The coefficients are obtained using the following formulae a n 1 n a n 2 n 1 pi a n 3 n 2 pi pj a n 4 n 3 pi pj pk a n 5
55. 1 2 4 1 4 1 A 3 5 7 and B 5 9 2 7 9 8 6 5 3 The results are ALPHA A B C ALPHA 15 11 23 XEQ MLIE gt Lie A B 24 19 65 58 85 34 ALPHA B A C ALPHA 15 11 23 XEQ MLIE gt Lie B A 24 19 65 58 85 34 The program listing is shown on the left Note the usage of the scratch matrix to temporarily hold the result of the two matrix products always the same limitation imposed by M M and the extensive usage of the alpha string management functions like ASWAP necessary to deal with the three matrix names in the string In fact SWAP swaps the contents of the Alpha register around the first comma character encountered which makes it so interesting in this case 1 LBL MLIE OPI OP2 RES in Alpha 15 ARCL 00 RES RES 2 XEQ 00 calculate OP1 OP2 16 MAT 3 ST lt gt A complete string to stack 17 g 4 MNAME RES 18 PURFL purge 5 ASTO 00 19 MNAME 6 ST lt gt A restores complete string 20 RTN done 7 Qac OP1 0P2 8 ABSP OP1 OP2 22 DIM get dimension 9 ASWAP OP2 0P1 23 ASWAP OP2 RES OP1 10 OP1 0P2 24 ASWAP RES OP1 OP2 11 XEQ 00 calculate OP2 OP1 25 MATDIM create RES 12 CLA 26 ASWAP OP1 OP2 RES 13 ARCL 00 RES 27 M M matrix product 14 E ipl S RES 2 28 END return c Angel M Martin December 2014 Page 55 of 124 SandMatrix_4 Manual Revision N Matr
56. 21 to control the display prompt set or not clear Initially keeping track of the different sub function launchers can be a bit challenging but easy enough to remember that it s just two of them XF in the SandMath and xV in the SandMatrix or their corresponding index based counterparts XF and EV c Angel M Martin December 2014 Page 118 of 124 SandMatrix_4 Manual Revision N The alternative Vectors as Matrices V VN performs the same tasks n dimensional vector dot product but using a different approach treating the vectors as column matrices it simply uses M M to calculate the result multiplying the first operand vector by the transpose of the second operand vector All data input output are driven under program control The execution time is longer than DOTN trading so convenience for speed To appreciate the workings of V VN you need to consider that it transposes V2 before doing the multiplication and that it calculates the Frobenius norms of each matrix on the fly to obtain the angle The dot product is placed in a 1x1 matrix named V V in X Mem Here s the listing of the program that clearly shows all the housekeeping chores required to prepare the strings needed in ALPHA for the matrix functions as input Even if it s somehow slower and less efficient it s a good academic example of utilization of the standard matrix functions 01 LBL V V T 31 FNRM 02 FS 06 subr
57. 38 39 40 41 42 43 7 a 3 FT FT o a a 4 q FT 3 FT a FT TF 4 HI V 2 PROMPT prompt upper bound CCD MATRX show RUNNING HEV FROOT Solve for Ev TONE 4 found Eye ARCL X PROMPT display result GTO 00 next guess LBL EV subroutine myn MIDN make matrix identity y MAT multiply it by scalar guess g ARCL 00 prepare Aplha string MAT calculate the eigen matrix MDET get its determinant END return works for N dimensional orders In that regard its execution time provided that a decent CHRPOL the other program that calculates CHRPOL obtains a the eigen values simultaneously When compared to other approaches the program listed above is a most minimalistic that s its real benefit and the reason that justifies its inclusion in the SandMatrix module However relying on FROOT is clearly not a robust approach to calculate eigenvalues The calculation of the characteristic polynomial using dedicated methods is a necessity c Angel M Martin December 2014 Page 64 of 124 SandMatrix_4 Manual Revision N 3 Dimensional case EV3X3 Let s start with the particular case n 3 In this scenario there are simple formulas to calculate the characteristic polynomial which make the calculations simpler and faster The formulas are derived from the properties of the characteristic polynomial Let s enumerate the mo
58. 4 Manual Revision N When the end of a column or row is reached the pointer s index advances to the next or previous column or row If the pointer s index is moved beyond the boundaries of the matrix it cannot be moved back using these functions You must use MSIJ or MSIJA The following sequence of keystrokes will create the matrix ABC in extended memory 5 6 7z ABC 10 Keystrokes Display Comments ALPHA ABC ALPHA 2 003 XEQ MATDIM 2 003 Dimensions matrix ABC in X Mem 0 XEQ MSIJA 0 000 Sets pointer to 1 001 position 5 XEQ MSR 5 000 Enters element and advances pointer to next column for next entry 6 XEQ MSR 6 000 Ditto as above 7 XEQ MSR 7 000 Pointer automatically moves to second row also setting flag 09 8 XEQ MSR 8 0000 9 XEQ MSR 9 0000 10 XEQ MSR 10 0000 This sets both flags 09 and 10 SF 08 This sets the editor to display only XEQ MEDIT 1 1 5 0000 R S 1 2 6 0000 R S 1 3 7 0000 R S 2 1 8 0000 R S 2 2 9 0000 R S 2 3 10 0000 Updated Matrix Editor Row Input mode Another more effective way to enter the element values involves using PMTM instead of MEDIT to handle them one row at a time This drastically speeds up the process although some limitations apply e The maximum length for all values and the blank spaces in between them is 24 characters as it uses the Alpha regis
59. 454C 01C_ 307F6 _ lt lt 129 ALIST 454D 3B8 READ 14 d 130 ALIST 454E 3D8 C lt gt ST XP 131 ALIST 454F 148 SETF 6 132 ALIST 4550 24c FSET9 133 ALIST 4551 013 JNC 02 134 ALIST 4552 288 SETF 7 135 ALIST 4553 3D8 C lt gt ST XP 136 ALIST 4554 3E8 WRITI5 e a 137 ALIST 14555 7130 LDI S amp X 138 ALIST 2556 cans a 139 ALIST 4557 24c FSET 9 140 ALIST 4558 360 CRTN_ _ 141 ALIST fas59 P226 C C 1 S amp X 142 ALIST 455A 226 CA o tearm dh ees B BEOW R c Angel M Martin December 2014 9 bit LCD write Clear LCD and reset things EXIT3 Adjust F10 Status ADJF10 Normal Function ReturnKB NERKB to delete rightmost chr save it for later P NC XQ Disable PER enable RAM gt 0952 ENCPOO anything in Alpha yes goon no abort if empty from table Reset everything and leave NC XQ Mainframe Message gt 1C6C MSGA remove last Alpha char ABSP4 recall deleted char value store in A for comparisons lt space gt complete the logic CHUNK4 repeat the prompt GOBACK carry if different allow new space entry BAIL OUT check for chr char value carry if not is there SPACE chr allow new BAI L OUT recall deleted char value Got a radix If so we neet to replace it without comma entry both if need be recall deleted char value
60. 5 matrix Y Register Pointer Value 0 000 4 005 3 000 3 005 0 003 4 003 c ngel M Martin December 2014 Page 34 of 124 SandMatrix_4 Manual Revision N Miscellaneous Arithmetic Functions Maxima and Minima Function Description Input Output 5 MAX Finds the maximum element in matrix Matrix Name in Alpha Sets element pointer to it Outputs element value to X reg 6 MIN Finds the minimum element in matrix Matrix Name in Alpha Sets element pointer to it Outputs element value to X reg 7 MAXAB Like MAX but in absolute value Sets Matrix Name in Alpha element point to it Outputs element value to X reg 8 CMAXAB Finds maximum absolute value in k Matrix name in Alpha kkk in X reg th column Sets element pointer to it Outputs element value to X reg 9 RMAXAB Finds maximum absolute value in k th Matrix name in Alpha kkk in X reg row Sets element pointer to it Outputs element value to X reg Examples Calculate the different maxima and minima for the following matrix Column Function Result Pointer Result value MAX al4 4 MAXAB a44 36 CMAXAB a43 24 RMAXAB a24 12 MIN a44 36 Miscellaneous Arithmetic functions Norms and Sums Function Description Input Output 10 CNRM Column Norm Finds the largest sum Matrix name in Alpha of the absolute values of the elements Outputs column norm
61. 7x42 8 x 12 which plot is shown below 2 ENTER 7 CHS ENTER 8 CHS ENTER 12 XEQ QUART gt gt gt gt X1 2 000 x2 1 000 X3 2 000 x4 3 000 The presentation of complex roots will not stop the execution unless you set flag 21 c Angel M Martin December 2014 Page 80 of 124 SandMatrix_4 Manual Revision N 4 3 2 General case degree N PROOT BAIRS Given a polynomial P P z aj2z ag 1 a 0 i 0 This method is based on quadratic factorizations that is one quotient polynomial of degree 2 plus a reminder polynomial of degree one reducing the original degree by 2 and thereby changing the expression as follows P z P z Q z R z with P z bi z4n i i 2 1 n 2 This will then be repeated until the reduced polynomial P x reaches degree one or two Let Q x x42 px q and R x rx s Then the reduced polynomial coefficients are given by and we have the following expressions for the coefficients of the reminder r b n 1 s b n 2 p b n 1 2 clearly with both r and s depending on the p q values formally expressed as r r p q and s s p q The problem is thus obtaining the coefficients p q of such a quotient polynomial that would cancel the reminder i e that make r 0 and s 0 This is accomplished by using an iterative approach starting with some initial guesses for them p0 q0 ite
62. 9 registers CMEDIT RE 1 1 Complex matrix editor 5 0 RE 2 1 Loads the real and 0 R S 0 R S 0 0000 imaginary parts of ele ments into R17 the column matrix B Finally it comes the time for the real work using MSYS to solve the system and MCEDIT again in view only mode to review the results Keystrokes Display ALPHA R R 17 0 0000 Calculates the solution MSYS matrix X and loads it into R17 SE 108 Sets editor for view only operation R17 Displays the complex MEDIT RE 1 1 0 0372 results for J and Is R S IM 1 1 0 1311 which are in R17 If RE 2 1 0 0437 you have a printer at R S IM 2 1 0 1543 tached and set flag 08 before executing CMEDII all elements will be printed out automatically c Angel M Martin December 2014 Page 31 of 124 SandMatrix_4 Manual Revision N The solution is h 0 0372 0 1311i l 0 0437 0 1543 As you can see this is an EE student s dream for circuit analysis if this is in your area of interests you should check 2 N Li out the macro program written by Ted Wadman Chris Coffin AT A NI AG E and Robert Bloch as one of the proverbial three best KORAP ETI UAS RAS EICANS examples of utilization of the Advantage Module Using Your HP 4 MAA The program is documented in its dedicated Grapevine booklet available at http www hp41 org LibView cfm Command View amp ltemID 523 and for further convenience Jean Francois Garn
63. Albillo Ulrich Deiters Angel Martin JM Baillard Angel Martin Angel Martin JM Baillard JM Baillard Angel Martin JM Baillard Angel Martin I have adapted most of the FOCAL programs for optimal fit in the SandMatrix but as you can see the original authors are always credited including W amp W for the array functions set renamed here as CCD MATRIX Many of the routines in this manual include the program listing this provides an opportunity to see how the functions are used and of course adds completion to the documentation Xtra Bonus High Rollers Game There is a gigantic Easter egg included in the SandMatirx hidden somewhere there s a rendition of the High Rollers game so you can relax in between hard thinking sessions of math really There was simply too much available space in the new bank of the lower page to leave it unused so this 500 bytes MCODE rendition of the game written by Roos Cooling see PPCJ V14 N2 p31 was begging to be included As to how to access it the discovery is part of the enjoyment Hint ever wondered about those section header functions eee ak Ocal mali Choose any combination from the available digits on the right which sum matches the target on the left repeating until there s no more digits left YOU WIN or there aren t possible combinations YOU LOSE Use R S to proceed back arrow to delete digits The game will ask you to try again and will keep the count of the sc
64. B or 10 200i 200i 1 5 200i 200 30 i 1 0 We ll use the individual matrix functions instead of MATRX program already covered in the previous sections c ngel M Martin December 2014 Page 30 of 124 SandMatrix_4 Manual Revision N The main thing to sort out in this example is the dimension of the matrices involved The coefficients matrix A is a 2 x 2 complex matrix thus as per the previous paragraphs we will need 4x4 1 17 registers The independent terms matrix B is a 2 x 1 complex matrix thus will need 4x2 1 9 registers This makes for a total of 26 registers needed for the example therefore we adjust the SIZE accordingly first typing XEQ SIZE 026 Next we create the two matrices in main memory starting at ROO and R17 respectively Note the shortcut in the RO name dropped the zero ALPHA R ALPHA LPHA R17 ALPHA 4 004 XEQ MATDIM 4 002 XEQ MATDIM The next step is entering the element values using CMEDIT because that is the only editor capable of editing complex matrices as we know CMEDIT RE 1 1 Complex matrix editor 10 R S 200 RE 1 2 Loads the real and 0 200 RE 2 1 imaginary parts of ele 0 200 R75 RE 2 2 ments into RO the 0 R S 170 R75 170 0000 coefficient matrix A R17 ALPHA Dimensions the col 4 002 MATDIM 4 0020 umn matrix R17 to 4 x 2 for 2 complex rows and 1 complex column It needs
65. B C or X B C in Alpha 3 MAT Multiplies scalar element to each element A B C or X B C in Alpha 4 MAT Divides each element by scalar or element A B C or X B C in Alpha 5 M M Calculates the true matrix product A B C in Alpha The matrix arithmetic functions provided are scalar addition subtraction multiplication and division as well as true matrix multiplication The scalar arithmetic functions can use two matrices as operands or one scalar and one matrix When using two matrices the matrices do not have to be of the same dimension but the total number of elements in each must be the same This also applies to the result matrix Note that the i j notation below assumes that the dimensions of the matrices are the same If this is not the case the i j notation does not apply Matrix multiplication on the other hand calculates each new element by summing the products of the first matrix s row elements by the second s column elements The number of columns in the first matrix must equal the number of rows in the second matrix The result matrix must have the same number of rows as the first matrix and the same number of columns as the second matrix If there is a scalar operand it must be in the X register and X must be specified in the Alpha register The input specifies matrix name A or X matrix name B or X result matrix C in Alpha register The outputs are respectively Cy a xX OF Cy a x OF d a Cy x t bij o
66. For the data input we have several choices here we ll Use the PMTP function seen before just pretending the vector components are analogous to polynomial coefficients which is irrelevant to the actual inner workings of PMTP 1 004 XEQ PMTP gt R1 _ we type 2 ENTER 3 ENTER 7 ENTER 1 R S 6 009 XEQ PMTP gt R6 _ we type 3 ENTER 1 ENTER 4 ENTER 6 R S Re entering the control codes in X and Y if not already there we execute the function which returns DOTN gt 43 see table below for all the available data STACK INPUTS OUTPUTS Results T u 46 52626239 Z lull 7 874007874 Y bbb eee U IIV II 7 937253933 X bbb eee V U V 43 000000 L cos u This is a good example of Jean Marc s very complete and economical programming Needless to say it executes at blazing light speed as you would expect from an MCODE routine like this Note The SandMath module includes functions IN and OUT in the auxiliary FAT therefore you d need to use XF to execute them that can be used for data entry in the n dimensional case as follows IN OUT sequentially enter data or review a block of registers e Enter the initial register index for IN then proceed with all required entries and terminate with a blank R S to end the sequence e Input the control word in X in the form bbb eee and OUT will display all registers sequentially Use flag
67. Functions in the Header section Function Description Input 1_ MATRX Easy Matrix Program Driver for Major Matrix Ops 2 ZML_ Matrix Function Launcher Prompts for function 3 ZDST_ Distance Functions Launcher Prompts PP PL LL PPL 4 EV ___ Sub Function Launcher Prompts for index 5 ZV _ Sub Function Launcher Prompts for name MATRX is the main driver program provided in the Advantage Pac for the major matrix calculations MDET MINV SIMEQ TRNPS Nice and easy maybe the only one to use for users not needing any further functionality MTR was part of the same program but has been eliminated in this revision The following extract describing the use of MATRX is taken from the Advantage Pac manual and it s included here for convenience and completeness It s useful to revise the underlying concepts as well 2 3 1 The Matrix Program This chapter describes the matrix program MATRX the easy user friendly way to use the most common matrix operations on a newly created matrix To use MATRX you do not need to know how the calculator stores and treats matrices in its memory The next chapter lists and defines every matrix function in the pac including those called by MATRX Using these functions on their own requires a more intimate knowledge of how and where the calculator stores matrices What this program can do Consider the equations 3 8 X 7 2 X 16 5 1 3 x
68. Long Live the Advantage ROM showcasing the matrix functions included in it As one can expect from that reference it s an excellent example and therefore more that worth including in the SadnMatrix The original article is partially reproduced below it is so well described that I could not resist adding it practically verbatim POLFIT is a small user friendly fully prompting 62 line program 124 bytes written specifically to demonstrate the excellent matrix capabilities of the Advantage ROM POLFIT can find the coefficients of a polynomial of degree N which exactly fits a given set of N 1 arbitrary data points not necessarily equally spaced where N is limited only by available memory Among the many functions we could fit to data polynomials are by far the easiest to evaluate and manipulate numerically or symbolically so our problem is Given a set of n 1 data points x1 y1 xn 1 yn 1 find an Nth degree polynomial y P x al a2 x a3 x2 a4 x3 4 anti xn which includes the n 1 data points x1 y1 x2 y2 xn 1 yn 1 The coefficients a1 an 1 can be determined solving a system of n 1 equations om om om Jia h ll x Jia ye 1 Jf I t Tes Masa ansa Yna Program listing 0i LBL POLFIT to use simply XEQ POLFIT 02 N prompts for the degree N of the polynomial 03 PROMPT and waits for
69. MEDIT in many aspects although the symbol a is used in the prompts They are slightly faster and offer the added convenient feature that unless the matrix is LU decomposed for integer element values the zeros after the decimal point are not shown in the prompt regardless of the current display settings FIX or otherwise This makes for a clearer UI The program listing is shown below note how the different entry points set the appropriate subset of user flags and that they all share the main section for the actual element input and review LBL OMR 35 0 clears FO F7 36 37 38 39 sets F1 41 sets FO 42 43 44 sets FO amp F1 45 46 47 check status 48 resets pointer to 1 1 49 go to first element 50 51 sets F1 amp F3 52 53 54 sets F3 55 56 check status 57 colum row number 58 just in case 59 _1 00x 60 row 61 yes transpose 62 set pointer to row col 63 64 element symbol 65 recall index 66 prompt index 67 recal value FS 04 LU decomposed GTO XX synthetic jump INT integer AINT yes append IP FRC fractional yes append all FC 00 view only AVIEW yes show it FC 00 view only GTO 02 yes skip editing jsp append PROMPT show current value MS store new value FC 01 by column J yes next column FS 01 by row I yes increase row E1 F10 FS 03 by row DSE X yes F9 FC IND X end of matrix row GTO 00 no next element
70. MNAME bring result name r 83 g F 35 RTN r 14 MATDIM creates scratch 36 LBL 02 T 15 ay 37 r 416 ARCL 01 7 38 MIDN r 17 a Be yx A P Pr 390 XH T 18 RCL IND 00 40 RCLINDOO next coeff r 19 MAT initial value rt MAT T 20 ISG 00 next index T 42 PpP r 43 MAT add it to partial result 22 XEQ02 T 44 END The auxiliary matrix is needed because unfortunately M M does not allow the result product matrix to be the same as any of the multiplication factors At least we double use it for other intermediate calculations as well identity matrix products killing two birds with the same stone This concludes the core matrix sections it s time now to embark into the fascinating journey of characteristic polynomials and eigenvalues as a prelude to the advanced polynomial chapter c ngel M Martin December 2014 Page 60 of 124 SandMatrix_4 Manual Revision N 4 Polynomials and Linear Algebra Hi AY POLYN USER ABY POLYN 01 Linear algebra is the branch of mathematics concerning vector spaces as well as linear mappings between such spaces Such an investigation is initially motivated by a system of linear equations in several unknowns Such equations are naturally represented using the formalism of matrices and vectors Function Description Input Output 1 CHRPOL Characteristic Polynomial Under prgm control 2 EIGEN Eigen Values by SOLVE Under prgm
71. MTM are as follows e A maximum length of 24 characters is possible during the prompt This includes the blank separators the comma radix and the negative signs if present e No support for the Exponential format is implemented EEX You need to use any of the other editors if your element values require such types of data Obviously this makes PMTM the ideal choice for matrices containing integer numbers as elements but not exclusively so as it can also be used for other values real numbers as long as the two conditions above are respected c Angel M Martin December 2014 Page 39 of 124 SandMatrix_4 Manual Revision N t the heart of PMTM there is the function MROW Enter Matrix Row responsible for the presentation of the prompt in Alpha and accepting the keyboard inputs there to make up the string or list with all values It also provides the logic of actions for the control keys like ENTER Back arrow R S etc MROW is called in a loop as many times as rows exist in the matrix while ANUMDL in the SandMath is used every iteration each time a row is being processed to extract the individual element data from the global string in the prompt Below is the program listing for PMTM and as you can see it s just a sweet amp short driver for MROW that also takes advantage of the auxiliary functions in the SandMatrix T LBL PMTM 2 0 MSIJA position pointer to 1 1 recall p
72. Matrix case These characters are not part of the final list and therefore aren t included in the total count Another restriction of PMTP is that values cannot be expressed in exponential form using EEX which key is ignored during the process You can use negative and decimal values as the CHS and radix keys are active Obviously the back arrow key is always active to correct wrong entries 1 LBL PEDIT r 27 Joo 2 SF 08 flags mode r 28 RCL IND Y append current value d 3 ENTER copies cntl word to Y 29 FRE aaa Chass fractional part r 4 I lt gt J swaps bbb and eee r 30 ARCL X yes append as is ros E r a integer r 6 r 32 yes append IP only r 7 SIZE current size Fo 33 FC 00 editable F 8 X lt gt Y r 34 AVIEW no show already 9 X gt Y not enough T 35 FC 08 editable T 10 PSIZE adjust size T 36 GTO 02 no next coeff ral RDN r 12 RDN cntl word to X reg J append r B GTO 00 skip over T 39 CF 22 reset data entry flag LBL PVIEW T 40 PROMPT ags mode value entered fl d r m FC 22 ll d r 4 GTO 02 no next coeff 17 ADV POLYN shows convention r 43 STO IND Z yes store it r 18 PSE r RDN discard entry r 19 ENTER copies cntl word to Y r 20 PDEG OOo polyn degree 46 DSE X decrement counter r 24 X lt gt Y cnt word to X reg raz NOP T 2 STOL saves it in L T 48 ISG Y increment register r z3 X lt gt Y degree to X reg T 49 GTO 01 next register 24 LBL 01 r 50 LASTX get control word 25
73. O 11 50 GTO 05 51 LBL 11 52 E 53 RCL 02 54 RCL 01 55 RCL 00 56 CROOT 57 FS C 06 58 RTN 59 X 60 ARCL Z 61 PROMPT 62 FC 43 63 GTO 01 64 X lt gt Z 65 CLX 66 X lt gt Z 67 LBL 01 68 QROUT 69 END show other two roots done Like EIGEN before this function will behave differently in RUN and Program modes skipping the data entry part during a program execution Note that in manual mode EV3X3 a matrix named EV but that the subroutine will work with any 3x3 matrix which name is in Alpha This is compatible with EIGEN in its subroutine mode as well automatically creates The roots are obtained using the SandMath function CROOT an all MCODE implementation of the Cardano Vieta formulas Function QROUT is also used to display them c Angel M Martin December 2014 Page 66 of 124 SandMatrix_4 Manual Revision N General case N dimensional general matrix CHRPOL The original CHRPOL as it appeared in previous versions of the SandMatrix was written by Eugenio Ubeda as published in the UPLE and later on adapted to the SandMatrix Note however that it didn t make use of any advanced Matrix function It was a user friendly program providing step by step guidance for the data entry and didn t require any set up preparation like creating matrices prior to the execution In this version CHRPOL has b
74. OL also requires an auxiliary matrix for intermediate calculations The matrix file is temporarily created during the execution for this purpose and deleted upon completion of the program While this is transparent to the user you may want to remember this fact due to the extended memory needed to allow for it with a total of 3 x n 2 2 registers used including the file headers The last point to remember about MPOL is that it uses data registers ROO and RO1 which therefore should not be used to store the polynomial coefficients e R00 has the polynomial control word and is used as counter for the loop execution e RO1 has the matrix name It s left unchanged Below you can see the program listing for MPOL not a long program albeit not as short as a simple polynomial evaluation for real variables Note the use of function I J to check for square matrix as well as the shortcut ADV MTRX that puts the error message WOT SQUARE in the display and terminates the execution f 01 LBL MPOL Mname in Alpha 233 Pee 02 SQR is it square T 24 ARCLOL r o3 LU LU form fF 25 fae DAH 04 ADV MTRX no prompt error T 26 M M T o5 CCD MTRX shows RUNNING r z ur r o E 3 ent l word in X T 28 ST r 07 7 29 MMOWVE o8 STO 00 T 30 IsG 00 next index r 09 ASTO 01 saves Mname in R01 T 31 GTO 00 loop back Fr 10 DIM dimensions 7 32 XEQ02 r 11 p r 33 PURFL purge auxiliary mat r 12 MATDIM creates scratch r 34
75. OS R S Y4 2 enter 4th y value 0 6 ACOS 5 COS R S Y5 enter 5th y value 0 8 ACOS 5 COS R S Y6 enter 6th y value 1 ACOS 5 COS R S al 1 0250E 9 R S a2 5 0000 R S a3 7 0867E 8 R S a4 20 0000 R S a5 2 6188E 7 R S a6 16 0000 So disregarding the very small coefficients due to rounding errors the undisguised polynomial is P x cos 5 arccos x 5 x 20 x 3 16 x45 You might want to execute now CAT 4 or EMDIR to see that the matrices used are still available so that you can redisplay the coefficients solve for a new set of y values or use the polynomial for interpolation etc CAT 4 MX M036 the system matrix is 6x6 36 elements MY M006 the coeff matrix is 6x1 6 elementss 554 0000 EM Room left this value varies with your configuration c Angel M Martin December 2014 Page 91 of 124 SandMatrix_4 Manual Revision N 4 4 5 Orthogonal Polynomial Fit OPFIT Orthogonal polynomials are a very advantageous method for polynomial regression Not only it allows for a more progressive approach but also the accuracy of the values so obtained is typically better This program employs this method even if it doesn t calculate any orthogonal polynomials explicitely Given m value pairs xi yi and a maximum degree to explore n this program calculates the n n 3 2 polynomial coefficients of the
76. P s infamous MATH PAC That program was capable of calculating the roots of a polynomial up to degree five which perhaps back then when it first came out could be regarded as a remarkable affair but by today standards certainly isn t much to write home about _ Function _ Description _ Input Output 1 QUART Solution of Quartic Equation Polynomial coeffs in Memory 2 PROOT Polynomial Roots Prompts for all data 3 RTSN Subroutine mode of PROOT Polynomial coeffs in Memory 4 BRSTW Quadratic Factors Bairstow method Cnt l word in X reg The SandMatrix picks up where the SandMath left things off providing functions to calculate the roots of the quadratic and cubic equations ie polynomials of degrees 2 and 3 The next step would then be a Quartic equation or polynomial of degree 4 4 3 1 Quartic Equation solutions QUART QUART solves the equation x a x b x c x d 0 If you have a polynomial not in monic form which leading coefficient is not 1 simply divide all the equation by this coefficient With this convention we can use the stack registers T Z Y X to hold the coefficients a b c and d which provides a convenient method for data input The method used can be summarized as follows First the term in x is removed by a change of argument leading to 4 2 x p x q xt r 0 E Then the resolvant z p z 2 p 4r
77. Page 104 of 124 SandMatrix_4 Manual Revision N Vector Subtract V1 V2 1 B X x result Y y result Z z result Coordinate Transformations refer to the next section C Z0 Y0 X0 for instructions USERI ILC DP CP lt M UV Distance between V1 and V2 D d result Restore the main menu after or between operations J DP CP lt MUV optional To view the components of V2 the vector in the stack IE X x result Y y result Z z result To exchange Vi and V2 the vector components in F DP CP lt MUV M N O and X Y Z To store V2 s components as vector register n in n H DP CP lt MUV R3n 1 R3n 2 R3n 3 To recall the conents of vector register n into V2 X Y Z n I X x result pushing V2 into V1 Y y result Z z result Remarks You can eliminate the displaying of results on the Vector Calculator by setting flag 04 This lets you perform successive calculations more quickly by not having to step through the display of the results You can still view the results when you want by pressing E This program uses local Alpha labels as explained in the owner s manual for the HP 41 assigned to keys A F H J and A E These local assignments are overridden by any User key assignments you might have made to these same keys thereby defeating this program Therefore be sure to clear any existing User key assignments of these keys before us
78. RPOL RUNNING scrolls in the display then lt aK X K Reminder of convention set F21 a3 1 000000 Coefficient of x 3 if you want AVIEW a2 3 000000 Coefficient of x 2 to stop each time R S See the program code below in its entire splendor al 2 413100 a0 0 343548 RUNNING X 0 180390390 X 1 121568609 X 1 698238062 Coefficient of x First coef independent term Scrolls in the display then First eigenvalue Second eigenvalue Third and last c Angel M Martin December 2014 Page 67 of 124 SandMatrix_4 Manual Revision N Remarks Two auxiliary matrices are used but the original matrix is left unaltered The first part of the program up to line 60 calculates the coefficients of the characteristic polynomial and displays them for informational purposes It then transfers the execution to the root finder routines Note that for cases n 3 and n 4 we take advantage of the dedicated functions CROOT in the SandMath and QUART which results in a much faster execution than the general case using RTSN MNAME in Alpha 55 stool it s monic 2 SQR is it square 55 E3 E 1 001 3 LU yes but LU form 56 1 00 n 1 cnt l word 4 ADV MATRX not square show error 57 5 ASTO 01 MNAME 58 PURFL 6 CCD MATRIX shows RUNNING 59 p 7 J P 60 PURFL 8 MAT B A 61 PVIEW fo
79. RS Bairstow Method Follow program instructions F FROOT Roots of f x FNAME in ALPHA a b in Y X reg P POLZER From Poles to Zeros Prompts for poles C PCPY Polynomial Copy From to control words in stack D DTC Deletion of Tiny coeffs Control word in X E PEDIT Polynomial Editor Control word in X V PVIEW Polynomial View Control word in X L PVAL Polynomial Evaluation Control word in Y point in X F POLFIT Polynomial Fitting Follow program instructions I POLINT Polynomial interpolation Follow program instructions H CHRPOL Characteristic polynomial MNAME in ALPHA Notes e The back arrow key cancels the action and returns to the main ZML launcher M _ prompt e The USER and ALPHA keys are also active to invoke the sub function launchers 2V and F e You can refer to the appropriate section within this manual or the SandMath manual for specific details of all these functions e The SandMath functions executed from here will not be registerer in the SandMath s Last Function facility DST will be described in the next section of the manual c Angel M Martin December 2014 Page 97 of 124 SandMatrix_4 Manual Revision N The Last Function functionality The latest releases of the SandMath and SandMatrix modules include support for the LASTF functionality This is a handy choice for repeat executions of the same function i e to execute again the last executed functi
80. Root Matrix name in Alpha A sqrt A The result matrix replaces the input 17 MTRACE Calculates the Trace of a Square Matrix name in Alpha Matrix Output is put into W reg Trace aii i 1 2 m 18 R aRR Row division by diagonal element Matrix name in Alpha row kkk in X reg akj akj akk j 1 1 n All row elements divided by akk 19 ZIJJI Sum of crossed elements products Matrix name in Alpha SCEP aij aji Output is put in X reg The algorithms used impose some restrictions to the matrices These are generally not checked by the programs thus in some instances there wont converge to a solution Suffice it to say that the programs are not foolproof and assume the user has a general understanding of the subjects so they won t be used foolishly Matrix Exponential MEXP In mathematics the matrix exponential is a matrix function on square matrices analogous to the ordinary exponential function Let X be an nxn real or complex matrix The exponential of X denoted by e X or exp X is the nxn matrix given by the power series _ 2 eX Va k k 0 where X40 is the identity matrix I The above series always converges so the exponential of X is well defined Note that if X is a 1x1 matrix the matrix exponential of X is a 1x1 matrix consisting of the ordinary exponential of the single element of X Finding reliable and accurate methods to compute the matrix exponentia
81. ST 451B 037 JC 06 80 ALIST 451C CLRF 8 81 ALIST 451D 82 ALIST 451E 83 ALIST 451F NULL 84 ALIST fixed bug 4520 37B ard p 85 ALIST 4521 MS PNC XQ 86 ALIST 4522 EEU gt 44B9 87 ALIST 4523 198 C M ALL 88 ALIST 4524 106 A C S amp X 39 ALIST 4525 f130 LDI S amp X 90 ALIST 45265 fo20 space 91 ALIST 4527 foe NC XQ 92 ALIST 4528 MEP gt 452B 93 ALIST 4529 I 94 ALIST 452A MA gt 44E0 95 ALIST _ 452B 366 PAHC S amp X 96 ALIST 452C 01F JC 03 97 ALIST 452D 348 SETF 12 98 ALIST 452E j0A3 JNC 20d 99 ALIST 452F Hea LDI S amp X 100 ALIST 4530 02D ae 101 f4531 366 PAHC S amp X 102 Executed within DELCHR 4532 4102F JC 05 103 an opportunistic routine 14533 134C PFSET 12 104 just grouping common code 14534 lo17 JC 02 105 4535 loca CLRF 10 ic 106 ALIST 4536 fo63 JNC 12d 107 ALIST s37 i98 C M ALL 108 ALIST 4538 3D8 C lt gt ST XP 109 ALIST 4539 14C FSET 6 110 ALIST 453A 043 JNC 08 111 ALIST 453B 112 ALIST 453C OIC 207 113 ALIST 453D 114 ALIST 453E 284 115 ALIST 453F 3D8 C lt gt ST XP 116 ALIST 4540 3E8 WRIT 15 e 117 ALIST 4541 184 CLRF 11 118 ALIST 3EO RTN 119 ALIST 1149 NC XQ 120 ALIST 024 gt 0952 121 ALIST 3B8 READ 14 d 122 2BC RCR 7 123 transfer staus of UF28 to F9 4547 248 SETF 9 124 adds the converted crh code 14548 1EE C C C ALL 125 to the LCD and prepares ALPHA fas49 013 JNC 02 126 454A 244 CLRF 9 127 ALIST l 454B__ 3D9 NC XQ 128 ALIST
82. SandMatrix_4 Manual Revision N SANIMATRIX HN for khe HP Y 4 Ertansioans Matrix User s Manual and Quick Reference Guide o oo een ess SB OO 8S oe 2g S 0 2 ssse ete ta naor ee a ime on oe ee S S ne ae sf Written and programmed by Angel M Martin December 2014 Page 1 of 124 December 2014 z c Angel M Martin SandMatrix_4 Manual Revision N This compilation revision 4 4 4 Copyright 2012 2014 Angel M Martin Acknowledgments Documentation wise this manual begs steals and borrows from many other sources in particular from the HP 41 Advantage Manual Not so from the CCD Manual but obviously that was how it all began with the excellent implementation of the Array Functions by W amp W GmbH Thanks to the following contributors must be given Jean Marc Baillard Valentin Albillo Eugenio Ubeda and Ulrich Deiters Original authors retain all copyrights and should be mentioned in writing by any party utilizing this material No commercial usage of any kind is allowed Screen captures taken from V41 Windows based emulator developed by Warren Furlow Its breakpoints capability and MCODE trace console are a godsend to programmers See www hp41 org Published under the GNU software licence agreement c Angel M Martin December 2014 Page 2 of 124 SandMatrix_4 Manual Revision N Table of Contents Revision N
83. V1 is stored in ALPHA registers M N and O You can imagine the registers shared in a three dimensional stack like So c ngel M Martin December 2014 Page 102 of 124 SandMatrix_4 Manual Revision N The Vector stack is two vector level high so it accommodates two vectors Note however that each level contaris three components the x y Z components far each vector The diagram below shows you what happens in vector entry and vector stack movement from the point of view of the vector stack and from the point of view of the RPN and vector stacks together When you enter two vectors as you would prior to executing a typical vector operation the first one you key in becomes V1 and the second one you key in becomes V2 A vector entry the function VENTER or pressing R S in the Vector Calculator copies the bottom vector V2 into the top Vector V1 Then when you key in the next vector it overwrites the copy in the bottom vector V2 leaving the first vector in V1 and the second vector in V2 LE co nter vector s mponents Ve Vector Stack Lift 2 Vector enter 3 Enter second vector s components yy Vue Z Hy Vy 2 V ENTER vE J or V ENTER V in Vector Calculator Ro Roe Ros EA PALES ttt vebla Oe E Instructions e Starting VC invoking the vector calculator does not clear the vector stack so you can still work with previously
84. VIEW Views Polynomial Coefficients Control word in X Reg 4 2 1 Defining and Storing Polynomials A polynomial is an expression of the form n n 1 2 A X an 1T aor 2 Q where a n 0 Or more concisely Polynomials can only be stored in main memory ie not as X mem files thus the way to handle them will be by a contro word of the form bbb eee which denotes the beginning and end registers that hold the polynomial coefficients a i The coefficients are stored starting with the highest order term first ie xn in register bbb and ending with the zero th term last stored in register eee It follows that the degree of a polynomial n verifies n eee bbb For instance the control word 1 007 represents a polynomial of degree 6 which coefficients are stored as follows a 6 in RO1 a 5 in R02 a 4 in R03 a 3 in R04 a 2 in ROS a 1 in RO6 and a 0 in R07 The Polynomial Editor There are three functions available in the SandMatrix to enter and review polynomials in the calculator The main one is PEDIT which takes the input from the control word in the X register and sequentially prompts for each coefficient value The first thing it does is present a reminder of the convention used relating the subindex to the power of the variable for each term IT tak EXAK gt 012 A nice feature is that it ll check for available data registers to complete all the storage re adjusting the calculator SIZE if n
85. WAP place in hot spot 5 0 initial sum value 5 DIM gets its dimensions 6 sets pointer to 1 1 6 E 7 7 I lt gt J 0 001 recall element 8 add to partial result 9 MATDIM add one more column end of row 10 TRNPS transpose it no next row 11 INT end of matrix 12 MATDIM make it a column matrix no next element 13 SUM summ all elements done 14 PURFL purge scratch 15 ASWAP bring focus to original 16 CLAC alpha housekeeping 17 ABSP to erase all tracks 18 END Row Division by Diagonal element Diagonal Unitary R aRR This function is used to modify the values of all elements dividing each row by its diagonal element that is aij aij aii j 1 2 n In effect the result matrix has all its diagonal elements equal to 1 i e diagonal unitary This type of calculation is useful for row simplification steps in matrix reductions more like a vestigial function from when the major matrix operations were not available i e the CCD days pre Advantage Pac MNAME in Alpha 19 RDN discard product 2 SQR square 20 FC 09 end of row 3 LU yes but LU 21 GTO 00 no get next element 4 ADV MATRX not square show error 22 FS 10 end of matrix 5 0 23 GTOO2 yes exit 6 MSUA set pointer to 1 1 24 MRIJ recall pointer 25 ENTER 8 MR recall diag element 26 INT 9 1 X inverse value 27 ENTER 10 X lt gt Y pointer to X 28 I lt gt J does E3 if integer 11 MSIJ set pointer 29 j 00j 12 X lt gt Y value back to X reg 30 MSU se
86. ally large ones Programming with the Matrix functions is more about Alpha strings and auxiliary data sets than concerning with data registers and to some extent even algorithmic strategy Because they are FOCAL programs they are slower than other areas although the 41CL has blurred the lines separating MCODE and FOCAL in terms of speed In terms of its contents it was clear from the beginning that it should be an extension to the SandMath However the dilemma was how to manage the dependencies should it be a self contained ROM or rely on functions from other modules The former option implied including many auxiliary functions in the FAT s taking precious entries and causing redundancy in the global scheme The latter option however meant a potential loss of usability since several modules were involved the Library 4 the SandMath AMC_OS X the Solve amp Integrate ROM the Polynomial ROM etc The solution to this riddle came only with the latest revision of the SandMath 3x3 which added a third bank with Solve and Integrate plus an important consolidation of functions in its auxiliary FAT This really cleared things off for the SandMatrix in that itself for a total of only 8k effective footprint needed additionally since the Library 4 is located in the otherwise reserved page 4 So there you have it the SandMatrix kind of replaces all previous versions of the Advanced Matrix ROM the Matrix ROM and th
87. and press R S you will see the main menu picture on the right above This menu shows you the choice of matrix operations you have in MATRX Press J to recall this menu to the display at any time This will not disturb the program in any way To clear the menu at any time press Back Arrow This shows you the contents of the X register but does not end the program You can perform calculations and then recall the menu by pressing J However you don t need to clear the program s display before performing calculations e The program starts by asking you for a new matrix It has you specify real vs complex and the order dimension of a square matrix for A e The program does not clear previous matrix data so previous data possible meaningless data will fill your new matrices A and B until you enter new values for their elements e Each element of a complex matrix has two values a real part and an imaginary part and requires four times as much memory to store as an element in a real matrix The prompts for real parts x11 x12 etc are 1 1 1 2 etc The prompts for complex parts x11 i yl1 x2 i y22 etc are RE 1 1 IM 1 1 etc Remarks Alteration of the Original Matrix The input matrix A is altered by the operations finding the inverse the determinant the transpose and the solution of the matrix equation You can re invert A and re transpose AT to restore the original form of A How
88. and right of the original matrix Note that those must have been created previously using MATDIM or otherwise the UNDEF ARRAY will be shown Function Description Input Output 17 YC C Multiplies each element in column k of Matrix name in Alpha kkk IIl in X reg matrix by value in Y ref and adds it to y in Y reg corresponding element in column It changes the elements in column 18 PIV Finds the pivot value in column k that Matrix Name in Alpha kkk in X reg is the maximum absolute value of an element on or below the diagonal 19 R gt R Compares elements in rows k and I If Matrix name in Alpha kkk IlIl in X reg and only if the first non equal element in k is greater than its corresponding element in then the comparison is positive for the do if true rule of programming Outputs YES if first non equal element in row k is greater than element in row I NO in all other case Examples Calculate the pivot element under the second column and compare the first and third rows for the matrix below Input Function Pointer Output 2 PIVOT a42 12 1 003 R gt R NO 9 1 11 12 a42 C3 Cea 12 24 36 Both PIV and YC C are vestigial from the CCD ARRAY FNS group and arguably not very useful now that the major matrix operations are also available c Angel M Martin December 2014 Page 36 of
89. ange them The display appears without the at the end of the line 1 1 1 0000 If you have a printer attached while flag 08 is set it will print out all the elements of the matrix without pausing Directly accessing any element You can directly access any specific element while the editor is active and the User keyboard is also active To access the element in the i th row and the j th column enter iii jjj and press A This is as in the MATRX program You can drop leading zeros in iii and trailing zeros in jjj For a complex matrix you can directly access the real part of element i j Then use R S to access its imaginary part You can drop leading zeros in the i part and trailing zeros in the j part A zero part defaults to a 1 Exiting the Editor To leave the editor before it has reached the last element do either e Press J e Try to access a nonexistent element For instance in a 4 x 4 matrix press 5 A How to Specify a Matrix Given the matrix multiplication operation AB C you know A and B and are looking for the product matrix C In performing this operation the calculator must be given the identities of the existing matrices A and B and also be told where to put the result matrix C However the result matrix can be the same as one of the input matrices All given matrices must al ready exist as named dimensioned matrices Naturally only A and B must contain valid data Some functions use only one
90. ap string 34 CLST 8 MAT scalar multiplication 35 MMOVE copy result to 9 MNAME recall MNAME 36 DSE 00 decrement index 10 MEXP exponential 37 GTO 00 loop back if not ready 11 END done 38 cu 39 ARCL 01 MNAME 40 MAT copy result to 41 PURFL purge 42 Pr 43 PURFL purge P 44 MNAME recal MNAME to Alpha 45 END done Remarks Both MPWR and M 2 need one auxiliary matrix P to temporarily place the results of the matrix product Additionally MPWR needs a second auxiliary matrix as well An alternative listing for M 1 X that includes a convergency check is shown in next page Note how the calculations to check for the condition are a taxing step in that it requires a scratch matrix to calculate its norm On the positive side though it ll spare us the wait for a non convergent process that would take much longer until it s apparent so So after some consideration the longer version is now in the module c ngel M Martin December 2014 Page 53 of 124 SandMatrix_4 Manual Revision N 2 1 X 1 n 20 X gt Y meets condition 3 STO 05 save it in ROS 21 GTO 00 yes goon 4 SQR square 22 4 no 5 LU yes but LU 23 PURFL get rid of scratch 6 ADV MATRX not square show error 24 DIVRGNT 7 CCD MATRX show RUNNING PROMPT show error message 8 ASTO 01 save MNAME in R01 26 9 DIM dimansion to X reg 27 CLA 10 Ea scratch matrix 28 ARCL 01 MNAME to Alpha 11 MATDIM 29 MLN matrix logarithm 12 MIDN ma
91. are all in MCODE Functions in black are MCODE entries to FOCAL programs Polynomial Division Copy of Polynomial Euyclidean Division Polynomial Editor Partial Fraction Expansion Prompts for Polynomial Polynomial Fit Aitken Interpolation From Poles to Zeros Polynomial Product Prime Factors Decomposition Polynomial Roots Polynomial Sum Polynomial Evaluation Polinomial View Quartic Equation Roots Subroutine for EIGEN Driver for PDIV from to cntl words in Y X cont words in Y and X cntl word in X Under prgm control cntl word in X Under prgm control Under prgm control Under prgm control cntl words in Z Y bbb in X number in X Under prgm control cntl words in Z Y bbb in X Cntl word in Y x in X Cntl word in X coeffs in Stack a4 1 Under prgm control shows results polynomial copied cntl words remainder amp result prompts for each coeff value see description to decode prompts for complete list calculates polynomial fit interpolation made shows coeffs and roots cntl word result in X prime factors in XM Matrix Shows all roots cntl word result in X Result in X Sequential listing of coeffs shows results Under prgm control Light blue and pink background denotes new or improved in revisions M and N Yellow background entries denote additions to revision M the Vector calculator groups Angel Martin JM Baillard JM Baillard Angel Martin JM Baillard Angel Martin Valentin
92. artin MIDN Identity Matrix OP1 in Alpha Makes it Identity Matrix Angel Martin MLIE Matrix Lie Product OP1 0P2 RES in Alpha A B B A Angel Martin MLN Matrix Natural Log OP1 in Alpha Matrix replaced by LN M Angel Martin MPOL Matrix polynomial Mname in Alpha Cnt l word in X Calculates P A Angel Martin MPWR Matrix Power to X OP1 in Alpha x in X Matrix replaced by M INT x ngel Martin MRDIM Matrix Redimension OP1 in Alpha dim in X Matrix redimensioned Angel Martin MRND Random Matrix Dim in X MName in ALPHA Random Elements Angel Martin MSQRT Matrix Square Root OP1 in Alpha Matrix replaced by SQRT M ngel Martin MSORT Sorts matrix elements OP1 in Alpha Matrix Elements sorted Angel Martin MSZE Matriz Size OP1 in Alpha Matrix size in X Angel Martin MTRACE Matrix Trace OP1 in Alpha Trace in x Angel Martin MZERO Zeroes a Matrix OP1 in Alpha All elements zeroed Angel Martin OMC Output Matrix by Columns OP1 in Alpha Shows elements by columns ngel Martin OMR Output Matrix by Rows OP1 in Alpha Shows elements by rows ngel Martin OCX Output x th column OP1 in Alpha Col in X Shows Col elements ngel Martin ORX Output x th row OP1 in Alpha Row in X Shows Row elements ngel Martin PMTM Prompts for Matrix OP1 in Alpha Prompts for complete Rows ngel Martin PSCAL Pascal Matrix OP1 in Alpha Pascal elements ngel Martin R aRR Unitary Diagonal OP1 in Alpha Diagonal elements 1 ngel Martin SQR Tests for Squa
93. artin December 2014 Page 85 of 124 SandMatrix_4 Manual Revision N input display XEQ INTPOL X 473 15 R S X0 480 R S YO 1 7905 R S Y 1 79050 R S X1 450 R S Y1 0 9322 R S Y 1 59452 R S X2 500 R S Y2 2 6392 R S Y 1 55067 R S X3 400 R S Y3 0 24577 R S Y 1 55453 R S X4 530 R S Y4 4 4569 R S Y 1 55495 linear interpolation quadratic interpolation cubic interpolation 4th order From this we conclude that 1 55 MPa is a reasonably good estimate and that the linear interpolation was certainly not sufficient Incidentally the true value is 1 554950 MPa The program listing is shown below ro xoy 2 FC 55 T 34 AIP r 3 SF 21 F 35 X lt Y T 4 X F 36 gt i 5 PROMPT x value of point r 37 PROMPT prompts for Yk r 6 STO 00 T 38 DSE02 r 7 3 05 r 39 GTO 02 8 STO 01 40 LBLO3 Ho 41 RCLIND 02 10 RCL 01 Paz r a INT k r 43 LASTX r an E T 44 RAZ r 3 k 1 ro45 l r 44 E3 E 1 00 k 1 Fr 46 ISG02 o B 47 RCLIND 02 r 416 4 00 k 1 T 48 LASTX r 47 STO 02 T ag T 18 RCL 01 T 50 ST Z r 19 INT k T 51 LASTX T 2 5 T 52 RDN r 24 k 3 T 53 RDN T 2 P F 54 F 23 55 LBLO2 r 24 ay 56 STOINDO1 T 25 AIP 57 ISG02 T 2 J 58 GTO03 27 PROMPT prompts for Xk F 59 y r 28 RCL 00 F 60 ARCLX r 29 T 6l AVIEW r 30 STO IND 01 r 62 ISG 01 r 31 ISG 01 T 63 GTOO1 next order r 32 mye r 64 END done c Angel M Martin December 2014 Page 86 o
94. ased j W amp W GmbH MRR Recall and back one in Row OP1 in Alpha element in X decreased j W amp W GmbH MS Store element at pointer value in X OP1 in Alpha Element stored HP Co MSC Store and advance in Column value in X OP1 in Alpha element stored increased i W amp W GmbH MSIJ Sets pointer of current matrix iii jjj in X pointer set W amp W GmbH MSIJA Sets points of Matrix in Alpha iii jjj in X OP1 in Alpha pointer set W amp W GmbH MSR Store and advance in Row value in X OP1 in Alpha element stored increased j W amp W GmbH MSWAP Swapps part of a matrix Lj k l b m n in XYZ Elements Swapped W amp W GmbH MSYS Linear Systems OP1 OP2 RES in Alpha Resolves Linear System HP Co PIV Sets pointer to pivot element Col in X OP1 in Alpha Element value in X W amp W GmbH R lt gt R Row Exchange k lt gt l kkk II in X Rows swapped W amp W GmbH c Angel M Martin December 2014 Page 9 of 124 WO ON DMN BWHN PRP PHB HHP HRP HPWwWWWWWWWWWNNNNNNNNNNRP RP RP RP RP RP RP RP PB Noun fP WNP OO WAN DU PBPWNHRP OHO WAN DU PBPWNHRPOUWUO WAN DU BPWN EF OO SandMatrix_4 Manual Revision N R gt R Row comparison test kkk III in X skip line if false W amp W GmbH RMAXAB Absolute maximum row in X OP1 in Alpha element in X pointer to ij W amp W GmbH RNRM Row Norm OP1 in Alpha Row Norm in X W amp W GmbH RSUM Row Sum OP1 RES in Alpha sums of rows in RES matrix W amp W GmbH SUM Element Sum OP1 in Alpha el
95. ative to the original system and the axis about which the rotation is performed You can then enter points in the original system x y z that you want transformed to the new system x y z or enter points in the new system x y z that you want transformed to the original system x y z For a two dimensional case enter z0 as zero A Two Dimensional Rotation about the Axis 0 0 1 ORIGINAL SYSTEM y P P TEAN ks Ney A liy l After specifying the new origin x y z you specify the rotation angle For a three dimensional system with a non Zero angle of rotation you also specify its rotation vector a b c The rotation vector defines the axis about which the rotation is to be done it can have any non zero magnitude Two dimensional transformations are handled as a special case of three dimensional transformations with a b c set to 0 0 1 Equations P P T n n 1 cost P T cos P T x n sin P P n n 1 cosh P cos P x 1 sin 0 T where new system coordinates old system coordinates origin of new system unit rotation vector a b c rotation angle ajno o c ngel M Martin December 2014 Page 109 of 124 SandMatrix_4 Manual Revision N Instructions You can start TR either directly XEQ TR or from the Vector Calculator C in VC The Vector Calculator is covered in the Vector Operat
96. auty to behold JM s mastery of the RPN stack LBL PCPY 1 LBL PVAL p cnt l word in X 2 RCL Y bbb eee1 3 E3 4 5 INT 6 I lt gt J does E3 for integers RCL IND Z 7 SIGN puts bbb eee in L ix 8 RDN ISG Z 9 ENTER GTO 14 10 ENTER 10 X lt gt Y 11 SIGN 12 CLX 12 RDN 13 RCL IND L 13 END 14 STO IND Y 15 ISG Y 16 CLX 1 LBL DTC ent word inx 17 ISGL 18 GTO 06 RCL IND X 19 CLX ABS 20 SIGN E 7 threshold value 21 X lt Y 22 I lt gt J GTO 06 23 X lt gt Z 24 X lt gt Y ISG X 25 FRC GTO 05 26 ISG X E 27 INT ST Y drecrease Y 28 E5 29 overwrite w zero 30 31 END cnt l word to X When using the FOCAL program above be careful that the register ranges for both polynomials do not overlap c ngel M Martin December 2014 Page 75 of 124 SandMatrix_4 Manual Revision N 4 2 4 Polynomial Evaluation 1 amp 2 derivatives PVAL dPL dPL2 Calculating derivatives and integrals of polynomial functions is particularly simple For the polynomial function P x on the left below the derivative with respect to x and the indefinite integral are shown in the center and right formulas respectively n n n a a k aT Y ajir 1 ian ill oa i 0 1 o tt 1 1 The subject of Polynomial evaluation is as old as the HP calculators are surely you remember examples provided in the HP 25 manual and even earli
97. azing landmark in the legacy of the 41 platform So much so that rather than re invent the wheel HP decided to use it almost in its entirety in the Advantage Pac only enhancing it with the major matrix operations sorely missing in the CCD implementation which incidentally were the subject of the majority of Matrix programs written for the CCD Perhaps because the relative tardiness of its appearance with the HP 42S already on the horizon or due to other factors like the HP 48S luring folks into RPL the fact is that Matrix programs using the Advantage Pac functions were very few and in between The demise of PPC and the newsletter wars that followed suit certainly didn t encourage the scene either and the end result was slightly disappointing in terns of net results About 30 years later the SandMatrix picks up the gauntlet and compiles a collection of noteworthy programs and routines on Matrix and Polynomial algebra with the specific criteria to be based on the CCD Advantage function set in an attempt to straighten the record and pay the due credit to that superb toolset that had been so underutilized 1 1 The logical next chapter after the SandMath In many respects previous revisions of the SandMatrix were very conventional There were no auxiliary FATs with sub functions a la SandMath although it had a dedicated function launcher with an alternate keyboard Most of the new routines are written in FOCAL and the programs are typic
98. ccuracy of the solutions and therefore their run times depends on the display settings BAIRS factorizes the polynomial p x ap X a x 14 an 1 X an into quadratic factors and solves p x 0 n gt 1 If deg p is odd we have p x ap X b X U X V1 eee X Um X Vm with m n 1 2 If deg p is even D X aoX u1 X V1 X U2 X V2 X Um X Vm With m n 2 The coefficients u and v are found by the Newton method for solving 2 simultaneous equations Then p is divided by x u x v and u amp v are stored into R ee 1 amp Ree respectively The process is repeated until all quadratic factors are found Example 2 Solve x 6 x 4 8 x14 64 x 345 x7 590 x 312 0 Using PMTP to store the coefficients beginning in R09 thus the control word is 9 015 Keystrokes Display Result 9 015 XEQ PMTP RO _ 1 ENTER CHS 6 ENTER 8 ENTER 64 ENTER CHS 345 ENTER 590 ENTER CHS 312 R S 9 015 XEQ BAIRS shows precisions factors The solutions are Z 4 000 and Z 2 000 Z 2 000 J3 000 and conjugate not shown Z 1 000 and Z 3 000 c Angel M Martin December 2014 Page 83 of 124 SandMatrix_4 Manual Revision N 4 4 Extended Polynomial Applications A few related topics in that polynomials are involved even if some programs don t make direct utilization of matrix functions Here too the SandMatrix complements the f
99. control 3 EV Subroutine for EIGEN Under prgm control 4 EV3 Eigen values 3x3 Matrix in X Mem 5 EV3X3 Eigen values 3x3 Prompts Matrix Elements 6 JACOBI Symmetrical Eigenvalues Under prgm control 4 1 Eigenvectors and Eigenvaules An eigenvector of a square matrix A is a non zero vector v that when the matrix is multiplied by v yields a constant multiple of v the multiplier being commonly denoted by A That is Av Av The number A is called the eigenvalue of A corresponding to v In analytic geometry for example a three element vector may Ay be seen as an arrow in three dimensional space starting at the origin In that case an eigenvector of a 3x3 matrix v is an arrow whose direction is either preserved or exactly reversed after multiplication by A The corresponding eigenvalue determines how the length of the arrow is changed by the operation and whether its direction is reversed or not determined by whether the eigenvalue is negative or positive O X X A vector with three elements may represent a point in three dimensional space relative to some Cartesian coordinate system It helps to think of such a vector as the tip of an arrow whose tail is at the origin of the coordinate system In this case the condition u is parallel to v means that the two arrows lie on the same straight line and may differ only in length and direction along that line If we multiply any square matrix A with
100. corresponding n polynomials of degrees 1 2 3 n that best fit the given data therefore equivalent to the least squares method It also obtains the determination coefficients and typical errors for each degree The method followed uses the construct x dO PO x d1 P1 x dn Pn x where pO pl pn are the orthogonal polynomials corresponding to the entered data that satisfy the expression Lpi Pj 0 for every i j The advantage of this approach is a better accuracy as it avoids the resolution of the usual n linear systems frequently ill conditioned that arise in the least squares method Example To check the program we took the following 11 value pairs from the polynomial P x x44 2x43 3x42 4 x 5 Xi 3 2 1 0 1 2 3 4 5 6 7560 Yi 179 57 15 5 3 9 47 165 435 953 1839 Using the data above explore up to degree n 4 showing the correlation coefficients the D factors and the errors for each of the alternatives The results are all provided in the table below Degree n Corrlt r 2 Errors e 2 Determ d 2 Coefficients n 4 Ri 4 482218E 1 E1 1818197E3 D11 228000E2 a1 1 228000E2 a0 1 486000E2 al 3 720000E1 n 2 R2 9 000134E 1 E2 3 294720E4 D2 4 000000E1 a2 4 000000E1 a0 1 700000E1 al 7 200000E1 n 3 R3 9 821452E 1 E3 5 883429E3 D3 6 000000E0 a2 4 000000E0 a3 6 000000E0 a0 5 000000E0 al 4 000000E0 a2 3 000
101. destroys part of the file s header information Instead use PURFL to purge the entire matrix Changing Matrix Dimensions If you redimension a matrix to a different size then the existing elements are reassigned to new elements according to the new dimensions Extra old elements are lost extra new elements take on the values already present in the new registers except in extended memory where new elements are set to zero Redimensioning 2 x 3 to2 x2 1 2s m E 2 lost A S 6 2 SG Redimensioning 2 x 3 to2 x4 il 2 3 E 23 4 k S 6 5 6 T This is what happens each time you dimension a new matrix since the old elements from the previous current matrix remain until you change them Caution When MATDIM is used to redimension a matrix stored in extended memory the position of the matrix pointer is not readjusted If the pointer happened to be positioned to an element that is outside the new bunds of the redimensioned matrix it must be repositioned to be within the new bounds by executing either MSIJ or MSIJA with valid indices before the pointer can be used again Existing matrices in extended memory cannot be redimensioned to completely fill extended memory The maximum allowable size of a redimensioned matrix is one register less than the currently available extended memory A new matrix can however be dimensioned to completely fill available extended memory Using the Matrix Editors There are two matrix editors MEDIT for
102. direction vector U u v w and another line L determined by its anchor point A a b c and one direction vector U u v w The program LL3 will prompt for the different components leaving the result in the X register Example L is defined by A 2 3 4 amp U 1 4 7 and L is defined by A 2 1 6 amp U 2 9 5 XEQ LL3 SAA 6 ENTER 1 ENTER 2 R S AA 4 ENTER 3 ENTER 2 R S AUl 5 ENTER 9 ENTER 2 R S AU 7 ENTER 4 ENTER 1 R S d 0 364106847 c Angel M Martin December 2014 Page 116 of 124 SandMatrix_4 Manual Revision N The programs are shown below really simple when the right functions are used 01 LBL PL3 0 XEQO2 02 AM 31 AXV D3 XEQO01 32 VUNIT D4 XEQ02 33 VRCL 00 O5 VUNIT B4 A vV D6 AXV 35 GTO05 D7 VMOD 36 LBL PPL3 O Os GTOO05 37 APL 09 LBLO1L 38 PROMPT 10 PROMPT B9 R 1 VENTER 40 sTOO00 2 EXSCR 41 RDN 3 A 42 VENTER 4 PROMPT 43 EXSCR 5 EXSCR 44 AM 6 AV 45 PROMPT 17 RTN 46 EXSCR 18 LBL02 47 A V 19 VENTER 48 ST 00 20 EXSCR 19 V lt gt A 1002 UA 50 VMOD 2 PROMPT 51 ST 00 3 EXSCR 52 X lt gt 00 H4 RTN 53 LBLO5 25 LBL LL3 54 ABS 26 XEQO01 55 d 27 VSTO 00 56 ARCLX 28 au 57 AVIEW 29 PROMPT 58 END Other Utility Functions Functions R S and its inverse S R will convert rectangular to spherical coordinates and back The conventi
103. dy exist it will be created if not already there MCON does a simple thing converts the value in the X Reg into a matrix with all elements equal to this value This is useful in some calculations and for matrix manipulations See the simple program listings for these routines below A B expected in Alpha MNAME in Alpha 2 DIM dimension 2 clear all elements 3 ASWAP swap Alpha 3 get constant back to X 4 MATDIM re dimension target 4 K prepare alpha string 5 ASWAP undo the swap 5 MAT add x to all elements r 6 CLST prepare pointers 6 MNAME recall MNAME to Alpha r 7 MMOVE move all elements 7 END done z END done c Angel M Martin December 2014 Page 42 of 124 SandMatrix_4 Manual Revision N MZERO is the unsung hero behind other routines as the proper way to clear a matrix file since CLFL cannot be used because it also clears the header register it was meant for Data files Use it safely for matrices in main and x memory MSORT uses an auxiliary matrix in main memory RO where RGSORT from the SandMath is applied to then data are copied back to the original matrix It also checks for available registers adjusting the calculator SIZE if necessary The contents of those n x m 1 data registers will be lost 1 LBL MSORT MName in Alpha 1 LBL MZERO MNAWME in Alpha 2 SIZE current SIZE 2 DIM get dimension 3 MSZE matrix size 3 SF 25
104. e Polynomial ROM not counting the one co produced w JM Baillard Also in this regard it s worth mentioning that the SandMatrix is totally independent from the JMB_Matrix ROM which doesn t use the Advantage function set at all c Angel M Martin December 2014 Page 7 of 124 SandMatrix_4 Manual Revision N 1 2 The many names of Dr Who The SandMatrix is the last incarnation of a series of different modules previously released that also dealt with Matrix and Polynomial algebra Some of them were based on the Advantage itself combining the matrix functions with other applications and thus followed the same bank switching implementation two pages with two banks in the upper page The differences amongst them were about what else beyond the matrix set they included once you removed the less notorious content of the Advantage The table below illustrates this showing the dependencies and choices made in all the predecessors of the SandMatrix Size Main Dependency Requires Notes 8k 8k j ALGEBRA Advantage n a 4k 8k MATRIX_4k z Advantage n a 4k POLYN_4k 4k 8k MATRIX_4L4 Lib 4 y Advantage 8k 4k POLYN_4k n a Includes SOLVE INTEG Adv_Matrix 8k 4k Adv_Matrx4_ POLYN_4L4 Lib 4 Includes SOLVE INTEG 9k n a Lib 4 Includes CURVE FIT Adv_Matrix4_Il SIROM for EIGEN only 8k Lib 4 SandMatrix SandMath We sure have a much simpler situation now glad to say
105. e 2 Calculate the eigenvalues for A with aij 1 2 3 9 Solution pA x 0 076 x3 15 x2 18 x 0 x1 16 117 x2 1 117 x3 2 89100E 9 It is therefore a relatively easy exercise to write a program to deal with this case as shown in the program listing in next page c ngel M Martin December 2014 Page 65 of 124 SandMatrix_4 Manual Revision N 1 LBL EV3X3 2 CF 06 clear subroutine flag 3 EV 4 E l 5 E3 E 1 001 6 3 7 3 003 8 MATDIM 9 IMR enter elements 10 GTO 06 LBL 3EV SF 06 set subroutine flag 14 CCD MATRX show RUNNING 15 MTRACE calculates tr A 16 CHS change sign 17 STO 02 save it in R02 18 MDPS get the sum of minors 19 STO 01 as a combination 20 ZWJI of functions into RO1 21 ST 01 22 MDET calculate determinant 23 CHS change sign 24 STO 00 25 FS 06 subroutine mode 26 GTO 11 yes skip prompting 27 CF 21 28 CFS Y N offer choice 29 AVIEW 30 LBL 01 decode the Y N input 31 GETKEY 32 4a 33 X Y 34 GTO 11 choice rejected 35 30 Program remarks 36 37 X Y 38 GTO 01 wrong key choice accepted coefficientes loop last one yes jump over no get next one proceed with roots fill stack with coeffs calculate roots was subroutine yes end show results always a real one complex no skip prompting yes clear Z p 42 AIP 43 44 ARCL IND X 45 PROMPT 46 E 47 48 X lt 0 49 GT
106. e 2m x 2n scheme given above Storage Space in Memory Since the dimensions required for a complex matrix are four times greater than the actual number of complex elements an m X n complex matrix being dimensioned as 2m x 2n realize that the number of registers a complex matrix occupies in memory is correspondingly four times greater than a real matrix with the same number of elements In other words think of a complex matrix s storage size in terms of its MATDIM or DIM dimensions not its number of complex elements Using Functions with Complex Matrices Most matrix functions do not operate meaningfully on complex matrices since they don t recognize the different parts of a complex number as a single number the results returned are not what you would expect for complex entries Valid Complex Operations Certain matrix functions work equally well with real and complex functions These are MSYS Solving simultaneous equations MINV Matrix inverse MAT Matrix add MAT Matrix subtract MAT Matrix scalar multiply but only by a real scalar in X reg M M_ Matrix multiplication Both the input and result matrices must be complex Example 2 Engineering student A C Dimmer wants to analyze the electrical circuit shown below The impedances of the components are indicated in complex form Determine the complex representation of the currents il and i2 Za 10 The system can be represented by the complex matrix equation AX
107. e now available within the SandMatrix saving a page in the calculator configuration ports It also facilitated further consolidation of functions removing the poor man FOCAL implementation of the same capabilities from the SandMatrix The net result is a much more capable module that now ncludes all the main components of Algebra Vectors Polynomials and Matrices The 3D Vector functions can be executed by their names using function ZV or their indexes within the secondary FAT using function XV These two functions are further connected to the main module function launcher using the ALPHA and USER keys respectively at its prompt Note also that the aE pompt toggles cyclically amongst three personalities or modes upon repeated pressing of the key as follows M _ for matrix functions P _ for polynomial functions and V _ for vector functions These refer to the dedicated keyboards as can be seen in the custom overlays shown later in the manual Because prompting functions cannot be easily located in secondary FATs a few of the vector functions have also been placed in the main FAT of the module These are VRCL VSTO V lt gt and VVIEW which use the prompt to select the register s needed in their operation To make room for their entries the auxiliary functions mainly dealing with ALPHA string management have been relegated to the auxiliary FAT as they are non prompti
108. ecessary PEDIT does not use any data registers itself c Angel M Martin December 2014 Page 71 of 124 SandMatrix_4 Manual Revision N Note that PEDIT includes in the prompts the current value held in the corresponding data register so you don t need to type a new one if it s already correct Alternatively you can use PVIEW to review the coefficients without any editing capabilities In this mode the prompts don t have the question mark at the end which indicates the value cannot be changed from the program In edit mode In review mode You can control wether PVIEW stops after each prompt or does the complete listing without stopping by setting or clearing the user flag 21 Note also that if the coefficient is an integer value it will not display the zeroes after the decimal point in both editi and review modes A faster alternative for data entry is PMPT the polynomial prompt This one does for polynomials what PMTM did for matrices the data entry is done as a list in Alpha containing the values of all coefficients at once Obviously this is limited by the total length available in the Alpha register 24 characters including the blank spaces that separate each entry and the minus signs for negative values The two leftmost characters in the prompt indicate the first data register used to sore the coefficients not the row as in the
109. ecomposition or partial fraction expansion of a rational fraction that is a fraction such that the numerator and the denominator are both polynomials is the operation that consists in expressing the fraction as a sum of a polynomial possibly zero and one or several fractions with a simpler denominator In symbols one can use partial fraction expansion where f and g are polynomials to change expression forms as shown below f x filz Xz egw where gj x are polynomials that are factors of g x and are in general of lower degree Thus the partial fraction decomposition may be seen as the inverse procedure of the more elementary operation of addition of rational fractions which produces a single rational fraction with a numerator and denominator usually of high degree The full decomposition pushes the reduction as far as it will go in other words the factorization of g is used as much as possible Thus the outcome of a full partial fraction expansion expresses that fraction as a sum of fractions where the denominator of each term is a power of an irreducible not factorable polynomial and the numerator is a polynomial of smaller degree than that irreducible polynomial To decrease the degree of the numerator directly the Euclidean division can be used but in fact if f already has lower degree than g this isn t helpful Implementation POLZER may be an old program but PFE is a much more modern event written by
110. ector in a system of simultaneous equations Solving Complex Simultaneous Equations The easiest way to work with complex matrices is to use the MATRX program It automatically dimensions input and output complex matrices However MSYS can solve more complicated systems of equations than MATRX can In addition a complex result matrix from the MATRX program cannot be used for many complex matrix operations outside of MATRX This is because MATRX will dimension a complex column matrix differently than 2m x 2 Instead it uses the dimensions 2m X 1 in which the real and imaginary parts of a number become successive elements in a single column c ngel M Martin December 2014 Page 29 of 124 SandMatrix_4 Manual Revision N This form has the advantage of saving memory and speeding up operations The complex matrix editor and MSYS can also use this 2m X 1 form though they do not require it This means you can use MSYS on a matrix system from MATRX You can convert an existing 2m x 2 complex column matrix to the 2m X 1 form by transposing it redimensioning it to 1 x 2m then retransposing it There is no easy way back Accessing Complex Elements If you use the complex matrix editor CMEDIT or the editor in the MATRX program you can access complex elements as if they were actual complex numbers Otherwise such as when you use pointer setting functions you must access complex elements as real elements stored according to th
111. een re written from the ground up really taking advantage of the powerful matrix function set It is a much improved solution about twice as fast and with half the comparable code It however now requires you to first create the matrix and input its elements Algorithmically it still uses the same modification of the Leverrier Faddeev method to determine the coefficients of the characteristic equation of the n x n matrix which roots are the eigenvalues of the matrix It also employs the matrix trace in the process The coefficients are calculated using the iterations b1 tr B1 with B1 the original matrix and bk tr Bk k with Bk A Bk 1 bk 1 I k 2 n The program works for orders n between 3 and 14 The case n 2 has a trivial solution given by b2 1 b1 tr A and b0 det A therefore doesn t need to be included Example Obtain the characteristic polynomial for the matrix A given below 1 0 69 0 28 A 0 69 1 0 18 0 28 0 18 1 Keystrokes Display Result ALPHA AA ALPHA current X reg Matrix name in Alpha 3 003 XEQ MATDIM 3 003 Creates matrix in X Mem XEQ IMR ali Prompts for data also 1 R S al 2 showing current values 0 69 CHS R S al 3 0 28 R S a2 1 0 69 CHS R S a2 2 1 R S a2 3 0 18 R S a3 1 0 28 R S a3 2 0 18 R S a3 3 Last element 1 R S 1 000 XEQ CH
112. eginning of this section find the inverse determinant and transpose of A and then find the solution matrix of the equation AX B 3 8 7 2 xy 16 5 1 3 0 9 Xa 22 1 Keystrokes Display Comments XEQ MTRX RL CX Starts the MTRX program A RL ORDER Selects a real Matrix 2 R S A I DT BSE Dimensions a 2x2 square matrix A 1 1 a11 Enters the Editor and displays old value 3 8 R S 1 2 a12 enters the new value for a11 7 2 R S 2 1 a21 1 3 R S 2 2 a22 9 CHS R S A I DT BSE enters a and returns main menu B I A I DT B SE Inverts A SHIFT A 1 1 0 0704 Displays the current contents R S 1 2 0 5634 of A after the inversion R S 2 1 0 1017 R S 2 2 0 2973 R S A I DT BSE B 1 A I DT B SE Re inverts A to the original B A I DT B SE Transposes A J A 1 1 3 8000 Displays the current contents R S 1 2 1 3000 of A after the transposition R S 2 1 7 2000 R S 2 2 0 9000 R S A I DTB SE SHIFT B A I DT BSE Re transposes A to the original A C DT DET 12 7800 Det A D B 1 1 b11 gt Enters the editor for B and displays old elements 16 5 R S 2 1 b12 Enters the new value for b4 22 1 CHS R S A I DT B SE Enters b and returns main menu E SE A I DT B SE Solves the system AX B placing X in B SHIFT D R S R S or J 1 1 11 2887 2 1 8 2496 A
113. ement sum in X W amp W GmbH SUMAB Absolute Values Sum OP1 in Alpha element absolute sum in X W amp W GmbH TRNPS Transpose OP1 in Alpha Matrix replaced w transposed HP Co YC C Adds Y Col I to Col k value in Y kkk lll in X column k changed W amp W GmbH MEDIT Matrix Editor prompts for elements Edits Matrix HP Co CMEDIT Complex Matrix Editor prompts for coeffs Edits Complex matrix HP Co MPT Matrix Prompt prompts for element element stored at pointer ngel Martin ADV MATRIX Section Header none Displays Not Square ngel Martin I lt gt J Swaps indexes iii jjj in X j 00i in X i00j in LastX Angel Martin IMC Input Matrix by Columns OP1 in Alpha Inputs elements by columns ngel Martin IMR Input Matrix by Rows OP1 in Alpha Inputs elements by rows ngel Martin LU Tests for LU decomposed MName in Alpha YES NO Do if True ngel Martin M 1 X x th root of a Matrix OP1 in Alpha xin X Matrix replaced by its root ngel Martin M 2 Matrix Square OP1 in Alpha Matrix replaced by M M ngel Martin MAT Copy Matrix OP1 RES in Alpha Copies matrix A into B ngel Martin MATP Driver for M M Driver for M M Under prgm control ngel Martin MCON Constant OP1 in Alpha xin X Makes all elements x ngel Martin MDPS Diagonal Product Sum OP1 in Alpha Sum of diagonal products ngel Martin MEXP Matrix Exponential OP1 in Alpha Matrix replaced by exp M Angel Martin MFIND Element finder OP1 in Alpha x in X Element pointer if found Angel M
114. ended memory The analogous function for the polynomial is PMTP which requires the control word in x a number of the form bbb eee denoting the beginning and ending registers that contain the polynomial coefficients In this case 2 006 XEQ PMTP gt atthe prompt R2 _ we type 2 ENTER CHS 1 ENTER 3 ENTER CHS 4 ENTER 5 R S Note how in this case the function knows there s no more rows to add and also that negative values are easily input using the CHS key Upon completion the coefficients are stored in registers RO1 to R05 The last step is executing MPOL itself To do that we place the matrix name in Alpha and the polynomial control word in X then call MPOL The resulting P A is stored in a new matrix named P also located in an XM file therefore A is not overwritten Note however that this will overwrite P if it already exists In this case we have 3548 1887 4705 P A 3727 1987 4962 2539 1351 3385 c Angel M Martin December 2014 Page 59 of 124 SandMatrix_4 Manual Revision N The result matrix name is placed in ALPHA when the execution ends so you can directly use any matrix editor routine like OMR to review its elements Note how OMR wii display integer values without any zeros after the decimal point regardless of the current FIX settings Set flag 21 to stop the display of each individual element In addition to the result matrix P A MP
115. er models It s no surprise then that it s found its way to the SandMatrix with the added bonus of morphing into an all MCODE implementation which has been extended to include the evaluation of the first and second derivatives as well The evaluation leaves the result value in X and the argument in LastX but the control word is maintained in the Y register for convenience Let s see a few examples to clarify Example Evaluate the Polynomial and the first two derivatives for P x below at points x 2 and x 3 P x 5 x45 4x 443 x43 42 x42 x41 Which has the following expressions for the derivatives P x 25 x4 4 16x 3 9 x 2 4x41 P x 100 x 3 48 x42 18 x 4 Using PMTP to enter the coefficients in RO1 RO6 we type as follows 1 006 XEQ PMTP gt RI 5 ENTER 4 ENTER 3 ENTER 2 ENTER 1 ENTER 1 R S The control word is left in X therefore just type the point of evaluation and the required function names as shown below 2 XEQ PVAL gt 259 0000000 RDN 3 CHS XEQ PVAL gt 956 0000000 RDN 2 V DPL gt 573 0000000 RDN 3 CHS gt 1 663 000000 RDN 2 EV DPL2 gt 1 032 000000 RDN 3 CHS gt 2 318 000000 You can verify the obtained results using the analytical expressions for P x and P x simply enter their coefficients in memory and use PVAL and dPL as appropriate For example evaluating P x and its first derivative
116. es all other functions expect them already dimensioned Function Description Input Output 1 MAT Makes matrix B equal to A Matrix names in Alpha A B B A Matrix A must already exist 2 MATP Driver for M M operation Under program control Creates both matrices on the fly 3 MCON Matrix from a constant Matrix name in Alpha constant in X reg Makes aij x i 1 2 m j 1 2 n Makes all matrix elements equal to x 4 MFIND Finds an element within a matrix Matrix Name in Alpha element in X reg Returns pointer to X and set to element 5 MIDN Makes identity Matrix Matrix name in Alpha must exist Makes aii 1 and aij 0 for i j 6 MRDIM Re dimensions Matrix properly Matrix name in Alpha dimension in X It keeps existing elements in place Output is a new matrix adds to name 7 MSORT Sorts all elements within a matrix Matrix Name in Alpha Reorders elements in ascending order 8 MSZE Calculates the Matrix size Matrix name in Alpha Size mxn Output is placed into X reg 9 MZERO Zeroes clears all elements in matrix Matrix name in Alpha Makes aij 0 i 1 2 m j 1 2 n All elements are set to zero A few remarks on each of these functions follow as well as the program listings MAT copies an existing matrix into another with names in Alpha Prior to doing the bulk element copy it redimensions the target matrix to be the same as the source one Jt is however not required that the target matrix alrea
117. ever if you have calculated the determinant or the solution matrix then A is in its LU decomposed form To restore A simply invert it twice The LU decomposition does not interfere with any subsequent MATRX operation except transposition and editing do not attempt to edit an LU decomposed matrix unless you intend to change every element For more information on LU decomposition refer to LU Decomposition in the next chapter Matrix Functions c Angel M Martin December 2014 Page 17 of 124 SandMatrix_4 Manual Revision N Matrix Storage The MATRX program stores a matrix A starting in RO of main memory it is named RO Its column matrix B is stored after it and the result matrix X overwrites B Refer to the chapter Matrix Functions for an explanation of how matrices are named and stored and how much room they need MATRX cannot access any other matrices with the exception of the previous RO and its corresponding column matrix Redefined Keys This program uses local Alpha labels as explained in the owner s manual for the HP 41 assigned to keys A E J a b and d These local assignments are overridden by any User key assignments you might have made to these same keys thereby defeating this program Therefore be sure to clear any existing User key assignments of these keys before using this program and avoid redefining these keys in the future Example 1 Given the system of equations at the b
118. f 124 SandMatrix_4 Manual Revision N 4 4 3 Prime Factors Decomposition PRMF PF gt X TOTNT This section describes the three functions provided in the SandMatrix related to Prime factorization Function Description Input Output 1 PRMF Prime Factors Matrix Form Argument in X reg 2 PF gt X From Factors to Number Prime factors in Matrix file 3 TOTNT Euler s Totient function Argument in X reg The first one PRMFC extends the basic prime factorization capability in the SandMath PFCT The difference is that whereas PFCT only uses the Alpha register to output the result as Alpha string here the prime factors and their multiplicities are also stored in a matrix in X Mem named PRFM This ensures that no information will be lost scrolled off the display if the length exceeds 24 char and also provides a permanent storage of the results You can use PF gt X to check the result it re builds the original argument from the values in the PRMF matrix using the obvious relationship x I1 PF i m i for i 1 2 primes Euler s Totient function In number theory Euler s totient or phi function n is an arithmetic function that counts the totatives of n that is the positive integers less than or equal to n that are relatively prime to n The graphic below shows well sort of the first thousand values of n
119. f the magnitude of the cross product Using the Vector functions Type Result 3 ENTER 2 ENTER 2 CHS VENTER 2 2 3 2 ENTER 2 CHS ENTER 3 CHS AXV 10 5 10 VMOD 15 000 2 7 500 Example 2 Resolve the following three loads along a 175 degree line Use the dot product on the sum of the three loads to do so You will first need to convert the polar coordinates to rectangular coordinates Remember to set z 0 Save the results for the polar coordinates of L3 and the 175 line so that you can re use them to find the resolution dot product when L3 is doubled This example stores those results in vector registers 1 and 2 c ngel M Martin December 2014 Page 107 of 124 SandMatrix_4 Manual Revision N 4 185 LB A 62 170 LB A 143 YAN 1 5 100 LB 4 2614 The solution is the dot product of the resulting vector and the unit vector in the desired direction Each vector must be converted to rectangular coordinates so here are the keystrokes Keystrokes Action Result XEQ DEG Sets angular mode 0 ENTER 143 ENTER 170 L1 in polar coordinates P R rectangular 135 768 102 309 0 VENTER pushes it to V2 0 ENTER 62 ENTER 185 L2 in polar coordinates P R rectangular 86 852 163 345 0 A V adds L1 L2 48 916 265 654 0 VENTER pushes it to V2 0 ENTER 261 ENTER 100 L3 in polar coordinates P R rectangular 15 643 98 769 0 VSTO 01 saves L3
120. f vector entry is the R S key Whenever you enter the vector components from the keyboard when the menu was the last thing displayed before keying in the three components Pressing R S will perform the same function as VENTER The following table shows the keystrokes to execute vector operations on the Vector Calculator program VC For a definition of each operation refer to the Summary of Vector Operations following the Instruction Table Instructions Key in Display Start the program for the Vector Calculator VC XEQ VC DP CP lt MUV Enter the three components of your first vector V1 z1 ENTER z1 Separate two vectors with a vector enter after the first y1 ENTER yi set of coordinates execute VENTER or if the menu x1 R S DP CP lt M UV was the last thing displayed before you entered the first or VENTER component press R S Key in the second vector V2 Do not press R S z2 ENTER z2 y2 ENTER y2 x2 x2 Display the main menu optional J DP CP lt M UV Execute a vector operation Dot Product V1 V2 A DP DOT result Cross Product V1 x V2 B CP X x result Y y result Z z result Angle between V1 and V2 C lt lt result Norm magnitude of V2 D M M result Unit Vector of V2 E UV X x result Y y result Z z result Vector Add V1 V2 A X x result Y y result Z z result c ngel M Martin December 2014
121. from the original due to rounding off during operations Editing and Viewing an LU Decomposed Matrix LU decomposed matrices are stored in a different form than normal matrices e Certain elements contain alpha data or Non normalized numbers to be precise e The matrix status register is modified to indicate that the matrix is in LU form Editing any element of the matrix will clear the LU flag in the status register which makes the matrix unrecognizable to the program Because of this if you edit one element you must edit them all if you wish to use the matrix again Note that the matrix will no longer be in LU decomposed form after this action You can view the contents of an LU decomposed matrix by doing one of the following e From the MATRX main menu press SHIFT A to view individual elements without modifying them e Set flag 08 before executing MEDIT or CMEDIT This allows you to view the elements without modifying them c Angel M Martin December 2014 Page 28 of 124 SandMatrix_4 Manual Revision N Header Register X ray LU The graphic below shows the different fields in the Matrix header register 14 bytes in total 13 12 11 10 9 8 7 6 5 4 3 2 1 0 4 FileAddr_ LU of Columns Activeij FileSize Note that a matrix file in X mem has its type set to 4 in leftmost byte and that the matrix dimensions can be derived from the information in the file size field
122. g a register 33 My specify vector MY to be created in X MEM 34 MATDIM creates and dimensions vector MY in X MEM B5 LBL B ask for yi data and store them in MY 36 0 specifies 1st element of the vector and 37 MSIJ resets the index to the 1st element B8 LBL 02 loop for next data and store them in MY 39 MRIJ recalls the current value of the index 40 y forms the prompt to ask for yi 41 AIP appends the index to the prompt 42 J appends to the prompt 43 PROMPT prompts the user to enter yi 44 MSR stores it in MY and updates the index 45 FC 10 are we done with all elements 46 GTO 02 not yet go back to ask for the next yi 47 MX MyY all yi stored Specify MX MY for the system 48 MSYS solves the system for the coefficients 49 LBL C retrieve and display each coeff 50 0 specifies ist element of the coeffs vector 51 MSIJ resets the index to the 1st coefficient 52 LBL 03 loop to retrieve the next coefficient 53 MRIJ recalls the current value of the index 54 A forms the prompt to display each coeff 55 AIP appends the index to the prompt 56 J appends to the prompt 57 MRR retrieves the value of the current coeff 58 ARCL X appends the value to the prompt 59 PROMPT shows the value to the user 60 FC 10 are we done outputting all the coeffs 61 GTO 03 not yet go back for the next coefficient 62 END all done End of execution As the Advantage ROM can work with matrices directly i
123. gramming Information The subroutine CT can be used in your own programs It performs coordinate transformations rotations and translations in three dimensions It takes the x y and z values from the stack X Y and Z registers and transforms them to another system or from the new system to the original system Comments To use CT load the translation vector T the unit rotation vector N and the rotation angle set flag 01 to go to the new system or clear flag 01 to go to the original system Set flag 05 to rotate the vector s coordinates P The result is returned to the X Y and Z registers and in Ri RO2 and RO3 Note that CT is located in the secondary FAT thus it requires ZV or 2V to run c Angel M Martin December 2014 Page 113 of 124 SandMatrix_4 Manual Revision N Program listings As you can see by comparing it to the original programs the code length is drastically reduced and the program clarity is also much improved with a very intuitive structure behind all functionality OL LBL TR 01 LBL 3VC 02 SIZE 49 FC 01 02 CF 04 w 44 50 GTO02 03 LBLJ 04 X gt Y 51 VRCL 04 CF 21 05 _ PSIZE 52 h D5 SF 27 eres 2 06 EXSCR en 08 AVIEW 025 ER OME 09 EXSCR 10 vSTO p 11 h 58 GTOO1 10 SIOP A 2 ax 59 VSTO eee 130 ROT lt O VRCL 12 GTOJ 4 PROMPT wi 13 LBLd
124. he index based launcher ZV which provides visual feedback that the chosen function is the intended one or not This feature is active in RUN mode when entering it into a program and when single stepping a program execution but obviously not so during the standard program runs LASTF Operating Instructions No separate function exists The Last Function feature is triggered by pressing the radix key decimal point the same key used by LastX while the launcher prompts are up This is consistently implemented across all launchers supporting the functionality in the three modules SandMath SandMatrix and PowerCL they all work the same way When this feature is invoked it first briefly shows LASTF in the display quickly followed by the last function name Keeping the key depressed for a while shows NULL and cancels the action In RUN mode the function is executed and in PRGM mode it s added as a program step if programmable or directly executed if not programmable The functionality is a two step process a first one to capture the function id and a second that retrieves it shows the function name and finally parses it All launchers have been enhanced to store the appropriate function information either index codes or full names in registers within a dedicated buffer with id 9 The buffer is maintained automatically by the modules created if not present when the calculator is switched ON and its conten
125. ial After completion the control word for the reminder is left in X and the control word for the quatient is saved in ROO The solutions are q x x 4x Se and r x 14 x 3 c Angel M Martin December 2014 Page 73 of 124 SandMatrix_4 Manual Revision N Example 3 Calculate the addition and subtraction of the polynomials a x and b x below a x 2x 4 4 x 5x 6 and b x 1x 33x 2741 We ll use P P and P P for convenience It ll automatically store the coefficients of the operand polynomials in registers R04 to R07 and in registers R08 to R11 respectively The result polynomial will be stored starting with register R12 leaving the operand polynomials untouched After completion the control word for the result is left in X The solutions are a x b x 4 x x 12 x 7 a x b x 7 x 2 x 5 Below you can see the program listing for the four arithmetic driver routines 2 CF 01 33 N 1 order P1 3 GTO 00 34 PROMPT n1 4 e 35 5 36 37 EE Loo m 4 7 XEQ 10 combined data entry 38 3 8 FC 01 product 39 4 00 n 4 9 GTO 00 yes go there 40 STO 00 10 RND division 41 PEDIT 11 PDIV 42 XEQ 05 adjust index 12 X lt gt Y reminder cntl word 43 ENTER push stack 13 STO 00 store 44 N 2 order P2 14 X lt gt Y 45 PROMPT n2 15 PVIEW show quotient 46 n2 eee1 16 X lt gt 00 47 I lt gt J 0 00 n2 eee1 GTO 02 48 eee1 1 00 eee1 n2 LBL 00 _
126. ient and reminder 1 Let a x ao x a xX an 1 X an and b x bo x b1 x bm 1 X bm then there are only 2 other polynomials q x and r x such that a b q r with deg r lt deg b Note that PDIV does not work if deg a lt deg b but in this case q 0 and r a Example 1 Find the result of the polynomial product of a x b x where a x 2 x 5 x 21 x 23 x 3 x 5 and b x 2 x 3 x 1 We ll use P P for convenience It ll automatically store the coefficients of the operand polynomial in registers R04 to R09 and in registers R10 to R12 respectively The result polynomial will be stored starting with register R20 leaving the operand polynomials untouched The solution is p x 4 x 4 x 55 x 114 x 84 x 24 x 12 x4 5 Example 2 Find the quotient and reminder for the polynomial division a x b x where a x 2 x 5 x 21 x 23 x 3 x 5 and b x 2 x 3 x 1 We ll use P P for convenience It ll store the dividend coefficients in registers R04 to R09 and the divisor s in registers R10 to R12 Note that in this case the coefficients are already there as entered in the previous example so you just have to press R S during the process The solutions are displayed sequentially starting with the quotient first The indices convention message aK X K is shown prior to the enumeration of each result polynom
127. ier put it in ROM module format available at http www hp41 org LibView cfm Command View amp ltemID 613 Flectrical ae Circuits for Students The module also contains the other two famous applications of yore 1 Electrical Circuits for Students 2 Statics for Students and 3 Computer Science on your HP 41 a k a the HP 16C Emulator Anybody curious enough to see what could be done with the Advantage is encouraged to check those out you ll be rewarded The last example asks you to solve a set of six simultaneous equations with six unknown variables This requires the use of MSYS as the constant matrix B is not a column matrix Example 3 Silas Farmer has the following record of sales of cabbage and broccoli for three different weeks He knows the total weight of produce sold each week the total price received each week and the price per pound of each crop The price of cabbage is 0 24 kg and the price of broccoli is 0 86 kg Determine the weights of cabbage and broccoli he sold each week Week 1 Week 2 Week 3 Combined Weight kg 274 233 331 Combined Value 130 32 112 96 151 36 The following set of linear equations describes the two unknowns the weights of cabbage and broccoli for all three weeks where the first row of the constant matrix represents the weights of cabbage for the three weeks and the second row represents the weights of brocco
128. iliary FAT purely on a convenience basis to make room in the main FAT for other more relevant functions so they re available using the sub function launchers XVL or XVL Refer to the corresponding sections in the manual for usage instructions and details Remember to always check Jean Marc Baillard s pages on these and related subjects really a treasure trove of solid programs you can use In particular for the Euclidean distances and the Vector products Attp hp41programs yolasite com distance php Attp hp41 programs yolasite com dotcross php Appendices Note Make sure that revision N or higher of the Library 4 module is installed c Angel M Martin December 2014 Page 120 of 124 SandMatrix_4 Manual Revision N Appendix M MCODE listings for LU And MROW There are a few new M Code functions in the SandMatrix that make direct usage of the module s subroutines A representative example is given below showing the very short routine LU that checks whether the matris is in its decomposed form simply by reading the appropriate digit in the matrix header register 1 LU Header OBF 2 LU Header 015 3 LU Header 00C 4 LU PORT DEP Jumps to Bank_2 5 LU XQ adds 4 to XS 6 LU gt A5D9 LNCHO 7 LU lt parameter gt 8 LU JNC 01 9 LU ENROM1 restore bank 1 10 LU C N ALL header register 11 LU PT 9 LU dig
129. in stack MMOVE and MSWAP Copies or Exchanges the submatrix defined by pointers in the source matrix to the area defined by one pointer in the target matrix The inputs require both matrix names in Alpha separated by a comma plus the pointers in the stack as follows in X reg ii j j for A s initial element in Y reg Hi jjj for A s final element bes sae When executing MMOVE and MSWAP if A and B are the same matrix and the source submatrix overlaps the target submatrix the elements are processed in the following order reverse column order last to first and reverse element order last to first within each column ttt MY Source matrix A Target matrix B When an input of the form iii jjj is expected in the X register a zero value for either the i part or the j part is interpreted as 1 Zero alone equals 1 001 This is true for the iii ijj values that MMOVE and MSWAP expect in the X and Z registers but not for the pointer value in the Y register For the Y register input a zero value for the i part is interpreted as m the last row while a zero value for the j part is interpreted as n the last column This convention facilitates easy copying or exchanging of entire matrices because simply by clearing the stack CLST or entering three zeros you specify the elements 1 001 X and mmm nnn Y for the first matrix and element 1 001 Z for the second matrix thus defining two entire matrices For example in a 4 x
130. ing this program and avoid redefining these keys in the future Summary of Vector Operations The vector operations are accessible in two different ways e By using the Vector Calculator and its redefined keys as explained above e By directly executing a vector function using its Alpha name like any other HP 41 nonkeyboard function e Vi refers to the first or top vector the one in M N and O V2 refers to the second or bottom vector the one in X Y and Z The operations perform the same calculations regardless of how they are executed These characteristics are given in the table below along with their Alpha names and descriptions You can also execute these operations by Alpha name from inside the Vector Calculator though it is usually more convenient to use the Vector Calculator s redefined keys c Angel M Martin December 2014 Page 105 of 124 SandMatrix_4 Manual Revision N Table of Vector Functions This table shows all functions implemented in the module Note that the convention followed indicates V1 level in X Y Z and V2 level in M N O that is reversed from the Advantage s Function Effect A V Adds vectors V1 and V2 Result vector v2 v2 is placed in V1 with v1 saved in LastV VO V2 is left unchanged A V Subtracts vectors V1 and V2 Result vector v2 v1 is placed in V1 with vi saved in LastV V0 V2
131. input matrix and some functions automatically use one of the input matrices for output So the minimum number of matrices to specify is one and the maximum is three A matrix function checks the Alpha register for the names that is the locations of the matrices it needs for input and output Before executing that function you should specify all needed parameters on one line in the Alpha register separating each with a comma Alpha Register input matrix input matrix result matrix c Angel M Martin December 2014 Page 22 of 124 SandMatrix_4 Manual Revision N Scalar Operations Scalar input and output must be in the X register and so this location does not need to be specified unless the function in question can use either a scalar or a matrix for the same input parameter To specify the X register use X For instance MATDIM requires a scalar input and a matrix name so you do not need to specify the X register On the other hand the scalar arithmetic functions such as MAT can use either two matrices or a scalar and a matrix for input Therefore you must specify X if you want to use it The Current Matrix The current matrix is the last one accessed used by a matrix operation If the Alpha register is clear and you execute a matrix function that requires a matrix specification the current matrix is used by default If there is no current matrix UNDEF ARRAY results The result matrix of a matri
132. inter to 1 1 3 MSIJA set pointer to 1 1 3 SEEDT time based seed 5 MRIJ recall pointer 4 6 INT i 6 random number 7 MRIJ recall pointer 7 RND current settings 8 FRC Ojjj 83 EDGT sum of digits 9 I lt gt J j 9 MSR store element 10 l j 10 FC 10 end of matrix 11 2 11 GTO 00 no loop back 12 i j 2 12 END yes done 13 MRIJ recall pointer 14 INT i 15 E 16 i 1 17 NCR Cli j 2 i 1 18 MSR 19 FC 10 end of matrix 20 GTO 00 no loop back 21 END yes done c Angel M Martin December 2014 Page 38 of 124 SandMatrix_4 Manual Revision N 3 Upper Page Functions in detail This chapter is all above and beyond the matrix functionality present in the Advantage Pac a true extension of its capabilities into new and often uncharted territories ABY MATRIX USER 46 HIV MHITRIX 3 1 The Enhanced Matrix Editor s Often the most tedious part of a matrix calculation becomes the data entry for the input matrices and the review of the results With this in mind the SandMatrix includes convenient alternatives to MEDIT the standard Matrix Editor from the Advantage seen in the previous chapter There are as follows Function Description Input Output 1 PMTM Prompt Matrix by Rows Matrix name in Alpha 2 IMR Input Matrix by Rows Matrix name in Alpha 3 IMC Input Matrix by Columns Matrix name in Alpha 4 OMR Output Matrix by Rows Matrix name in Alpha
133. ions chapter Enter coordinates as rectangular coordinates and specify angles according to the current setting Degrees Radians or Grads mode e For two dimensions input zero for the z value e For pure translation input zero for the rotation angle e For pure rotation input zeros for x0 YO and z0 e The sign of the rotation angle is determined by the right hand rule and the direction of the rotation vector For two dimensions counter clockwise rotation is considered positive e You can switch into and out of the Vector Calculator by pressing C C for Calculator and Coordinate transformations You can then perform vector operations upon vector coordinates in the stack and in storage registers Refer to Remarks for the storage locations of the vector coordinates e The view function C E is very useful for reviewing the coordinates of the point in the stack PR FG NEW USER DERUD e Q Once you have entered your variables this menu shows you which key corresponds to which function in TR To restore this menu to the display at any time press J f the USER annunciator is On If it is not on press USER to turn it on Or if the calculator is displaying results you can press R S until the menu appears This will not disturb the program in any way To clear the menu at any time press This shows you the contents of the X register but does not end the program Y
134. it 12 LU C 0 PT 13 LU 14 LU 15 LU BR a Lastly and just in case you though that functions PMTM and PMTP are actually not a big deal which would be the logical conclusion if you only look at their FOCAL program listing here is in all its gory detail the listing for its MCODE heart function MROW I ll spare you the more onerous details but suffice it to say that it was an involved assignment And don t forget that another function is also used to support the matrix prompt mode ANUMDL although in this case I just had to copy HP s code from the HP IL Development Module thanks HP Header 1 2 AMROW Header 3 AMROW Header Input Matrix Row 4 AMROW Header 5 AMROW Header ngel Martin 6 AMROW B65D 0c4 CLRF 10 start anew no CHS yet 7 AMROW 184 CLRF 11 start anew no commas yet 8 AMROW 344 CLRF 12 start anew no digits yet 9 AMROW B660 OF8 READ 3 X 0 AMROW 070 N CALL 1 AMROW 345 PNC XQ Clears Alpha 2 AMROW 040 gt 10D1 CLA 3 AMROW 215 PNC XQ Build Msg all cases 5 SMROW 12 O rr A O 6 AMROW B667 0B0 C N ALL row number in BCD format i 7 AMROW B668 137C RCR 12 move the MSB to C 0 1 8 AMROW B669 lac PT 2 9 AMROW B66A 010 LD PT O l 20 AMROW B66B 12D0 LD PT B add colon to digit 21 AMROW 3E8 WRIT 15 e write it in display 9 bit 22 AMROW 355 PNC XQ blank space to LCD 23 AMROW 03C gt 0FD5 DSPL20 i 24 AMROW 33D NCGO In
135. ix Trace and remaining functions MTRACE In linear algebra the trace of an n by n square matrix A is defined to be the sum of the elements on the main diagonal the diagonal from the upper left to the lower right of A i e n tr A ay dag ann X Gii i l where aii represents the entry on the i th row and i th column of A The trace of a matrix is the sum of the complex eigenvalues and it is invariant with respect to a change of basis Note that the trace is only defined for a square matrix i e n xn Some of the properties of the trace are quite interesting and useful for other calculations like eigenvalues and even determinants In particular one could use the relationship that defines the trace of a product of matrices tr XTY tr XY tr X tr Y X gt Xi jYij i j If we use an identity matrix in place of Y on the equation above it s clear that tr A SUM A o i where the o symbol denotes the Hadamard or entry wise product as obtained by MAT The program in the SandMath however uses a direct approach summing the elements in the diagonal it s faster and doesn t require any auxiliary matrix to hold intermediate results Eigenvalues relationships The trace of a matrix is intricately related to its eigenvalues In contrast with the determinant which is the product of its eigenvalues if A is a square n by n matrix with real or complex entries and if A1 An
136. ke it Identity 30 RCL 05 1 n 13 CLA 31 X prepare string 14 ARCL 01 MNAME to Alpha 32 ASWAP 15 4 prepare string 33 MAT element multiplication 16 MAT intermediate result 34 MNAME MNAME to Alpha 17 ASWAP 35 MEXP exponential matrix 18 FRNM get its norm 36 END done The scratch matrix is removed in case there is divergence or reused to calculate the logarithm if not thus at least it s not all a waste of time If there is no convergence and you have nothing else to do you may still go ahead and hit R S after the error message to see how the precision factor keeps increasing until the OUT OF RANGE condition A general purpose algorithm for the p th root The principal p th root of a non singular matrix A det A 0 may be computed by the algorithm MO A Mk 1 Mk 2 1 p 2 Mk I p 1 Mk 1 p X0 I Xk 1 Xk 2 14 p 2 Mk 1 1 p 1 Mk where I is the Identity matrix Mk tends to I as k tends to infinity Xk tends to A 1 p as k tends to infinity The convergence is also quadratic if A has no negative real eigenvalue c Angel M Martin December 2014 Page 54 of 124 SandMatrix_4 Manual Revision N Lie Product of two Matrices MLIE The lie product is defined as the resulting matrix obtained from the difference between the right and left multiplications of the matrices or in equation form Lie A B Lie B A AB BA Example Calculate the Lie product for matrices
137. l is difficult and this is still a topic of considerable current research in mathematics and numerical analysis The SandMath uses a direct approach so no claims of discovering new algorithms exp A I A A7 2 A 3 4 0 FANKI c Angel M Martin December 2014 Page 46 of 124 SandMatrix_4 Manual Revision N The program adds new terms until their contribution is negligible i e it results in the same matrix after addng it This by itself poses an interesting question how to check whether two matrices are the same Obviously doing it element to element would be a long and impractical method The alternative is to use the matrix Frobenius norm as a surrogate criterion assuming that for very similar matrices they ll be equal when they have the same norm There s no saying to the execution time or whether the calculator numeric range will be exceeded in the attempt so you can expect several iterations until it converges The matrix norm will be displayed after each iteration so you ll have an indication of the progress made comparing two consecutive values Logarithm of a Matrix MLN In mathematics a logarithm of a matrix is another matrix such that the matrix exponential of the latter matrix equals the original matrix It is thus a generalization of the scalar logarithm and in some sense an inverse function of the matrix exponential Not all matrices have a logarithm and those matrice
138. lator It redefines the functions in the top two rows of keys to these vector operations addition subtraction distance dot product cross product angle between vectors norm and unit vector This pac also offers these operations to you as regular functions without the Vector Calculator that you can execute like any other Hp 41 nonkeyboard function Their Alpha names are given under Summary of Vector Operations The vector operations operate on three dimensional vectors described in rectangular coordinates That is every vector has three components Vx Vy and Vz For a two dimensional vector Vz must be equal to zero A complement to VC is the Coordinate Transformations program TR This means you can carry out vector operations and transformations on the same data since you can access either program from the other one The use of coordinate transformations is covered in the next section Coordinate Transformations Method The Vector Calculator program VC creates a vector stack that works in concert with the regular RPN stack X Y Z and T registers When you enter the three components of a vector in the order Vz Vy Vx they occupy the regular stack like so The RPN Stack V ENTER V ENTERS V e x lt N How do the two stacks relate to each other Basically the bottom level of the vector stack V2 is stored in registers X Y and Z of the stack while the upper level of the vector stack
139. li Since the constant matrix is not a column matrix you must use MSYS and not the SE function in the MATRX program c Angel M Martin December 2014 Page 32 of 124 SandMatrix_4 Manual Revision N 1 1 dy dip ayy 274 he 33 331 0 24 O86 d dy doy 120 32 112 96 151 36 Where the subindices indicate the crop 1 broccoli 2 cabbage and the week 1 2 3 and the first row describes the weight equations and the second the prices relationship Calling FACTORS the coefficients matrix and LINKS the constant matrix we first create them by dimensioning in X Memory as follows ALPHA FACTORS ALPHA ALPHA LINKS ALPHA 2 002 XEQ MATDIM 2 003 XEQ MATDIM Next we ll use PMTM to input all the element values Note that even the longest row has 20 characters including the separator blanks which is below the limits of the ALPHA register length of 24 characters max With FACTORS in Alpha we type XEQ PMTM gt at the prompt Ri _ we type 1 ENTER 1 R S gt at the prompt R2 _ we type 0 2 4 ENTER 0 8 6 R S With LINKS in Alpha we type XEQ PMTM gt at the prompt Ri _ we type 2 7 4 ENTER 2 3 3 ENTER 3 3 3 R S gt at the prompt R2 _ we type 1 2 0 3 2 ENTER 1 1 2 9 6 ENTER 1 5 1 3 6 R S All set up we simply execute MSYS to obtain the solutions sought
140. main memory using the name RO in Alpha and the dimension in X ALPHA RO ALPHA 3 003 XEQ MATDIM Since the elements are all integer numbers this is an ideal candidate for PMTM XEQ PMTM gt at the prompt Ri _ we type 6 ENTER 3 ENTER CHS 2 R S gt at the prompt R2 _ we type 1 ENTER 4 ENTER CHS 3 R S gt at the prompt R3 _ we type 2 ENTER 3 ENTER CHS 1 R S And now the festival begins type XEQ TRNPS RO is transposed XEQ MINV RO which was transposed is inverted XEQ MDET gt 0 040 is the solution c Angel M Martin December 2014 Page 27 of 124 SandMatrix_4 Manual Revision N Note that if you had wanted to find the transpose of the original matrix after having found its determinant you would have needed to invert the matrix twice to change the LU decomposed form back to the original matrix LU Decomposition The ower upper LU decomposition is an unrecognizably altered form of a matrix often containing Alpha data This transformation properly occurs in the process of finding the e Solution to a system of equations MSYS SE in the MATRX program e Determinant MDET DT in MATRX program e Inverse MINV I in MATRX program The first two of these operations convert the input matrix to its LU decomposed form and leave it there whereas inversion leaves the matrix in its inverted form
141. mentation Before you ask no there isn t a memory buffer or any similar fancy trick implemented in the Vectors ROM for a full fledged vector stack Because there isn t a dedicated memory area for it it follows that the implementation must use the standard means for all purposes meaning the real stack and Alpha registers Even with this limitation it s possible to implement a poor man s version of a vector RPN stack with just two levels plus also featuring Last Vector functionality for the most important cases The following paragraphs describe the details of such an implementation 1 Two stack levels V1 and V2 using the stack and Alpha Logically the three components of the first vector level V1 will occupy the X Y and Z registers in the stack Monadic_ functions should return the result in the X register placing the x coordinate in LastX for easy retrieval should the original vector is to be recalled Dual functions will operate on both the stack and the Alpha registers M N and O which hold the second vector operand V2 In addition to the Vector Recall Storage and Exchange a few other functions are included for convenient handling of the levels VENTER V lt gt A and LASTV see below With all these the 2 level vector stack becomes useful and suitable for the majority of usual scenarios Fully Programmable VRCL VSTO V lt gt VVIEW Using the non merged functions technique the numeric argument is
142. ms Summarizing the SandMatrix is a true algebra module with not only powerful Matrix capabilities inherited and extended on its own but also Vectors and Polynomial functions second to none in the HP 41 platform Yet its FAT internal architecture and launcher menus should make its usage intuitive and easy to learn hopefully you d agree and have as much fun using it as I ve had putting it together Note Make sure that revision N or higher of the Library 4 module is installed c Angel M Martin December 2014 Page 13 of 124 SandMatrix_4 Manual Revision N 2 Lower Page Functions in detail The first section groups the auxiliary functions used for ALPHA string management plus some leftover functions that either didn t belong to the other categories or were added at latest stages of the development SNIMHTRX 4 USER 01 ei SNIMHTRK Y 2 1 Alpha String Management sub functions The use of the ALPHA register for Input Output certainly isn t new in the 41 platform but the utilization by the Matrix functions effectively turned it into an abstraction layer for programming therefore the importance of auxiliary utilities like these Some of these functions are also included in the AMC_OSX Module yet it appeared convenient not to add that module as another dependency even if it s just a 4k footprint for its 3 banks so here they are as well
143. multiplication 49 PEDIT PPRD 50 RCL 00 bbb eee1 51 X lt gt Y bbb eee2 52 LBL 05 53 ENTER bbb eee2 54 I lt gt J eee bbb2 55 INT eee2 56 E 57 eee2t1 combined data entry 58 END 30 PVIEW show result reminder 31 RTN done c Angel M Martin December 2014 Page 74 of 124 SandMatrix_4 Manual Revision N 4 2 3 Deleting Coefficients and Moving Polynomials DTC PCPY PSWP The functions in this section perform the following housekeeping chores e Copy a polynomial from a source to a destination location e Swap polynomial coeffiecients between two locations and e Delete small coefficients below 1E 7 which typically appear due to rounding errors in the intermediate operations This has a cumulative effect that can alter the final result if not corrected In revision N of the SandMatrix both PCPY and PSWP are implemented as MCODE functions faster and more flexible as they allow overlapped ranges of data registers PCPY is located in the main FAT but PSWP is incuded in the secondary FAT thus you must use one of the launchers to execute it These functions require the polynomial control word bbb eee in Y and the new 1 register address in X The new control word is left in X upon completion Only the control word in X is required as input for DTC The three small routines below were written by JM Baillard You can see the program listings for these always a be
144. n LastX VRCL__ Recalls vector register nn to V1 level pushes vi into V2 and v2 is lost Supports INDirect addressing VSTO __ Stores v1 into vector register nn Supports INDirect addressing VUNIT Replaces vi with its unitary vector that is v v1 v1 Original v1 is placed in LastV V2 is unchanged c ngel M Martin December 2014 Page 106 of 124 SandMatrix_4 Manual Revision N VVIEW __ Sequentially views the components of vector register nn Supports INDirect addressing V 0 Conditional test on the three components of v1 being zero Returns YES NO skips line in a program if FALSE V 0 Conditional test on at least one component of v1 not zero Returns YES NO skips line in a program if FALSE V A Conditional test on vi being equal to v2 Returns YES NO skips line in a program if FALSE V A Conditional test on v1 not equal to v2 Returns YES NO skips line in a program if FALSE Remember that of all these only the prompting functions with underscores next to the name are located in the main FAT and the rest are sub functions in the secondary FAT therefore you need to use XV or XV to execute them Example 1 Find the area of the triangle determined by the vectors vi 3 2 2 and v2 2 2 3 Recall that the area of the parallelogram determined by vi and v2 equals the magnitude of vi x v2 V2 10 0 0 3 2 2 The solution is hal
145. n X Mem POLFIT doesn t use any main RAM registers and so it will run even at SIZE 000 This has the added advantage pun intended of avoiding any register conflicts with other programs POLFIT creates two matrices in X Mem namely MX and MY which aren t destroyed upon termination Retaining MX allows the user to compute the coefficients of another polynomial using the same x data but different y data In that case the x data need not be entered again only the new y data must be entered Further as the MX matrix is left in LU decomposed form after the first fit the second fit willproceed much faster Retaining MY allows the user to employ the polynomial for interpolating purposes root finding numeric integration or differentiation etc Lines 2 11 prompt the user for the degree of the polynomial then allocate the system matrix in Extended Memory MATDIM and reset the indexes MSIJ c ngel M Martin December 2014 Page 90 of 124 SandMatrix_4 Manual Revision N e Lines 12 22 set up a loop that will fill up the rows of MX Notice the use of the miscellaneous function AIP to build the prompt and MSR to store the value and automatically advance the indexes to point to the next element e Lines 23 27 form a tight loop that computes each power of xi and uses MSR to store it and advance the indexes Flag 9 logs if we re done with the column in which case we would proceed to the next row If so Flag 10 is
146. n program by Narmwon Kim available at the HP 41 archive site which features a simpler user interaction and data entry output but at the expense of more limited functionality It is also less general purpose and more geared towards control system applications http www hp41 org LibView cfm Command View amp ltemID 776 c Angel M Martin December 2014 Page 96 of 124 SandMatrix_4 Manual Revision N Other Polynomial Launchers Roots and Utils For convenience purposes several root finding and other polynomial utilities functions are grouped in an independent launcher combining functions from both the SandMath and the SandMatrix under common themes This launcher is accessed as an alternate personality of the ZDST function no more FAT entries were available pressing the XEQ key to invoke it In fact XEQ toggles between both personalities as shown in the picture below The following tables show which functions are available under each of the two screens Note that some are from the SandMath module in a logical grouping of the roots theme Straight Line equation 1 STLINE y1 x1 y2 x2 in stack 2 QROOT Quadratic Equation a b c in stack 3 CROOT Cubic Equation a b c d in stack 4 QUART Quartic Equation monic b c d e in stack a 1 N PROOT Polynomial Roots Follow program instructions B BAI
147. ng The FOCAL programs that use them have also been modified accordingly to reflect the new arrangements Like it was the case in the Vectors ROM the coordinate transformation and vector calculator programs TR and VC from the Advantage Pac have been re written using the new 3D Vectors functions included in the module and included in the main FAT User instructions and capabilities are identical but its execution speed is largely faster as they take advantage of the MCODE implementation of the underlying functions Besides a few other new geometry functions also went to the auxiliary FAT completing the coordinate transformations and 2D 3D distances function set They ll be described in section 4 of the manual Note that all these important additions required making some changes to the Library 4 make sure you use revision N or higher in conjunction with the SandMatrix revision N Note Make sure that revision N or higher of the Library 4 module is installed c Angel M Martin December 2014 Page 6 of 124 SandMatrix_4 Manual Revision N 1 Introduction The release of the CCD Module by W amp W in 1983 provided for the first time convenient and reliable tools for matrix algebra in the 41 platform It was an MCODE quantum leap ahead beyond the very many user programs written on the subject in the previous years Looking back it s clear that the ARRAY FNS was beyond a doubt an am
148. ng goose FROOT is working on it EV 10 00000 ev found in FIX 5 The original matrix is not modified in any way but note that an auxiliary matrix is created for the calculations This scratch matrix is not purged automatically from X Mem you ll have to do that after you re done calculating as many eigenvalues as you need c Angel M Martin December 2014 Page 63 of 124 SandMatrix_4 Manual Revision N EIGEN Below is the program listing for FAT entry EV Note how the equation to solve already requires an auxiliary since a global label is always needed by FROOT You can refer to the SandMath manual if you need to refresh your understanding of FROOT and FINTG 1 LBL EIGEN 2 FS 06 subroutine mode r 3 GTO 01 yes Skip data entry T 4 SNDMATRX 4 prompts ORDER T 5 STOP r 6 E fr 7 E3 E 1 001 rg n 00n r 9 EV hard coded name r 10 MATDIM create square matrix F input elements 13 ASTO 00 save MNAME in ROO d 14 SQR not square d 15 LU LU decomposed r 16 ADV MATRX show error r 17 DIM dimensions r 18 F scratch matrix F 19 MATDIM as identity one 21 LOW V 22 PROMPT prompt lower bound EIGEN initial guess is given compares favorably to that of eigenvalues The difference of course is that whilst EIGEN does it one at a time 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
149. o n 0 200 400 600 800 1000 Examples Calculate the prime factors and the totient for the following numbers n PF phi 1 477 7 211 1 260 819 735 3 5 7 37 211 362 880 123 456 246 3 643 41 088 000 c Angel M Martin December 2014 Page 87 of 124 SandMatrix_4 Manual Revision N The programs are listed below There s no fancy algorithm for TOTNT it just counts the number of prime factors after doing the decomposition as a preliminary step Euler s Totient Function 55 GTO 03 skip if yes 2 SF 04 flag case 56 ST L divide number by PF 3 XEQ10 get all Prime Factors 57 LASTX Reduced number 4 0 58 GTO 00 loop back 5 sets pointer to 1 1 59 LBL 03 Store Exponent 6 argument to x 60 RCL 00 recover PF 7 61 MSR store in matrix get element 62 GTO01 next factor invert it 63 LBL 02 New PF found sign change 64 STO 01 Store for comparisons 65 RCL 00 previous exponent add 1 66 MSR Store Old PF Exponent multiply 67 RDN end of row 68 ST L divide number by PF loop back 69 LASTX Reduced number refesh display 70 DIM done 71 X lt gt Z Bring the new PF back 18 LBL PRMF Prime Factors 72 MSR store new PF 19 CF 04 flag case 73 FS C 00 Was it Prime 20 LBL 10 74 GTO01 Bail Out we re done 21 PRMF 75 X lt gt Y Bring the number back 22 272 76 GTOOS Start Over 23 E3 E 1 002 77 LBL PF gt X Rebuild number 24 MATDIM Create Matrix 78 SF 04 flag case 25 CLX 79 PRMF matrix name 26 MSHA
150. of dimension 2x1 e CN is the coefficients matrix of dimension 2x2 The linear system is solved as many times as iterations needed to establish the convergence With each factorization the program obtains two roots This is repeated for until all roots have been found Program Details In manual RUN mode PROOT prompts first for the order n ie the degree and for each of the coefficients sequentially It then presents the option to store the roots into a matrix in X Mem To use it you just have to press Y at the prompt below All roots are stored in matrix ROOTS of dimension n x 2 with the first column holding the real parts and the second the imaginary parts of each root assumed complex The global label ROOTS is also meant to be used in subroutines for program execution It expects the degree stored in ROO and the coefficients stored in registers RO3 until R 3 n Registers RO1 and R02 are used internally and cannot be used for your data In subroutine mode the roots will always be stored in the matrix ROOTS Example 1 Find the five roots of the polynomial below P x 2 x 7 x 20 x 81 x7 190 x 150 Keystrokes Display Result XEQ PROOT ORDER Prompts for the degree 5 R S Z aK X K Reminder of convention a5 prompts for coeffs showing current 2 R S a4 7 R S a3 20 R S a2 81 R S al 190 R S
151. ointer row number prompts for string default reset l separate elements last one reached yes exit store element end of row no do next element end of matrix no do next row 19 MNAME recall Mname 20 END done AMROW is the first function listed in CAT 2 within the ADV MATRIX group and rightfully so Note that even if PMTM is not strictly an MCODE function de facto it is a hybrid one and therefore it s denoted in blue color all throughout this manual If PMTM is the beauty then MROW is the beast If you re interested you can review the MCODE listings for it in appendix M Below are two examples of the lists being edited for the first two rows of a given matrix i ac ee and Eee The built in logic allows for just one negative sign and one radix character per each value entry Note that MROW is also used by PMTP the Polynomial Input function which has a very parallel structure to PMTM and is used to enter the coefficients of a polynomial into data registers It will be covered in the polynomial section later on The remaining routines in this section all deal with Input and Output of the matrix elements depending on whether it s done following the Row or Column sequence as well as two functions to only view one specific row or column OXR and OXC c Angel M Martin December 2014 Page 40 of 124 SandMatrix_4 Manual Revision N They are very much equivalent to
152. ointer by one none 8 J Decrements jjj pointer by one none Storing and Recalling the Element s Value alone or sequentially The following functions provide a faster more automated alternative to adjusting the pointer value to access each element These combine storing or recalling values and then incrementing or decrementing the i or j index so that the pointer is automatically set to the next element Function Description Inputs 9 MS Stores value in X reg into current element Value in X Reg 10 MR Recalls current element to X reg None Returns element to X reg 11 MSC Stores value in X reg to current element and Value in X reg advances pointer to next element in column 12 MSR Stores value in X reg to current element and Value in X reg advances pointer to next element in row 13 MRC Recalls current element to X reg and then None advances pointer to next element in column Returns element value to X reg 14 MRR Recalls current element to X reg and then None advances pointer to next element in row Returns element value to X reg 15 MRC Recalls current element to X reg and then None decrements pointer to previous in column Returns element value to X reg 16 MRR Recalls current element to X reg and then None decrements pointer to previous one in row Returns element value to X reg c Angel M Martin December 2014 Page 24 of 124 SandMatrix_
153. ompts for index Executes Function Angel Martin xvs Vector Function Launcher Prompts for name Executes Function Angel Martin MATRX Easy Matrix Program Driver for Major Matrix Ops Under prgm control HP Co TR Coordinates Transformation Under prgm control Under prgm control HP Co vc Vector Calculator Prompts DP CP lt M UV Under prgm control HP Co V lt gt _ Vector Swap Vector register in Memory Swaps vector with with V1 Angel Martin VRCL__ Vector Recall Vector register in Memory Recalls vector to V1 Angel Martin VSTO__ Vector Storage Vector register in Memory Stores V1 in Memory Angel Martin VVIEW __ Shows Vector Components Vector register in Memory Shows vector components Angel Martin V VN N dimensional Dot product Prompts for coeffs Result in Matrix Angel Martin CCD MTRX Checks for LU Square Matrix MNAME in Alpha Displays Running Angel Martin C lt gt C Column exchange k lt gt l kkk III in X Columns swapped W amp W GmbH CMAX Column Maximum Col in X OP1 in Alpha Element value in X W amp W GmbH CNRM Column Norm Col in X OP1 in Alpha Column norm in X W amp W GmbH CSUM Column Sum OP1 RES in Alpha Sum of Cols in RES matrix W amp W GmbH DIM Matrix Dimension OP1 in Alpha Dimension placed in X W amp W GmbH FNRM Frobenius Norm OP1 in Alpha Value in X W amp W GmbH l Increase row index OP1 in Alpha increased i HP Co l Decrease row index OP1 in Alpha decreased i HP Co J Increase column index OP1 in Alpha increa
154. on without having to type its name or navigate the different launchers to access it The implementation is not universal it only covers functions invoked using the dedicated launchers but not those called using the mainframe XEQ function It does however support two scenarios a functions in the main FATs as well as b those sub functions from the auxiliary FATS Because the latter group cannot be assigned to a key in the user keyboard the LASTF solution is especially useful in this case The following table summarizes the launchers that have this feature Module Launchers LASTF Method SandMatrix 4 XML XDST Captures sub fnc id revision M XxVS _ Captures sub fnc NAME XV _ Captures sub fnc id Revision N FCAT XEQ Captures sub fnc id Note that the Alphabetical launcher V will switch to ALPHA mode automatically Spelling the function name is terminated pressing ALPHA which will either execute the function in RUN mode or enter it using two program steps in PRGM mode by means of the V function plus the corresponding index using the so called non merged approach This conversion happens entirely automatically With revision N the LASTF operation is also supported when excuting a sub function from within the FCAT enumeration using the XEQ hot key which is very handy for those fncs with elusive spelling Another new enhancement is the display of the sub function names when using t
155. on used is shown in the figure below with the azimuth angle theta measured in the XY plane between the X axis and the projection of the vector S and the Zenith angle phi measured from the Z axis to the vector the radius P The calculations are made using the internal TOPOL and TOREC OS routines same ones used for the native P R and R P functions z axis x y z y x y 0 X axis c Angel M Martin December 2014 Page 117 of 124 SandMatrix_4 Manual Revision N N dimensional Vector Operations DOTN V VN DOTN is an all MCODE implementation of a n dimensional vector dot scalar product the norms of each operand and the angle between them Originally written by JM Baillard the input parameters are the control words for each vector in registers X and Y more about this later and the result value are placed in the stack Obviously the vector components must be input in the appropriate registers which you can do using any of the available input programs available in the SandMatrix will be seen with detail in the polynomial section later in the manual Incidentally the code for DOTN is located in the second bank of the lower page taking advantage of the available room after the removal of the digital functions Example Calculate the scalar product of vectors U 2 3 7 1 and V 3 1 4 6 storing their components in registers R01 R04 for U and R06 R09 for V
156. ores io ila R c ngel M Martin December 2014 Page 11 of 124 SandMatrix_4 Manual Revision N The Vector Calculator subfunctions come next Note the two sections in the listing where the second groups auxiliary functions used by the FOCAL programs and other less relevant functions seldom used O VCALC Section Header none Triggers FCAT Angel Martin 1 AtV Vector addition Data in V1 and V2 Sum vector in V1 Angel Martin 2 A V Vector Subtraction Data in V1 and V2 Difference vector in V1 Angel Martin 3 A V Vector Dot Product Data in V1 and V2 Result in X reg Angel Martin 4 AXV Vector Cross Product Data in V1 and V2 Product vector in V1 Angel Martin 5 A V Vector Division Data in V1 and V2 Division vector in V1 Angel Martin 6 EXSCR Alpha Exchange Vector in V2 Swapped with scratch Angel Martin 7 LASTV Last Vector recall none V1 pushed to V2 LastV to V1 Angel Martin 8 X V Multiplication by Scalar Data in stack Result in V1 Angel Martin 9 V lt gt A Swaps vector levels Data in V1 and V2 Swaps vectors Angel Martin 10 VADST Distance between vectors Data in V1 and V2 Distance in X reg Angel Martin 11 VANG Angle between vectors Data in V1 and V2 Angle in X reg Angel Martin 12 VCHS Negative vector Vector in V1 Negative vector in V1 Angel Martin 13 VENTER Enters V1 into V2 level Vector in V1 Pushes V1 into V2 Angel Martin 14 VIEWV Views V1 vector coordinates Vector in V1 Sh
157. ote that in MATP I have chosen PMTM to enter the element data values therefore it s somehow limited by the same constraints described before ie total length in Alpha and no support for the EEX key c Angel M Martin December 2014 Page 45 of 124 SandMatrix_4 Manual Revision N 3 2 2 New Math functions Completing the core function set The next group includes advanced application areas in core matrix math Function Description Input Output 9 M 1 X Brute force Matrix X th Root Matrix name in Alpha order in X A exp 1 x Ln A The result matrix replaces the input 10 M 2 Square power of a square Matrix Matrix name in Alpha A A 2 A A The result matrix replaces the input 11 MDPS Matrix Diagonal Product Sum Matrix name in Alpha MDPS gt aii aii 1 i 1 2 n Output is result in X reg 12 MEXP Exponential of a Matrix Matrix name in Alpha A exp A The result matrix replaces the input 13 MLIE Matrix Lie Product Matrix names in Alpha A B C C AB BA Result matrix C must be different 14 MLN Matrix Logarithm Matrix name in Alpha A Ln A The result matrix replaces the input MPOL Matrix Polynomial Matrix name in Alpha control word in X P A ak A k Output is matrix P in X Mem 15 MPWR Matrix Power of integer order Matrix name in Alpha order in X reg A Ax The result matrix replaces the input 16 MSQRT Matrix Square
158. ou can perform calculations and then continue the program by pressing J However you do not need to clear the program s display before performing calculations c Angel M Martin December 2014 Page 110 of 124 SandMatrix_4 Manual Revision N Instruction Table for TR Start program TR The menu items in the dis play indicate the locations of functions in the top row of keys Enter the origin for the new system Input the rotation angle of the new system Zo Yo ENTER Xo 6 R S 4 For a three dimensional system Input the ro c c tation vector s coordinates b b For a two dimensional system just press a tN tO NEW R S 5 To transform the coordinates of a point from z Z the original system to the new system tN y y enter the three coordinates of that point and x A tN X x select tN For two dimensions set z 0 R S f Y y RzS t Z 7 Rzs IN 10 NEW 6 To transform the coordinates of a point from z z the new system to the original system t0 y y enter the three coordinates of that point and x t0 X x select tO For two dimensions set z 0 R7S t Y y R S t Z 2z R S t tN 10 NEW 7 To view the coordinates of the point in the I E X x coordinate stack R78 t Y y coordinate R S t Z z coordinate R7S t N10 NEW 8 To transform another set of coordinates go back to step 5 or 6 9 To set up a new transformed system select E NEW
159. outine use T 32 r 03 GTO 00 yes Skip data entry r 33 V2 T 04 SNDMTRX 4 prompts ORDER T 34 FNRM T o5 STOP T 35 r 06 INT F 36 ACOS 07 nyg T 37 XoY T o8 MATDIM P38 V lt r 09 XEQ 05 V1 data input T 39 ARCLY T 10 DIM 7 40 PROMPT show angle r a y2 T 4 RTN F MATDIM 42 LBLO5 13 XEQ 05 V2 data input 4 3 T 44 XoF 15 nyay r aa D r 16 CLX T 46 MSIJA position pointer r 17 MATDIM r 18 tiyg r 39 TRNPS r T 20 1V2 v v r T 2a M M r r 2 ASHF T 52 ARCLX r z3 0 YF 53 M r 24 MSUA position pointer T 54 PROMPT r 25 MR recall element r 55 MS T 2 ENTER T 56 k 27 js r 57 FC 10 reached the end r 28 ARCL X r 58 GTO 04 no loop back r 29 PROMPT show result r 59 MNAME T 30 yg 7 60 END The usage of user flag 06 determines whether the program is used as a subroutine in which case the data entry is skipped This is more or less consistently done throughout the SandMatrix module and has the benefit of saving one entry in the FAT which would be needed for the subroutine label Line 4 uses the header function SNDMTRX 4 which in program mode adds the text ORDER to the display not ALPHA This saves bytes and keeps the contents of ALPHA unchanged c Angel M Martin December 2014 Page 119 of 124 SandMatrix_4 Manual Revision N Note Functions EV3 and PF gt X are handy companions to the main programs EV3X3 and PRMF respectively They ve been placed in this section of the aux
160. ows X Y Z coordinates Angel Martin 15 VINV Vector Inverse Vector in V2 Inverse vector in V1 Angel Martin 16 VMOD Vector Modulus Vector in V2 Modulus in X reg Angel Martin 17 VNORM Vector Norm Vector in V2 Norm in X reg Angel Martin 18 VUNIT Unitary Vector Vector in V2 V v in V1 Angel Martin 19 V 0 Conditional V1 0 Vector in V2 YES NO Do if True Angel Martin 20 V A Conditional V1 V2 Data in V1 and V2 YES NO Do if True Angel Martin 21 V O Conditional V1 0 Vector in V2 YES NO Do if True Angel Martin 22 VHA Conditional V1 V2 Data in V1 and V2 YES NO Do if True Angel Martin 23 AUX FNS High Rollers Game none The game begins Ross Cooling 24 AMROW Input Row OP1 in Alpha row in x Prompts for Row Angel Martin 25 ABSP Alpha Back Space Text in Alpha Last chr deleted W amp W GmbH 26 AIP Appends integer part xin X INT x appended to Alpha Angel Martin 27 ASWAP Alpha Swap A B in Alpha B A in Alpha Angel Martin 28 CLAC CLA from Comma Text in Alpha Removed from left to comma W amp W GmbH 29 DOTN N dimensional Dot product cnt l words in Y X cnt l word result in X JM Baillard 30 EQT Display Curve Equation Eq in ROO 1 16 Eq displayed in Alpha Angel Martin 31 I J Multiplies indexes iii jjj Product i j in X ngel Martin 32 1 Are indexes the same iii jjj YES NO Do if True ngel Martin 33 I lt gt J Swaps indexes iii jjj jij iii Angel Martin 34 PF gt X Prime Factors to Number Matrix w P
161. pha 42 72 85 END 43 STO 02 Remarks The program is relatively short but hefty in data requirements three auxiliary matrices are created and used during the calculations meaning that the total numbers of registers needed including the original matrix is 4 x dim A Note also that the convergence is based on equal Frobenius norms of two consecutive iterations and that the comparison is made using the full 9 decimal digits see instruction X Y in line 75 A rounded comparison would result in shorter execution times but it wouldn t be as accurate As usual these routines will result in ALPHA DATA if the matrix is in LU decomposed form c Angel M Martin December 2014 Page 48 of 124 SandMatrix_4 Manual Revision N Square root of a Matrix MSQRT In mathematics the square root of a matrix extends the notion of square root from numbers to matrices A matrix B is said to be a square root of A if the matrix product BB is equal to A Just as with the real numbers a real matrix may fail to have a real square root but have a square root with complex valued entries In general a matrix can have many square roots however a positive semidefinite matrix M that satisfy that x M x gt 0 for all x in R has precisely one positive semidefinite square root which can be called its principal square root Computing the matrix square root in the SandMatrix uses a modification of the Denman Beaver
162. put List in Alpha 25 112 ALIST Not such a big deal you keep saying Well let s have a look at the remaining part in the Libary 4 c ngel M Martin December 2014 Page 121 of 124 SandMatrix_4 Manual Revision N 1 ALIST 4aco een Delete char plus logic 2 ALIST 44ce Ss 51515 ae ee Oe SRE ae DELCHR ee 3 ALIST ALIST as NC 4 ALIST 5 ALIST 6 ALIST numeric input 7 AUST 44D3 093 INC 18d_ 4____ _NO KEEP LOOKING ____ 8 ALIST 44D4 TOBE ACMS recall LS digit from A 13 9 ALIST 44D5 4130 LDI S amp X 1 0 ALIST 44D6 f003 PESCON ETS __ pre load the numeric mask ___ 1 ALIST 44D7 2FC RCR 13 move it to C S amp X 2 ALIST 44D8 3e8 WRIT 15 e write it in display 9 bit 3 ALIST 348 SETF 12 enable SPACE 4 ALIST TOALPH O 5 ALIST i 6 ALIST Disable PER enable RAM 7 ALIST __ ENcPoo 3 ALIST A H 9 ALIST APNDNW 20 ALIST GOBACK a 21 AUST ____ reset PTEMP bits __ 22 ALIST Enable Display not cleared 23 ALIST ENLCD f 24 AUST ANCHOR1 JNC 21d ONE PROMPT __ _ J 25 ALIST a FSET7 decimal key pressed 26 AUST M6 03B _ JNC 07 JNO KEEP LOOKING 27 ALIST FSET 11 been used already 7 28 AUST JC 04 ONE PROMPT 29 ALIST EILSE e no more radix unless deletion _ 30 ALIST PNC XQ adds proper radix sign 32 ALIST ANCHOR2 JNC 18d 33 ALIST C N ALL 34 AUST a 106 _ acesax O oO OOO O
163. r Cy ias bij or ee Cy a by for all i j in C Ci 8 by for all j j in C ij ij ij Cy ay X x OF Cy ay gt x or Cy x by or Cy X Ob OF Cy a X b for all i j in C Cy ay by for all i j in C j The true matrix multiplication calculates each new element i j by multiplying the i th row in A by the j th column in B The input is the three matrix names in Alpha where C must be different from the two operands A and B The output is C Ss a X by where A has p columns and B has p rows c ngel M Martin December 2014 Page 26 of 124 SandMatrix_4 Manual Revision N 2 3 2 Major Matrix Operations The major matrix operations are inversion finding the determinant transposition and solving a system of linear equations Function Description Input 1 MDET Finds the Determinant of a square matrix Matrix Name in Alpha 2 MINV Inverts and replaces the square matrix Matrix Name in Alpha 3 MSYS Solves a system of linear equations Matrix Name A Name B in Alpha 4 MTRPS Transposes and replaces the real matrix Matrix name in Alpha This is where the Advantage really took the original CCD implementation to its full fulfillment as the CCD was sorely lacking the major operations no doubt due to the size constrains in a module that already had tons of other wonders and was packed bursting to its seams I recall the awe with which we used to run MINV and the other
164. r information 9 ASWAP 62 CCD MATRIX shows RUNNING 10 DIM n 00n 63 PDEG new destination 11 INT n 64 STO 00 as expected by RTSN 12 STO 00 65 4 13 E 66 X gt Y n lt 4 14 n 1 67 GTO 04 yes particular case 15 MDET determinant 68 CLX no general case 16 RCL 00 69 E 17 CHSYX independent term 70 n 1 18 STO IND Y stored in Rn 1 71 E6 19 ASWAP 72 0 000 00 n 1 20 MAT avoids LU issues 73 3 build the from to 21 DIM 74 E3 E 1 003 22 g auxiliary array 75 1 003 OO n 1 23 MATDIM 76 REGMOVE as expected by RTSN 24 FRC 0 00n 77 RTSN 25 2 78 GTO 00 go to EXIT 26 2 00n 79 LBL 04 27 STO 00 80 X Y n 4 28 CF 21 not halting VIEW 81 GTO 03 82 RCL 02 a3 VIEW 00 shows index 83 RCL 03 a2 31 84 RCL 04 al 32 MIDN I 85 RCL 05 a0 33 sp 86 QUART 34 MTRACE tr B 87 GTO 00 go to EXIT 35 RCL 00 88 LBL 03 36 INT k 1 89 RCL 01 a3 37 E 90 RCL 02 a2 38 k 91 RCL 03 al 39 92 RCL 04 a0 40 CHS 93 CROOT 41 STO IND 00 pk tr B k 94 X 42 XA 95 ARCL Z 43 MAT pk I 96 PROMPT real root 44 P 97 FC 43 is RAD on 45 MAT B p I 98 GTO 01 yes complex roots 46 CLA 99 X lt gt Z no real roots 47 ARCL 01 100 CLX so we clear Z 48 igp 101 X lt gt Z 49 M M B A B p1 102 LBL01 50 ISG 00 103 QROUT output roots 51 GTO 00 104 LBL 00 52 DIM n 00n 105 MNAME bring MNAME back 53 FRC 0 00n 106 END done 54 E c Angel M Martin December 2014 Page 68 of 124 SandMatrix_4 Manual Revision N
165. rammable and can be entered into a program line using a technique called non merged functions This approach is identical to the one used in the SandMath module and derives from the original implementation in the HEPAX module A sub function catalog FCAT is also available listing the functions included within the groups Direct execution or programming if in PRGM mode is possible just by stopping the catalog at a certain entry and pressing the XEQ key The FCAT catalog behaves very much live the native ones in the machine you can stop it using R S SST BST them press ENTER to move to the next sub section cancel or resume the listing at any time As additional bonus the sub function launcher V will also search the main FAT if the sub function name is not found within the multi function group so the user needn t remember where a specific function sought for was located In fact XV will also find a function from any plugged in module in the system even outside of the SandMatrix module A comprehensive Vector Function Launcher prompt The Vector launcher is one of the three modes of the main module launcher MLA by pressing the A key at the initial M _ prompt which changes it into the V _ prompt As it occurs with theme modules there are a large number of functions that work together and ideally should all be available in a USER keyboard for optimal utilization And as it s become customary see
166. rating until there is no change in two consecutive values r p q r 0 or r p q r s p q s 0 or s p q s Expressing it using their partial derivarives it results dp sr dp dq sr dq r dq ds 5p dq ds 5q s Using the relationships 1 above we can formally obtain the partial derivatives using the coefficients of the original polynomial ai The problem will then be equivalent to solving a system of 2 linear equations with two unknowns dp and dq From equation 1 above it follows dbi Sp ci b i 1 p c i 1 q c i 2 i 2 3 n 2 5bi 5q C i 1 Making use of equation 2 to apply it for i n we have as final expression b n 1 c n 1 dp cn dq dq b n 2 p b n 1 3 qcn dp c n 1 p cn c ngel M Martin December 2014 Page 81 of 124 SandMatrix_4 Manual Revision N Starting with p0 0 5 qO 0 5 as initial guesses we ll obtain dp and dq for each pair of values p q With them we adjust the previous guess so that the new corrected values for p and q are g dp p p q q dq ee i This will be repeated until the precision factor s is smaller than the convergence criteria The precision factor is calculated as follows e abs dp abs dq abs p abs q The program dimensions and populates matrices RS and CN to hold the current values of p q and the coefficients Cn respectively e RS is the column matrix
167. rbolic er j a atbKtcXt2 11 Parabola ka saibi he gae 12 Linear Exponential i RIN iii aae 13 Normal gy a a l X 4akeb 456LBL 13 i7 RIH 46 aet X b t2 c is LBL ad 47 h 19 3 th 2 RIN Note that EQT does not perform any gt g Fa phd i4 calculations thus it s just an embellishing jai pi a5 5A act lt b LN 429 addition to CURVE 2 abt S1 Rep 23 RIK 52 RTH The original listing was originally 248l B6 SILL 15 published in the AECROM manual and it s 25 abt i x 54 1 atktb 2oec reproduced here practically unaltered 26 RTH 55 hr E7e LBL 8 36 RTH 28 aetibX 3 EHD 29 RIN c Angel M Martin December 2014 Page 84 of 124 SandMatrix_4 Manual Revision N 4 4 2 Polynomial interpolation POLINT The program POLINT follows the Aitken s interpolation method It s an elegant simple implementation and a nice example of utilization of the capabilities of the platform It was written by Ulrich K Deiters and it is posted at _http www hp41 org LibView cfm Command View amp ltemID 600 The program performs polynomial interpolations of variable order on xi yi data sets with the order determined by the number of data pairs It is applied as follows You have a set of xi yi data pairs The xi are all different and they need not be equidistant You need to know the y value at the location x which is not one of the
168. re Matrix MName in Alpha YES NO Do if True ngel Martin ZUJI Sum of crossed products OP1 in Alpha L aij aji in X Angel Martin ADV POLYN Section Header none Displays S ak XAk ngel Martin BAIRS Bairstow Method Cntl word in Z guesses in Y X shows results JM Baillard CHRPOL Characteristic Polynomial OP1 in Alpha Characteristic Pol Coefs Roots ngel Martin DTC Delete Tiny Coefficients Cntl word in X Tiny coeffs deleted JM Baillard EIGEN Eigen Values by SOLVE Under prgm control Eigen Values by Solve ngel Martin EV3X3 Eigen values 3x3 Prompts Matrix Elements Eigen Values by Formula ngel Martin JACOBI Symmetrical Eigenvalues Under prgm control Eigen Values by Jacobi Valent n Albillo LL3 3D Line to Line distance Under prgm control Result in X ngel Martin PL3 3D Point to Line distance Under prgm control Result in X ngel Martin PPL3 3D Point to Plane distance Under prgm control Result in X ngel Martin P P Polynomial Addition Driver for PSUM w CF 01 shows results ngel Martin P P Polynomial Substraction Driver for PSUM w SF 01 shows results ngel Martin p P Polynomial Multiplication Driver for PPRD shows results ngel Martin c ngel M Martin December 2014 Page 10 of 124 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 SandMatrix_4 Manual Revision N P P PCPY PDIV PEDIT PFE PMTP POLFIT POLINT POLZER PPRD PRMF PROOT PSUM PVAL PVIEW QUART HEV Functions in blue
169. real matrices and CMEDIT for complex matrices They are otherwise quite similar The matrix editors are used for three purposes c Angel M Martin December 2014 Page 21 of 124 SandMatrix_4 Manual Revision N e Entering new values into the elements of a matrix e Reviewing and changing editing the elements of a matrix either in order or by random access of specific elements e Viewing without being able to change the elements of a matrix flag 08 set When you execute MEDIT or CMEDIT the editor displays element 1 1 of the matrix specified in the Alpha register or of the current matrix if the Alpha register is empty Pressing R S steps the display through the elements for a complex matrix each part of the complex element is shown separately Function Display Function Display MEDIT 1 1 1 0000 CMEDIT RE 1 1 1 0000 R S 1 2 2 0000 R S IM 1 1 1 0000 R S RE 1 2 2 0000 R S X register R S X register The at the end of the display line indicates that you can change that value In effect you are being asked whether this is the value you want If you want to change the element you see just enter the new value and press R S You do this for a brand new matrix as well as for correcting or altering a single value If you press R S without entering a new value the current value remains unchanged Viewing without editing If you set flag 08 the editor will let you only view the elements not ch
170. rent matrix powers as per the order of the polynomial terms As it s the case all throughout polynomials Honer s method proves very useful to reduce all the matrix powers to matrix multiplications with considerable execution time reduction and simplification of the code Example Calculate P A for the following matrix and polynomial P x 2x x 3x 4x 5 and 42 3 A 325 214 This is also a good example to become familiar with the editor and input routines available in the SandMatrix First we ll create and populate the matrix using the Matrix Editor input functionality very recommended for integer elements as follows ALPHA A ALPHA 3 003 XEQ MATDIM creates the matrix in X Mem then XEQ PMTM gt at the prompt R1 _ we type 4 ENTER 2 ENTER 3 R S gt at the prompt R2 _ we type 3 ENTER 2 ENTER 5 R S gt at the prompt R3 _ we type 2 ENTER 1 ENTER 4 R S The Matrix has been completely input using batches or lists including all elements of each row simultaneously this is an advantageous way to handle them that results in faster and less error prone method not based on a single element prompt Note how pressing ENTER during this process results into a blank space in the display separating each of the elements and that the sequence is terminated pressing R S Upon completion the matrix elements are stored in the Matrix file in ext
171. ribed above f tn we 2f 2n f tn Inti In Gy Tn 1 Flan OF en Fen En 1 The figure below shows a book example of a cubic polynomial and its fisrt and second derivatives parabola and straight line and even the third derivative constant line here all have real roots but that s clearly not always the case Note how the roots of a function correspond to the points where the derivative ot its primitive polynomial is zero i e their local minimum maximum as we know from function theory Egwald Linear Algebra Derivatives of Polynonials c Angel M Martin December 2014 Page 77 of 124 SandMatrix_4 Manual Revision N 4 2 5 Polynomials over Integer field Cohn s irreducibility criterion If F is a field a non constant polynomial is irreducible over F if its coefficients belong to F and it cannot be factored into the product of two non constant polynomials with coefficients in F Arthur Cohn s irreducibility criterion is a sufficient condition for a polynomial to be irreducible in Z x that is for it to be unfactorable into the product of lower degree polynomials with integer coefficients The criterion is often stated as follows If a prime number p is expressed in base 10 as p Gy 10 Am 1 1 iii o a 10 dg where 0 lt ak lt 9 then the polynomial formed with the same factors below is irreducible in Z x m m 1 f x Oyn0 4y 12 4 0 dp COHN
172. rime Facts in XMEM Restores the original argument Angel Martin 35 PL2 2D Point to Line distance Coordinates in Stack Distance in X reg Angel Martin 36 PP2 2D Point to Point distance Coordinates in Stack Distance in X reg Angel Martin 37 R S Rectangular to Spherical Coordinates in XYZ Coordinates in XYZ Angel Martin 38 S R Spherical to Rectangular Coordinates in XYZ Coordinates in XYZ Angel Martin 39 ST lt gt A Swaps Alpha Stack V1 in Stack V2 in Alpha V2 in Stack V1 in Alpha Angel Martin 40 FCAT Sub function Catalog Has hot keys Lists Launches functions Angel Martin 41 REV Revision Message none Animated sequence Nelson Crowle 42 COHN Irreducibility Criteria Control word in X Stops If irreducible R04 has Angel Martin 43 CROUT Outputs Cubic Roots Roots in Stack Shows messages Angel Martin 44 CT Subroutine for TR Under program control See Advantage s manual HP Co 45 dPL Polynomial 1 derivative Cntl word in Y x in X P x in X argument in L Angel Martin 46 dPL2 Polynomial 2 derivative Cntl word in Y x in X P x in X argument in L Angel Martin 47 MSQ2 2x2 Matrix Square Root MNAME in ALPHA Replaces original matrix Angel Martin 48 MTR Matrix subroutine Under program control See Advantage Manual HP Co 49 PSWP Polynomial Swap Control word in Y new rg in X Coeeficients Swapped JM Baillard 50 TOTNT Euler s Totient Function argument in X Result in X Angel Martin c Angel M Martin December 2014
173. rompts for dimension Data entry starts Note how the symmetric elements are skipped input the last element Asks for precision Scrolling on the display After a while 2 5m in normal 41 the four ev s are displayed Keystrokes Display Result XEQ JACOBI ORDER 4 R S al 1 25 R S al 2 41 CHS R S al 3 10 R S al 4 6 CHS R S a2 2 68 R S a2 3 17 CHS R S a2 4 10 R S a3 3 5 R S a3 4 3 CHS R S a4 4 2 R S PREC 5 R S RUNNING X 0 03302 R S X 98 52170 R S X 1 18609 R S X 0 25920 Example Repeat the same case but using CHRPOL to obtain the polynomial and its roots Keystrokes Display Result ALPHA AA ALPHA 4 004 XEQ MATDIM XEQ PMTM current X reg 4 003 R1 i B 25 ENTER CHS 41 ENTER 10 ENTER CHS 6 R S CHS 41 ENTER 68 ENTER CHS 17 ENTER 10 R S un R2 i ew u R3 f u 10 ENTER CHS 17 ENTER 5 ENTER CHS 3 R S R4 AAS CHS 6 ENTER 10 ENTER CHS 3 ENTER 2 R S XEQ CHRPOL R S R S R S R S RUNNING 5 aK XAK a4 1 a3 100 a2 146 al 35 a0 1 00000 RUNNING X1 98 52170 X2 1 18609 X3 0 25919 X4 0 03302 Matrix name in Alpha Creates mtrix in X Mem prompts for row 1 prompte for row 2 promp
174. s iteration Let YO A and ZO I where I is the n x n identity matrix The iteration is defined by Yk Zp Zk Y net o gt H bole N Convergence is not guaranteed even for matrices that do have square roots but if the process converges the matrix Yk converges quadratically to a square root A while Zk converges to its inverse A Contrary to the exponential and logarithm programs the square root convergence is checked using the rounded values of the norms for two consecutive iterations You can set FIX 9 for maximum accuracy and longest run time not a problem on V41 and on the 41CL of course Example 1 Find a square root of the 3 order Hilbert matrix 1 1 2 1 3 A 1 2 1 3 1 4 1 3 1 4 1 5 We ll use IMR to input the element values as PMTM is not really suitable for this example Previously we need to create the matrix as follows ALPHA HILB3 ALPHA 3 003 XEQ MATDIM Once all elements are entered we execute MSQRT which shows the norms of the different iterations Let s assume we set the calculator in FIX 9 for the maximum accuracy available then the result matrix is as follows Final Frobenius norm 1 238278374 0 917390290 0 345469265 0 197600714 Sqrt A 0 345469265 0 374984280 0 270871020 0 197600714 0 270871020 0 295943995 Squaring the result matrix again you can use M 2 for that we can check
175. s that do have a logarithm may have more than one logarithm Furthermore many real matrices only have complex logarithms making it so even more challenging The SandMatrix uses the following algorithm If A 1 lt 1 the logarithm of a n x n matrix A is defined by the series expansion Ln A A I A 1 2 A 1 3 A 1 44s where I is the identity matrix Example 1 Calculate the exponential of the matrix A given below and then calculate its logarithm to see how the result matrix compares to the original i 2 3 A 0 1i 2 1 3 2 The first part of the assignment is rather simple Executing MEXP results in the following matrix 19 45828375 63 15030507 66 98787675 exp A 8 534640269 32 26024414 33 27906416 16 63953207 58 45323648 61 70173665 However trying to calculate the logarithm will not work because exp A doesn t satisfy the requirement Det exp A I 52 95249156 therefore trying MLN on it will eventually reach an OUT OF RANGE condition Example 2 Calculate the Logarithm of the following matrix 1 2 0 1 0 3 A 01 08 0i 0 1 02 0 9 In this example A I 0 5099 lt 1 thus the program will work The result matrix after executing MLN is as follows 0 167083396 0 069577923 0 287707999 Ln A 0 097783005 0 240971674 0 103424021 0 086500972 0 235053124 0 131906636 c Angel M Martin December 2014 Page 47 of 124 SandMatrix_4 Manual
176. sed j HP Co J Decrease column index OP1 in Alpha decreased j HP Co M M Matrix Product OP1 OP2 RES in Alpha matrix product in RES W amp W GmbH MAT element multiplication value in X OP1 X in Alpha aij aij x W amp W GmbH MAT addition of scalar value in X OP1 X in Alpha aij aij x W amp W GmbH MAT element substraction value in X OP1 X in Alpha aij aij x W amp W GmbH MAT Division by scalar value in X OP1 X in Alpha aij aij x W amp W GmbH MATDIM Dimensions a matrix mmm nnn in X OP1 in Alpha Matrix Dimensioned W amp W GmbH MAX Maximum element OP1 in Alpha Element value in X W amp W GmbH MAXAB Absolute maximum OP1 in Alpha Element value in X W amp W GmbH MDET Determinant OP1 in Alpha Determinant in X HP Co MIN Minimum element OP1 in Alpha minimum element in X W amp W GmbH MINV Inverse Matrix OP1 in Alpha Matrix replaced w Inverse HP Co MMOVE Moves part of a matrix Lj k l b m n in XYZ Elements moved W amp W GmbH MNAME Get current Mname to Alpha none Matrix Name in Alpha W amp W GmbH MR Recall element from pt none value in X HP Co MRC Recall and advance in Column OP1 in Alpha element in X increased i W amp W GmbH MRC Recall and back one in Column OP1 in Alpha element in X decreased i W amp W GmbH MRIJ Recall ij pointer of current none pointer in X W amp W GmbH MRIJA Recall ij pointer of Alpha OP1 in Alpha pointer in X W amp W GmbH MRR Recall and advance in Row OP1 in Alpha element in X incre
177. st important ones The polynomial pA x is monic its leading coefficient is 1 and its degree is n The most important fact about the characteristic polynomial was already mentioned in the motivational paragraph the eigenvalues of A are precisely the roots of pA x The coefficients of the characteristic polynomial are all polynomial expressions in the entries of the matrix In particular its constant coefficient pA 0 is det A 1 n det A and the coefficient of x n 1 is tr A tr A where tr A is the matrix trace of A For a 2x2 matrix A the characteristic polynomial is therefore given by det A tr A A 2 For a 3x3 matrix the formula specifies the characteristic polynomial to be det A cA tr A d 3 trA tr A where c2 is the sum of the principal minors of the matrix w Given the above definitions it is clear now why functions MDPS and IJJI will be helpful to obtain the coefficients of the characteristic polynomial for n 3 In effect when using those functions the formulas change as follows c2 MDPS XIJJI For the manual mode not as subroutine a choice is offered to see the coefficients of the polynomial before calculating its roots i e the eigenvalues J which will only take Y N as valid inputs Example 1 Calculate the eigenvalues for A with aij ij Solution pA x 75 349 x3 66 x2 60 x 0 x1 66 890 x2 0 897 x3 2 24000E 9 Exampl
178. sult matrix in advance The routine will guide you step by step thru the complete sequence including the element data input and output c Angel M Martin December 2014 Page 43 of 124 SandMatrix_4 Manual Revision N MIDN is a good example of a sorely missing function the majority of matrix algorithms involve identity matrices one way or another so having a routine that does the job becomes rather important The SandMatrix routine follows a single element approach storing ones in the main diagonal after zeroing the matrix first This is faster and more convenient that block based methods even if not requiring scratch matrices for intermediate calculations See the example below courtesy of Thomas Klemm DIM n i n a DIM n n 2 4 i 11 O O O 11 0 O a2 2 3i gt 10 0 O gt 11 0 O O gt 10 1 O 10 0O 0 11 0 O O 10 0O 1 10 0 0 1 LBL MIDN MNAME in Alpha 1 LBL IDN2 2 MZERO clear all elements 2 DIM current dimension 3 o S ENTER push it to Y 4 MSUA set pointer to 1 1 INT n 5 E element value 5 MATDIM row matrix nx 1 6 LBL 00 6 E 7 MSC store and increase 7 MCON all ones 8 FC 09 end of row 8 X lt gt Y n 9 J yes next row 9 n 1 10 FC 10 end of matrix 10 LASTX n 11 GTO 00 no next element 11 I lt gt J 0 00n 12 END yes done 12 n 1 00n 13 MATDIM shorter and faster even if more pedestrian 14 TRNPS 15 X lt gt Y original nxn 16 MATDIM bach to shape 17 END done Of
179. t is identified by the value i jj7 for its location in the i th row of the j th column You can drop leading zeros in the i index and trailing zeros in the j index The value of the pointer defines the current element Setting and recalling the Pointer Function Description Inputs 1 MSIJA Sets element pointer of matrix in Alpha Name in Alpha iii jjj in X reg 2 MSIJ Sets element pointer of current matrix iii jjj in X reg 3 MRIJA Recalls element pointer of Matrix in Alpha _ Name in Alpha iii jjj in X reg 4 MRIJ Recalls element pointer of current matrix _ iii jjj in X reg The following functions increment and decrement the element pointer rowwise iii or column wise jjj If the end of a column is reached with the i index or the end of a row is reached with the j index then the index advances to the next larger or smaller column or row and sets flag 09 If the index advances beyond the size of the matrix both flags 09 and 10 are set These functions always either set or clear flags 09 and 10 If the conditions listed above don t occur the flags are cleared every time the functions are executed Incrementing and Decrementing the Pointer The following functions were not in the original CCD ARRAY FNS group therefore are HP s Function Description Inputs 5 I Increments iii pointer by one none 6 I Decrements iii pointer by one none 7 J Increments jjj p
180. t pointer 13 ENTER 31 X lt gt Y 14 ENTER fill stack w value GTO 01 next row 15 LBL 00 33 16 MR recall element 34 DIM get dimansion 17 z multiply 35 END end 18 MSR store and increase column c ngel M Martin December 2014 Page 57 of 124 SandMatrix_4 Manual Revision N MPDS Sum of Diagonal and Crossed Elements products XIJII Other two functions directly related to the eigenvalues are MDPS and ZIJJI They compute sums of pairs of element multiplication either for those in the diagonal aii a kk or for crossed i e opposite ones aij aji with i j excluding the diagonal 2 1 4 2 3 0 Armed with these functions the characteristic polynomial of a 3 x 3 matrix can be expressed very succinctly as we ll see in Chapter 4 of the manual Example Calculate the trace and the sums of diagonal and crossed elements for the matrix below 22 4 Tr A 2 1 1 2 1 1 3 MDPS 2 1 1 1 2 1 1 2 0 1 LYaij aji 2 1 4 24 3 0 10 Program listings easy does it element wise Same maha E BPS Mae in Alpha 2 SQR square 2 SQR square 3 LU yes but LU 3 LU yes but LU 4 ADV MATRX not square show error 4 ADV MATRX not square show error 5 DIM dimension to X reg 5 CF 00 default case 6 INT n 6 DIM dimension to X reg 7 E 7 3B 8 n 1 8 X lt Y isi gt 3 9 E3 E 1 00 n 1 9 SF 00 flag case
181. ter to temporarily hold them e Decimal and negative values are supported in this mode but values with exponential notation i e 2 4 E23 cannot be entered using PMTM Here s the how the sequence would change using this approach Keystrokes Display Comments ALPHA ABC ALPHA 2 003 XEQ MATDIM 2 003 Dimensions matrix ABC in X Mem XEQ PMTM R1 prompts to enter the first row 5 ENTER 6 ENTER 7 R S R2 prompts for the second row 8 ENTER 9 ENTER 10 R S done Function PMTM will be covered later in the manual as part of the new functions section c Angel M Martin December 2014 Page 25 of 124 SandMatrix_4 Manual Revision N 234 M FUNCTIONS P This section briefly defines the matrix functions besides the dimensioning storing and recalling functions discussed above Note that most of these functions are not meaningful for matrices containing Alpha data and that many of these functions are not meaningful for complex matrices In any case A complex matrix appears as a real matrix to all functions except CMEDIT Refer to Working with Complex Matrices for more information on using these functions with complex matrices 2 3 1 Matrix Arithmetic Function Description Input 1 MAT Adds scalar or element to each element A B C or X B C in Alpha 2 MAT Subtracts scalar element to each element A
182. the 41Z and SandMath manuals a dedicated launch pad is the best solution to solve this need With this approach it s not necessary to make multiple key assignments to quickly access all of the functions saving memory and allowing for other USER key mappings The V prefix indicates a prompting for the function keys which are logically mapped to the same real functions on the standard 41C keyboard Prompting functions are also included in this implementation c Angel M Martin December 2014 Page 99 of 124 SandMatrix_4 Manual Revision N The picture below shows the Vector Keyboard as invoked by the V launcher oe a TE F XEQ K EATER Y N E Vx 8 Tx Cc H EALS LOG LN D RCL M SIN COS TAN f Note that with exception of the conditional tests all mapped keys are direct no need to use SHIFT unless for INDirect addressing Note as well that the prompts also support using keys from the two top rows for quick argument entry 1 10 Vector Conditionals Other useful functions are those used to test whether vectors in V1 and V2 levels are equal different or whether the V1 level contains a zero vector V 0 V 0 V A and V A They return YES NO in RUN mode and skip the next line if false when used in a program c Angel M Martin December 2014 Page 100 of 124 SandMatrix_4 Manual Revision N A word on Vector Stack imple
183. the X register to create a matrix It does not clear zero the elements of a new matrix in main memory but retains the existing contents of the previous matrix or registers Zt does clear the elements of a new matrix in extended memory You then enter values numeric or Alpha into a matrix via the matrix editors Naming a Matrix The name you give a matrix determines where it will be stored A matrix to be stored in main non extended memory must be named Rxxx where xxx is up to three digits You can drop leading zeros The matrix will be stored starting in Rxx For example R007 is the same as R7 which would store this matrix header in RO7 As a shortcut if you specify matrix R its name and location will be RO A matrix to be stored in extended memory can be named with up to seven Alpha characters excepting just the letter X which is reserved to name the X register and the letter R followed by up to three digits which is reserved to name the main memory arrays You do not need to specify a file type it will automatically be given one unique to matrices Use the Alpha register to specify matrix names When specifying more than one name as parameters for certain functions separate them with commas Dimensioning a Matrix Specify the dimensions of a new matrix as mmm nnn where m is the number of rows and n is the number of columns You can drop leading zeros for m and trailing zeros for n For a complex matrix specify
184. the inversion 11 MATDIM auxiliary matrix P 40 Q Q 12 a 41 MINV invert auxiliary 13 MATDIM auxiliary matrix Q 42 MAT sum it to partial result 14 MIDN 43 IR 15 LBL 00 4 2 16 gok 45 MAT divide by scalar 2 17 MINV 46 18 MAT auxiliary matrix 47 s 19 CLA 48 ARCL 01 20 ARCL 01 49 MAT 21 P 50 FC 00 were norms equal 22 MAT 51 GTO 00 no next iteration 23 py 52 PURFL purge P 24 2 s O 25 MAT 54 PURFL purge Q 26 FNRM Frobenius norm 55 27 VIEW X show progress 56 PURFL purge 28 X lt gt 00 swao with old norm 57 MNAME matrix name to Alpha 29 RCL 00 recall new one again 58 END done As usual this routine will result in ALPHA DATA if the matrix is in LU decomposed form c ngel M Martin December 2014 Page 50 of 124 SandMatrix_4 Manual Revision N Appendix Square root of a 2x2 Matrix A square root of a 2x2 matrix M is another 2x2 matrix R such that M R 2 where R 2 stands for the matrix product of R with itself In many cases such a matrix R can be obtained by an explicit formula Let AB u 4 3 where A B C and D may be real or complex numbers Furthermore let T A D be the trace of M and 6 AD BC be its determinant Let s be such that s 2 6 and t be such that t 2 T 2s That is _ s iv6 t 4VJ7T 2s Then if t 0 a square root of M is R 1 A s B t C D s There it is directly without doing any iterations or finding inverses Your assignment now is
185. to X reg in each column of matrix Sets pointer to first element of column 11 FNRM Frobenius Norm Calculates the square Matrix name in Alpha root of the sum of the squares of all Outputs Frobenius norm into X reg elements in matrix 12 RNRM Row Norm Finds the largest sum of Matrix name in Alpha the absolute values of the elements in Outputs row norm to X reg each row of matrix Sets pointer to first element of row 13 SUM Sums all elements in matrix Matrix name in Alpha Outputs the sum to X reg 14 SUMAB Sums absolute values of all elements Matrix name in Alpha in matrix Outputs the sum to X reg 15 CSUM Finds the sum of each column and Matrix name result matrix name stores them in a result vector Vector in Alpha 16 RSUM Finds the sum of each row and stores Matrix name result matrix name the sums in a result vector Vector in Alpha For CSUM and RSUM the number of elements in the result matrix vector must equal the number of columns rows in the input matrix c Angel M Martin December 2014 Page 35 of 124 SandMatrix_4 Manual Revision N Examples Calculate the Colum and Rows Sums for the matrix below using the names RSUM and CSUM for the result matrices Miscellaneous Arithmetic functions Matrix Reductions 10 26 42 The result matrices vectors are located at the bottom
186. to write a short program to calculate the square root of a 2x2 matrix applying the formula above Go ahead and try your hand at it or cheat and look below MNAME in Alpha 15 ARCLT recall MNAME 2 sg Prepare Alpha string 16 as prepare string 3 MAT create scratch 17 ARCLT M M 4 ASWAP bring to hot spot 18 ST X 2s 5 MDET determinant 19 MTRACE tr 6 ABS asolute value 20 tr 2s 7 SQRT S 21 SQRT t 8 MIDN 22 MAT A A s I 9 R get s to X reg 23 AS 10 ASWAP M 24 MAT A A t 11 ASTO T save MNAME in T 25 12 e 26 PURFL get rid of scratch 13 MAT s 27 MNAME MNAME to Alpha 14 CLA 28 END done Note Not as trivial as you may think because the LU decomposition performing the determinant will conflict with other functions needed Therefore one scratch matrix should be used here as well Example calculate one square root of the matrix given below and compare its square power to it 82 5 i aa 8 2 a ZEVS Aas e J 6 1 2v5 9475 245 c Angel M Martin December 2014 Page 51 of 124 SandMatrix_4 Manual Revision N Matrix Integer Powers and Roots M 2 MPWR M 1 X This application will be dealt with using a relatively brute force approach in that the powers will be computed by successive application of the matrix multiplication therefore the restriction to integer powers MPWR calculates the general case n whilst M 2 is used
187. ts are preserved while it is turned off during deep sleep No user interaction is required If no last function information yet exists the error message NO LASTF is shown If the buffer 9 is not present the error message is NO BUF instead c Angel M Martin December 2014 Page 98 of 124 SandMatrix_4 Manual Revision N 5 Vectors and Geometry 5i VECTOR CALE V CALE USER This section was first inspired by the Advantage Pac FOCAL programs VC and TR which have now been re written using the new MCODE functions for enhanced performance and accuracy Where the SandMatrix implementation adds significant value is in the convenience and usability aspects The vector calculator for instance is a launcher based scheme that extends the Advantage menu driven concept a few notches providing more functionality and wider range as will be described later on Data registers are also handled in a vector oriented fashion operating on 3 registers blocks at once and supporting INDirect addressing all fully programmable using the so called non merged functions technique Accessing the Vector sub Functions Multi Functions V and V provide access to the entire set of vector sub functions grouped in two sections The sub functions can be invoked either by its index within the group using V or its direct name using ZV This is implemented in such a way that they are also prog
188. ts for row 3 prompts for row 4 Scrolling on the display Reminder of convention Coefficient of x 4 Coefficient of x 3 Coefficient of x 2 Coefficient of x First coef independent term Scrolling on the display Frst root Second root Third root Fourth and last root The solution is Chr A x 4 100 x43 146 x 2 35 x 1 c Angel M Martin December 2014 Page 70 of 124 SandMatrix_4 Manual Revision N 4 2 Managing Polynomials The remaing of this chapter is about polynomials Let s first cover those functions used to manage the data entry and output for them polynomial math and some handy utilities used in the other programs Function Description Input Output 7 DTC Deleting Tiny Coefficients Control word in X 8 P P Polynomial Sum Driver for PSUM 9 P P Polynomial Subtraction Driver for PSUM 10 P P Product of Polynomials Driver for PPRD 11 P P Division of Polynomials Driver for PDIV 12 PCPY Polynomial Copy Control word in X reg destination in Y 13 PDIV Euclidean Division Control words in Y and X regs 14 PEDIT Edits Polynomial Coefficients Control word in X Reg 15 PMTP Prompts for Coeffs in Alpha List Control word in X Reg 16 PPRD Polynomial Multiplication Control words in Y and X regs 17 PSUM Polynomial Addition amp Subtraction Control words in Y and X regs 18 PVAL Polynomial Evaluation Control word in Y argument in X 19 P
189. uct 55 Matrix Trace 56 Unitary Diagonal 57 Sum of Diagonal Crossed element products 58 Matrix Polynomial 59 3 2 Polynomials and Linear Algebra Eigenvectors and Eigenvalues 61 Characteristic Polynomial 62 SOLVE based implementation 63 Formula based 3 Dimensional Case 65 General n dimensional case Faddevv Leverrier 67 Jacobi method for Symmetric Matrices 69 3 3 Managing Polynomials Defining and Storing Polynomials 71 Polynomial Arithmetic 73 Evaluating and Copying Polynomials 75 Evaluating Polynomials and their Derivatives 76 Appendix Irreducible Polynomials over Z X 78 Polynomial Root Finders 79 Quartic Equation 80 General case Bairstow Method 81 3 4 Applications of Polynomials Equations for Curve Fitting programs 84 Polynomial Interpolation 85 Prime Factors Decomposition Totient function 87 Fitting data to Polynomials 89 Appendix Orthogonal Polynomial Fit 92 From Poles to Zeros and back 93 Partial Fractions Expansion 94 Extra bonus Polynomial Launchers 97 c Angel M Martin December 2014 Page 4 of 124 SandMatrix_4 Manual Revision N 4 Geometry and Vector Analysis 4 1 Subfunctions Catalog and Launchers 98 The Last Function functionality 99 4 2 Vector Analysis Vector Stack Implementation 101 Vector Operations 102 Table of Vector functions 106 Coordinate Transformation 109 Calculating 2D and 3D distances 115 Other Utility functions 117 N dimensional Vector operations 119 Appendix M
190. ulations which allows free usage of Q for the 13 digit math routines Then it is transferred from P to Q upon exiting the function where it stays for LASTV to pickup until unless Q is used by the OS in other action Viewing the vector components Functions VIEWV and VVIEW provide a sequential displaying of the three vector components for V1 or any vector stored in memory The display is used and not Alpha so level 2 is not disturbed and each component value is tagged with its own label X Y or Z These functions are also fully programmable The time lapsed in between components display is fixed but the displaying will be halted while any key is kept depressed c Angel M Martin December 2014 Page 101 of 124 SandMatrix_4 Manual Revision N New versions of the classic Advantage Programs The Vectors ROM contains new versions of the popular Vector programs from the Advantage Pac VC and TR CT Their usage is completely compatible even if they use all new functions instead of the original FOCAL programs Obvious advantages are faster execution shorter program listings and more accuracy due to the 13 digit math routines employed within the new functions Also fewer data registers are needed since level 2 is in Alpha s M N O and not in R01 R02 R03 as in the Advantage s case Vector operations The VC program simulates a Vector Calculator superimposed on your normal calcu
191. unctionallity included in the SadnMath The table below summarizes them Function Description Input Output 1 EQT Equation Display Equation number in ROO 0 1 to 15 2 POLINT Polynomial interpolation Under program control 3a PRMF Prime Factors decomposition Argument in X reg 3b PF gt X From prime factors to argument Prime factors in matrix PRMF 3c TOTNT Euler s Totient function Argument in X reg 4 POLFIT Polynomial Fitting Under program control 5 OPFIT Orthogonal Polynomial Fit Under program Control 6a POLZER From Poles to Zeroes Under program control 6b PFE Partial Fractions Expansion Under program control 4 4 1 Displaying the Equations for Curve Fitting Programs EQT As there was plenty of available space in the module I decided to include this routine to complement the Curve Fitting program in the SandMath CURVE The routine EQT will write in Alpha the actual equation which reference number is in register ROO ranging from 0 to 15 as per the table below 0 Linear wLeOLBL ER JAILBL A2 1 Reciprocal 62 XE IND A 31 atbL Wx 2 Hyperbola A3 AYIER 32 RTH 3 Reciprocal Hyperbola R4 RIR I3JeLeL 69 ar a5 GTO Eg 34 abbke c k 5 Modified Power G5 LBL ae 35 RTH 6 Root 6 atbs 36eLBL 1A 7 Exponential va Db FE ratCbzKhete Kt2 8 Logarithmic leap M i 38 RTH 9 Linear Hyperbolic oF ae satona ges Aa A 10 2 Order Hype
192. us an easy driver for M M MFIND will search a given matrix looking for an element that equals the value in the X register If it is found it returns its location pointer to the X reg and leaves the pointer set to it If it s not found it returns 1 to X and the pointer is outside the matrix You can further use this result adding the conditional test function X gt 0 available in the SandMath right after MFIND which in a program will skip a line if the element wasn t found Below are the program listings for your perusal 1 LBL MFIND MNAME in Alpha 1 LBL MATP 2 0 2 DIM1 M1 dimension 3 MSUA sets pointer to 1 1 3 PROMPT prompt for it 4 LBL 05 4 M1 matrix name M1 5 RDN target value to X reg 5 MATDIM create matrix in X mem r 6 MR recall element 6 PMTM input elements r 7 X Y equal 7 DIM2 M2 dimension d 8 GTO 02 yes exit 8 PROMPT prompt for it r 9 J no increase column 9 M2 matrix name M2 r 10 FC 10 end of matrix 10 MATDIM create matrix in X mem r 11 GTO 05 no next element 11 PMTM input elements r 12 RDN target value to X reg 12 DIM r 13 CLX 13 FRC of columns for M2 r 14 M1 r put 1 inX 15 DIM exit 16 INT of rows for M1 17 cresult matrix dimension 18 ae matrix name M 19 MATDIM create matrix in X mem 20 M1 M2 prepare Alpha string 21 2 22 END done 22 AROT 23 M M matrix product 24 ASHF remove acratch 25 OMR output values 26 END done N
193. vector is stored in R03 R04 R05 which is vector storage register 1 The origin of the new system is stored in R06 R07 R08 which is vector storage register 2 The rotation angle is stored in R13 while R09 R10 and R11 are used for scratch If you will be using vector storage operations VSTO VRCL and the Vector Calculator along with TR keep in mind that TR uses RO R13 when it is initialized XEQ TR This means you should not store vectors in vector registers 1 through 4 if you plan to use TR in your vector calculations Flags Flag 01 is used to indicate whether the transformation is to be made to the new system or to the original system When flag 1 is set the transformation is to the new system Flag 05 is set when the system is rotated Example 1 The coordinate systems x y and x y are shown below Convert the points Pi P2 and P3 to equivalent coordinates in the x y system Convert the point P 4 to equivalent coordinates in the x y system 4 S P 9 7 Pa 6 8 y x EE 2 27 7 4 p Pi 2 7 3 6 c Angel M Martin December 2014 Page 112 of 124 SandMatrix_4 Manual Revision N Keystrokes Display Action FIX 4 sets the display format used here XEQ TR 0 ENTER 4 CHS ENTER 7 R S 27 R S R S 2 dimensional 0 ENTER 7 ENTER 9 CHS Z0 Y0 X0 7 0000 ROT lt cba r AN O NEW 9
194. we left all those behind What isn t included When compared to the original Advantage Pac the following functionality areas are not included in the SandMatrix but in other dedicated modules and in a superior implementation if I may add as shown in the table below Section In Module Also Available in Comments Digital Functions Digit Pac HP IL Development Includes 16C Emulator Solve amp Integrate SandMath 3x3 Solve amp Integrate ROM Fully embedded Curve Fitting SandMath 3x3 AECROM Fully embedded Complex Operations HP 41Z Dedicated 8k ROM Vectors Coordinates Now also included Vector Calculator ROM Dedicated 4k ROM Differential Equations Diffeq ROM Math Pac Dedicated 8k ROM Time Value of Money Financial Pacs HP 12C don t care that much Note Make sure that revision N or higher of the Library 4 module is installed c Angel M Martin December 2014 Page 8 of 124 O ON DN AUNE SandMatrix_4 Manual Revision N Function index at a glance And without further ado here s the list of functions included in the module SNDMTRX 4 Section Header none Displays Order ngel Martin ML Matrix Function Launcher Prompts for function Executes Function Angel Martin DST Distance Functions Launcher Prompts PP PL LL PPL Executes function Angel Martin xV Vector Function Launcher Pr
195. x function becomes the current matrix following that operation To find out the name of the current matrix execute MNAME Its name is returned into the Alpha register overwriting its previous contents Default Matrix Parameters If you don t specify any or all the matrices that a matrix function needs then certain default parameters exist Default parameters are those automatically assumed if you don t specify them The most common default you will probably use is the current matrix If you don t specify a particular matrix name and the Alpha register is clear then the default matrix is the current one For matrix operations requiring up to three matrix names in the Alpha register the following table gives the conventions to interpret the parameters Alpha Register s Contents Matrices Specified A B C A B C A B A B B A A A A A B A A B A B current A B 7A current A A nA current current A X A B X reg A B X A X reg A A A X A X reg A A X A A A ignores X X X reg current current blank current current current c ngel M Martin December 2014 Page 23 of 124 SandMatrix_4 Manual Revision N 2 2 2 Storing and Recalling individual Matrix elements The matrix editor provides a method of storing and reviewing matrix elements For programming you can use the following functions to manipulate individual matrix elements A specific elemen
196. xi You start the program XEQ POLINT and enter x at the prompt x R S Then you enter the first data pair x0 R S preferably one which has an x_i close to x y0 R S The program returns y0 You enter another data pair R S The program returns the results of a linear x1 R S interpolation yi R S You enter another data pair R S The program returns the results of a x2 R S quadratic interpolation y2 R S You enter another data pair R S The program returns the results of a cubic x3 R S interpolation y3 R S and so on until you exceed the SIZE of your calculator Going beyond the cubic interpolation is seldomly useful High order interpolations become increasingly sensitive to round off errors and inaccuracies of the input data The number of data registers used depends on the order of the interpolation An nth order interpolation which uses n 1 pairs of data occupies the registers ROO to R 2n 4 e g a cubic interpolation needs all registers up to R10 If a printer is connected the interpolation results are printed out and the empty R S entries are not required Example Given the table below with a set of vapor pressure data for superheated water what is the vapor pressure at 200 C 473 15 K T K 380 400 450 480 500 530 560 p MPa 0 12885 0 24577 0 93220 1 7905 2 6392 4 4569 7 1062 Here s the sequence followed to resolve it c ngel M M
197. z 16 q7 64 0 is solved by CROOT and if we call Zi z2 and z the 3 roots of this equation the zeros of E are x 4 sign q z2 23 A re sign q z _ z Note that QUART uses ROO to R04 for scratch therefore those registers cannot hold the polynomial The data output is done automatically by the program presenting the roots as either real or complex conjugated This is done using the status of flags 01 and 02 as appropriate but the user needs not to concern him or herself with the decoding rules The output uses function ZOUT from the SandMath which uses J to denote the imaginary unit i Examplei Solve x 2 x 35 x 36 x 180 0 2 ENTER 35 ENTER 36 ENTER 180 XEQ QUART gt gt gt gt X1 6 000 X2 3 000 X3 2 000 X4 5 000 c Angel M Martin December 2014 Page 79 of 124 SandMatrix_4 Manual Revision N Example2 Solve x 5 x 11 x 189 x 522 0 5 ENTER 11 ENTER 189 ENTER 522 XEQ QUART gt gt gt gt Z 2 J5 000 note how true integer values don t display zeros after the decimal point X3 3 000 X4 6 000 Example3 Solve x 8 x 26 x7 168 x 1305 0 8 ENTER 26 ENTER 168 ENTER 1305 XEQ QUART gt gt gt gt Z 2 J5 000 note how true integer values don t display zeros after the decimal point Z 6 J3 000 Example 4 Calculate the roots of the polynomial Q x x44 2 x43

Download Pdf Manuals

image

Related Search

Related Contents

CGS 6.3.0 Release Notes  意味の似た言葉を調べる(ロジェシソーラス)  Télécharger - Gilles Berhault  Mellanox OFED Linux User`s Manual  AP6  取扱説明書(耳あな型補聴器イヤメイトAK-05)    English Instructions on how to set up QQ2 Plus  Edital do Concurso 28 04 2014  Evaluation Kit for Power Line Communication User's Manual  

Copyright © All rights reserved.
Failed to retrieve file