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

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

## 1. Algorithm for orders divisible by 4

A diagonal magic cube of order m divisible by 4 can exist only if the order is higher than 4. An associated diagonal magic cube can exist under the same condition.

### 1.1 Associated diagonal magic cubes (m = 4x, m >= 8)

An associated diagonal magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = a*pqr,

where
p = i (i < m/2),   3m/2 - 1 - i (i >= m/2),
q = j (j < m/2),   3m/2 - 1 - j (j >= m/2),
r = k (k < m/2),   3m/2 - 1 - k (k >= m/2).

a*pqr is a pantriagonal diagonal or Nasik magic cube which is also complete. For more information, see the page for pantriagonal diagonal magic cubes or Nasik magic cubes.

Back

## 2. Algorithm for odd orders

A diagonal magic cube of odd order m can exist only if the order is higher than 4. An associated diagonal magic cube can exist under the same condition. This algorithm works for orders higher than 6.

Note Here is an order-5 diagonal magic cube. An algebraic construction method for an order-5 diagonal magic cube is still unknown.
Note It is unknown whether an order-5 associated diagonal magic cube can exist or not.

### 2.1 Associated diagonal magic cubes (m = 2x+1, m >= 7)

This condition is satisfied by an order-m associated pandiagonal magic cube, which exists for every odd order higher than 6. If you would like to construct an associated diagonal magic cube that is not pandiagonal, you can use the following method.
Let a*ijk, where i,j,k = 0,...,m-1, be an order-m associated pandiagonal magic cube, then the diagonal magic cube aijk is given by the following equation:
aijk = a*pqr,

where
p = f(i), q = f(j), r = f(k),
f(0) = 1, f(1) = 0, f(m-2) = m-1, f(m-1) = m-2, f(x) = x for 1 < x < m-1.

Back

## 3. Algorithm for singly-even orders

A diagonal magic cube can exist for any singly-even (even but not divisible by 4) order higher than 4. This algorithm works for orders higher than 6.

Note Examples of order-6 diagonal magic cubes are here. An algebraic construction method for an order-6 diagonal magic cube is still unknown.
Note A diagonal magic cube of singly-even order cannot be associated.

### 3.1 Non-associated diagonal magic cubes (m = 4x+2, m >= 10)

A diagonal magic cube aijk of order m, 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,3(cijk) (m/2)2 + Sm/2,3(dijk) (m/2) + Sm/2,3(eijk) + 1,

where
Sm/2,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 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 = D(G8(v, z), i, j, k),
cijk = 2i + j + k   (mod. m/2),   0 <= bijk < m/2,
dijk = i + 2j + k   (mod. m/2),   0 <= cijk < m/2,
eijk = i + j + 2k   (mod. m/2),   0 <= dijk < m/2,

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

The function GN(v, z) (where N is a power of 2, 0 <= v < N, and z >= 0) is defined as follows:
when v is even:
GN(v, 0) = v,
GN(v, 1) = v + 1,
GN(v, 2) = N/2 - 1 - v/2,
GN(v, 3) = N - 1 - v/2,
GN(v, 2x+4) = N - 1 - v   for x >= 0,
GN(v, 2x+5) = v   for x >= 0,

when v is odd:
GN(v, 0) = v,
GN(v, 1) = v - 1,
GN(v, 2) = N - 1 - (v-1)/2,
GN(v, 3) = N/2 - 1 - (v-1)/2,
GN(v, 2x+4) = N - 1 - v   for x >= 0,
GN(v, 2x+5) = v   for x >= 0.

The function GN(v, z) satifies the following properties (only these properties are needed for GN(v, z)).

(1) { GN(v, z) | 0 <= v < N } = { 0, 1, ..., N-1 } for every z such that 0 <= z < m/2,
(2) If v is even, Sumz=0,m/2-1{GN(v, z)} = (N-1)(m-2)/4 + N/2,
(3) If v is odd, Sumz=0,m/2-1{GN(v, z)} = (N-1)(m-2)/4 + N/2 - 1,
(4) GN(2v, 0) = GN(2v+1, 1), GN(2v, 1) = GN(2v+1, 0), GN(2v, 1) - GN(2v, 0) = 1,
(5) GN(v, 0) + GN(N-1-v, 0) = N-1.

The condition (4) is required for the adjustment of the diagonals of bijk by the function D(x, i, j, k) defined below, and (5) is required for the magicness of the four triagonals of bijk.

The function D(x, i, j, k) defined as follows is used to adjust the diagonals of bijk.
D(x, i, j, k) = x or {x + (-1)x}.

We define D(x, i, j, k) = x + (-1)x only if i, j, and k satisfy one of the following conditions:
• j* = k* + 1 (mod. m/2),   i >= m/2,   i* = k*.
• j* = k* + 1 (mod. m/2),   i >= m/2,   i* = k* - 1 (mod. m/2).
• i* = k* + 1 (mod. m/2),   j >= m/2,   j* = k*.
• i* = k* + 1 (mod. m/2),   j >= m/2,   j* = k* - 1 (mod. m/2).
• j* = k* + (m+2)/4 (mod. m/2),   i >= m/2,   i* = j*.
• j* = k* + (m+2)/4 (mod. m/2),   i >= m/2,   i* = j* - 1 (mod. m/2).
Recall that i*, j*, and k* are defined as i* = min{i, m-1-i}, j* = min{j, m-1-j}, and k* = min{k, m-1-k}, respectively.

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.