![]() |
More "Matrix Results on HP and TI Machines" - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: More "Matrix Results on HP and TI Machines" (/thread-72366.html) |
More "Matrix Results on HP and TI Machines" - Valentin Albillo - 04-26-2005 Hi, all: The original thread was already quite deep and I want you to consider this. In a nutshell, Palmer O. Hanson, Jr. was using the Nth-order Hilbert matrix to test the respective accuracies of assorted brands and models of calculators and computers, by computing its determinant for orders 7 to 10, and then analyzing the results and drawing bold conclusions from them. And then, after you posted a number of results and conclusions, Rodger Rosenbaum posted this:
"The calculator couldn't get that result even if it and I absolutely agree with him because he's absolutely correct: you're *not* computing the determinant of a Hilbert matrix to begin with, but an approximation to said matrix, because terms such as 1/3 and 1/7 are represented internally with different accuracy (i.e.: different values) in different calculators. As the *initial* matrix being used is *not* the same, and as precisely the Hilbert matrices are extremely ill-conditioned, meaning that the smallest change in the input brings out a large change in the output, it's fairly obvious that the results can't be compared because, by definition of ill-conditioned matrices and by the fact that the initial matrix is extremely ill-conditioned, you would get different results even in the very same machine and using the very same program if you were to start with terms such as 1/3 being initially stored as 0.3333333333, then as 0.333333333333. Try it. On the other hand, Palmer's original idea of using some suitably large, difficult (read "ill-conditioned") matrix is inherently a good accuracy test, as it requires so many arithmetic operations, and many of them carried near the limits of internal accuracy, where errors are usually largely amplified by the combined effects of the finite accuracy of the initial values' internal representations and the choice of basic arithmetic algorithms.
What to do ? The best of both worlds, namely:
To that effect, I propose we repeat all tests using the "Albillo's Matrix (tm)" ( :-)) that I've carefully crafted for this thread, i.e: 58 71 67 36 35 19 60which is a random 7x7 matrix (so that even the HP-15C can find its determinant, 8x8 would be too large) with quite small elements, yet suitably difficult indeed, as you'll see. Of course we could have used the Hilbert matrices, multiplying all elements by some large value in order to make sure they were integer to begin with. But as you can easily check, this results in a matrix which has both very large elements and very small ones at the same time, i.e.: very unbalanced, which is not a fair test either. On the other hand, my 7x7 "Albillo's Matrix" consist entirely of small, two-digit integer values, perfectly balanced: all the elements are of the same order of magnitude. Try it with all the machines you can. In exact arithmetic, its determinant should come out as 1. What do you get instead ? What's the relative error ? You might be surprised. Best regards from V.
Edited: 26 Apr 2005, 10:48 a.m.
Good idea, but how about ... - Gene - 04-26-2005 Crafting two or three random matrices so that we won't have one that might, through chance, work out very well for one machine or the other?
Re: More "Matrix Results on HP and TI Machines" - Arnaud Amiel - 04-26-2005 The 49 gives 1 in exact or numeric mode...
Re: More "Matrix Results on HP and TI Machines" - whuy - 04-26-2005 Hi Valentin.
Cheers, Werner
Moral Of The Story - bill platt - 04-26-2005 Subtitle: why it is so hard to find young graduates who can actually do math
More importantly if you are rusty or ignorant with matrices, then it is dangerous to start using a calculator to do them to solve problems. This is from my own experience. Regards,
Bill
I second you, Bill! Also... - Vieira, Luiz C. (Brazil) - 04-26-2005 I'd add to the following:
Quote: More importantly if you are rusty or ignorant with matrices or any mid to advanced scientific subject, mainly number-related, then it is dangerous to start using a calculator to do them to solve problems. Cheers.
Luiz (a Brazilian engineer and teacher...) Edited: 26 Apr 2005, 11:37 a.m.
There you are - Valentin Albillo - 04-26-2005 Hi, Gene: Gene posted:
"Good idea, but how about crafting two or three random matrices so that we won't have one that might, through chance, work out very well for one machine or
There you are, you may try "Albillo's Matrix 2": 86 69 53 33 18 10 87and "Albillo's Matrix 3": 60 53 61 65 50 37 64which is even *worse*. Both determinants are exactly 1. For added fun, try and compute their inverses, which also have determinants equal to 1 and integer elements. And no, I'm *not* giving the inverse matrices, see if you can compute them and to what "accuracy" (for lack of a better word ...)
Best regards from V.
Re: More "Matrix Results on HP and TI Machines" - Arnaud Amiel - 04-26-2005 Thanks for the clarification. I could not figure out why I got 1. I tried quite a few things but didn't think of this flag as its name is not very desciptive and I never had any experience playing with it until now.
Arnaud
More "Matrix Results on HP and TI Machines" - Jeff - 04-26-2005 Welp, I hate to say it, but electronic calculators are NOT machines.
Re: More "Matrix Results on HP and TI Machines" - Rodger Rosenbaum - 04-26-2005 Valentin, I notice that the number 71 appears 4 times in this first test matrix you provide, and 17 appears once. Is this an unconscious indication of your love for the HP71?
Re: More "Matrix Results on HP and TI Machines" - Valentin Albillo - 04-26-2005 Hi, Rodger:
Rodger posted: Yessss !! :-) An HP-71B with a Math ROM and plenty of RAM it's just about a dream come true for anyone who loves Numerical Analysis and wants to do complicated things fast and, above all, *easily*. Want some proof ? Just have a look at my two "HP-71B Math ROM Baker's Dozen" articles recently published in Datafile to see what you can do with this combination in at most 4 or 5 lines of extremely simple code. Next best choices would be the HP42S, the HP-41CX + Advantage ROM, and the HP-15C, as long as we stay within HP models. Otherwise, a number of SHARP models would also be eligible. P.D.: Apart from the four 71's and the one 17, you'll notice there are also three 41's, one 67, two 46's, two 45's, one 35, two 33's, two 31's, one 27, one 19, and one 10, to name a few ! Best regards from V.
Edited: 26 Apr 2005, 1:20 p.m.
Re: I second you, Bill! Also... - EL - 04-26-2005 Yes! I agree, imagine in thermodynamics, routine plug and chug...and the result is a negative Sdotgen...impossible! Yet you could get it from an equation.
EL
Re: There you are - whuy - 04-26-2005 Now tell us, Valentin, how did you create these examples? Re: There you are - Rodger Rosenbaum - 04-26-2005 Please don't tell us right away, Valentin!
And a hint for you Werner. Compute the correlation matrix for Valentin's examples and note how the row wise correlation varies as you move from row 1 to row 7.
Re: Moral Of The Story - Dave Shaffer (Arizona) - 04-26-2005 As Bill said: "This is from my own experience." Many of you have probably seen this, but just in case: How do you get good judgment? From experience.
How do you get experience? From bad judgment!
[LONG] Commented Results for HP-71B (and HP-15C) - Valentin Albillo - 04-27-2005 Hi all, These are the results you get when processing the "Albillo's Matrix 1" with an HP-71B + Math ROM and an HP-15C. As you will see, despite the "innocent", even "easy" look of the matrix (a small 7x7 matrix, with small 2-digit positive integer elements), even 15 digits of internal accuracy won't get us more than two correct digits in our results. Less internal digits, say 13, won't give even one correct digit in some computations. This is all worsened to the extreme if the results are to be used as some intermediate step in a chain calculation. You'll end up having no correct digits at all extremely soon. If you're aware that the matrix is difficult to begin with (like those nasty-looking Hilbert matrices), you may we forewarned to extensively check the accuracy of the results you get. But if you happen to inadvertently stumble upon such an "innocent" looking matrix as this one, blindly trusting your results can result in utterly catastrophic failure. You've been warned ! :-)
The results are structured like this:
Now for the commented results:
Best regards from V.
Re: [LONG] Commented Results for HP-71B (and HP-15C) - whuy - 04-27-2005 Valentin - what are the reasons that MAT SYS is more accurate than MAT INV? In-place inversion performs the same calculations, in a different order. TI CC40 basic beats the HP71B! - Gene - 04-27-2005 All I have done so far is compute the determinant of the first matrix on the TI Compact Computer 40 running the Matrices program in the math cartridge. Exact Determinant = 1 CC40 computed determinant = 1.00282671 Error of 0.2827% Wow!
Gene
Re: [LONG] Commented Results for HP-71B (and HP-15C) - Valentin Albillo - 04-27-2005 Hi, Werner:
Werner posted: I don't think so. Inverting a matrix using MAT SYS is equivalent to solving N systems of N equations with N unknowns at the same time, each system giving one column of the inverse matrix. This being so, you need extra memory (as you're solving N systems at a time, instead of one), but you only need to perform the first stage of the reduction process and you need to do it only once for all N systems. Once you've got a triangularized matrix, a simple and fast procedure of back substitution will give all columns of the inverted matrix very quickly. On the other hand, MAT INV does an in-place inversion, so it needs no extra memory, but has to do a lot more work than a simple triangularization.
Best regards from V.
Re: More "Matrix Results on HP and TI Machines" - WigglePig - 04-27-2005 Not machines? Howso? OED defines "machine" as: "A material structure designed for a specific purpose, and related uses." and/or "An apparatus constructed to perform a task or for some other purpose; also in derived senses." Or even more succinctly: "A complex device, consisting of a number of interrelated parts, each having a definite function, together applying, using, or generating mechanical or (later) electrical power to perform a certain kind of work (often specified by a preceding verbal noun)." So, I propose that a calculator be known henceforth as a "machine" if the writer so wishes. With learned regards
JasonG
Re: More "Matrix Results on HP and TI Machines" - WigglePig - 04-27-2005 And I missed this one: "Used contextually for the particular kind of machine which the speaker or writer intends, as: a sewing machine; a printing machine or mechanical printing press; a shearing-machine (Austral. and N.Z.); a typewriter; a calculating machine or computer; a slot machine; a washing machine; etc." Note the specific use of "calculating machine". :-) Tra
WigglePig, reverting to ubiquitous anonymity.
Re: [LONG] Commented Results for HP-71B (and HP-15C) - Rodger Rosenbaum - 04-27-2005 Werner, I believe I remember reading somewhere (other than the math pac user manual; maybe a PPC publication) that the SYS keyword does iterative refinement as part of the solution process.
Re: [LONG] Commented Results for HP-71B (and HP-15C) - whuy - 04-27-2005
Hi Valentin. A = LU (we'll disregard pivoting) to find the inverse, we have to find a matrix X so that LUX = I
Following the same algorithm as normal equation solving, we
LY = I - equivalent to finding INV(L). There is a way of doing that 'in-place', doing the same calculations as a 'blind' elimination step, but using your advance knowledge of where the zeroes and ones are. If you write it out for a 5x5 matrix you'll
Once Y is determined, we have to find X such that
I may not know any longer what a correlation matrix is or
So, therefore, I ask again: what does the 71-B User's Guide state as reason for the obvious increase in accuracy of SYS over INV?
Cheers, Werner
Re: [LONG] Commented Results for HP-71B (and HP-15C) - whuy - 04-27-2005 Thanks, Rodger - that's what I thought, even if the rusty memory could only come up with 'residual correction' i.o iterative refinement ;-)
Werner
Re: More "Matrix Results on HP and TI Machines" - Rodger Rosenbaum - 04-27-2005 N.B. Edited to include transpose results.
AM#1 Transpose of AM#1 The HP48G is using 15 digit arithmetic for all internal matrix calculations, and it shows.
It's interesting that the transpose gives so much better results for the less accurate machines. Edited: 27 Apr 2005, 11:18 a.m. after one or more responses were posted
The Inverse to matrix 1 from the CC40 - Gene - 04-27-2005 Here's the determinant of Valentin's matrix #1 from the TI CC40: 1.00282671 Here's the inverse, truncated to integer values.
96088630+ 319303+ -535934+ 2317100+ -11322856+ 30111202+ -96237375+
Looks like the CC40 holds up rather well! But...15 digits? - Gene - 04-27-2005 Valentin's always saying (and I thought it true too), that the HP71B carries 15 digits too.
Why would the 48g series be so much more accurate?
Re: The Inverse to matrix 1 from the CC40 - Valentin Albillo - 04-27-2005 Hi, Gene:
Thanks for your results, which are indeed impressive, by the way. Some suggestions:
Thanks and best regards from V.
Re: But...15 digits? - Arnaud Amiel - 04-27-2005 The 48 and 49 use for some algorithms some extended reals which have a 15 digits mantissa. I supose on the 71 the 15 digits are used for 12 digit mantissa, sign and exponent. Arnaud
1234 to remove if it is not true...
Re: But...15 digits? - Rodger Rosenbaum - 04-27-2005 "Valentin's always saying (and I thought it true too), that the HP71B carries 15 digits too. Why would the 48g series be so much more accurate?"
Because the HP71 and the HP48S don't maintain those 15 digits for every partial result when doing matrix computations; they sometimes round things to 12 digits before proceeding with the rest of the computation. Paul McClellan reworked the matrix math in the HP48G to use 15 digits all the way through every internal matrix function. He also added all those extra nifty matrix functions such as SVD, LU, QR, etc.
Re: The Inverse to matrix 1 from the CC40 - Rodger Rosenbaum - 04-27-2005 Valentin said: "Compute also the determinant of the computed inverse and the product (matrix)*(computed inverse) and post the determinant and the matrix obtained (no truncation, all digits) as well as the respective norms, if possible." Valentin, it occurs to me that what we should really do here is subtract the 7x7 identity matrix from the product of the computed inverse and the original matrix, and then compute a norm. That gives us the norm of the error; I think that's the measure we really want.
And, did you notice my (edited) post of 10:40 AM? I get substantially different results for the determinant of the transpose.
Re: The Inverse to matrix 1 from the CC40 - Gene - 04-27-2005 Slightly more significant digits. I'll have to work on the determinant of the inverse, etc. I'm actually NOT that familiar with the CC40 (but given its accuracy, perhaps I should get that way!)
96088630+ 319303+ -535934+ 2317100+ -11322856+ 30111202+ -96237375+ Re: The Inverse to matrix 1 from the CC40 - Valentin Albillo - 04-27-2005 Hi, Rodger: Rodger posted:
"it occurs to me that what we should really do here is subtract the 7x7 identity matrix from the product of the computed inverse and I think so as well, be my guest. And, did you notice my (edited) post of 10:40 AM? I get substantially different results for the determinant of the transpose. " I did notice your post but not the edited version. I don't know why working with the transpose instead results in much greater accuracy, but if I remember correctly, when Palmer issued more or less essentially this same topic a few months ago (must be a personal obsession of his!), he did include a particular 4x4 matrix and some results for the HP-15C. When I tried said matrix in my HP-15C I incorrectly read rows for columns in Palmer's example and did work with the transpose instead. My results were much more accurate than Palmer's, which was rather puzzling and the time, and obviously still is. If anyone can explain the situation, I for one would be very interested to know. Thanks and best regards from V.
Re: There you are - John Smitherman - 04-27-2005 Hi Valentin. Using the TI 83+ I get the following determinants:
V.M. #1: 0.999646804
John
Re: More "Matrix Results on HP and TI Machines" - John Limpert - 04-27-2005 It's still a machine. The moving parts are just smaller :-).
Re: The Inverse to matrix 1 from the CC40 - Palmer O. Hanson, Jr. - 04-27-2005 The HP-15C results for the 4x4 that Valentin mentioned were not mine since I don't have an HP-15. The results were extracted from Kahan's paper "Mathematics written in Sand". It may be an obsession. It all started two years ago when Richard Nelson and I agreed to do a history of the old contests between users of TI and HP machines. Solving matrix problems was one of the contests going all the way back to the HP-25 and the SR-52. The agreed-to problems involved inverting Hilberts and solving linear equations involving hilberts. I went over the old issues of TI PPC Notes and Richard's PPC Calculator Journal and I had some questions about the results we got way back then in the late 1970's. I tried to reproduce and to understand some of those old results, reexamined the results in Kahan's paper, and here we are.
results - Mike (Stgt) - 04-28-2005 On a HP-40G (emulated) the DET of matrix 1 and 3 are 1, alas for the inverse it is _not_.
Ciao.....Mike
Results for TI-95 PROCALC + Mathematics module - Marcus von Cube - 04-28-2005 I entered AM#1 into my TI-95 and got the following results:
det=1.000416554
So far I was unable to compute the determinant of the inverse and there may be typing errors (I copied the values manually, too lazy to connect one of my printers...)
Exact results with the HP-71B - Valentin Albillo - 04-28-2005 Hi, all: Though using DET to compute the Albillo's matrices determinants does result in quite poor results (due to their extreme ill-conditioning and inherent loss of precision caused by the many division operations the internal triangularization algorithm entails), this doesn't mean we can't obtain exact results in a 71B. In fact, we just need another approach that doesn't involve divisions at any step, and one such approach is to use the "determinant expansion by minors" technique. This algorithm is of considerable theoretical interest, and can be recursively used to compute any determinant using just multiplications and additions, never a division in sight. As such it is highly inefficient for matrices above 4x4, say, but for just the purpose of showing how you can in theory compute those difficult determinants exactly, it will do.
Thanks to the powerful HP-71B's BASIC implementation, a simple version of the expansion by minors can be coded as a recursive subprogram in just 4 lines (with arbitrary line numbers): 100 SUB XDET(A(,),D) @ DIM N,E,I,J,K @ N=UBND(A,1) You must previously dimension the matrix (with OPTION BASE 1) and a real variable to return the value of the determinant, then populate the matrix and call the subprogram, like this: Albillo Matrix 1:
From the keyboard do: >OPTION BASE 1 @ DIM A(7,7) @ MAT INPUT A [ENTER]
Albillo Matrix 2: >MAT INPUT A [ENTER]
Albillo Matrix 3: >MAT INPUT A [ENTER] Please keep in mind that this version of XDET is just a proof-of-concept implementation, to show that it can be done, and as such has no error handling (the matrix must be at least 2x2, for instance), and is extremely inefficient, as it has to recursively call itself (N-1)!/2 times to compute an NxN determinant. This means that for each of our three examples it calls itself (7-1)!/2 = 360 times, and it will take some 2 min. in Emu71 running on a 2.4 Ghz PC, and one or two hours on a real 71B. It also uses up large amounts of RAM as it deepens the recursion level. However, it can be easily optimized in a number of ways. For instance, a preliminary search to locate rows/columns containing 0's, then expanding by minors along these rows/columns would mean avoiding a whole sub-branch of recursion for each 0 located. If no 0's are present, they can be created by suitably adding and subtracting rows. Also, when N is 2, XDET refrains from recursing again to "compute" the required 1x1 determinants, but computes instead the 2x2 determinant directly (halving the number of recursive calls needed). This could be done for N=3 instead, which would result in greater time savings.
Best regards from V.
Exact results with the HP ... - Nenad (Croatia) - 04-28-2005 Implementing one of my HP machines (physically even smaller than the HP71B) the following result is obtained in 11 seconds: DET (Albillo Matrix #3)=1 without any tricks, programming, etc. Anybody interested which HP and how :-)
Re: Results for TI-95 PROCALC + Mathematics module - Palmer O. Hanson, Jr. - 04-29-2005 I had run AM#1 on my TI-95. I did not get your answer. Then I ran the determinant of the inverse of AM#1 and I got your answer. I suspect that the reason for the difference is that you did not look closely at the subscript prompts. If you do you will see that the second prompt appears as a(2,1) which means that the user enters the matrix elements into the TI-95 by columns not by rows. That is the same convention that was used in the TI-59. TI uses entry by rows in the CC-40 and TI-74. To my knowledge all of the HP products use entry by rows.
The difference between our results is one more confirmation that the calculator generated determinant of a matrix will not be the same as the calculator generated determinant of the transpose of the matrix. The following table shows the differences for four calculators for AM#1: AM#1 AM#1 Transpose The TI-59 and the TI-95 both use 13 digit mantissas, but the TI-59 has the well known non-commutative multiply and truncates while the TI-95 does not have the multiply problem and rounds. The HP-41 Math Pac results support the idea that AM#1 is really more difficult than a 7x7 Hilbert.
Re: Exact results with the HP ... - HrastProgrammer - 04-29-2005 Anybody interested which HP and how :-)
Jornada / Derive ?
Re: Exact results with the HP ... - Nenad (Croatia) - 04-29-2005 You are right, Hrast (as always, if I might add...) HP Jornada 720, with Derive 3.14 running on Pocket DOS Just wanted to point out that a really powerful CAS can be implemented on a machine like HP J 720/728 without any problems. The only issue is that this is a very old DOS version of Derive intended for PC/XT, but it works as a beast.
Derive itself is extremely powerful (and a very small) program. I remember that a DOS version was able to fit on a single 5,25" floppy. In addition to this, implementation of Pocket DOS on a HP J preserves the capabilities of many old and wonderful programs written for good old DOS.
Re: Results for TI-95 PROCALC + Mathematics module - Valentin Albillo - 04-29-2005 Hi, Palmer: Palmer posted: "The HP-41 Math Pac results support the idea that AM#1 is really more difficult than a 7x7 Hilbert." You bet ! :-) I carefully crafted my "Matrix Trilogy", AM#1-AM#3 to be random matrices, as innocent-looking as possible and with small, perfectly balanced integer elements, yet incredibly ill-conditioned. This makes them excellent for testing purposes.
As I see it, they have a number of important advantages when compared with Hilbert matrices:
The bottom line: I heartedly suggest you put aside your "faulty" Hilbert matrices, and use instead AM#1-3. This will certainly help produce accurate and meaningful (if discouraging) results.
Thanks for your interest and best regards from V.
Re: Results for TI-95 PROCALC + Mathematics module - whuy - 04-29-2005 Please don't leave me (us?) in the dark any longer, Valentin! How did you create them?
Werner
49g+ results for Valentin's #1 matrix - Gene - 04-29-2005 Of course, in exact mode, the 49g+ gives the exact results for Valentin's #1 matrix. However, in APPROXIMATE mode, I get very interesting results. Here's what I did... I took the exact matrix of integers, switched to approximate mode, then multiplied the integer matrix by 1. to convert all of the values to reals (they all now have "." after them in the matrix. When I compute the determinant of this "real" matrix, I get: 1. --- Error = 0? When I compute the determinant of the inverse of the matrix, I get: 0.998239455633 Error = 0.17605% or so. The RowNorm of the product of the inverse with the original matrix comes up 1.03, error of 3% The ColumnNorm of the product of the inverse with the original matrix comes up 1.014991, error of 1.4991%. I don't believe the 49g+ has the "Frobenius Norm" built-in. I'm really interested in the 1. determinant in approximate mode. The inverse is not exact - and I can post that if someone wants to see it.
Re: Results for TI-95 PROCALC + Mathematics module - Marcus von Cube - 04-29-2005 Quote: You are perfectly right (except that you should have said "transposed" instead of "inverse".)
I think the main reason for the different results is the way, columns are rearranged by pivoting.
Re: 49g+ results for Valentin's #1 matrix - whuy - 04-29-2005 Gene - Set Flag -54 (Use Tiny Element)
Cheers, Werner
Updated...Re: 49g+ results for Valentin's #1 matrix - Gene - 04-29-2005 Thanks. With Flag 54 set, the determinant of Valentin's #1 matrix is now: 0.999945522778, an error of 0.0054478% or so. Interestingly, the determinant of the INVERSE is: 0.999945522778, an error of 0.0054478% or so.
No joke. It is exactly the same.
Re: Updated...Re: 49g+ results for Valentin's #1 matrix - whuy - 04-29-2005 ? No it's .998239455633 like you wrote in your previous post Re: Updated...Re: 49g+ results for Valentin's #1 matrix - Gene - 04-29-2005 You're right. I think I won't sign any financial documents today...must not be following things too closely. :-)
Re: 49g+ results for Valentin's #1 matrix - Rodger Rosenbaum - 04-29-2005 Gene said:"I don't believe the 49g+ has the "Frobenius Norm" built-in." The Frobenius norm of a matrix is obtained with ABS().
Edited: 29 Apr 2005, 9:13 p.m.
Re: Results for TI-95 PROCALC + Mathematics module - Palmer O. Hanson, Jr. - 04-29-2005 One advantage that you didn't mention for your matrices is that they are easier to display so that one can check one's entry. Of course this comment doesn't apply to the HP-49 where one can get an exact Hilbert of any size entered with a few keystrokes. In his transmission of April 27 Rodger wrote: "All other things being equal (ceteris parabus, as the Romans would say), it is better to have more digits." My original comparison table of Hilbert results which started this whole exercise supports that statement. I have't seen anything in the discussion of your matrices which contradicts that statement. Do you disagree?
|