 English Japanese Home Site Map Top Prev.   3-D ( 1   2   3   4   5 )   4-D ( 1   2   3   4   5   6 )

# Algorithms to make Nasik magic tesseracts

[Order 16x] [Order 2x+1]

## 1. Algorithms for orders divisible by 16

A Nasik magic tesseract (namely, a pan-2,3,4-agonal magic tesseract) of even order can exist only if the order is divisible by 16. In this case, if the order is 32 or higher, an associated Nasik magic tesseract, which is 4D-compact or non-4D-compact, exists.

### 1.1 Non-associated Nasik magic tesseracts (m = 16x) (also complete and 4D-compact)

A Nasik magic tesseract aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation (aijkh is also complete and 4D-compact):
aijkh = Tm(bijkh) m3 + Tm(cijkh) m2 + Tm(dijkh) m + Tm(eijkh) + 1,

where
bijkh = i + (m/8)j + (m/4)k + (m/2)h   (mod. m),   0 <= bijkh < m,
cijkh = (m/2)i + j + (m/8)k + (m/4)h   (mod. m),   0 <= cijkh < m,
dijkh = (m/4)i + (m/2)j + k + (m/8)h   (mod. m),   0 <= dijkh < m,
eijkh = (m/8)i + (m/4)j + (m/2)k + h   (mod. m),   0 <= eijkh < 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 tesseract is expressed as follows by the XmlHypercube format by Aale de Winkel:
for m = 16:
LP({1,2,4,8},{8,1,2,4},{4,8,1,2},{2,4,8,1})= [0,1,2,3,4,5,6,7,15,14,13,12,11,10,9,8]
In general:
LP({1,m/8,m/4,m/2},{m/2,1,m/8,m/4},{m/4,m/2,1,m/8},{m/8,m/4,m/2,1})= [0,..,m/2-1,m-1,...,m/2]

Note
It can be proved that every order-16 Nasik magic tesseract is complete and 4D-compact, so an order-16 associated Nasik magic tesseract cannot exist. On the other hand, if the order is higher than 16 and divisible by 16, there exists a Nasik magic tesseract which is not complete or not 4D-compact. See 1.2 and 1.3 for non-complete Nasik magic tesseracts. A Nasik magic tesseract which is complete but not 4D-compact is constructed by the following XmlHypercube format.
There cannot exist a Nasik magic tesseract which is 2D-compact or 3D-compact.

m >= 32 and m is divisible by 32 (Nasik, complete, but not 4D-compact) :
LP({1,m/16,m/8,m/4},{m/4,1,m/16,m/8},{m/8,m/4,1,m/16},{m/16,m/8,m/4,1})= [0,..,m/2-1,m-1,...,m/2]
m >= 32 and m is divisible by 16 but not by 32 (Nasik, complete, but not 4D-compact) :
LP({8,m/16,m/8,m/4},{m/4,8,m/16,m/8},{m/8,m/4,8,m/16},{m/16,m/8,m/4,8})= [0,..,m/2-1,m-1,...,m/2]

Compare with the case of Nasik magic cubes. Back

### 1.2 Assciated Nasik magic tesseracts (m = 16x, m >= 32) (non-4D-compact)

#### 1.2.1 Case m = 32x

An associated Nasik magic tesseract (non-4D-compact) aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation:
aijkh = Um(bijkh) m3 + Um(cijkh) m2 + Um(dijkh) m + Um(eijkh) + 1,

where
bijkh = i + (m/16)j + (m/8)k + (m/4)h + 7m/32   (mod. m),   0 <= bijkh < m,
cijkh = (m/4)i + j + (m/16)k + (m/8)h + 7m/32   (mod. m),   0 <= cijkh < m,
dijkh = (m/8)i + (m/4)j + k + (m/16)h + 7m/32   (mod. m),   0 <= dijkh < m,
eijkh = (m/16)i + (m/8)j + (m/4)k + h + 7m/32   (mod. m),   0 <= eijkh < m,
Um(x) = x (if x < m/4 or x >= 3m/4),   m-1-x (otherwise).

This tesseract is expressed as follows by the XmlHypercube format by Aale de Winkel:
for m = 32:
LP({1,2,4,8},{8,1,2,4},{4,8,1,2},{2,4,8,1})= [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,6]

#### 1.2.2 Case m = 32x+16 and m >= 48

An associated Nasik magic tesseract (non-4D-compact) aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation:
aijkh = Um,8(bijkh) m3 + Um,8(cijkh) m2 + Um,8(dijkh) m + Um,8(eijkh) + 1,

where
bijkh = 8i + (m/16)j + (m/8)k + (m/4)h + 7(m/16+1)/2   (mod. m),   0 <= bijkh < m,
cijkh = (m/4)i + 8j + (m/16)k + (m/8)h + 7(m/16+1)/2   (mod. m),   0 <= cijkh < m,
dijkh = (m/8)i + (m/4)j + 8k + (m/16)h + 7(m/16+1)/2   (mod. m),   0 <= dijkh < m,
eijkh = (m/16)i + (m/8)j + (m/4)k + 8h + 7(m/16+1)/2   (mod. m),   0 <= eijkh < m,.
Um,8(x) = Pm,16(x mod 16, x mod (m/16)).

Pm,16(x, y) (where 0 <= x < 16, 0 <= y < m/16) is given by the following table, where e = m/16 and q = (m/16-3)/2.
When m = 48 (q = 0), only the center part colored by dark green is available.

 0 16+0 ... 16(q-1)+0 16q+0 16q+30 16q+8 16(q-1)+15 ... 16+15 15 2 16+2 ... 16(q-1)+2 16q+2 16q+26 16q+10 16(q-1)+13 ... 16+13 13 12 16+12 ... 16(q-1)+12 16q+11 16q+24 16q+3 16(q-1)+3 ... 16+3 3 14 16+14 ... 16(q-1)+14 16q+9 16q+28 16q+1 16(q-1)+1 ... 16+1 1 5 16+5 ... 16(q-1)+5 16q+5 16q+20 16q+13 16(q-1)+10 ... 16+10 10 7 16+7 ... 16(q-1)+7 16q+7 16q+16 16q+15 16(q-1)+8 ... 16+8 8 9 16+9 ... 16(q-1)+9 16q+14 16q+18 16q+6 16(q-1)+6 ... 16+6 6 11 16+11 ... 16(q-1)+11 16q+12 16q+22 16q+4 16(q-1)+4 ... 16+4 4 16(e-1)+11 16(e-2)+11 ... 16(e-q)+11 16q+43 16q+25 16q+35 16(e-q)+4 ... 16(e-2)+4 16(e-1)+4 16(e-1)+9 16(e-2)+9 ... 16(e-q)+9 16q+41 16q+29 16q+33 16(e-q)+6 ... 16(e-2)+6 16(e-1)+6 16(e-1)+7 16(e-2)+7 ... 16(e-q)+7 16q+32 16q+31 16q+40 16(e-q)+8 ... 16(e-2)+8 16(e-1)+8 16(e-1)+5 16(e-2)+5 ... 16(e-q)+5 16q+34 16q+27 16q+42 16(e-q)+10 ... 16(e-2)+10 16(e-1)+10 16(e-1)+14 16(e-2)+14 ... 16(e-q)+14 16q+46 16q+19 16q+38 16(e-q)+1 ... 16(e-2)+1 16(e-1)+1 16(e-1)+12 16(e-2)+12 ... 16(e-q)+12 16q+44 16q+23 16q+36 16(e-q)+3 ... 16(e-2)+3 16(e-1)+3 16(e-1)+2 16(e-2)+2 ... 16(e-q)+2 16q+37 16q+21 16q+45 16(e-q)+13 ... 16(e-2)+13 16(e-1)+13 16(e-1)+0 16(e-2)+0 ... 16(e-q)+0 16q+39 16q+17 16q+47 16(e-q)+15 ... 16(e-2)+15 16(e-1)+15

Compare with the definition of Pm,8(x, y) for Nasik magic cubes.

Pm,16(x, y) satifies the following properties (only these properties are needed for Pm,16(x, y)).
(1) 0 <= Pm,16(x, y) < m,
(2) If Pm,16(x, y) = Pm,16(x', y') then x = x' and y = y'   (normal),
(3) Sumv=0,3 {Pm,16(x+4v, y)} = 2(m-1)   (for 0 <= x < 4 and 0 <= y < m/16),
(4) Sumv=0,m/16-1 {Pm,16(x, v) + Pm,16(x+8, v)} = m(m-1)/16   (for 0 <= x < 8),
(5) Pm,16(x, y) + Pm,16(15-x, m/16-1-y) = m-1   (associated). Back

### 1.3 Assciated Nasik magic tesseracts (m = 16x, m >= 32) (also 4D-compact)

#### 1.3.1 Case m = 32x

An associated 4D-compact Nasik magic tesseract aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation:
aijkh = bijkh m3 + cijkh m2 + dijkh m + eijkh + 1,

where
bijkh = Um(b*ijkh) (if i is even), m - 1 - Um(b*ijkh) (if i is odd),
cijkh = Um(c*ijkh) (if j is even), m - 1 - Um(c*ijkh) (if j is odd),
dijkh = Um(d*ijkh) (if k is even), m - 1 - Um(d*ijkh) (if k is odd),
eijkh = Um(e*ijkh) (if h is even), m - 1 - Um(e*ijkh) (if h is odd),

b*ijkh = j* + (m/16)k* + (m/8)h*   (mod. m),   0 <= b*ijkh < m,
c*ijkh = k* + (m/16)h* + (m/8)i*   (mod. m),   0 <= c*ijkh < m,
d*ijkh = h* + (m/16)i* + (m/8)j*   (mod. m),   0 <= d*ijkh < m,
e*ijkh = i* + (m/16)j* + (m/8)k*   (mod. m),   0 <= e*ijkh < 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),
h* = h (if h is even), m - 1 - h (if h is odd),

Um(x) = x (x < m/4 or x >= 3m/4), m-1-x (otherwise)    (identical to the definition of Um(x) in 1.2.1).

#### 1.3.2 Case m = 32x+16 and m >= 48

An associated 4D-compact Nasik magic tesseract aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation:
aijkh = bijkh m3 + cijkh m2 + dijkh m + eijkh + 1,

where
bijkh = Um,8(b*ijkh) (if i is even), m - 1 - Um,4(b*ijkh) (if i is odd),
cijkh = Um,8(c*ijkh) (if j is even), m - 1 - Um,4(c*ijkh) (if j is odd),
dijkh = Um,8(d*ijkh) (if k is even), m - 1 - Um,4(d*ijkh) (if k is odd),
eijkh = Um,8(e*ijkh) (if h is even), m - 1 - Um,4(d*ijkh) (if h is odd),

b*ijkh = 4j* + (m/16)k* + (m/8)h*   (mod. m),   0 <= b*ijkh < m,
c*ijkh = 4k* + (m/16)h* + (m/8)i*   (mod. m),   0 <= c*ijkh < m,
d*ijkh = 4h* + (m/16)i* + (m/8)j*   (mod. m),   0 <= d*ijkh < m,
e*ijkh = 4i* + (m/16)j* + (m/8)k*   (mod. m),   0 <= e*ijkh < 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),
h* = h (if h is even), m - 1 - h (if h is odd),

Um,8(x) = Pm,16(x mod 16, x mod (m/16)).    (identical to the definition of Um,8(x) in 1.2.2). Back

## 2. Algorithms for odd orders

A Nasik (namely, pan-2,3,4-agonal) magic tesseract of odd order can exist only if the order is higher than 16, and an associated Nasik magic tesseract of odd order can exist under the same condition.
Let L15 be lcm{y| y is odd and 3 <= y <= 15} = 32x5x7x11x13, where lcm means the least common multiple, and gcd means the greatest common divisor.

### 2.1 Case m = 2x+1, m >= 17, and gcd(m, L15) = 1 (associated)

In this case, m is prime to 3, 5, 7, 11, and 13.
A Nasik magic tesseract aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation:
aijkh = bijkh m3 + cijkh m2 + dijkh m + eijkh + 1,

where
bijkh = i + 2j + 4k + 8h + 7   (mod. m),   0 <= bijkh < m,
cijkh = i - 2j + 4k + 8h + 5   (mod. m),   0 <= cijkh < m,
dijkh = i + 2j - 4k + 8h + 3   (mod. m),   0 <= dijkh < m,
eijkh = i + 2j + 4k - 8h - 1   (mod. m),   0 <= eijkh < m.

This tesseract is expressed as follows by the XmlHypercube format by Aale de Winkel:
LP({1,2,4,8}+7,{1,-2,4,8}+5,{1,2,-4,8}+3,{1,2,4,-8}-1)

### 2.2 Case m = 2x+1, m >= 17, and 1 < gcd(m, L15) < m (associated)

Let q be gcd(m, L15) and p be m/q. In this case, p > 1 and q > 1.
A Nasik magic tesseract aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation:
aijkh = Sm,q(bijkh) m3 + Sm,q(cijkh) m2 + Sm,q(dijkh) m + Sm,q(eijkh) + 1,

where
bijkh = i + 2j + 4k + 8h + 7   (mod. m),   0 <= bijkh < m,
cijkh = i - 2j + 4k + 8h + 5   (mod. m),   0 <= cijkh < m,
dijkh = i + 2j - 4k + 8h + 3   (mod. m),   0 <= dijkh < m,
eijkh = i + 2j + 4k - 8h - 1   (mod. m),   0 <= eijkh < m,
Sm(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 (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).

### 2.3 Case m = 2x+1, m >= 17, and gcd(m, L15) = m (associated)

In this case, m is a divisor of L15 = 32x5x7x11x13.
A Nasik magic tesseract aijkh of order m, where i,j,k,h = 0,...,m-1, is given by the following equation:
aijkh = S**m(bijkh) m3 + S**m(cijkh) m2 + S**m(dijkh) m + S**m(eijkh) + 1,

where
bijkh = i + 2j + 4k + 8h + 7   (mod. m),   0 <= bijkh < m,
cijkh = i - 2j + 4k + 8h + 5   (mod. m),   0 <= cijkh < m,
dijkh = i + 2j - 4k + 8h + 3   (mod. m),   0 <= dijkh < m,
eijkh = i + 2j + 4k - 8h - 1   (mod. m),   0 <= eijkh < m,

where [x] means the integer part of x.
S**m(x) is defined as follows:

(1) if m is NOT equal to 45
S**m(x) = Rq,m/q(x mod q, x mod (m/q)) - 1,

where q is the greatest prime factor of m (q is equal to 7, 11, or 13).
Rq,m/q is an associated magic rectangle of order-(q,m/q). See the page for magic rectangles.

(2) if m is equal to 45
S**m(x) = R3,3,5((x/3) mod 3, x mod 3, x mod 5) - 1.

R3,3,5 is an associated 3-dimensional magic rectangle of order (3,3,5). Concretely, it is given by the following tables:

a magic rectangle of order (3,5,7) (associated) (shown as an order-(3,5,3) rectangle R3,5,3)

 31 3 38 13 30 24 41 12 36 2 14 25 19 20 37
 29 40 4 35 7 1 18 23 28 45 39 11 42 6 17
 9 26 27 21 32 44 10 34 5 22 16 33 8 43 15 Back Home Site Map Top Prev.   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 