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 3D-compact or non-3D-compact, exists.

1.1 Non-associated Nasik magic cubes (m = 8x) (complete and 3D-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 3D-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 3D-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 3D-compact. See 1.2 and 1.3 for non-complete Nasik magic cubes. A Nasik magic cube which is complete but not 3D-compact is constructed by the following XmlHypercube format. There cannot exist a 2D-compact Nasik magic cube.

m >= 16 and m is divisible by 16 (Nasik, complete, but not 3D-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 3D-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 3D-compact)

1.2.1 Case m = 16x (associated)

An associated Nasik magic cube (non-3D-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-3D-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)
08+0...8(q-1)+08q+08q+48q+98(q-1)+7...8+77
38+3...8(q-1)+38q+118q+88q+18(q-1)+4...8+44
58+5...8(q-1)+58q+38q+108q+78(q-1)+2...8+22
68+6...8(q-1)+68q+58q+68q+28(q-1)+1...8+11
8(e-1)+68(e-2)+6...8(e-q)+68q+218q+178q+188(e-q)+1...8(e-2)+18(e-1)+1
8(e-1)+58(e-2)+5...8(e-q)+58q+168q+138q+208(e-q)+2...8(e-2)+28(e-1)+2
8(e-1)+38(e-2)+3...8(e-q)+38q+228q+158q+128(e-q)+4...8(e-2)+48(e-1)+4
8(e-1)+08(e-2)+0...8(e-q)+08q+148q+198q+238(e-q)+7...8(e-2)+78(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)
049
1181
3107
562
211718
161320
221512
141923
P40,8(x, y)
0812177
3191694
51118152
61314101
3829252633
3724212834
3530232036
3222273139
U24,4(x)
x01234567891011121314151617181920212223
U24,4(x)08751720221991110221131214413618161523

U40,4(x)
x012345678910111213141516171819
U40,4(x)01918103337302717451325283632816151
x2021222324252627282930313233343536373839
U40,4(x)38242331731114263435221292629212039

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 3D-compact Nasik magic cubes (m = 8x, m >= 16)

1.3.1 Case m = 16x (associated and 3D-compact)

An associated 3D-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 3D-compact)

An associated 3D-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).

Q3,3(x, y)
102
543
687
Q5,5(x, y)
20314
98765
1011121314
1918171615
2023212422
Q3,15(x, y)
70819210311412513614
292827262524232221201918171615
303831393240334134423543364437

Note: These Qp,q(x, y) are not magic rectangles.

S9,3(x)
x012345678
S9,3(x)102543687

S25,5(x)
x0123456789101112131415161718192021222324
S25,5(x)2031498765101112131419181716152023212422

S45,15(x)
x012345678910111213141516171819202122
S45,15(x)708192103114125136142928272625242322
x23242526272829303132333435363738394041424344
S45,15(x)21201918171615303831393240334134423543364437

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)
1410457
1381315
9111262
R3,7(x,y)
10219165142
34711151819
20817613112
R5,7(x,y)
261983125134
206342414127
371518212933
935221223016
3223115281710

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)
7054359922874
63299345922425
8994389186756
413140344876101
2575978851179
R5,7,3(x,y,1)
621010332902351
9110084216069
20263353738086
37461056498615
5583167439644
R5,7,3(x,y,2)
279521284749104
5305872667565
50398897681217
81821461137743
10219847715236


For example, S*15(x) is shown as follows:
S*15(x)
x01234567891011121314
S*15(x)13211414897560103121

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.
[Legal indication] Prohibit the send of any spam or advertising.

This page was last updated on August 8, 2016.
"Magic Cubes and Tesseracts"   http://magcube.la.coocan.jp/magcube/en/
Copyright © 2004-2016, Mitsutoshi Nakamura. All rights reserved.

track feed Magic Cubes and Tesseracts RSS
SEO
loading
Magic Cubes and Tesseracts