n-DIMENSIONAL MAGIC FIGURES

While trying to find a workable process to make the 5 dimensional magic figure I found that using compatible groups improved the chances of making a valid magic hypercube. I also found that focusing primarily on one base line for each base line type was useful. I finally realized that the e base lines were the key. I built a 5-D counterpart of the 6-D hypercube shown below, and it worked. So do the tesseract, cube, and square counterparts. My statements below are derived from working with the 5-D hypercube and to some degree the tesseract and cube. I believe that all are applicable to n-dimensions but cannot always come up with a mathematical reason for why they work.

The base lines for a perfect 6-D magic hypercube are shown below. Relative to the immense number of possible hypercubes that can be made using base lines, it is a very simple construct. The numbers for the f base lines are written in base 16 as it is so much easier to do and the underlying 64-bit code pattern is much easier to derive. The f base line numbers actually represent just the first 32 bits of the base line. The other 32 bits are the inverse of the first 32. The f0x0 base line is thus 32 zero's followed by 32 one's. For anyone not familiar with the format used for the number, the initial 0x indicates that the number that follows is written in base sixteen. An alternate way of describing the 6-D magic hypercube is to use master base lines. Use of master base lines simplifies determination of a number at any position within the figure.

The combination of just the f base lines in the pattern below will produce all the numbers from 0 to (236-1). The resulting numbers are not, however, arranged correctly to make a magic hypercube. Addition of the a, b, c, d, and e base lines rearranges the numbers so that a valid magic hypercube is created. In other words uniform integral distribution can be achieved using only the f base lines, but in order to make a valid perfect 6-D magic hypercube all six base line types must be present in each of the 36 base hypercubes. A combination of uniform integral distribution and valid base hypercubes will insure that the finished hypercube is valid.

Sample Perfect 6-D Magic Hypercube
base # row column pillar file fifth sixth
1 a b0 c0 d0 e0 f0x0
2 a b0 c0 d0 e0 f0xffff
3 a b0 c0 d0 e0 f0xff00ff
4 a b0 c0 d0 e0 f0xf0f0f0f
5 a b0 c0 d0 e0 f0x33333333
6 a b0 c0 d0 e0 f0x55555555
7 a b0 c0 d0 f0x0 e0
8 a b0 c0 d0 f0xffff e0
9 a b0 c0 d0 f0xff00ff e0
10 a b0 c0 d0 f0xf0f0f0f e0
11 a b0 c0 d0 f0x33333333 e0
12 a b0 c0 d0 f0x55555555 e0
13 a b0 c0 f0x0 d0 e0
14 a b0 c0 f0xffff d0 e0
15 a b0 c0 f0xff00ff d0 e0
16 a b0 c0 f0xf0f0f0f d0 e0
17 a b0 c0 f0x33333333 d0 e0
18 a b0 c0 f0x55555555 d0 e0
19 a b0 f0x0 c0 d0 e0
20 a b0 f0xffff c0 d0 e0
21 a b0 f0xff00ff c0 d0 e0
22 a b0 f0xf0f0f0f c0 d0 e0
23 a b0 f0x33333333 c0 d0 e0
24 a b0 f0x55555555 c0 d0 e0
25 a f0x0 b0 c0 d0 e0
26 a f0xffff b0 c0 d0 e0
27 a f0xff00ff b0 c0 d0 e0
28 a f0xf0f0f0f b0 c0 d0 e0
29 a f0x33333333 b0 c0 d0 e0
30 a f0x55555555 b0 c0 d0 e0
31 f0x0 a b0 c0 d0 e0
32 f0xffff a b0 c0 d0 e0
33 f0xff00ff a b0 c0 d0 e0
34 f0xf0f0f0f a b0 c0 d0 e0
35 f0x33333333 a b0 c0 d0 e0
36 f0x55555555 a b0 c0 d0 e0

VARIATIONS OF THE PERFECT 6-D MAGIC HYPERCUBE

I would be remiss if I did not now provide the means to make numerous additional perfect 6-D magic hypercube. There are generalizations that can be made to the basic structure that will generate many additional examples. Some are obvious and one at least to me is baffling.

Reordering base hypercubes

There are 36 base hypercubes in the figure above. These can be arranged in 36! different orders. Every order is a different valid pan-2,3,4,5,6-agonal magic cube of order 64.

Alternate base lines

In the example the b, c, d, and e base lines all have subscripts of zero. The subscripts may be any of their possible values as long as each base line type is the same throughout the matrix, i.e. all e14729's. This means 2 b states, 8 c's, 128 d's, and 32768 e's or 67,108,864 possible combinations using the pattern above.

Modified code orders

In the example the position of the a's, b's, c's, d's, and e's is alphabetical with the f base lines interdicting in an ordered pattern. The order does not need to be alphabetical. Any order is OK as long as the pattern is maintained. There are 5!, 120, different orders possible. The above are obvious extensions of rules discussed elsewhere. Altogether they give 36!*67108864*120 different valid 6-D hypercubes based on the pattern above.

Codes tied to f groups

The a, b, c, and d codes have been kept the same in the modifications discussed above. For any given set of 6 f codes, they must be kept the same. For each set of f codes the order of the a, b, c, and d codes can be different and their number subscript can be different.

Other compatible f groups

In the above figure the same set of six f base lines is used in every dimension. There are many sets of compatible f base lines. The process used to determine compatible sets is discussed in the Compatible Base Line Rules section of Base Cube Rules. Any of these compatible sets can be used. Using a different compatible set in each of the dimensions also works. Using different compatible sets in combination with the other modifications discussed above give a tremendous number of verifiable perfect 6-D magic hypercubes.

Left and right sides of the pattern

There is an additional modification to the pattern above that appears to work. I say appears because I do not have an explanation of why it works. The manipulation has always worked with the 5-dimensional hypercube. That leads me to believe that the approach is general.

The sample hypercube can be viewed as having three parts, the f base lines, the base lines on the left of the f base lines, and the base lines on the right. Modification of the f base lines has already been discussed. If one of the other two parts is left as is, then the remaining part can be modified indiscriminately as long as the base hypercube requirements are met, i.e. there is one of each type of base line in the base hypercube. Base hypercube 31 could thus be f0, c3, b0, e2167, a, and d95. The other base lines to the right of the f base lines may be shuffled and reassigned other numbers without regard to any of the others on the right side. The base lines on the left, however, are severely restricted. With a given set of base lines on the right some changes on the left may be possible but making those changes then restricts additional changes on the right.

The ability to modify one side of the pattern as above results in a tremendous number of different hypercubes. There are, however, many valid hypercubes that ignore these restrictive rules. These other hypercubes are at this point beyond my reach.

PROOF

Looking at the first table in Statistics, one can see the immensity of the problem encountered in attempting to verify uniform integral distribution in hypercubes of 6 dimensions or larger. I am certain that the rules I have outlined above work but it is always nice to have verification and verification for these figures requires proof of uniform integral distribution. Verifying uniform integral distribution for even one hypercube of 6 dimensions would be difficult with the methods used for the cube, tesseract, and 5-D hypercube. Fortunately it can be proved mathematically.

Requirements

As stated in Magic Cube Basics there are two things that must verified to confirm that a magic figure has indeed been made. The figure must add to the magic constant in all the required ways and the figure must have uniform integral distribution, i.e. all integers from 0 to 2n2.

Addition properties

A proof of the base cube addition properties was given in Magic Cube Basics. That proof can be extended to base figures of all dimensions. The only requirement is that the base figure have in one of its directions an a code, a b code, ... , and an nth letter code. For the 6-D figure above that means an a, b, c, d, e, and f code. All the base 6-D hypercubes above meet this requirement.

In Basic Construction the addition properties of base squares were discussed. The rules can be extended to n-dimensional figures as well. Thus the addition of 235 times the first base 6-D hypercube plus 234 times the second base 6-D hypercube plus ... plus 20 times the last base 6-D hypercube gives a magic 6-D hypercube with all the appropriate additions.

Uniform integral distribution, but not magic

As I find it hard to think in 6-D much of this discussion will based on the cube. The cube generator will be used to illustrate the procedure and the observations extended to higher dimensions. Open the cube generator and under RESTART select BASE LINE ARRAY. In the first three pillar boxes select c0, c3, and c5. In the middle three column boxes and the last three row boxes enter the same three codes. This is the equivalent of entering just the f codes in the 6-D figure above. In the bottom row of the first square observe the numbers 0, 1, 2, 3, 7, 6, 5, 4. The row above that, is 8 more than the bottom row, the next row is 16 more, then 24, 56, 48, 40, and 32. The second square is 64 more than the first, the next square is 128 more, then 192, 448, 384, 320, and 256. The result is that all numbers from 0 to 511 are present in the cube, i.e. uniform integral distribution, but this is not a magic cube.

When looked at in binary the pattern created in the cube is much clearer. In every row the last three bits going from left to right are always: 000, 001, 010, 011, 111, 110, 101, 100. In every column going from bottom to top the middle three bits are the same as above. And in every pillar going from front to back the first three bits are again as above. The other six bits of the binary number in any individual row, column or pillar are all the same.

For the 6-D hypercube, the first row contains the integers from 0 to 31 followed by 63 to 32. The columns start with multiples of 64 from 0 to 1984, then 4032 to 2048. The pillars multiples of 4096 from 0 to 126,976 then 258,408 to 131,072. The files multiples of 262,144, etc. Again resulting in uniform integral distribution but not the correct addition pattern. The pattern made by the binary bits is again very informative. Associated with the f group in every dimension is a group of six bits that first count up from 000000 to 011111 and then down from 111111 to 100000 for all the lines that go in that direction.

Shuffling the numbers

Returning to the uncompleted cube above we now put b0 into each of the last three column boxes. This reverses the two halves of each of the rows numbered 3, 4, 7, and 8 counting from the bottom up. For example, the third line up now reads 23, 22, 21, 20, 16, 17, 18, 19 instead of 16, 17, 18, 19, 23, 22, 21, 20. Now enter the a code into each of the last three pillar boxes. This reverses the two halves of each of the rows in the even numbered squares. Some rows are reversed back to where they started. Another way of describing the changes above is to say that the numbers in the affected rows underwent a (4,0,0) vector change.

It is clear when looking at the cube changes above that no numbers were lost, half were just moved to new locations. The changes occurred within the selected rows but it is important to note the pattern of movement in all dimensions. When the third row of the first square changed, the seventh row of the first square and the third row of the fifth square also changed. Put another way, when the third row underwent a (4,0,0) vector change, the rows located a (0,4,0) vector and a (0,0,4) vector away underwent the same change. This occurs because the first half and the second half of both the a and the b0 codes are identical and thus effect the same changes 4 bits away.

When dealing with the 6-dimensional hypercube the same approach as above is taken except that there are five dimensions to change with the five codes; a, b0, c0, d0, and e0. The last six rather than last three bits are affected. The first 32 bits are exchanged with the last 32 bits in the exchange or a (32,0,0,0,0,0) vector change. For every line that is changed there is a concomitant change in the lines located (0,32,0,0,0,0), (0,0,32,0,0,0), (0,0,0,32,0,0), (0,0,0,0,32,0), and (0,0,0,0,0,32) vectors away.

Uniform integral distribution and addition properties

Returning again to the uncompleted cube above we now put b0 into each of the middle three row boxes. This causes a (0,4,0) vector change in columns 3, 4, 7, and 8 in all eight squares. Enter the a code into each of the middle three pillar boxes. This results in a (0,4,0) vector change in all columns of the even numbered squares. For every pair of numbers that are exchanged, the three middle bits of the binary code are inverted. The other six bits of the exchanged numbers are identical. Note that some of the numbers moved by reversing the columns were previously moved when the rows were switched, however, because of the simultaneous switch of the rows located (0,4,0) or (0,0,4) vectors away the last three bits of the numbers switched by the column exchange are the same.

To complete the cube enter b0 into each of the first three row boxes. It should be apparent that this causes a (0,0,4) vector change to columns 3, 4, 7, and 8 of every square. The a code in each of the first three column boxes causes a (0,0,4) vector change to all the even numbered rows as counted from the bottom. Every exchange results only in the inversion of the first three bits of the nine bit binary code. The other six bits of the exchanged pairs are identical.

Starting with an intermediate cube with just the c codes, each step above has resulted only in movement of numbers to new locations. Uniform integral distribution was maintained throughout. As stated earlier if each base cube has a, b, and c codes then the addition properties will be correct. Therefore the process has created a perfect magic cube.

Other than the added complexities of greater size and more dimensions, filling in the rest of the 6-dimensional hypercube follows the same procedure. The numbers are exchanged using one of the six (a,b,c,d,e,f) vectors where one of the letters is 32 and the others all 0. Every exchange involves inversion of only one of the six sets of six bits in the binary code with the other 30 bits remaining the same. The set of six bits that is modified is the same set created by the f codes in those rows.

Variations

Most of the variations described above readily conform to the above proof. Using different compatible f groups in each section makes sense when you consider that the codes in the same rows as that f group only affect the same six bits of the binary code as the f codes. Using different b, c, d, and e codes consistently throughout the hypercube just changes the order of the numbers in the initial lines it does not affect the shuffling effects. Consistently placing the a, b, c, d, and e codes in different positions just places them in different dimensions where they accomplish the same task. Using different a, b, c, d, and e codes for each set of f codes is OK because the codes associated with a given set of f codes only effect that set of f codes. The only variation that is not explained is the ability to randomly modify either the left or right side of the matrix. I can't prove that, it is just an observation at this point.

THE PERFECT n-DIMENSIONAL MAGIC HYPERCUBES

From the example above it should be obvious how to make perfect magic hypercubes of any dimension. The matrix of base lines will have n columns and n2 rows. There must be a group of n compatible nth letter base lines in each column. There must be a base line of type a through the nth letter in each row. The subscripts for the letters follow the rules outlined above.

The value of the number at any position can be determined by taking an exclusive OR of the intersection of all the master base lines in binary at that position. The bit code value of all numbers will be n2 bits long including leading zeros if necessary. If the intersection in a direction is at the ith bit then the n2-bit code value for that dimension is the binary equivalent of the ith number of the master base line going in that direction. In like manner the n2-bit code value must be determined for all n dimensions. The exclusive OR combination of each of the n dimension's individual n2 bits is determined. The resulting n2 bit number is the number, in binary, at the position desired. This is the approach used by the 5-D Hypercube Generator's Magic Constant checker.

Looking at the first table in Statistics, one can see the immensity of the problem encountered in attempting to verify uniform integral distribution in hypercubes of 7 dimensions or larger. I am certain that the rules I have outlined above work but it is always nice to have verification and verification for these figures requires proof of uniform integral distribution. Verifying uniform integral distribution for even one hypercube of 6 dimensions would be difficult. It should be possible to verify a 6 dimensional hypercube, but it would take considerable time with my current resources. For now I leave verification of the higher dimensional hypercubes to others.