Re: HP15C MiniChallenge: Magic squares ! Message #5 Posted by Didier Lachieze on 10 June 2009, 9:53 p.m., in response to message #4 by Eamonn
Well, I realize that I've been a bit quick to jump to a solution. I found it quite intuitively and I've verified it for several magic squares but I don't have a complete demonstration ...
Here are some explanations:
let's take two 3x3 magic squares X, constant K and Y, constant L
( a, b, c ) ( r, s, t )
X = ( d, e, f ) Y = ( u, v, w )
( g, h, i ) ( x, y, z )
then
( ar + bu + cx, as + bv + cy, at + bw + cz )
X*Y = ( dr + eu + fx, ds + ev + fy, dt + ew + fz )
( gr + hu + ix, gs + hv + iy, gt + hw + iz )
the sum of the first column is:
(a+d+g)r + (b+e+h)u + (c+f+i)x = Kr + Ku +Kx = K(r+u+x) = K*L
and you can see in the same way (using only rows and columns constant property) that the result is the also K*L for all rows and columns.
However I've not found a way to prove it's the same for the main diagonals ... btw it's not true as on a few examples I've tried the diagonal constant is not K*L.
If we suppose that the rows and columns constant of X*Y is K*L then for X*X it's K^2 and for X*X*X it's K^3; and strangely this last one is also true for the diagonals for the different magic squares I've tried so far.
So I still have to prove that the constant for the diagonals of X*X*X is K^3...
Now, to add something else to this incomplete and potentially wrong solution, and as Valentin has expressed previously his interest in the old Sharp Pocket Computers, here is a program for the Sharp PC1403 using the Matrix functions entry points described earlier on this forum in
this thread:
The Sharp PC1403 uses 3 matrix: X and Y for calculation, M for memory.
The program below assumes that the magic square is in X and return the result of X^3 in X.
10:"A":CALL 26191:REM X>M
20:CALL 26186: REM X^2>X
30:CALL 26163: REM X<>Y
40:CALL 26199: REM M>X
50:CALL 26119: REM X*Y>X
60:PRINT X(0,0)+X(1,1)+X(2,2),X(0,2)+X(1,1)+X(2,0)
Example:
CALC mode
SHIFT down 'to enter in Matrix mode
3 ENTER 3 ENTER 'to dimension matrix X as 3x3
71 ENTER 89 ENTER 17 ENTER 'enter first row
5 ENTER 59 ENTER 113 ENTER 'enter second row
101 ENTER 29 ENTER 47 ENTER 'enter third row
3 ENTER 3 ENTER 'to dimension matrix Y as 3x3
ENTER (9 times) 'until you get MATRIX OPERATIONS on the display
BASIC mode
DEF A 'to run the program
It ends by printing the constant for the 2 main diagonals, so you can verify it's K^3.
For the example above it shows:
5545233. 5545233.
Edited to add some precisions to the explanations.
Edited: 11 June 2009, 3:25 a.m.
