Post Reply 
41CL Quiz: Determinant of 30x30 anti-Identity matrix
05-11-2018, 09:10 AM (This post was last modified: 05-11-2018 09:11 AM by Ángel Martin.)
Post: #1
41CL Quiz: Determinant of 30x30 anti-Identity matrix
This quiz is just for you, proud owners of a 41CL: -

Calculate the determinant of a 30x30 matrix with all elements equal to "1" except the diagonal, which has all zeros. I call this type "anti-Identity", but it's totally made up for you purists out there so don't nail me down just yet.

The exact result is Det = -29

My solution returns -28.999999977 in 11 minutes, give or take...

Hint: check in the CL Library for a suitable aid...

Cheers,
ÁM
Find all posts by this user
Quote this message in a reply
05-11-2018, 06:06 PM
Post: #2
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-11-2018 09:10 AM)Ángel Martin Wrote:  This quiz is just for you, proud owners of a 41CL: -

Sorry, Ángel, you know I couldn't resist ...

Quote:Calculate the determinant of a 30x30 matrix with all elements equal to "1" except the diagonal, which has all zeros. I call this type "anti-Identity", but it's totally made up for you purists out there so don't nail me down just yet.

The exact result is Det = -29

My solution returns -28.999999977 in 11 minutes, give or take...

I know, I know, this is just for the 41CL but nevertheless here's the result for the HP-71B under J-F Garnier's Emu71. From the command line:

>DESTROY ALL @ OPTION BASE 1 @ DIM A(30,30),C(30,30)
>MAT A=CON @ MAT C=IDN @ MAT A=A-C @ DET(A)

      -29.0000000001

The timing is 0.15 seconds, give or take a hundredth ...

Have a nice weekend and best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
05-11-2018, 07:34 PM (This post was last modified: 05-11-2018 07:39 PM by Ángel Martin.)
Post: #3
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-11-2018 06:06 PM)Valentin Albillo Wrote:  
(05-11-2018 09:10 AM)Ángel Martin Wrote:  This quiz is just for you, proud owners of a 41CL: -

Sorry, Ángel, you know I couldn't resist ...

Quote:Calculate the determinant of a 30x30 matrix with all elements equal to "1" except the diagonal, which has all zeros. I call this type "anti-Identity", but it's totally made up for you purists out there so don't nail me down just yet.

The exact result is Det = -29

My solution returns -28.999999977 in 11 minutes, give or take...

I know, I know, this is just for the 41CL but nevertheless here's the result for the HP-71B under J-F Garnier's Emu71. From the command line:

>DESTROY ALL @ OPTION BASE 1 @ DIM A(30,30),C(30,30)
>MAT A=CON @ MAT C=IDN @ MAT A=A-C @ DET(A)

      -29.0000000001

The timing is 0.15 seconds, give or take a hundredth ...

Have a nice weekend and best regards.
V.

Not a problem Valentín - I'm very glad you chimed in.
Ah the beauty of Saturn MCODE, I'm sooo jealous of such sheer power ;-)

The original goal of this exercise was to show that it's possible to deal with 900 element matrices using the expanded registers on the CL board. Obviously the bottleneck here is the FOCAL program that calculates the determinant. I'm toying with the idea of modifying the MCODE-based functions in the Advantage to also support the Y-registers, but it's a tall order...

Saludos y buen finde.
ÁM.

PS. I'm curious to know: does EMU-71 run faster than the real machine (being a PC application), or it also emulates the Saturn CPU speed?
Find all posts by this user
Quote this message in a reply
05-11-2018, 07:48 PM (This post was last modified: 05-11-2018 07:49 PM by John Keith.)
Post: #4
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
OK, more cheating. HP 50g, exact mode:

Code:

\<< { 30 30 } 1 CON 30 IDN - DET \>>

Result: 29
Physical calculator: 61 seconds.
Emulator: 2.17 seconds.

I'm sure the Prime would be much faster but I don't have mine handy.

John
Find all posts by this user
Quote this message in a reply
05-11-2018, 08:04 PM
Post: #5
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-11-2018 07:34 PM)Ángel Martin Wrote:  PS. I'm curious to know: does EMU-71 run faster than the real machine (being a PC application), or it also emulates the Saturn CPU speed?

No, it runs much faster, some 200x-240x faster on the 18-yo 32-bit single-core XP box I use to run it.

Frankly, I don't see the point of emulating the original speed, as it's the case with the old version of the Nonpareil emulator I have, which does just that and so sees very little use.

Buen finde y saludos.
V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
05-11-2018, 08:41 PM
Post: #6
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-11-2018 07:34 PM)Ángel Martin Wrote:  The original goal of this exercise was to show that it's possible to deal with 900 element matrices using the expanded registers on the CL board. Obviously the bottleneck here is the FOCAL program that calculates the determinant. I'm toying with the idea of modifying the MCODE-based functions in the Advantage to also support the Y-registers, but it's a tall order...

Saludos y buen finde.
ÁM.


Gene: My mind went to the Y-registers applications rom right away (rom ID 21). The PPC matrix functions and the JMB are in there in FOCAL. Will love to see what the YRRM program does at 50X on this. MUCH slower than Valentin's solution though. :-)
Find all posts by this user
Quote this message in a reply
05-12-2018, 02:50 AM (This post was last modified: 05-12-2018 03:01 AM by Joe Horn.)
Post: #7
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-11-2018 07:48 PM)John Keith Wrote:  OK, more cheating. HP 50g, exact mode:

Code:
\<< { 30 30 } 1 CON 30 IDN - DET \>>

Result: 29
Physical calculator: 61 seconds.
Emulator: 2.17 seconds.

I'm sure the Prime would be much faster but I don't have mine handy.

Prime in CAS view: det(makemat(1,30,30)-IDENMAT(30))
Result: -29
Physical calculator (HW rev C): 0.041 seconds
Emulator: around 0.00224 seconds

EDIT: The 50g's approx mode is much faster than exact mode in this case. If the input is a matrix of reals (TYPE 3) instead of a symbolic array of integers (TYPE 29), DET returns -29.0000000000 in 14.17 seconds.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
05-12-2018, 05:21 AM (This post was last modified: 05-12-2018 08:56 AM by Ángel Martin.)
Post: #8
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
First, thanks John, Joe & Valentín for your inputs - cheating perhaps, but definitely worth it ;-) Obviously there's no color in comparing a PC emulator speed with a real machine - but I agree the emulators that mimic the real speed fall short of delivering what they should...

Now let's come back to the snail-world for a while, should we.

(05-11-2018 08:41 PM)Gene Wrote:  Gene: My mind went to the Y-registers applications rom right away (rom ID 21). The PPC matrix functions and the JMB are in there in FOCAL. Will love to see what the YRRM program does at 50X on this. MUCH slower than Valentin's solution though. :-)

And your mind is going to the right place - I guessed you'd make the connection, eagle-eyed as you are ;-)

Here's the detailed description of the solution.

1. We need the CL-Expanded Memory and the Y-REGS Apps ROMS plugged in the CL. Their mnemonics are XPMM and YRGA, just use the function PLUG to configure the MMU. Each of these two is a 4k ROM, thus two pages will be used.

2. Unless you feel like entering the 900 elements by hand (ouch!), we also need a short data entry routine to build the test matrix. The code snippets below take care of it, and I've also thrown in another short one to create an identity matrix (the opposite to our test case, i.e. an Anti-AntiIdentity ;=O

The two routines we'll use are YONE - to create a matrix with all ones, and YZDG, to Zero the diagonal elements of a matrix. They can be chained so just press R/S after YONE to complete the task - or use them individually if you prefer).

3. With the routines loaded in RAM we can execute the order:

Remembering that the matrix control words are of the form bbb.eeerr, we type:

1.90030, XEQ "YONE", R/S, CF 00, 30, XROM "YDET" => -28.999999977

That's all there's to it - at least the command line here is comparable in size with those in the ultra-powerful universes shown by Valentín, John and Joe,

I'd love to hear other options you have in mind - specially faster ones - perhaps using other DETerminant programs as I hinted at in a previous post.

Code:
1    LBL "YONE"
2    ENTER^
3    FIX 3
4    RND
5    E
6    XEQ 00
7    RTN
8    RCL Z
9    LBL "YZDG"
10    E-5
11    +
12    0
13    LBL 00
14    YSTO IND Y(3)
15    ISG Y(3)
16    GTO 00
17    END

Code:
1    LBL "YIDN"
2    ENTER^
3    FIX 3
4    RND
5    CLYRGX
6    X<>Y
7    E-5
8    +
9    E
10    LBL 02
11    YSTO IND Y(3)
12    ISG Y(3)
13    GTO 02

Best,
ÁM
Find all posts by this user
Quote this message in a reply
05-17-2018, 09:58 AM
Post: #9
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
Disclaimer: please take this with the humour it's meant to be. I mean no meanness.

Just to rub salt in the wounds of all the HP owners (except perhaps for the Prime users), my 9750gII took 22 seconds to calculate the determinant of the anti-identity matrix. Mind you, it took me nearly twelve minutes to input the silly thing because I can't automatically generate an anti-identity matrix. But I thought that was pretty good calculation speed. Smile

Now back to the subject at hand... It's interesting to see the little secrets hidden away in the bowels of HP's ROM files, especially ones that had their foundations way back in the late seventies. I wonder where—and when—the functions from my calculator originated from?

(Post 221)

Regards, BrickViking
HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a)
Visit this user's website Find all posts by this user
Quote this message in a reply
05-17-2018, 01:55 PM (This post was last modified: 05-17-2018 01:59 PM by Claudio L..)
Post: #10
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-11-2018 07:48 PM)John Keith Wrote:  HP 50g, exact mode:
Physical calculator: 61 seconds.

(05-12-2018 02:50 AM)Joe Horn Wrote:  Prime in CAS view: det(makemat(1,30,30)-IDENMAT(30))
Result: -29
Physical calculator (HW rev C): 0.041 seconds

...50g's approx mode ... -29.0000000000 in 14.17 seconds.

The 50g can do slightly better...
newRPL with numbers in the matrix: 0.426 sec (result = -29 exact if matrix elements were exact)
newRPL with symbolic numbers: 2.589 sec (more comparable to using the CAS mode in the Prime, result = '-29' symbolic)
So the Prime CAS is roughly 30 times more efficient than newRPL at working with symbolic expressions... there's a lot of work for me to do in that department.

EDIT:
P.S.: Sorry for polluting this thread, it felt like a continuation of the other anti-identity thread.
Find all posts by this user
Quote this message in a reply
05-17-2018, 04:55 PM
Post: #11
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
Just curious, why you can't automatically generate an anti-identity matrix?
I created the anti-identity matrix by using small program.
casio fx-9860g slim: -29 in 29 seconds
casio fx-cg50: -29 in 6.5-7 seconds
Find all posts by this user
Quote this message in a reply
05-17-2018, 10:36 PM (This post was last modified: 05-17-2018 11:21 PM by brickviking.)
Post: #12
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-17-2018 04:55 PM)klesl Wrote:  Just curious, why you can't automatically generate an anti-identity matrix?
I created the anti-identity matrix by using small program.
casio fx-9860g slim: -29 in 29 seconds
casio fx-cg50: -29 in 6.5-7 seconds

Could you post that 9860 program here, or perhaps in "Not Remotely HP" sub-forum? I might keep an eye out for it, as it took me nearly 12 minutes to enter it by hand. I've done filling lists automatically, but not matrices. Annoyingly, my 9750g+ can't work with a matrix that large. It can create the initial matrix, but there's not enough memory left over to work with it unless I removed the other programs I've got installed.

9750gII: -29 in 20.5 seconds (without any speedups), 4 seconds (sped up to max)

(Post 222 (111x2, (55+55+1)*2, ...)

Regards, BrickViking
HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a)
Visit this user's website Find all posts by this user
Quote this message in a reply
05-18-2018, 03:47 AM
Post: #13
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-11-2018 07:48 PM)John Keith Wrote:  OK, more cheating. HP 50g, exact mode:

Code:

\<< { 30 30 } 1 CON 30 IDN - DET \>>

Result: 29
Physical calculator: 61 seconds.
Emulator: 2.17 seconds.

Even more cheating. HP 50g, approximate mode;

30 « 1. - -1. OVER ^ * » EVAL

Result: 29
Physical HP 50g: 0.015 seconds, give or take... :-)
Find all posts by this user
Quote this message in a reply
05-18-2018, 05:50 AM
Post: #14
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-17-2018 01:55 PM)Claudio L. Wrote:  The 50g can do slightly better...
newRPL with numbers in the matrix: 0.426 sec (result = -29 exact if matrix elements were exact)
newRPL with symbolic numbers: 2.589 sec (more comparable to using the CAS mode in the Prime, result = '-29' symbolic)
So the Prime CAS is roughly 30 times more efficient than newRPL at working with symbolic expressions... there's a lot of work for me to do in that department.

newRPL is impressive! I appreciate its creation Claudio.
Find all posts by this user
Quote this message in a reply
05-18-2018, 06:48 PM (This post was last modified: 05-18-2018 06:50 PM by hibiki.)
Post: #15
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
I see that the solution is 29 or -29 depending on whether the diagonal of 0's is descending from left to right or ascending. But my curiosity is why a simple sum or subtraction of a string of 1's (integers) multiplied 29 times and accumulated 29 times resulted in a non integer number in some responses.

My calcs: HP12C, HP15C, HP17BII+, HP20S, HP20B, HP32SII, HP34C, HP35S, HP42S, HP48GX.
Find all posts by this user
Quote this message in a reply
05-18-2018, 09:13 PM (This post was last modified: 05-18-2018 09:14 PM by Valentin Albillo.)
Post: #16
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-18-2018 06:48 PM)hibiki Wrote:  Iut my curiosity is why a simple sum or subtraction of a string of 1's (integers) multiplied 29 times and accumulated 29 times resulted in a non integer number in some responses.

The exact determinant of an all-integer matrix is always an integer, mathematically, but the algorithms used by many non-CAS models involve divisions by pivot elements and this may introduce non-exactness in the final result.

V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
05-18-2018, 09:39 PM
Post: #17
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
A test of accuracy could be to see for machines that can do this calculation...

What size matrix is the level at which the answer is a non-integer for the first time. Then ... what caused it to be a non-integer?
Find all posts by this user
Quote this message in a reply
05-18-2018, 10:58 PM
Post: #18
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-18-2018 09:39 PM)Gene Wrote:  A test of accuracy could be to see for machines that can do this calculation...

What size matrix is the level at which the answer is a non-integer for the first time. Then ... what caused it to be a non-integer?

It's not only a function of matrix size but also of its elements, you can get a non-integer determinant even for some 2x2 specific matrix. And I already said in the previous post what causes it: division by some pivot(s) which result in non-exact quotients.

Regards and have a nice weekend.
V.
.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
05-18-2018, 11:02 PM
Post: #19
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
Matrix maths is a bit beyond me, at least until I delve back into the basic concepts again. The last time I dealt with matrices was way way back in my secondary school years back in the early eighties. So terms like determinant and identity are rather lost on me, though I now know what an identity matrix is. No doubt I'll have to go look up simple references for the rest of the material.

[Post 224]

Regards, BrickViking
HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a)
Visit this user's website Find all posts by this user
Quote this message in a reply
05-19-2018, 12:33 AM
Post: #20
RE: 41CL Quiz: Determinant of 30x30 anti-Identity matrix
(05-18-2018 10:58 PM)Valentin Albillo Wrote:  
(05-18-2018 09:39 PM)Gene Wrote:  A test of accuracy could be to see for machines that can do this calculation...

What size matrix is the level at which the answer is a non-integer for the first time. Then ... what caused it to be a non-integer?

It's not only a function of matrix size but also of its elements, you can get a non-integer determinant even for some 2x2 specific matrix. And I already said in the previous post what causes it: division by some pivot(s) which result in non-exact quotients.

Regards and have a nice weekend.
V.
.

Thanks Valentin.

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. Can we really have a pivot that isn't a 0 or 1 in this case?

Apparently! :-)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)