Addition-Multiplication Magic Square

Author

Eric W. Weisstein
January 29, 2009

This notebook downloaded from http://mathworld.wolfram.com/notebooks/RecreationalMath/Addition-MultiplicationMagicSquare.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/Addition-MultiplicationMagicSquare.html.

©2009 Wolfram Research, Inc. except for portions noted otherwise

Examples

8×8

Different form of Horner

horner={
		{46,81,117,102,15,76,200,203},
		{19,60,232,175,54,69,153,78},
		{216,161,17,52,171,90,58,75},
		{135,114,50,87,184,189,13,68},
		{150,261,45,38,91,136,92,27},
		{119,104,108,23,174,225,57,30},
		{116,25,133,120,51,26,162,207},
		{39,34,138,243,100,29,105,152}};

Max[Flatten[horner]]

horner2={
{f n,g l,e m,h p,a q,d j,b k,c r},
{a j,d q,b r,c k, f l,g n,e p,h m},
{b l,c n,a p,d m,e j,h q,f r,g k},
{e q,h j,f k,g r,b n,c l,a m,d p},
{h k,e r,g q,f j,c m,b p,d n,a l},
{c p,b m,d l,a n,h r,e k,g j,f q},
{d r,a k,c j,b q,g p,f m,h l,e n},
{g m,f p,h n,e l,d k,a r,c q,b j}
}/.{a->7,b->4,c->1,d->8,e->3,f->6,g->9,h->2,j->15,k->29,l->23,m->17,n->27,p->13,q->19,r->25};

Sort[Flatten[horner]]==Sort[Flatten[horner2]]

Max[Flatten[#]]&/@{horner,horner2}

AdditionMultiplicationMagicQ/@{horner,horner2}

{Times@@@{horner,Transpose[horner]},Plus@@@{horner,Transpose[horner]}}

Boyer

boyer={{75,38,207,102,11,20,91,56},{5,44,49,104,57,50,153,138},{133,200,17,92,45,66,21,26},{99,30,39,14,175,152,23,68},{78,63,22,15,184,119,100,19},{136,161,76,25,42,117,10,33},{28,13,40,77,34,69,114,225},{46,51,150,171,52,7,88,35}};

Max[Flatten[boyer]]

AdditionMultiplicationMagicQ[boyer]

{Times@@@{boyer,Transpose[boyer]},Plus@@@{boyer,Transpose[boyer]}}

Show[GraphicsArray[MagicSquarePlot[#[[1]],PlotLabel->StyleForm["8×8 "<>#[[2]],FontFamily->"Times",FontSlant->"Italic",FontSize->14]]&/@Transpose[{{horner,boyer},{"Horner (1955)","Boyer (2005)"}}]],ImageSize->500]

9×9

AM9One={
		{200,87,95,42,99,1,46,108,170},
		{14,44,10,184,81,85,150,261,19},
		{138,243,17,50,116,190,56,33,5},
		{57,125,232,9,7,66,68,230,54},
		{4,70,22,51,115,216,171,25,174},
		{153,23,162,76,250,58,3,35,88},
		{145,152,75,11,6,63,270,34,92},
		{110,2,28,135,136,69,29,114,225},
		{27,102,207,290,38,100,55,8,21}};

AM9Two={
		{17,171,126,54,230,100,93,264,145},
		{124,66,290,85,57,168,162,23,225},
		{216,115,75,279,198,29,170,76,42},
		{261,186,33,210,68,38,200,135,69},
		{50,270,92,87,248,165,21,153,114},
		{105,51,152,150,27,207,116,62,330},
		{138,25,243,132,58,310,95,63,136},
		{190,84,34,184,125,81,297,174,31},
		{99,232,155,19,189,102,46,250,108}};

Max[Flatten[#]]&/@{AM9One,AM9Two}

AdditionMultiplicationMagicQ/@{AM9One,AM9Two}

{Times@@@{#,Transpose[#]},Plus@@@{#,Transpose[#]}}&/@{AM9One,AM9Two}

Show[GraphicsArray[MagicSquarePlot[#[[1]],PlotLabel->StyleForm["9×9 "<>#[[2]],FontFamily->"Times",FontSlant->"Italic",FontSize->14]]&/@Transpose[{{AM9One,AM9Two},{"(1)","(2)"}}]],ImageSize->500]

Boyer

Jan 29, 2009

SetDirectory["/Volumes/Users/Data/Math/addmult10+/"];

files=FileNames["*.txt"]

Length[%]

m=Import[#,"Table"]&/@files;

AdditionMultiplicationMagicQ/@m

MagicQ/@m

SemimagicQ/@m

Row Sums

Map[Union[Total[#]]&,m]

Length/@%

Column Sums

Map[Union[Total[Transpose[#]]]&,m]

Length/@%

Row Products

Map[Union[Times@@@#]&,m]

Length/@%

Column Products

Map[Union[Times@@@Transpose[#]]&,m]

Length/@%

Distinct Integers

(Unequal@@Flatten[#])&/@m

Maximum Integer Used

Max[Flatten[#]]&/@m

Diagonal Sums

Tr/@m

Reverse Diagonal Sums

Tr[Reverse/@#]&/@m

Diagonal Products

d=(Times@@Tr[#,List])&/@m

Reverse Diagonal Products

rd=(Times@@Tr[Reverse/@#,List])&/@m

Equal@@@Transpose[{d,rd}]

Sallows Square

MagicSquarePlot[{{1,-3,2},{-4,12,-8},{3,-9,6}}]