Grogono Photo Pages
Size:  Index   3x3   4x4   5x5   6x6   7x7   8x8   9x9   10x10   11x11   12x12   13x13 

A Technique to Make Magic Cubes

Creating a Magic Cube by Formula

Trenkler Cube

Fascinating E-Mail

I am most grateful to Marian Trenkler from Safarik University, Slovakia. He was kind enough to e-mail me His paper "A Construction of Magic Cubes" on creating Magic Cubes from a formula. This is a simple example for odd-order cubes (3, 5, 7, 9,etc.) based on the start of his paper. It shows an Excel spreadsheet employing his method. The horizontal and vertical totals are shown beside and below each yellow layer. The blue square shows the totals for the remaining axis with the corner squares showing the totals for the main diagonal. The size of the square is in B2. The formula shown below was taken from cell D4; it is similar in every yellow cell:

Make Your Own.

To make sure you can make your own easily, I have tested the accuracy of the formula below by copying it from the web page back into cell D4 of an Excel Spreadsheet. Once inserted it can then be copied into to all of the other yellow cells. It only remains to type in the axis labels - the 1,2,3 values and the 3 in cell B2.

I have used the same formula on bigger cubes and it works fine. If you want to download examples for a 3x3 and for a 7x7, Go to the Download Page.

D4 = ((D$2 - D$3 + $C4 - 1) - $B$2 * (INT ((D$2 - D$3 + $C4 - 1)/$B$2))) * $B$2 * $B$2 +
        ((D$2 - D$3 - $C4) - $B$2 * INT ((D$2 - D$3 - $C4)/$B$2)) * $B$2 +
        ((D$2 + D$3 + $C4 - 2) - $B$2 * INT ((D$2 + D$3 + $C4 - 2) /$B$2)) + 1

i.e., where the three axes are x,y,and z, and n represents the order of the square:

Value = ((x - y + z - 1) - n * (INT ((x - y + z - 1)/n))) * n * n +
        ((x - y - z) - n * INT ((x - y - z)/n)) *n +
        ((x + y + z - 2) - n * INT ((x + y + z - 2) /n)) + 1

Horiz Bar

Up to this point in his paper I know I understood him because the formula worked in my spreadsheet. He goes on to discuss some more complicated higher order "cubes" which I have yet to fully comprehend - probably because my intellectual digestion falls short of the requirement.

However, I was delighted with his demonstration of how to create a cube from a formula and thought others might enjoy it too and also enjoy not having to type in this complicated formula for themselves. Thank you Marian


Copyright © Mar 2010 Magic Squares
Mar 6, 2010