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 a_{ijk} of order m, where i,j,k = 0,...,m-1, is given by the following equation:

a_{ijk} = 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** 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 a_{ijk} is given by the following equation:

a_{ijk} = 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.

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

A diagonal magic cube a_{ijk} of order m, where i,j,k = 0,...,m-1, is given by the following equations:

when m is **not** divisible by 3:

a_{ijk} = b_{ijk} (m/2)^{3} + c_{ijk} (m/2)^{2} + d_{ijk} (m/2) + e_{ijk} + 1,

when m is divisible by 3:

a_{ijk} = b_{ijk} (m/2)^{3} + **S**_{m/2,3}(c_{ijk}) (m/2)^{2} + **S**_{m/2,3}(d_{ijk}) (m/2) + **S**_{m/2,3}(e_{ijk}) + 1,

where

**S**_{m/2,3}(x) = **Q**_{m/6,3}([x/3], x mod 3).

**Q**_{p,q}(x, y), where 0 <= x < p and 0 <= y < q, is given by the following equations (identical to **Q**_{p,q}(x, y) for Nasik magic cubes):

**Q**_{p,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 **Q**_{p,q}(x, y) and **S**_{m,q}(x).

The cubes b_{ijk}, c_{ijk}, d_{ijk}, and e_{ijk} are defined as follows:

b_{ijk} = D(**G**_{8}(v, z), i, j, k),

c_{ijk} = 2i + j + k (mod. m/2), 0 <= b_{ijk} < m/2,

d_{ijk} = i + 2j + k (mod. m/2), 0 <= c_{ijk} < m/2,

e_{ijk} = i + j + 2k (mod. m/2), 0 <= d_{ijk} < 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 **G**_{N}(v, z) (where N is a power of 2, 0 <= v < N, and z >= 0) is defined as follows:

when v is even:

**G**_{N}(v, 0) = v,

**G**_{N}(v, 1) = v + 1,

**G**_{N}(v, 2) = N/2 - 1 - v/2,

**G**_{N}(v, 3) = N - 1 - v/2,

**G**_{N}(v, 2x+4) = N - 1 - v for x >= 0,

**G**_{N}(v, 2x+5) = v for x >= 0,

when v is odd:

**G**_{N}(v, 0) = v,

**G**_{N}(v, 1) = v - 1,

**G**_{N}(v, 2) = N - 1 - (v-1)/2,

**G**_{N}(v, 3) = N/2 - 1 - (v-1)/2,

**G**_{N}(v, 2x+4) = N - 1 - v for x >= 0,

**G**_{N}(v, 2x+5) = v for x >= 0.

The function **G**_{N}(v, z) satifies the following properties (only these properties are needed for **G**_{N}(v, z)).

(1) { **G**_{N}(v, z) | 0 <= v < N } = { 0, 1, ..., N-1 } for every z such that 0 <= z < m/2,

(2) If v is even, Sum_{z=0,m/2-1}{**G**_{N}(v, z)} = (N-1)(m-2)/4 + N/2,

(3) If v is odd, Sum_{z=0,m/2-1}{**G**_{N}(v, z)} = (N-1)(m-2)/4 + N/2 - 1,

(4) **G**_{N}(2v, 0) = **G**_{N}(2v+1, 1), **G**_{N}(2v, 1) = **G**_{N}(2v+1, 0), **G**_{N}(2v, 1) - **G**_{N}(2v, 0) = 1,

(5) **G**_{N}(v, 0) + **G**_{N}(N-1-v, 0) = N-1.

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

The function D(x, i, j, k) defined as follows is used to adjust the diagonals of b_{ijk}.

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.

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.

Magic Cubes and Tesseracts