 English Japanese Home Site Map Next   3-D ( 1   2   3   4   5 )   4-D ( 1   2   3   4   5   6 )

# Algorithms to make magic cubes and magic tesseracts

1. Magic cubes
1. pantriagonal magic cubes (pan-3-agonal)
2. diagonal magic cubes (2,3-agonal)
3. pantriagonal diagonal magic cubes (pan-3-agonal and 2,3-agonal)
4. pandiagonal magic cubes (pan-2-agonal and 2,3-agonal)
5. Nasik magic cubes (pan-2,3-agonal)
2. Magic tesseracts
1. panmagic tesseracts (pan-4-agonal)
2. pantriagonal magic tesseracts (pan-3-agonal and 3,4-agonal)
3. pan-3,4-agonal magic tesseracts
4. strictly magic tesseracts (2,3,4-agonal)
5. pan and strictly magic tesseracts (pan-4-agonal and 2,3,4-agonal)
6. Nasik magic tesseracts (pan-2,3,4-agonal)
3. Other n-dimensional magic hypercubes

## 1. Algorithms to make magic cubes

This section explains general algorithms to construct magic cubes of classes pantriagonal (pan-3-agonal), diagonal (2,3-agonal), pantriagonal diagonal (pan-3-agonal and 2,3-agonal), pandiagonal (pan-2-agonal and 2,3-agonal), and Nasik (pan-2,3-agonal). The algorithms for the two classes pantriagonal and diagonal support magic cubes of singly-even order (that is, order (4x+2)), which used to be said to be difficult to construct.
Let m be the order of the cube and (aijk), where i,j,k = 0,...,m-1, be the cube (note that the indexes start from zero). The function gcd(x, y) means the greatest common divisor of x and y.
Definitions of terms are here. Explanation of classes of magic cubes is here.

### 1.1 Algorithms for pantriagonal magic cubes (pan-3-agonal)

A pantriagonal magic cube (or, panmagic cube) always exists if the order is higher than 3. In this case, an associated pantriagonal magic cube exists, too. See also algorithms for higher classes, pantriagonal diagonal and Nasik.

Note I constructed an order-6 associated pantriagonal magic cube in February 2008. Look here.
Note A 2D-compact magic cube exists for every order divisible by 4. Every 2D-compact magic cube is pantriagonal and cannot be diagonal or associated, so every 2D-compact magic cube exactly belongs to the class 'pantriagonal'. (On the other hand, a magic square or a magic tesseract can be both 2D-compact and associated. See algorithms for pan-3,4-agonal magic tesseracts).

• Case m = 4x
• Case m = 2x+1 and m >= 5
• Case m = 4x+2 and m >= 6

### 1.2 Algorithms for diagonal magic cubes (2,3-agonal)

A diagonal magic cube (or, strictly magic cube) can exist only if the order is higher than 4. The following algorithms work for orders higher than 6. See also algorithms for higher classes, pantriagonal diagonal, pandiagonal, and Nasik.

Note Here are diagonal magic cubes of order-5 and order-6. An algebraic construction method for a diagonal magic cube of order 5 or 6 is still unknown.
Note Hans-Bernhard Meyer proved there cannot exist an order-5 associated diagonal magic cube. See his site.
Note An associated diagonal magic cube of singly-even order cannot exist.

### 1.3 Algorithm for pantriagonal diagonal magic cubes (pan-3-agonal and 2,3-agonal)

A pantriagonal diagonal magic cube (or, a PantriagDiag magic cube) of even order can exist only if the order is higher than 7 and divisible by 4. See also algorithms for a higher class, Nasik.

Note It is unknown whether an odd order pantriagonal diagonal magic cube which is not Nasik can exist or not.
I constructed an order-25 pantriagonal diagonal magic cube which is not Nasik in October 2006. See this file (CSV file).
It is still unknown whether a prime order pantriagonal diagonal magic cube which is not Nasik can exist or not.

### 1.4 Algorithms for pandiagonal magic cubes (pan-2-agonal and 2,3-agonal)

A pandiagonal magic cube can exist only if the order is divisible by 8, or odd and higher than 6. In this case, an associated pandiagonal magic cube can exist. See also algorithms for a higher class, Nasik.

• Case m = 8x
• Case m = 2x+1 and m >= 7

### 1.5 Algorithms for Nasik magic cubes (pan-2,3-agonal)

A Nasik magic cube (or, a pan-2,3-agonal magic cube) can exist only if the order is divisible by 8, or odd and higher than 8. In this case, if the order is higher than 8, an associated Nasik magic cube exists. Furthermore, if the order is higher than 8 and divisible by 8, a Nasik magic cube exists which is both associated and 3D-compact. There cannot exist a 2D-compact Nasik magic cube.

Note It can be proved that every order-8 associated Nasik magic cube is complete and 3D-compact, so an order-8 associated Nasik magic cube cannot exist. Top

## 2. Algorithms to make magic tesseracts

This section explains general algorithms to construct magic tesseracts of classes panmagic (pan-4-agonal), pantriagonal (pan-3-agonal and 3,4-agonal), pan-3,4-agonal, strictly magic (2,3,4-agonal), pan and strictly magic (pan-4-agonal and 2,3,4-agonal), and Nasik (pan-2,3,4-agonal). The algorithm for the class pantriagonal supports magic tesseracts of singly-even order (that is, order (4x+2)), which used to be said to be difficult to construct.
Let m be the order of the tesseract and (aijkh), where i,j,k,h = 0,...,m-1, be the tesseract (note that the indexes start from zero). The function gcd(x, y) means the greatest common divisor of x and y.
Definitions of terms are here. Explanation of classes of magic tesseracts is here.

### 2.1 Algorithms for panmagic tesseracts (pan-4-agonal)

A panmagic tesseract (namely, a pan-4-agonal or panquadragonal magic tesseract) can exist only if the order is divisible by 4, or odd and higher than 6. In this case, if the order is higher than 6, an associated panmagic tesseract can exist. See also algorithms for higher classes, pan-3,4-agonal and Nasik.

Note It can be proved that every order-4 panmagic tesseract is complete and 4D-compact, so an order-4 associated panmagic tesseract cannot exist though an order-4 associated pantriagonal magic cube exists.

### 2.2 Algorithms for pantriagonal magic tesseracts (pan-3-agonal and 3,4-agonal)

A pantriagonal magic tesseract exists for any order except 3 and 6. (An order-3 pantriagonal magic tesseract cannot exist, and it is unknown whether an order-6 pantriagonal magic tesseract can exist or not.) If the order is odd or divisible by 4, an associated pantriagonal magic tesseract exists. See also algorithms for higher classes, pan-3,4-agonal and Nasik.

Note An associated magic tesseract of singly-even order cannot exist though an associated magic cube of singly-even order can exist.

### 2.3 Algorithms for pan-3,4-agonal magic tesseracts

A pan-3,4-agonal magic tesseract can exist only if the order is divisible by 4, or odd and higher than 8. In this case, if the order is higher than 7, an associated pan-3,4-agonal tesseract can exist. See also algorithms for a higher class, Nasik.

Note Every 2D-compact magic tesseract is pan-3,4-agonal and cannot be diagonal, so every 2D-compact magic tesseract exactly belongs to the class 'pan-3,4-agonal'. An associated 2D-compact magic tesseract exists for any order 4x >= 8 though a 2D-compact magic cube cannot be associated.
Note It can be proved that every order-4 pan-3,4-agonal magic tesseract is complete and 2D-compact.

• Case m = 4x
• Case m = 2x+1 and m >= 9

### 2.4 Algorithm for strictly magic tesseracts (2,3,4-agonal)

It is unknown what condition is required and sufficient for the existence of a strictly magic tesseract, namely, a 2,3,4-agonal magic tesseract. A strictly magic tesseract exists for any even order higher than 7 and for any odd order higher than 14, and cannot exist for order 3, 4, or 5. The following algorithms work for even orders divisible by 4 and higher than 7, and odd orders higher than 14. See also algorithms for higher classes, pan and strictly magic and Nasik.

where L13 = lcm{y| y is odd and 2 < y < 14} = 32x5x7x11x13, where lcm means the least common multiple.

### 2.5 Algorithm for pan and strictly magic tesseracts (pan-4-agonal and 2,3,4-agonal)

A pan and strictly magic tesseract, namely, a pan-4-agonal and 2,3,4-agonal magic tesseract, of even order can exist only if the order is divisible by 4 and higher than 7.

### 2.6 Algorithms for Nasik magic tesseracts (pan-2,3,4-agonal)

A Nasik magic tesseract, namely, a pan-2,3,4-agonal magic tesseract, can exist only if the order is divisible by 16, or odd and higher than 16. In this case, if the order is higher than 16, an associated Nasik magic tesseract can exist. Furthermore, if the order is higher than 16 and divisible by 16, a Nasik magic tesseract exists which is both associated and 4D-compact.
There cannot exist a Nasik magic tesseract which is 2D-compact or 3D-compact.

Note It can be proved that every order-16 associated Nasik magic tesseract is complete and 4D-compact, so an order-16 associated Nasik magic tesseract cannot exist.

where L15 = lcm{y| y is odd and 2 < y < 16} = 32x5x7x11x13, where lcm means the least common multiple. Top

## 3. Algorithms to make other n-dimensional magic hypercubes

This section refers to algorithms to construct n-dimensional magic hypercubes with particular properties.

### 3.1 Algorithms for magic knight tour hypercubes of dimension n and order 4

A magic knight tour hypercube is a magic hypercube in which the path from the cell (a) to the cell (a+1) of the hypercube, where a = 1,2,..., is always (2-dimensional) knight jump. This section refers to the case of dimension n and order 4.
A magic knight tour hypercube of dimension n and order 4 exists if n is odd and n > 2. In this case, the hypercube can construct by a general construction algorithm using binary digits. Such a hypercube cannot exist for n = 2 (to begin with, a mere knight tour is impossible), and it is unknown whether it exists for even n > 3.

Examples of order-4 magic knight tour hypercube of dimension 5 and dimension 7 are here. Top

References
Kiyomi Ohmori, Shimpen Mahojin (Japanese), Fuzambo, 1992, ISBN 4-572-00696-2.
Akira Hirayama & Gakuho Abe, Researches in Magic Squares (Japanese), Osaka Kyoikutosho, 1983.
William H. Benson & Oswald Jacoby, Magic Cubes: New Recreations, Dover, 1981, ISBN 0-486-24140-8.
Marián Trenkler, Magic cubes, The Mathematical Gazette 82 (1998), 56-61.
Marián Trenkler, A construction of magic cubes, The Mathematical Gazette 84 (2000), 36-41.
Marián Trenkler, Magic p-dimensional cubes of order n=/2(mod 4), Acta Arithmetica 92 (2000), 189-194.
Marián Trenkler, Magic p-dimensional cubes, Acta Arithmetica 96 (2001), 361-364.
Thomas R. Hagedorn, On the existence of magic n-dimensional rectangles, Discrete Mathematics 207 (1999), 53-63.
Thomas R. Hagedorn, Magic retangles revisited, Discrete Mathematics 207 (1999), 65-72.
Guenter Stertenbrink & Jean Charles Meyrignac, Computing Magic Knight Tours, http://magictour.free.fr/ Home Site Map Next   3-D ( 1   2   3   4   5 )   4-D ( 1   2   3   4   5   6 )

Mitsutoshi Nakamura (Feedback)    To send an email to me, please enable JavaScript on your browser.
[Legal indication] Prohibit the send of any spam or advertising. Magic Cubes and Tesseracts 