English
Japanese
Home
Site Map
Top
Prev.
Next
3-D ( 1 2 3 4 5 )
4-D ( 1 2 3 4 5 6 )
Algorithms to make Nasik magic cubes
[Order 8x] [Order 2x+1]
1. Algorithms for orders divisible by 8
A Nasik (namely, pan-2,3-agonal) magic cube of even order m can exist only if the order is divisible by 8. In this case, if the order is 16 or higher, an associated Nasik magic cube, which is 3-compact or non-3-compact, exists.
1.1 Non-associated Nasik magic cubes (m = 8x) (complete and 3-compact)
A Nasik magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation (aijk is also complete and 3-compact):
aijk = Tm(bijk) m2 + Tm(cijk) m + Tm(dijk) + 1,
where
bijk = i + (m/4)j + (m/2)k (mod. m), 0 <= bijk < m,
cijk = (m/2)i + j + (m/4)k (mod. m), 0 <= cijk < m,
dijk = (m/4)i + (m/2)j + k (mod. m), 0 <= dijk < m,
Tm(x) = x (where x < m/2), 3m/2-1-x (otherwise) (identical to the definition of Tm(x) for pantriagonal magic cubes).
This cube is expressed as follows by the XmlHypercube format by Aale de Winkel:
for m = 8:
LP({1,2,4},{4,1,2},{2,4,1})= [0,1,2,3,7,6,5,4]
for m = 16:
LP({1,4,8},{8,1,4},{4,8,1})= [0,1,2,3,4,5,6,7,15,14,13,12,11,10,9,8]
In general:
LP({1,m/4,m/2},{m/2,1,m/4},{m/4,m/2,1})= [0,..,m/2-1,m-1,...,m/2]
The F. A. P. Barnard order-8 Nasik magic cube was constructed by a similar way to this method.
Note
It can be proved that every order-8 Nasik magic cube is complete and 3-compact, so an order-8 associated Nasik magic cube cannot exist. On the other hand, if the order is higher than 8 and divisible by 8, there exists a Nasik magic cube which is not complete or not 3-compact. See 1.2 and 1.3 for non-complete Nasik magic cubes. A Nasik magic cube which is complete but not 3-compact is constructed by the following XmlHypercube format. There cannot exist a 2-compact Nasik magic cube.
m >= 16 and m is divisible by 16 (Nasik, complete, but not 3-compact) :
LP({1,m/8,m/4},{m/4,1,m/8},{m/8,m/4,1})= [0,..,m/2-1,m-1,...,m/2]
m >= 16 and m is divisible by 8 but not by 16 (Nasik, complete, but not 3-compact) :
LP({4,m/8,m/4},{m/4,4,m/8},{m/8,m/4,4})= [0,..,m/2-1,m-1,...,m/2]
Compare with the case of Nasik magic tesseracts.
Addendum
If the order is a power of 2, you can construct another Nasik magic cube by using binary digits. (The Gakuho Abe order-8 Nasik magic cube seems to have been constructed by this method.) For more information, see Dwane H. Campbell's site.
Back
1.2 Associated Nasik magic cubes (m = 8x, m >= 16) (not 3-compact)
1.2.1 Case m = 16x (associated)
An associated Nasik magic cube (non-3-compact) aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = Um(bijk) m2 + Um(cijk) m + Um(dijk) + 1,
where
bijk = i + (m/8)j + (m/4)k + 3m/16 (mod. m), 0 <= bijk < m,
cijk = (m/4)i + j + (m/8)k + 3m/16 (mod. m), 0 <= cijk < m,
dijk = (m/8)i + (m/4)j + k + 3m/16 (mod. m), 0 <= dijk < m,
U(x) = x (if x < m/4 or x >= 3m/4), m-1-x (otherwise) (identical to the definition of Tm(x) for pantriagonal magic cubes).
This cube is expressed as follows by the XmlHypercube format by Aale de Winkel:
for m = 16:
LP({1,2,4},{4,1,2},{2,4,1})= [3,11,10,9,8,7,6,5,4,12,13,14,15,0,1,2]
for m = 32:
LP({1,4,8},{8,1,4},{4,8,1})= [6,7,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,24,25,26,27,28,29,30,31,0,1,2,3,4,5]
1.2.2 Case m = 16x+8 and m >= 24 (associated)
An associated Nasik magic cube (non-3-compact) aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = Um,4(bijk) m2 + Um,4(cijk) m + Um,4(dijk) + 1,
where
bijk = 4i + (m/8)j + (m/4)k + 3(m/8+1)/2 (mod. m), 0 <= bijk < m,
cijk = (m/4)i + 4j + (m/8)k + 3(m/8+1)/2 (mod. m), 0 <= cijk < m,
dijk = (m/8)i + (m/4)j + 4k + 3(m/8+1)/2 (mod. m), 0 <= dijk < m,
Um,4(x) = Pm,8(x mod 8, x mod (m/8)).
Pm,8(x, y) (where 0 <= x < 8, 0 <= y < m/8) is given by the following table, where e = m/8 and q = (m/8-3)/2.
When m = 24 (q = 0), only the center part colored by dark green is available.
Pm,8(x,y)
| 0 | 8+0 | ... | 8(q-1)+0 | 8q+0 | 8q+4 | 8q+9 | 8(q-1)+7 | ... | 8+7 | 7 |
| 3 | 8+3 | ... | 8(q-1)+3 | 8q+11 | 8q+8 | 8q+1 | 8(q-1)+4 | ... | 8+4 | 4 |
| 5 | 8+5 | ... | 8(q-1)+5 | 8q+3 | 8q+10 | 8q+7 | 8(q-1)+2 | ... | 8+2 | 2 |
| 6 | 8+6 | ... | 8(q-1)+6 | 8q+5 | 8q+6 | 8q+2 | 8(q-1)+1 | ... | 8+1 | 1 |
| 8(e-1)+6 | 8(e-2)+6 | ... | 8(e-q)+6 | 8q+21 | 8q+17 | 8q+18 | 8(e-q)+1 | ... | 8(e-2)+1 | 8(e-1)+1 |
| 8(e-1)+5 | 8(e-2)+5 | ... | 8(e-q)+5 | 8q+16 | 8q+13 | 8q+20 | 8(e-q)+2 | ... | 8(e-2)+2 | 8(e-1)+2 |
| 8(e-1)+3 | 8(e-2)+3 | ... | 8(e-q)+3 | 8q+22 | 8q+15 | 8q+12 | 8(e-q)+4 | ... | 8(e-2)+4 | 8(e-1)+4 |
| 8(e-1)+0 | 8(e-2)+0 | ... | 8(e-q)+0 | 8q+14 | 8q+19 | 8q+23 | 8(e-q)+7 | ... | 8(e-2)+7 | 8(e-1)+7 |
Compare with the definition of Pm,16(x, y) for Nasik magic tesseracts.
Pm,8(x, y) satifies the following properties (only these properties are needed for Pm,8(x, y)).
(1) 0 <= Pm,8(x, y) < m,
(2) If Pm,8(x, y) = Pm,8(x', y') then x = x' and y = y' (normal),
(3) Sumv=0,3 {Pm,8(x+2v, y)} = 2(m-1) (for 0 <= x < 2 and 0 <= y < m/8),
(4) Sumv=0,m/8-1 {Pm,8(x, v) + Pm,8(x+4, v)} = m(m-1)/8 (for 0 <= x < 4),
(5) Pm,8(x, y) + Pm,8(7-x, m/8-1-y) = m-1 (associated).
The following are examples for m = 24 and m = 40.
P24,8(x, y)
| 0 | 4 | 9 |
| 11 | 8 | 1 |
| 3 | 10 | 7 |
| 5 | 6 | 2 |
| 21 | 17 | 18 |
| 16 | 13 | 20 |
| 22 | 15 | 12 |
| 14 | 19 | 23 |
P40,8(x, y)
| 0 | 8 | 12 | 17 | 7 |
| 3 | 19 | 16 | 9 | 4 |
| 5 | 11 | 18 | 15 | 2 |
| 6 | 13 | 14 | 10 | 1 |
| 38 | 29 | 25 | 26 | 33 |
| 37 | 24 | 21 | 28 | 34 |
| 35 | 30 | 23 | 20 | 36 |
| 32 | 22 | 27 | 31 | 39 |
U24,4(x)
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| U24,4(x) | 0 | 8 | 7 | 5 | 17 | 20 | 22 | 19 | 9 | 11 | 10 | 2 | 21 | 13 | 12 | 14 | 4 | 1 | 3 | 6 | 18 | 16 | 15 | 23 |
U40,4(x)
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| U40,4(x) | 0 | 19 | 18 | 10 | 33 | 37 | 30 | 27 | 17 | 4 | 5 | 13 | 25 | 28 | 36 | 32 | 8 | 16 | 15 | 1 |
| x | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
| U40,4(x) | 38 | 24 | 23 | 31 | 7 | 3 | 11 | 14 | 26 | 34 | 35 | 22 | 12 | 9 | 2 | 6 | 29 | 21 | 20 | 39 |
Expression by the XmlHypercube format by Aale de Winkel:
for m = 24:
LP({4,3,6},{6,4,3},{3,6,4})= [22,19,9,11,10,2,21,13,12,14,4,1,3,6,18,16,15,23,0,8,7,5,17,20]
for m = 40:
LP({4,5,10},{10,4,5},{5,10,4})= [4,5,13,25,28,36,32,8,16,15,1,38,24,23,31,7,3,11,14,26,34,35,22,12,9,26,29,21,20,39,0,19,18,10,33,37,30,27,17]
Back
1.3 Associated 3-compact Nasik magic cubes (m = 8x, m >= 16)
1.3.1 Case m = 16x (associated and 3-compact)
An associated 3-compact Nasik magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = bijk m2 + cijk m + dijk + 1,
where
bijk = Um(b*ijk) (if the index i is even), m - 1 - Um(b*ijk) (if i is odd),
cijk = Um(c*ijk) (if the index j is even), m - 1 - Um(c*ijk) (if j is odd),
dijk = Um(d*ijk) (if the index k is even), m - 1 - Um(d*ijk) (if k is odd),
b*ijk = j* + (m/8)k* (mod. m), 0 <= b*ijk < m,
c*ijk = k* + (m/8)i* (mod. m), 0 <= c*ijk < m,
d*ijk = i* + (m/8)j* (mod. m), 0 <= d*ijk < m,
i* = i (if i is even), m - 1 - i (if i is odd),
j* = j (if j is even), m - 1 - j (if j is odd),
k* = k (if k is even), m - 1 - k (if k is odd),
Um(x) = x (x < m/4 or x >= 3m/4), m-1-x (otherwise) (the same as the definition of Um(x) in 1.2.1).
1.2.2 Case m = 16x+8 and m >= 24 (associated and 3-compact)
An associated 3-compact Nasik magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = bijk m2 + cijk m + dijk + 1,
where
aijk = bijk m2 + cijk m + dijk + 1,
where
bijk = Um,4(b*ijk) (if the index i is even), m - 1 - Um,4(b*ijk) (if i is odd),
cijk = Um,4(c*ijk) (if the index j is even), m - 1 - Um,4(c*ijk) (if j is odd),
dijk = Um,4(d*ijk) (if the index k is even), m - 1 - Um,4(d*ijk) (if k is odd),
b*ijk = 2j* + (m/8)k* (mod. m), 0 <= b*ijk < m,
c*ijk = 2k* + (m/8)i* (mod. m), 0 <= c*ijk < m,
d*ijk = 2i* + (m/8)j* (mod. m), 0 <= d*ijk < m,
i* = i (if i is even), m - 1 - i (if i is odd),
j* = j (if j is even), m - 1 - j (if j is odd),
k* = k (if k is even), m - 1 - k (if k is odd),
Um,4(x) = Pm,8(x mod 8, x mod (m/8)) (the same as the definition of Um,4(x) in 1.2.2).
Back
2. Algorithms for odd orders
A Nasik (namely, pan-2,3-agonal) magic cube of odd order m can exist only if the order is higher by 8, and an associated Nasik magic cube of odd order can exist under the same condition.
The function gcd means the greatest common divisor.
2.1 Case m = 2x+1, m >= 9, and gcd(m, 3x5x7) = 1 (associated)
In this case, m is prime to 3, 5, and 7.
A Nasik magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = bijk m2 + cijk m + dijk + 1,
where
bijk = i + 2j + 4k + 3 (mod. m), 0 <= bijk < m,
cijk = i - 2j + 4k + 1 (mod. m), 0 <= cijk < m,
dijk = i + 2j - 4k - 1 (mod. m), 0 <= dijk < m.
This cube is expressed as follows by the XmlHypercube format by Aale de Winkel:
LP({1,2,4}+3,{1,-2,4}+1,{1,2,-4}-1)
2.2 Case m = 2x+1, m >= 9, and 1 < gcd(m, 3x5x7) < m (associated)
Let q be gcd(m, 3x5x7) and p be m/q. In this case, p > 1 and q > 1.
A Nasik magic cube aijk, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = Sm,q(bijk) m2 + Sm,q(cijk) m + Sm,q(dijk) + 1,
where
bijk = i + 2j + 4k + 3 (mod. m), 0 <= bijk < m,
cijk = i - 2j + 4k + 1 (mod. m), 0 <= cijk < m,
dijk = i + 2j - 4k - 1 (mod. m), 0 <= dijk < m,
Sm,q(x) = Qp,q([x/q], x mod q),
where [x] means the integer part of x.
Qp,q(x, y), where 0 <= x < p and 0 <= y < q, is given by the following equations:
Qp,q(x, y) =
qx + y
(if 0 < x < p-1 and x is even),
qx + (q-1-y)
(if 0 < x < p-1 and x is odd),
y/2 + (q-1)/2
(if x = 0 and y is even),
(y-1)/2
(if x = 0 and y is odd),
y/2 + (p-1)q
(if x = p-1 and y is even),
(y-1)/2 + pq - (q-1)/2
(if x = p-1 and y is odd).
Qp,q(x, y) satifies the following properties (only these properties are needed for Qp,q(x, y)).
(1) 0 <= Qp,q(x, y) < pq (= m),
(2) If Qp,q(x, y) = Qp,q(x', y') then x = x' and y = y' (normal),
(3) Sumv=0,p-1 {Qp,q(v, y)} = q(pq-1)/2 (column magicness),
(4) Qp,q(x, y) + Qp,q(p-1-x, q-1-y) = pq-1 (associated).
The following are examples of Qp,q(x, y) and Sm,q(x) for m = 9 (p = 3, q = 3), m = 25 (p = 5, q = 5), and m = 45 (p = 3, q = 15).
Q5,5(x, y)
| 2 | 0 | 3 | 1 | 4 |
| 9 | 8 | 7 | 6 | 5 |
| 10 | 11 | 12 | 13 | 14 |
| 19 | 18 | 17 | 16 | 15 |
| 20 | 23 | 21 | 24 | 22 |
Q3,15(x, y)
| 7 | 0 | 8 | 1 | 9 | 2 | 10 | 3 | 11 | 4 | 12 | 5 | 13 | 6 | 14 |
| 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 |
| 30 | 38 | 31 | 39 | 32 | 40 | 33 | 41 | 34 | 42 | 35 | 43 | 36 | 44 | 37 |
S9,3(x)
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| S9,3(x) | 1 | 0 | 2 | 5 | 4 | 3 | 6 | 8 | 7 |
S25,5(x)
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| S25,5(x) | 2 | 0 | 3 | 1 | 4 | 9 | 8 | 7 | 6 | 5 | 10 | 11 | 12 | 13 | 14 | 19 | 18 | 17 | 16 | 15 | 20 | 23 | 21 | 24 | 22 |
S45,15(x)
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| S45,15(x) | 7 | 0 | 8 | 1 | 9 | 2 | 10 | 3 | 11 | 4 | 12 | 5 | 13 | 6 | 14 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 |
| x | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | |
| S45,15(x) | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 30 | 38 | 31 | 39 | 32 | 40 | 33 | 41 | 34 | 42 | 35 | 43 | 36 | 44 | 37 | |
2.3 Case m = 2x+1, m >= 9, and gcd(m, 3x5x7) = m (associated)
In this case, m is equal to 15(=3x5), 21(=3x7), 35(=5x7), or 105(=3x5x7).
A Nasik magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = S*m(bijk) m2 + S*m(cijk) m + S*m(dijk) + 1,
where
bijk = i + 2j + 4k + 3 (mod. m), 0 <= bijk < m,
cijk = i - 2j + 4k + 1 (mod. m), 0 <= cijk < m,
dijk = i + 2j - 4k - 1 (mod. m), 0 <= dijk < m,
S*15(x) = R3,5(x mod 3, x mod 5) - 1,
S*21(x) = R3,7(x mod 3, x mod 7) - 1,
S*35(x) = R5,7(x mod 5, x mod 7) - 1,
S*105(x) = R3,5,7(x mod 3, x mod 5, x mod 7) - 1.
R3,5, R3,7, R5,7, and R3,5,7 are associated magic rectangles of orders (3,5), (3,7), (5,7), and (3,5,7), respectively. Concretely, they are given by the following tables:
magic rectangles of orders (3,5), (3,7), and (5,7) (associated)
R3,5(x,y)
| 14 | 10 | 4 | 5 | 7 |
| 1 | 3 | 8 | 13 | 15 |
| 9 | 11 | 12 | 6 | 2 |
R3,7(x,y)
| 10 | 21 | 9 | 16 | 5 | 14 | 2 |
| 3 | 4 | 7 | 11 | 15 | 18 | 19 |
| 20 | 8 | 17 | 6 | 13 | 1 | 12 |
R5,7(x,y)
| 26 | 19 | 8 | 31 | 25 | 13 | 4 |
| 20 | 6 | 34 | 24 | 14 | 1 | 27 |
| 3 | 7 | 15 | 18 | 21 | 29 | 33 |
| 9 | 35 | 22 | 12 | 2 | 30 | 16 |
| 32 | 23 | 11 | 5 | 28 | 17 | 10 |
a magic rectangle of order (3,5,7) (associated) [Nakamura, April 2004] (shown as an order-(5,7,3) rectangle R5,7,3)
R5,7,3(x,y,0)
| 70 | 54 | 35 | 99 | 22 | 87 | 4 |
| 63 | 29 | 93 | 45 | 92 | 24 | 25 |
| 89 | 94 | 38 | 9 | 18 | 67 | 56 |
| 41 | 31 | 40 | 34 | 48 | 76 | 101 |
| 2 | 57 | 59 | 78 | 85 | 11 | 79 |
R5,7,3(x,y,1)
| 62 | 10 | 103 | 32 | 90 | 23 | 51 |
| 91 | 100 | 8 | 42 | 1 | 60 | 69 |
| 20 | 26 | 33 | 53 | 73 | 80 | 86 |
| 37 | 46 | 105 | 64 | 98 | 6 | 15 |
| 55 | 83 | 16 | 74 | 3 | 96 | 44 |
R5,7,3(x,y,2)
| 27 | 95 | 21 | 28 | 47 | 49 | 104 |
| 5 | 30 | 58 | 72 | 66 | 75 | 65 |
| 50 | 39 | 88 | 97 | 68 | 12 | 17 |
| 81 | 82 | 14 | 61 | 13 | 77 | 43 |
| 102 | 19 | 84 | 7 | 71 | 52 | 36 |
For example, S*15(x) is shown as follows:
S*15(x)
| x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| S*15(x) | 13 | 2 | 11 | 4 | 14 | 8 | 9 | 7 | 5 | 6 | 0 | 10 | 3 | 12 | 1 |
Addendum:
For m = 105, we can use a magic rectangle of order (3,35), (5,21), or (7,15) instead of that of order (3,5,7). (Aale de Winkel pointed out that.) We can construct these magic rectangles by using the order-(3,5,7) magic rectangle, or without using it. For more information, see this page for magic rectangles.
Back
Home
Site Map
Top
Prev.
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.
This page was last updated on January 20, 2008.
"Magic Cubes and Tesseracts" http://homepage2.nifty.com/googol/magcube/en/
Copyright © 2004-2008, Mitsutoshi Nakamura. All rights reserved.