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

[Order 8x] [Order 2x+1]

1. Algorithms for orders divisible by 8

   A pandiagonal magic cube of even order m can exist only if the order is divisible by 8. In this case, if the order is higher than 15, an associated pandiagonal magic cube can exist. Also refer the page for Nasik magic cubes, which class is higher than pandiagonal.

Note It is unknown whether an order-8 associated pandiagonal magic cube can exist or not.

1.1 Non-associated pandiagonal magic cubes (m = 8x)

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

where
Tm(x) = x (where x < m/2), 3m/2-1-x (otherwise)    (identical to the definition of Tm(x) for pantriagonal magic cubes).

The definitions of bijk, cijk, and dijk are as follows:
if i+j+k is even:
bijk = i + (m/4)j - (m/4+s)k   (mod. m),   0 <= bijk < m,
cijk = (m/4)i + j - (m/4+s)k   (mod. m),   0 <= cijk < m,
dijk = (m/4)i + (m/2)j + k   (mod. m),   0 <= dijk < m,

if i+j+k is odd:
bijk = -i - (m/4)j + (m/4+s)k + m/2   (mod. m),   0 <= bijk < m,
cijk = -(m/4)i - j + (m/4+s)k + m/2   (mod. m),   0 <= cijk < m,
dijk = (m/4)i + (m/2)j + k   (mod. m),   0 <= dijk < m,

where
s = -1 (if m-24 is divisible by 32), 1 (otherwise).

1.2 Associated pandiagonal magic cubes (m = 8x, m >= 16)

1.2.1 Case m = 16x

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

where
Tm(x) = x (where x < m/2), 3m/2-1-x (otherwise),
Um(x) = x (if x < m/4 or x >= 3m/4), m-1-x (otherwise).
(identical to the definitions of Tm(x) and Um(x) for pantriagonal magic cubes)

The definitions of bijk, cijk, and dijk are as follows:
if i+j+k is even:
bijk = i + (m/4)j - (m/4+s)k   (mod. m),   0 <= bijk < m,
cijk = (m/4)i + j - (m/4+s)k   (mod. m),   0 <= cijk < m,
dijk = (m/4)i + (m/8)j + k + 3m/16   (mod. m),   0 <= dijk < m,

if i+j+k is odd:
bijk = -i - (m/4)j + (m/4+s)k + m/2   (mod. m),   0 <= bijk < m,
cijk = -(m/4)i - j + (m/4+s)k + m/2   (mod. m),   0 <= cijk < m,
dijk = (m/4)i + (m/8)j + k + 3m/16   (mod. m),   0 <= dijk < m,

where
s = -1 (if m-24 is divisible by 32), 1 (otherwise).

1.2.2 Case m = 16x+8, m >= 24

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

Tm(x) is already defined in the case of m = 16x. Um,4(x) is defined in the page for Nasik magic cubes.
The definitions of bijk, cijk, and dijk are as follows:
if i+j+k is even:
bijk = i + (m/4)j - (m/4+s)k   (mod. m),   0 <= bijk < m,
cijk = (m/4)i + j - (m/4+s)k   (mod. m),   0 <= cijk < m,
dijk = (m/4)i + (m/8)j + 4k + 3(m/8+1)/2   (mod. m),   0 <= dijk < m,

if i+j+k is odd:
bijk = -i - (m/4)j + (m/4+s)k + m/2   (mod. m),   0 <= bijk < m,
cijk = -(m/4)i - j + (m/4+s)k + m/2   (mod. m),   0 <= cijk < m,
dijk = (m/4)i + (m/8)j + 4k + 3(m/8+1)/2   (mod. m),   0 <= dijk < m,

where
s = -1 (if m-24 is divisible by 32), 1 (otherwise).

Back

2. Algorithms for odd orders

   A pandiagonal magic cube of odd order m can exist only if the order is higher by 6, and an associated pandiagonal 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 >= 7, and gcd(m, 3x5) = 1 (associated)

In this case, m is prime to both 3 and 5.
A pandiagonal 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 + 3k + {(m-1)/2+3}   (mod. m),   0 <= bijk < m,
cijk = i + 3j + 2k + {(m-1)/2+3}   (mod. m),   0 <= cijk < m,
dijk = 2i + 3j - k + {(m-1)/2+2}   (mod. m),   0 <= dijk < m.

2.2 Case m = 2x+1, m >= 7, and 1 < gcd(m, 3x5) < m (associated)

Let q be gcd(m, 3x5) and p be m/q. In this case, p > 1 and q > 1.
A pandiagonal magic cube aijk of order m, 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 + 3k + {(m-1)/2+3}   (mod. m),   0 <= bijk < m,
cijk = i + 3j + 2k + {(m-1)/2+3}   (mod. m),   0 <= cijk < m,
dijk = 2i + 3j - k + {(m-1)/2+2}   (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 (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 >= 7, and gcd(m, 3x5) = m (associated)

In this case, always m = 15.
A pandiagonal magic cube aijk of order m, where i,j,k = 0,...,m-1, is given by the following equation:
aijk = S*(bijk) m2 + S*m(cijk) m + S*m(dijk) + 1,

where
bijk = i + 2j + 3k + {(m-1)/2+3}   (mod. m),   0 <= bijk < m,
cijk = i + 3j + 2k + {(m-1)/2+3}   (mod. m),   0 <= cijk < m,
dijk = 2i + 3j - k + {(m-1)/2+2}   (mod. m),   0 <= dijk < m,
S*15(x) = R3,5(x mod 3, x mod 5) - 1.

R3,5 is an order-(3,5) associated magic rectangle. For more information, see the page for Nasik magic cubes.

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.
This page was last updated on October 1, 2007.
"Magic Cubes and Tesseracts"   http://homepage2.nifty.com/googol/magcube/en/
Copyright © 2004-2007, Mitsutoshi Nakamura. All rights reserved.

RSS
blog seo tool : track word  blog SEO tool