Bases other than binary can be used to make magic figures using the same basic concepts. The concepts need to generalized to accommodate these other bases. When building base figures from these base lines it is better to think of the combination as (mod o) additions (where o is the base used) of the individual components of the number rather than an exclusive OR.


The smallest possible magic square is of order-3 and there is only one that can be built using the numbers from 1 to 9. It can be shown in eight different aspects, however. The square is not pan-magic as not all broken diagonals will add to S. There are undoubtedly many other simple magic figures that can be made like this with master base lines but the focus of this site is the figures that are also pan-magic. A 1 was added to all of the numbers in the magic square in order to have the number range correspond to the traditional 1-9 series. The base lines, base squares, and master base lines, however, reflect their analytic origin.

Using (mod 3) addition and the base lines 120 and 120 for the first base square and 210 and 201 for the second, the order-3 square can be constructed as shown at right. All the base lines are the same because 012 is equivalent to its reversed form, 021, or any of their shifted versions. Reversal just creates a different aspect of the same square. Notice that the row master base line shown does not correspond to any of the rows in the magic square but the column base line does (after adding 1). The base lines could also be 201 and 012 for base square I, and 102 and 012 for base square II so that both base lines correspond to master base lines. This illustrates the point that base lines can be redundant, i.e. more than one set of base lines can generate the same base square.

The base lines can be modified to try different base line combinations. Only base lines that have a 0, a 1 and a 2 in some order will result in valid squares but not all combinations of valid base lines will yield the valid magic square. Can you create the other 7 aspects by changing the base lines? A solution set is given on the Answers page.


The simplest pan-magic square that can be built using ternary math is a 9x9 square. By analogy with the binary A type base line, the ternary base line must be three digits long and must contain a 0, 1, and 2. As with the binary I chose to start the ternary base lines with zero to simplify the process. Notice that was not possible with the order-3 square above. There are thus two possible A type base lines, 012 and 021. This could be abbreviated using an alphanumeric code but that approach would prove difficult for B, C, etc type base lines. I will generically name them A, B, C, etc. type lines and not attempt to describe each one exactly.

Like the order-4 pan-magic square, the order-9 pan-magic square requires B type base lines as well as the A type lines. A program was written to determine all possible combinations of two 9-digit ternary base lines that would give a valid order-9 base square. The only requirements for the base lines were that they all contain three 0's, three 1's and three 2's and that they start with zero. The base squares were required to have all rows, columns, diagonals and broken diagonals add to 9. One of the two A type base lines described above was in all the squares generated. Paired with A type base lines were 72 B type base lines. These base lines can be generated as follows:

  1. Split the base line into three groups of three.
  2. Put any 3-digit ternary number starting with zero into the first third of the 9-digit base line (000, 001, 002, 010, etc.).
  3. Enter a 3-digit ternary number in the second third of the base line. This 3-digit ternary number cannot have any digit in common with the first 3-digit ternary number (000112 is valid, 000110 is not because there is a zero in the third position of each part).
  4. Place the three ternary digits in the last third of the base line that are different from the corresponding ternary digits in the first two thirds (i.e. 000112221, 012200121, etc.).

By combining all A type base lines with all B type base lines, 288 order-9 base squares are created. Four base squares must be combined to make a magic square. Multipliers for the base squares to be combined are powers of 3. Not all combinations of four ternary base squares will give valid magic squares. It is best to start by combining two base squares by multiplying one base square by 3 and adding the second and then checking for uniform integral distribution. The intermediate square can then be multiplied by 3 and a third base square added with checking, etc.


The features of the order-4 pan-magic squares all have their equivalent in these order-9 pan-magic squares. The complete feature manifests itself as a group of three numbers along every diagonal that are spaced at vectors (3,3) and (6,6) apart. This will be designated as {complete3}. The {2compact2} feature is matched by the sum of all nine numbers in each 3x3 sub-square. The {2compact3} is matched by the sums of the corners of 7x7 squares plus the numbers at the center of the edges of the 7x7 squares plus the number in the center of the 7x7 square, i.e. the nine numbers are evenly spaced in a 7x7 grid. A modification of Aale de Winkel's compact nomenclature will define the features in the ternary squares as {2compact3}9 and {2compact7}9. In this modification, the 9 after the brackets indicates that there are 9 numbers evenly spaced in a 3x3 or 7x7 grid respectively.

Shifted rows and columns are also present in the order-9 square. They are in three groups of three numbers shifted by three each time in the same direction. The shifted lines are in the rows and the columns and they can be shifted in both directions. Rows or columns in the order-9 squares spaced 3 or 6 apart can also be exchanged retaining all the pan-magic properties as can be done with the order-4 squares. All order-9 pan-magic squares will have all these features.

When the sums of the nine numbers in every 3x3 sub-square are all equal, {2compact3}9, then any set of nine numbers defined by the set {(0,0), (0,j), (0,2j), (k,0), (k,j), (k,2j), (2k,0), (2k,j), and (2k,2j)} are also equal to that constant. In this set, j and k are the distances between numbers in the x and y dimensions of the grid. For the 3x3 sub-squares both j and k equal 1. Both j and k can have any integral value that is not divisible by 3. If values exceed the size of the square then the wrap around property is used. When j and k are both divisible by 3 but not by 9, then a second set of nine evenly spaced numbers is accessed. These include the evenly spaced numbers in the 7x7 sub-squares described above, i.e. {2compact7}9. The next set of nine evenly space numbers require that j and k be divisible by 9 but not 27. The smallest member of this set are the 19x19 sub-squares in the order-27 magic squaresl, i.e. {2compact19}9.

The order-9 pan-magic squares cannot be complete by the traditional definition, but they can be by the new definition above. It is possible for the primary square to be associated by the traditional definition. Most order-9 pan-magic squares do not have this feature. The associated feature is of course lost when rows or columns are shifted to the opposite side or are exchanged.


Master Base Lines of Order-9 Pan-Magic Squares

The 9x9 worksheet of the SquareLines Excel Spreadsheet available on the Downloads page gives the five order-9 pan-magic squares that are replicated at right. There is a converter on the worksheet to convert the master base lines to the magic squares. The worksheet also provides magical sums for the features. The first two squares at right are just simple order-9 pan-magic squares. Additional examples can be made by changing the base square order. Be sure not to duplicate any number.

Square 3 is also a simple order-9 pan-magic square but the central number is 40, the midpoint of the number series. Having the midpoint in the center of the pan-magic square is not sufficient to make the square associated. Square 4 also has the 40 in the center of the square but it is an associated order-9 pan-magic square. In order to make an associated magic square, all its base squares must be associated. For the base square to be associated, every pair of numbers that are diametrically equidistant from the center of the square must add to 2. This means that all 0's are opposed by 2's and 1's opposed by 1's. A 1 must also be at the center of every base square.

The popular Sudoko puzzle is a 9x9 square of the digits from 1 to 9. Each digit is repeated nine times in the square in a structured manner. The pattern requires that each row and each column as well as each square in the grid of nine 3x3 sub-squares all contain all nine digits. This pattern does not normally have the characteristics of a pan-magic square, but it is possible to combine two of the order-9 base squares to make a Sudoko type pattern. With the addition of 1 to each number, square 5 is an example of one such construction. The primary diagonals of this square also contain each of the nine digits. The square is also associated. For this square the base square order must be 1, 2, 3, 4 or 1, 2, 4, 3 in order to retain just the numbers 0-8.


It is possible to make larger ternary squares with additional features, but the next size square that can be built with ternary base lines, is the next power of 3 or order-27. To make squares of this size, C type ternary base lines must be used. The C type base lines are made by a method analogous to that used for the B ternary base lines except the line is initially broken into three 9-digit pieces.

The 27x27 worksheet of the SquareLines Excel Spreadsheet available on the Downloads page gives the six order-27 pan-magic squares available below with sums for the features.

Square 1 is a {2compact3,19}9, and complete3 (3 evenly spaced numbers on every diagonal combined) order-27 pan-magic square. In this square rows or columns spaced any multiple of 3 apart may be exchanged to generate different order-27 pan-magic squares with the same properties. As with most figures made from base figures the order of the 6 base square multipliers can be shuffled in any of the 6! possible arrangements by changing the Base Square Order.

The second square is {2compact7,19}9, and complete3. The first two order-27 squares have features comparable to the first two order-8 squares discussed in Order-2p Squares.

Squares 3 to 5 are associated order-27 pan-magic square. Square 3 is also {2compact19}9, and complete3 proving that an associated square can also have the ternary definition of complete property. Square 4 is like square 3 but it is also {2compact3}9. Square 5 is like square 3 but it is also {2compact7}9. Rows or columns spaced 9 or 18 apart may be exchanged yielding different order-27 pan-magic squares, but these will not be associated. Exchanging rows or columns other multiples of 3 apart will yield invalid squares. The Base Square Order can be shuffled with retention of all properties including the associated property.

Square 6 is also associated and {2compact3}9. It is not complete3. There are nine inlaid order-9 pan-magic squares. The center 9x9 square is associated. Exchanging rows or columns spaced 9 or 18 apart will destroy the associated property in the large square and may destroy it in the small square as well, but some exchanges will retain the associated property in the central order-9 square.