41CL Quiz: Determinant of 30x30 antiIdentity matrix

05192018, 04:50 AM
Post: #21




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05192018 12:33 AM)Gene Wrote: I should have said for these matrices as specified here. Some with only the 0 and 1 elements which **ought** to be an integer answer are getting round off with 0 and 1's. But of course. For the "antiidentity" matrices, the first that gives a noninteger determinant is the 5x5 case (12digit HP71B/Math ROM, 15digit internally.) Using a short routine I wrote, for general (0,1) square matrices I've readily found 5x5 and 4x4 cases with noninteger determinants, some of them quite peculiar. Ditto for (1,3) 2x2 matrices, and so on and so forth ... Regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection 

05192018, 05:14 AM
(This post was last modified: 05202018 05:47 AM by Ángel Martin.)
Post: #22




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
Glad to see this thread growing a life of its own... FWIW I'm kneedeep wading in the Advantage/CCD MCODE investigating a way to adapt the Matrices/MSYS/DET code to use the CL Yregisters instead... conceptually quite simple but the code structures make it rather tricky. Stay tuned.


05192018, 11:53 PM
Post: #23




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
.
Selfquote to add numerical examples to what I said in my previous post: (05192018 04:50 AM)Valentin Albillo Wrote: For the "antiidentity" matrices, the first that gives a noninteger determinant is the 5x5 case (12digit HP71B/Math ROM, 15digit internally.) Antiidentity: >MAT DISP A; 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 >DET(A) 3.99999999999 Up to 30x30, the maximum error is found for the 10x10 case: Det = 9.00000000003 Quote:I've readily found 5x5 and 4x4 cases with noninteger determinants, some of them quite peculiar. 5x5 case: >MAT DISP A; 1 0 1 1 1 1 1 0 1 0 0 1 0 1 1 1 1 1 0 1 0 1 1 1 0 >DET(A) 5.00000000001 4x4 case: This one is most peculiar: >MAT DISP A; 0 0 0 1 0 0 1 0 1 1 1 1 1 1 1 0 >DET(A) 1.E24 (!!) 3x3 case: >MAT DISP A; 1 1 1 0 0 1 1 1 0 >DET(A) .000000000001 2x2 case: (13 elements) >MAT DISP A; 1 2 3 1 >DET(A) 5.00000000001 And this deserves a full facepalm or two: >MAT DISP A; 3 1 3 1 >DET(A) .000000000003 Of course the exact determinant is 0 because both rows are identical. The fact that it does not detect it but instead goes on a spree using a fulldrawn algorithm with pivot(s) and such for so ultrasimple a case it truly astounding. Best regards and have a nice weekend. V. . All My Articles & other Materials here: Valentin Albillo's HP Collection 

05202018, 12:06 AM
Post: #24




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
Thank you, Valentin. Food for me to chew on.
Ever trying to learn. 

05202018, 09:21 AM
Post: #25




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05192018 11:53 PM)Valentin Albillo Wrote: >MAT DISP A; The venerable 42S solves 2x2 cases separately, and so does not fall into this trap. (but Free42 does ;)) That, however, does not solve the problem as the equivalent 3 1 0 3 1 0 0 0 1 yields the determinant 3.e12 as well. Not much to be done about that, save for the 48G's (and successor's) approach to return an integer determinant for a matrix with integer coefficients (it's actually even better than that but that would require a longer explanation ;) Cheers, Werner 

05202018, 03:09 PM
Post: #26




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
.
Hi, Werner: (05202018 09:21 AM)Werner Wrote: The venerable 42S solves 2x2 cases separately, and so does not fall into this trap. (but Free42 does ;)) That, however, does not solve the problem as the equivalent I think that something very simple could and should have been done, namely to use the expanded formula for 2x2 and 3x3 cases, which entails very, very few multiplications and additions and no divisions whatsoever. This would be both faster and exact as compared to using the general reduction algorithm on such simple cases. HP did whatever needed to be done to ensure that 2^3 gives exactly 8 but didn't care that det(3,1,3,1) isn't 0 as it should. Quote:(it's actually even better than that but that would require a longer explanation ;) As we say here, "prisa no tenemos y tarde no es", i.e. "It's not too late and we're not in a hurry" so go ahead with that longer explanation, please, I'm all ears ... :D Regards. V. . All My Articles & other Materials here: Valentin Albillo's HP Collection 

05202018, 03:39 PM
Post: #27




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05202018 09:21 AM)Werner Wrote: ... For me, this clearly illustrates the move from a calculatorforenginners to a calculatorforstudents (math oriented). For an engineer, it doesn't matter so much that the determinant is exactly 0 or some 1e12. Moreover, engineers usually deal with real, floating point numbers, rarely with pure integers. JF 

05212018, 09:37 AM
Post: #28




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
To illustrate what the 48G (and successors) do to calculate the determinant, take
the Hilbert matrix of order 5, multiplied by 2520 to make all elements integers. [[ 2520 1260 840 630 504 ] [ 1260 840 630 504 420 ] [ 840 630 504 420 360 ] [ 630 504 420 360 315 ] [ 504 420 360 315 280 ]] The adjustment of the determinant is controlled by flag 54, Tiny element. When that flag is clear, the determinant is adjusted, when set it is not. So, with the above matrix on the stack, DET will show 381024.000008 54 Set 381024 54 Clear Now divide the matrix by 10, introducing a few fractional numbers. The result is 3.81024000008 54 Set 3.81024 54 Clear Divide it by 10^10 again (so the original matrix is divided by 10^11) 3.81024000008e50 54 Set 3.81024e50 54 Clear It is clear that the algorithm does not just check for integers. What it does is it determines the scaling factor to guarantee that the least significant digit of the computed determinant, divided by this scaling factor, has a nonnegative exponent, and therefore the ratio can be rounded to integer to possibly achieve greater accuracy. (These are not my words, but Paul McClellan's ;) This scaling factor is 10^(N*s), where s is the exponent of the least significant digit of all elements of the NxN matrix. Some provisions are being made:  flag 54 set, then the scaling factor is set to 0, meaning no rounding is to be performed  When all elements of the matrix are zero, the scaling factor is set to 1  for n>79, the scaling factor is set to zero as even in extended precision we risk overflow Cheers, Werner 

05212018, 09:41 AM
Post: #29




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05202018 03:39 PM)JF Garnier Wrote: For me, this clearly illustrates the move from a calculatorforenginners to a calculatorforstudents (math oriented). I've always wondered if the algorithm as I described above could deliver a wrongly rounded result, in which case I would have to agree with you. Otherwise, all it does is delivering a more accurate result, and I have no problem whatsoever with that. For those who do, just set Flag 54. Cheers, Werner 

05222018, 07:46 AM
Post: #30




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
Thanks for your detailed explanations about the determinant adjustment on the 48G series.
So I changed my mind, I recognize that it is not just a trick to artificially round the determinant results in integer matrix problems, but is generally an improvement of the accuracy, in a way similar to the much older 2^3 accuracy fix mentioned by Valentin. You quoted Paul McClellan, do you have any references to articles or forum posts where he may have described more on the subject? Quote:I've always wondered if the algorithm as I described above could deliver a wrongly rounded result, in which case I would have to agree with you. Yes, and the fact that the adjustment can be disabled with flag 54 may suggest that, in some situations, it may be better not to adjust the determinant. JF 

05222018, 08:50 AM
Post: #31




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05202018 03:39 PM)JF Garnier Wrote: For an engineer, it doesn't matter so much that the determinant is exactly 0 or some 1e12. Moreover, engineers usually deal with real, floating point numbers, rarely with pure integers. Good point. If we can get to the moon using slide rules with about three significant figures, twelve sig figs should be enough to do just about anything! Tom L Cui bono? 

05222018, 11:17 PM
Post: #32




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
I suppose just returning the determinant of the antiidentity matrix "by inspection" would be considered cheating? E.g the determinant of the NxN antiidentity matrix is N1 for odd N, or 1N for even N.


05222018, 11:40 PM
Post: #33




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05222018 11:17 PM)ijabbott Wrote: I suppose just returning the determinant of the antiidentity matrix "by inspection" would be considered cheating? E.g the determinant of the NxN antiidentity matrix is N1 for odd N, or 1N for even N. I would not consider that cheating, although I suggested so in post #13. BTW, there is a typo there: the RPL program returns 29, not 29 (I expected someone would notice it, but apparently no one did). 

05232018, 01:30 AM
(This post was last modified: 05232018 10:09 AM by brickviking.)
Post: #34




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05222018 11:40 PM)Gerson W. Barbosa Wrote:(05222018 11:17 PM)ijabbott Wrote: I suppose just returning the determinant of the antiidentity matrix "by inspection" would be considered cheating? E.g the determinant of the NxN antiidentity matrix is N1 for odd N, or 1N for even N. I noticed it (the typo), but failed to notify anyone else of this fact. And I did note the values swapping signs on increment. I thought that was a bit peculiar, but given I know nothing much about matrix operations, I chalked it up to my inexperience. And it seems that x49gp is faster than the real 50g by quite some margin, indicating about 3.1 seconds to cough up a 29 instead of the 16.5ish seconds I'd been seeing. Clockspeed seems to affect this time on the 50g, but not by as much as I'd hoped. I can't raise the clockspeed past 101 MHz before the calculator starts either behaving erratically, or just plain locking up. (Post 231) Regards, BrickViking HP50g Casio fx9750G+ Casio fx9750GII (SH4a) 

05232018, 02:29 AM
Post: #35




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05232018 01:30 AM)brickviking Wrote:(05222018 11:40 PM)Gerson W. Barbosa Wrote: BTW, there is a typo there: the RPL program returns 29, not 29 (I expected someone would notice it, but apparently no one did). I meant noticing the typo. Yes, that property allows for a fast and compact program when the only goal is finding the determinant. 

05232018, 11:31 AM
(This post was last modified: 05232018 11:33 AM by Ángel Martin.)
Post: #36




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05192018 05:14 AM)Ángel Martin Wrote: Glad to see this thread growing a life of its own... FWIW I'm kneedeep wading in the Advantage/CCD MCODE investigating a way to adapt the Matrices/MSYS/DET code to use the CL Yregisters instead... conceptually quite simple but the code structures make it rather tricky. Stay tuned. Not easy but after a couple of days reverseengineering the original (and largely convoluted!) MCODE progress has been made: behold the YAdvantage Module, which uses the CL Yregisters in full functionality. Just use the control character "Y" (instead of the original "R") and the matrix will be created/used from the Expanded registers area, from YR000 to YR1023. Testing is holding up well so far, including the major operations (MDET, MINV, MSYS). The "Y" control character replaces the same code used before with "R". I don;t know if both can be enabled simultaneously, so further investigation is in order. To be continued. 

05232018, 06:00 PM
Post: #37




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
This thread took an interesting turn.
For those interested, here's a couple of links that were very useful to me: FractionFree Methods for Determinants And (more advanced), very similar concepts but applied to factorization methods: RoundoffErrorFree Algorithm for Solving linear systems... In both cases the full text is available for free to download, just point and click. 

05232018, 06:52 PM
Post: #38




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
Thanks for sharing!
Wikis are great, Contribute :) 

05312018, 07:40 AM
(This post was last modified: 05312018 07:46 AM by Ángel Martin.)
Post: #39




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05232018 11:31 AM)Ángel Martin Wrote: .... To be continued. The YAdvantage module is finally ready for beta testing. I'll spare you the details but it's been tricky to modify the original code in all needed points to take advantage of the CL YRegisters, but I *believe* I figured them all out... BTW the benchmark with the 30x30 antiidentity matrix is now 16 seconds to calculate its determinant  down from the 11 minutes using the FOCAL program. And the result is 29.000000000 exact to 9 decimal places. Not bad! ;) 

05312018, 12:55 PM
Post: #40




RE: 41CL Quiz: Determinant of 30x30 antiIdentity matrix
(05312018 07:40 AM)Ángel Martin Wrote:(05232018 11:31 AM)Ángel Martin Wrote: .... To be continued. Amazing results Angel! It's truly impressive what you are able to accomplish once you put your mind to it. Well done! Which manual provides the best description of using the YRegisters? Bob Prosperi 

« Next Oldest  Next Newest »

User(s) browsing this thread: