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 pantriagonal magic cubes

[Order 4x][Order 2x+1] [Order 4x+2]

1. Algorithms for orders divisible by 4

   A pantriagonal magic cube can exist for any order divisible by 4. An associated pantriagonal magic cube can exist under the same condition. If the order is higher than 4, there exists a pantriagonal diagonal magic cube, which satisfies a stronger condition than pantriagonal. Furthermore, if the order is divisible by 8, there exists a Nasik magic cube, which satisfies a stronger condition than pantriagonal diagonal.

2.1 Non-associated pantriagonal magic cubes (m = 4x) (also complete and 2D-compact)

A pantriagonal magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation (aijk is also complete and 2D-compact):
aijk = Tm(bijk) m2 + Tm(cijk) m + Tm(dijk) + 1,

where
bijk = i + (m/2)j + (m/2)k   (mod. m),   0 <= bijk < m,
cijk = (m/2)i + j + (m/2)k   (mod. m),   0 <= cijk < m,
dijk = (m/2)i + (m/2)j + k   (mod. m),   0 <= dijk < m,
Tm(x) = x (where x < m/2), 3m/2-1-x (otherwise).

This cube is expressed as follows by the XmlHypercube format by Aale de Winkel:
for m = 4:
   LP({1,2,2},{2,1,2},{2,2,1})= [0,1,3,2]
for m = 8:
   LP({1,2,2},{2,1,2},{2,2,1})= [0,1,2,3,7,6,5,4]
In general:
   LP({1,m/2,m/2},{m/2,1,m/2},{m/2,m/2,1})= [0,...,m/2-1,m-1,...,m/2]

Back

2.2 Associated pantriagonal magic cubes (m = 4x)

An associated pantriagonal magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = bijk m2 + Tm(cijk) m + Um(dijk) + 1,

where
bijk = 2hm/2(k mod m/2) + rm(i, k)   (if [4i/m] + j + [2k/m] is even),   m - 1 - {2hm/2(k mod m/2) + rm(i, k)}   (otherwise),
cijk = (i + j + k) mod m   (if k is even),   {m/2 - 3 - (i + j + k)} mod m   (otherwise),
dijk = (-i + j + k) mod m,

Tm(x) = x (where x < m/2), 3m/2-1-x (otherwise)    (identical to the definition for non-associated cubes).
Um(x) = x (if x < m/4 or x >= 3m/4), m-1-x (otherwise),
hm/2(x) = x (if x < m/4), m/2-1-x (otherwise),
rm(x, y) = 0 (if [2x/m + 1/2] + [2y/m + 1/2] is even), 1 (otherwise).

The following is an example for m = 4:

bijk
k = 0
0303
2121
1212
3030
k = 1
1212
3030
0303
2121
k = 2
2121
0303
3030
1212
k = 3
3030
1212
2121
0303

cijk
k = 0
0123
1230
2301
3012
k = 1
2103
1032
0321
3210
k = 2
2301
3012
0123
1230
k = 3
0321
3210
2103
1032

T4(cijk)
k = 0
0132
1320
3201
2013
k = 1
3102
1023
0231
2310
k = 2
3201
2013
0132
1320
k = 3
0231
2310
3102
1023

dijk
k = 0
0123
3012
2301
1230
k = 1
1230
0123
3012
2301
k = 2
2301
1230
0123
3012
k = 3
3012
2301
1230
0123

U4(dijk)
k = 0
0213
3021
1302
2130
k = 1
2130
0213
3021
1302
k = 2
1302
2130
0213
3021
k = 3
3021
1302
2130
0213

Here is the order-4 associated pantriagonal magic cube constructed by these bijk, T4(cijk), and U4(dijk).

Back

2. Algorithms for odd orders

   A pantriagonal magic cube of odd order can exist only if the order is higher than 4. An associated pantriagonal magic cube of odd order can exist under the same condition. If the order is higher than 8, there exists a Nasik magic cube, which satisfies a stronger condition than pantriagonal.

2.1 When the order m is NOT divisible by 3 (m = 2x+1, m >= 5) (associated)

An associated pantriagonal 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 = 2i + j + k + (m+3)/2   (mod. m),   0 <= bijk < m,
cijk = 2i - j + k + (m+1)/2   (mod. m),   0 <= cijk < m,
dijk = 2i + j - k + (m+1)/2   (mod. m),   0 <= dijk < m.

2.2 When the order m is divisible by 3 (m = 2x+1, m >= 5) (associated)

An associated pantriagonal magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = Sm,3(bijk) m2 + Sm,3(cijk) m + Sm,3(dijk) + 1,

where
bijk = 2i + j + k + (m+3)/2   (mod. m),   0 <= bijk < m,
cijk = 2i - j + k + (m+1)/2   (mod. m),   0 <= cijk < m,
dijk = 2i + j - k + (m+1)/2   (mod. m),   0 <= dijk < m.
Sm,3(x) = Qm/3,3([x/3], x mod 3).

Qp,q(x, y), where 0 <= x < p and 0 <= y < q, is given by the following equations (identical to Qp,q(x, y) for Nasik magic cubes):
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).

See the page for Nasik magic cubes to see examples of Qp,q(x, y) and Sm,q(x).

Back

3. Algorithms for singly-even orders

   A pantriagonal magic cube exists for any singly-even (even but not divisible by 4) order higher than 4. An associated pantriagonal magic cube of singly-even order also exists under the same condition.

3.1 Non-associated pantriagonal magic cubes (m = 4x+2, m >= 6) (also complete)

A pantriagonal magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equations (aijk is also complete):
aijk = a*ijk (if [2i/m]+[2j/m]+[2k/m] is even),
m3 + 1 - a*ijk (if [2i/m]+[2j/m]+[2k/m] is odd),
a*ijk = Fm(bijk, qijk) (m/2)2 + cijk (m/2) + dijk + 1,

where
bijk = i + j + k   (mod. m/2),   0 <= bijk < m/2,
cijk = i - j + k   (mod. m/2),   0 <= cijk < m/2,
dijk = i + j - k   (mod. m/2),   0 <= dijk < m/2,
Fm(x, y) = x + y (if x = m/2-2 or x is even),
4(x+1) - y - 1 (if x < m/2-2 and x is odd),
4(x+2) - y - 2 (if x = m/2-1),
qijk = 2[2i/m] + [2j/m] (if k < m/2),
3 - 2[2i/m] - [2j/m] (if k >= m/2).

The following tables are examples of Fm(x, y), Fm(bijk, qijk), a*ijk, and aijk for m = 6:
F6(x, y)
0123
00123
14567
21412108

F6(bijk, qijk)
k = 0
04141512
41405121
14041215
2610378
6102783
1026837
k = 1
41405121
14041215
04141512
6102783
1026837
2610378
k = 2
14041215
04141512
414051214
1026837
2610378
6102783

k = 3
3782610
7836102
8371026
15120414
51214140
12151404
k = 4
7836102
8371026
3782610
51214140
12151404
15120414
k = 5
8371026
3782610
7836102
12151404
15120414
512144140

a*ijk
k = 0
1441321053114
4112975011116
1354381171347
196296287178
599325687534
992256813165
k = 1
4212785110917
1335391151448
2451301154112
609126697335
972357793266
206394297276
k = 2
1346371161546
3431311252113
4012894911018
982455803364
216195307077
589227677436

k = 3
287178196296
687534599325
813165992256
1053114144132
5011116411297
1171347135438
k = 4
697335609126
793266972357
297276206394
5110917421278
1151448133539
1154112245130
k = 5
803364982455
307077216195
677436589227
1161546134637
1252113343131
4911018401289

aijk (an order-6 pantriagonal magic cube)
k = 0 (Plane No.1)
144132207164103
411297167106201
135438100204170
198155121287178
158124192687534
118195161813165
k = 1 (Plane No.2)
421278166108200
133539102203169
245130206163105
157126191697335
120194160793266
197154123297276
k = 2 (Plane No.3)
134637101202171
343131205165104
401289168107199
119193162803364
196156122307077
159125190677436

k = 3 (Plane No.4)
189146139196296
149142183599325
136186152992256
105311421617385
501111617688210
117134782213179
k = 4 (Plane No.5)
148144182609126
138185151972357
188145141206394
511091717590209
115144884212178
115411221517287
k = 5 (Plane No.6)
137184153982455
187147140216195
150143181589227
116154683211180
125211321417486
491101817789208

Note By generalizing this method, we can construct a panmagic hypercube of any singly-even order and any odd dimension. (For even dimension, a panmagic hypercube of singly-even order cannot exist.) The order-6 pantriagonal magic cube by Gakuho Abe seems to have been constructed by a similar way to this method.

Back

3.2 Associated pantriagonal magic cubes (m = 4x+2, m >= 6)

An associated pantriagonal magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equations:
aijk = bijk (m/2)3 + cijk + 1,

where
bijk = v1 (if t = (m-2)/4),
7-v0 (if t < (m-2)/4 and t + (m-2)/4 is even),
v0 (if t < (m-2)/4 and t + (m-2)/4 is odd),
cijk = k* (m/2)2 + i* (m/2) + j* (if i+j+k is even),
(m/2)3 - 1 - {k* (m/2)2 + i* (m/2) + j*} (if i+j+k is odd),
where
i* = i/2 (if i is even),
(m-1-i)/2 (if i is odd),
j* = j/2 (if j is even),
(m-1-j)/2 (if j is odd),
k* = k/2 (if k is even),
(m-1-k)/2 (if k is odd),
t = min[{(i* + j* - 2k*) mod (m/2)}, {(-i* - j* + 2k*) mod (m/2)}],
v0 = 4(k mod 2) + 2(j mod 2) + {(i+j+k) mod 2},
v1 = 7 - v0/2 (if v0 is even),
3 - (v0-1)/2 (if v0 is odd).

By generalizing this method, we can construct an associated panmagic hypercube of any singly-even order and any odd dimension.

Note (for m = 4x+2 and m >= 10)

If m is 10 or higher singly-even integer, we can construct another associated pantriagonal magic cube of order m. Such a magic cube aijk, where i,j,k = 0,...,m-1, is given by the following equations:
when m is not divisible by 3:
aijk = bijk (m/2)3 + cijk (m/2)2 + dijk (m/2) + eijk + 1,

when m is divisible by 3:
aijk = bijk (m/2)3 + Sm/2(cijk) (m/2)2 + Sm/2(dijk) (m/2) + Sm/2(eijk) + 1,

where
Sm/3(x) = Qm/6,3([x/3], x mod 3).

Qp,q(x, y), where 0 <= x < p and 0 <= y < q, is given by the following equations (identical to Qp,q(x, y) for Nasik magic cubes):
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).

See the page for Nasik magic cubes to see examples of Qp,q(x, y) and Sm,q(x).

The cubes bijk, cijk, dijk, and eijk are defined as follows:
bijk = G*8,m/2(v, z),
cijk = i + j + k + 1   (mod. m/2),   0 <= cijk < m/2,
dijk = i - j + k   (mod. m/2),   0 <= dijk < m/2,
eijk = i + j - k   (mod. m/2),   0 <= eijk < m/2,

where
v = 4[2i/m] + 2[2j/m] + {([2i/m] + [2j/m] +[2k/m]) mod 2},   (0 <= v <= 7),
z = i + j + k - 3(m-2)/4   (mod. m/2),   -(m-2)/4 <= z <= (m-2)/4.

The function G*N,m/2(v, z) (where N is a power of 2, m/2 is odd, and 0 <= v < N) is defined as follows:
when m/2 = 3 (mod. 4):
G*N,m/2(v, z) = v (if z = 0),
v/2 (if |z| > 0, z is even, and v is even),
N/2 + (v-1)/2 (if |z| > 0, z is even, and v is odd),
N - 1 - v/2 (if |z| > 0, z is odd, and v is even),
N/2 - 1 - (v-1)/2 (if |z| > 0, z is odd, and v is odd).

when m/2 = 1 (mod. 4):
G*N,m/2(v, z) = v (if z = 0),
N - 1 - v (if |z| = 1),
v/2 (if |z| > 1, z is even, and v is even),
N/2 + (v-1)/2 (if |z| > 1, z is even, and v is odd),
N - 1 - v/2 (if |z| > 1, z is odd, and v is even),
N/2 - 1 - (v-1)/2 (if |z| > 1, z is odd, and v is odd).

The function G*N,m/2(v, z) satifies the following properties (only these properties are needed for G*N,m/2(v, z)).

(1) { G*N,m/2(v, z) | 0 <= v < N } = { 0, 1, ..., N-1 } for every integer z,
(2) The sum Sumz=0,m/2-1{G*N,m/2(2v, z)} is independent of v,
(3) Sumz=0,m/2-1{G*N,m/2(2v, z)} + Sumz=0,m/2-1{G*N,m/2(2v+1, z)} = (N-1)m/2,
(4) G*N,m/2(v, z) = G*N,m/2(v, -z),
(5) G*N,m/2(v, z) + G*N,m/2(N-1-v, z) = N-1.

Here is an example for m = 10.

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