Higher dimensional magic figures can be built using obvious extensions of the properties of the order-4 pan-magic squares. There are additional factors to consider as each new dimension is added. Some are related to the new dimensions while others are related to the increasing size of the base lines and resulting exponential increase in size of the figure.

The magic cube counterpart of the 4 by 4 pan-magic squares is an 8 by 8 by 8 matrix of 512 consecutive numbers. For the numbers 1 to 512 each row, column, and pillar must add to 2052. In addition, the diagonals and broken diagonals of every 8 by 8 square and the four 3-D diagonals and all broken diagonals of the cube must add to the magic constant. The above properties are the requirements for the subset of magic cubes that are often called nasik magic cubes or nasik magic cubes of order-8, but are more precisely called order-8 pan-2,3-agonal magic cubes. In this name pan indicates the property of moving a face from one side of the cube to the other whereas for a square it was a column or row. The 2,3-agonal indicates the 2 and 3-dimensional diagonals of the cube. Order-8 means it is an 8 by 8 by 8 cube, the smallest nasik cube that can be made.

As a bonus, the cubes described here have every 2 by 2 by 2 cube, the corners of the cube, and the corners of every 3 by 3 by 3, 4 by 4 by 4, 5 by 5 by 5, 6 by 6 by 6, and 7 by 7 by 7 cube add to 2052. In addition, the corners of many rectangular prisms, shifted rows, shifted columns, shifted pillars, shifted diagonals, and other patterns add to the magic constant. Many easily described patterns within the cube always add to 2052. Finally, the addition properties for these cubes are maintained when faces of the cube are wrapped around to the opposite side in any order.


The first cube of this type has been attributed to Barnard1. A cube attributed to Frankenstein has often been called the first known perfect magic cube, but Frankenstein's cube does not include broken diagonals and thus is not nasik by the current definition. Another example was described by Planck2 in 1905. The next published example of this type of cube, submitted by Dwane H. Campbell, was described in the puzzle section of the 1979 issue of The Old Farmers Almanac. The solution to the puzzle in that issue is available through Yankee, Inc. This latter cube may be the first example of the subset described here. Barnard's and Planck's cubes cannot be constructed using the procedure outlined in this discussion although most other characteristics are the same. The first two cubes and their history can be found on Heinz's site.

There have been other nasik order-8 magic cubes published subsequent to 1979. Benson and Jacoby5 published a cube in 1982 that is the same as Planck's except that the numbers were translated using the wrap around property of the cube so that the 1 appears in the lower left corner of the front square of the cube. By most definitions, this would not be considered a different cube. It is only visually different. Hendricks'3 cube appears to have been constructed by a process that is similar to Barnard's cube and thus distinct from the focus subset described herein. Nakamura also has an algorithm to generate a cube of this type on his site. Abe's4 cube is part of the subset described here. The publication date given on Nakamura's site is 1983, but Abe's notes suggest it was first constructed in 1949. Can anyone confirm this date? See the references for further reading.

Hendricks3 also describes a nasik tesseract and a nasik 5-D hypercube. These also are made differently than those described here. It is not possible to make them using the downloadable tesseract and hypercube generators.

Cube Base Lines

As described in Basic Concepts the cube is constructed by combining three 8-bit base lines, one for each dimension. In one dimension is the A0 base line. Like the A0 base line in the order-4 squares, it has alternating 0's and 1's. This is the 8-bit equivalent of the decimal number 85. It can also be described as a repetition of the A0 base line from the order-4 square to fill the 8 bits. In the second dimension is one of the B base lines converted to an 8-bit code equivalent of 51 or 102. Again equivalent to repeating the two order-4 square B base lines.

The third dimension contains one of the C base lines shown in Basic Concepts: 15, 30, 45, 60, 75, 90, 105, or 120 converted to an 8-bit number. These codes are easily generated by entering the 4-bit equivalents of 0-7 in the first four bits of the 8-bit base lines. The inverse of the first four bits are entered into the last four bits of the base line.

Weaving Cube Base Lines

With the A0 base line in the first dimension, two possible B base lines in the second dimension, and eight possible C base lines in the third dimension, 16 possible base cubes are described. There is no reason that the A0 base line be confined to the first dimension, etc. In fact, a valid cube could not be made if that were so. There are six, 3!, possible dimensional arrangements of the A, B, and C base lines into first second and third dimensions, resulting in 16x6 or 96 possible base cubes.

A three way exclusive OR combines the base lines into a base cube as shown in the ORDER-8 BASE CUBE GENERATOR. This can be done be combining two of the base lines and then combining the result with the third. The result is that cells at the conjunction of three 0's or two 1's and a zero become 0's. Cells where one 1 and two 0's or three 1's are combined become 1's. This can also be looked at as a (mod 2) addition of the three base line bits that define that position. Because of the initial 0 in all of the base lines used for the construction of the base cube there will always be a zero at the 0, 0, 0 position of the base cube.

The ORDER-8 BASE CUBE GENERATOR allows one to test various combinations of 0's and 1's in the base lines. All the rows, columns, pillars, diagonals, broken diagonals, triagonals, and broken triagonals must add to 4 in order for the base square to be valid. If all the rows, columns, and pillars add to 4 in the figure then the "Agonal Sums" at the bottom of the figure will be OK. "Diagonal Sums" and "Triagonal Sums" include the associated broken diagonals and triagonals. All sums must be OK for the base cube to be valid. The base cube will only be valid when one of the base lines is an A base line, a second is a B base line and the third is a C base line. Try it! See what happens if the three base lines are three different C type.

Notice that when a number in the row base line is changed, the entire plane perpendicular to the changed number also changes. When a number in the column base line changes, the entire plane perpendicular to that numbers position in the column changes. And when a number in the pillar base line changes, the entire plane perpendicular to that numbers position in the pillar changes. The latter will be one of the squares.

As discussed in the weaving base lines section of Basic Construction any square cross section of the base cubes made by the prescribed approach will have the appearance of simple woven cloth. This is not true of the base cubes of other nasik magic cubes. Although difficult to envision the cubes can be considered to be woven in three dimensions resulting in a rectangular prism pattern of 0's and 1's.

Proof of Base Cube Addition Properties

The addition properties are inherent in the selection of the base lines. Since all base lines have four 1's and all rows, columns, and pillars of the base cube are either a base line or its inverse then all rows, columns and pillars must add to 4. For the 2-D diagonals if one of the base lines of the square is a C base line then one half of the diagonal is the inverse of the other since the second half of the C base line is the inverse of the first half. The other base line, either A0 or B type, has halves that are identical. This always results in four 1's in the diagonal or broken diagonal since one half of the diagonal is always the inverse of the other half. If the square has A0 and B base lines then each quarter of the diagonal is the inverse of the adjacent quarter, again resulting in four 1's in the whole diagonal. The 3-D diagonals must incorporate a C base line, therefore one half of the diagonal is the inverse of the other half. A more general proof of this is given in Überprüfen.

Other addition patterns also have their origins in the base cubes. For instance, the corners of the 2x2x2 sub cubes will always contain four 1's. If one picks a 2x2 square in the dimensions defined by the B and C base lines, then the adjacent 2x2 square in the direction of the A0 code will be its inverse. For the corners of a 3x3x3 cube one starts with the 3x3 square in the dimensions defined by the A0 and C base lines. The first and third bits of the B base lines are inverses so that the 3x3 square shifted by 2 in the B base lines direction will be an inverse. Thus, the corners of the 3x3x3 must always have four 1's. The corners of the 4x4x4 cubes again rely on shifting in the A0 direction, and the corners of the 5x5x5 cubes are inverted in the C direction. All nasik order-8 cubes are {3compact2,3,5}. I skip the 4 because a cube that is {3compact2} must also have the corners of all even sided rectangular prisms add to the constant.

Combining Base Cubes to Make Order-8 Pan-2,3-agonal Magic Cubes

There are 512 numbers in the 8x8x8 figure. This is 29. To build the magic cube in the prescribed manner will therefore require combining nine base cubes. With 96 base cubes there should be 969 possible magic cubes with a zero at position 0, 0, 0. With the caveat that a base cube cannot be used twice this value is reduced somewhat to 96!/87!. There are, however, only 6,436,518,100,992,000 by actual count. This is only about 0.93% of the potential cubes. The other potential cubes do not generate appropriate magic cubes because not all numbers from 0-511 are present and some numbers are repeated, i.e. the cubes have uneven integral distribution.

All 96 base cubes have uniform integral distribution, which for base cubes means 256 zero's and 256 one's. For the order-4 squares all combinations of the four different base squares also have uniform integral distribution, i.e. all the resulting magic squares have one of every number from 0 to 15. For the cube, however, not all combinations of different base cubes give uniform integral distribution. Some pairs of base cubes will not give uniform integral distribution after making a 2 X base cube I plus base cube II calculation. That is there will not be 128 of all of the numbers 0-3 in the resulting intermediate magic cube. The incompatibility can occur at any stage of the building process. Only ~5% of pairs of base cubes are incompatible but ~99% of 9 base cube combinations are. Additional information on incompatible pairs can be found in Base Cube Rules.

The BASE CUBE COMBINER adds a base cube to a second base cube that has been multiplied by 2. The multiplied base cube is fixed in this figure but the base lines of the added base cube can be modified. The underlying multiplied base cube can be seen by entering 0's into all the base line positions. It is the base cube originally shown in the ORDER-8 BASE CUBE GENERATOR. Notice that the intermediate cube shown originally has all valid magic sums but it does not have uniform integral distribution as stated at the bottom of the figure. The sums are valid because the two base cubes making up the combination are both valid. This pair of base cubes does not give uniform integral distribution when combined. Try changing to a different valid base cube. Most combinations of two base cubes will work.

If uniform integral distribution is lost after any base cube addition, it cannot be regained by adding any other base cube. The resulting cube will be missing some numbers and will repeat others. If valid base cubes are used, however, it will add to the appropriate magic constant in all directions because the addition and multiplication rules require it. What this means is that any combination of nine valid base cubes will have all the appropriate addition properties of a nasik magic cube. The combination, however, may not be a nasik magic cube because all the numbers from 0-511 are not present and some are present in more than one position. Validation of magic cubes made in the above way by checking the additions does not work. If valid base cubes are used, the only verification needed is to confirm uniform integral distribution, i.e. confirm that all numbers from 0 to 511 are present somewhere in the cube.

Master Base Line Exclusive OR Construction

It must be pointed out that there are valid base cubes that cannot be generated using base lines as described above. There are four 8 by 8 by 8 nasik magic cubes described on the home page and in Barnard's Cube that use alternate base cubes. This is not how they were originally constructed but they can be. These other cubes have all the same properties as the nasik magic cubes discussed here except for the master base lines.

There are more that 7.5 E+20 nasik magic cubes that can be made using alternate base cubes. These alternate base cubes are discussed in Other Nasik Cubes. It is also be possible to combine the alternate base cubes with the 96 derived using base lines to make still more nasik magic cubes. A quick way to determine if a magic cube is made using base lines follows. Translate the zero to the upper left corner of the first square if it is not there. Then pick any number from the row, the column and the pillar of the lines starting with zero. Convert all three numbers to binary and do an exclusive OR on each of the nine bit's triplets. Convert the resulting 9-bit number back to base ten and compare it to the number at the juncture of the three original numbers. If all numbers in the cubes are the same, then the cube could have been made using only base lines.

Multiplier Shuffling

The nine base cubes of a valid nasik magic cube can be rearranged in any order. The concept behind this was described in the identically named section of Basic Concepts. Rearrangement of the base cubes of a valid magic cube will always yield a new valid magic cube. Every valid nasik magic cube is thus one of 9! easily determined different valid nasik magic cubes.

Plane Exchanging

Valid Plane Orders After Exchanges

In a nasik order-8 magic cube, any pair of planes that are spaced four apart may be exchanged to generate a different order-8 pan-2,3-agonal magic cube. When planes spaced four apart are exchanged in the base line cubes, the A and the B type base lines in the resulting cube are unchanged. The C type base lines are changed to another C type base line. Since there must be at least one C type base line in every dimension, exchange of planes will always change the cube. From any starting cube, 8 different cubes can be generated with various combinations of this type of plane exchange in one planar direction. There are thus 512 different combinations when all three dimensions are considered.

There are also double exchanges that can be done to create different cubes. To do a double exchange, first split the cube in half perpendicular to an axis. Then in one half, perpendicular to that same axis, exchange two planes that are spaced two apart. In the other half, exchange the corresponding two planes. This has the effect of changing both the C type base lines and the B type base lines to different C and B base lines, but there are still A, B, and C type base lines in every base cube so the resulting cube is still valid.

There are four different ways that a double exchange can be done in any one planar direction, but when combined with the single exchange described above this leads to only eight additional cube orders in one planar direction. However, these eight new cubes are actually the same as the first eight but in the reversed order. Since this is just a different aspect of the same cube, they cannot be considered new cubes.

Quadruple exchanges are also possible. This is done by dividing the cube in quarters perpendicular to one axis. The planes in each quarter are then exchanged. Doing this changes all the base lines to different base lines of the same type but it does not create cubes that are different than those created using exchanges of planes spaced four apart.

Shorthand Descriptions of Magic Cubes

A shorthand method of identifying the many nasik magic cubes was introduced in the Basic Concepts section under "Base lines". For the magic cube, the shorthand code would consist of nine groups of three base lines. For instance, the code would be (C0B1A0, C0A0B0, B0C7A0, B0A0C0, A0C7B0, A0B1C5, C5A0B0, A0C2B0, B0C1A0) for the cube described in The Old Farmers Almanac. Another shorthand method would be to list just the numbers found in the master base lines since they can be used to generate the cube using an exclusive OR function as described above. For the cube above this would be; row: 0, 30, 97, 127, 388, 410, 485, 507 column: 0, 508, 346, 245, 83, 431, 265, 166 pillar: 0, 329, 150, 479, 40, 353, 190, 503.

The cube that appears in The Old Farmers Almanac is not identical to the cube described above. One must be added to all the values in the above cube so that the values are in the range 1-512 rather than 0-511.

A complication to a simple description is that there are 48 different aspects for the cube that appear visually different but are just simple manipulations of the cube. Benson and Jacoby5 suggest a possible way to group these 48 aspects under a single description. They suggest translating the one (or zero if used in range) to the lower left corner of the first square of the cube to correspond with Cartesian coordinates. An aspect is then picked based on a set of rules. I describe a way to group the aspects as well as the 9! different cubes obtained by multiplier shuffling in Magic Cube Guide as unique cubes. Neither of these approaches will easily describe the OFA cube, as it is not easy to describe a path from the master cube to the specific example. Benson and Jacoby suggest that all such cubes be shown in their format and not in any of the other 48*512 visually different ways. My approach just offers a way to compare cubes from disparate sources and is not useable for a non base line cube. I also place the zero in the upper left corner of the first square.

Base Cube Magic Constant

There are many sets of 8 numbers from the range of 0-511 that add to 2044. Most of these sets are just random groupings within the cube. Some of the patterns described by the eight number sets when translated throughout the cube always add to 2044. There are thousands of such patterns in the magic cubes that add to 2044 in all the possible cubes. Some patterns are very simple, such as the rows, columns, and pillars. Others are highly symmetrical such as the corners of various sized cubes. And many patterns are not simply described. Magic Constant Groups describes these groups. Some of the groups are also demonstrated in the magic constant checker in the cube generator.