Formulas for p-dimensional magic hypercubes

A magic hypercube of any dimension and any order can be defined by $$M^p_n$$ in which p is the dimension of the magic hypercube and n the size of the magic hypercube. $$M^p_n$$ is an array which contains the points $$|m(i_1,...,i_p):1\leq i_1,...,i_p\leq n|$$. The symbols on the left of the “:” symbolise the coordinate of any given point within the p-dimensional magic hypercube of order n. There are p coordinates in a p-dimensional hypercube. p has to be a positive integer as a point can not have a half amount or negative amount of coordinates . If $$p = 3$$ then $$M^3_n = |m(i_1,i_2,i_3):1\leq i_1,i_2,i_3\leq n|$$. On the right of the “:” are the boundaries of what values each coordinate can equal. So $$i_1$$ can equal any value between 1 and n, where n is also a positive integer. The same applies to $$i_2$$ and on until $$i_p$$. So say we take $$p = 3$$ just like in our previous example and $$n = 4$$, than $$M^3_4$$ = $$|m(i_1,i_2,i_3):1\leq i_1,...,i_p\leq 4|$$. Also n has to be an integer positive number. Another special property for n is that it cannot equal 2, the reason for this will be shown later.

3 different formulas are used to calculate the values of each point of $$M^p_n$$. Which formula to use is based on $$n$$. One formula is used when $$n\equiv 0 (mod \, 4)$$, the second when $$n\equiv 1 (mod 2)$$, and the third when $$n\equiv 2 (mod \, 4)$$. $$n\equiv 1 (mod \, 2)$$ means that the remainder of the division of $$n/2$$ is equal to 1. So $$3/2 = 1$$ with remainder 1 would suffice for $$n\equiv 1 (mod \, 2)$$ and $$4/2 = 2$$ with remainder 0 would not. $$n\equiv 1 (mod \, 2)$$ is true for all positive odd integers for n, so for instance 1,3,5 etcetera. $$n\equiv 0 (mod \, 4)$$ is true if n is a positive integer such as 4, 8, 12, 16 etcetera. All of the values that are true for $$n\equiv 0 (mod \, 4)$$ are even. These values specifically are called doubly even. $$n\equiv 2 (mod \, 4)$$ is true if n is a positive integer such as 6, 10, 14, 18 etcetera. These are all the other positive even integers which did not follow the condition $$n\equiv 0 (mod \, 4)$$. These values of n for which $$n\equiv 2 (mod \, 4)$$ is true are called singly even.

Another way of representing $$x (mod \, n)$$ is $$x - n \lfloor \frac{x}{n} \rfloor$$ which will be used later on during the proofs of the $$n\equiv 1 (mod \, 2)$$ and $$n\equiv 2 (mod \, 4)$$ formulas.

The formulas for the construction of $$n\equiv 1 (mod \, 2)$$, $$n\equiv 0 (mod\, 4)$$ and $$n\equiv 2 (mod\, 4)$$ that have been used in the magic hypercube generator are all based upon the formulas created by mathematician Marián Trenkler. The $$n\equiv 0 (mod\, 4)$$ formula that Trenkler proposed has been followed completely and some adjustments have been made to the $$n\equiv 1 (mod\, 2)$$ formula and the $$n\equiv 2 (mod\, 4)$$ formula. This chapter will prove that each of the formulas work, how they work and will show how the formulas were implemented in javascript in the p-dimensional magic hypercube generator.

The aim of the p-dimensional magic hypercube generator is to have the ability of creating simple magic hypercubes of any whole positive dimension and whole positive order,which follow the minimum conditions, which are the following:

  1. Each coordinate within $$M^p_n$$ has a value that is a number in $$\{ 1,...,n^p\}$$
  2. No 2 points within $$M^p_n$$ with different coordinates have the same value
  3. Each row has the same sum , which equals the magic constant
  4. Each main diagonal has the same sum as that of the rows and also equals the magic constant

Since there are 3 formulas, $$n\equiv 1 (mod \, 2)$$, $$n\equiv 2 (mod \, 4)$$ and $$n\equiv 0 (mod \, 4)$$, which cover all integer values of n, it has to be proven that all these formulas follow the requirements 1-4.

Requirement 1 and 2 will make sure that the magic squares are filled with consecutive numbers starting at 1. Requirement 1 states that all values have to be within the set $$\{ 1,...,n^p\}$$, which means that all values within $$M^p_n$$ have to be either equal to or bigger than 1 and smaller or equal to $$n^p$$. A value in the set $$\{ 1,...,n^p\}$$ is always 1 bigger than its predecessor and one smaller than the following number. If $$p = 2$$ and $$n =3$$, then $$\{ 1,...,3^2\} = \{ 1,...,9\} = \{ 1,2,3,4,5,6,7,8,9\}$$. The reason that the maximum value of the set is $$n^p$$ is that in a magic hypercube $$M^p_n$$ there are p lines of length n. Meaning that in each line there are n spots. Just like how multiplying a side of a square by itself gives its area, which is basically the same as p = 2, and multiply the side of a cube by itself twice gives its volume, which is the same as p = 3, the amount of spots within a magic hypercube is calculated by multiplying the length n, p times with itself. Multiplying a value p times by itself is the same as putting that value to the power p, which gives $$n^p$$. Because there are $$n^p$$ values in a $$M^p_n$$ magic hypercube, it has to be filled with the numbers $$\{ 1,...,n^p\}$$ to be consecutive, as this gives $$n^p$$ different values meaning that each spot in the magic hypercube $$M^p_n$$ can be equal to a different value. Requirement 2 is needed because the values will only be consecutive when there are no duplicate values. Therefore these requirements together make sure that the magic hypercube consists only out of consecutive numbers.

Requirement 3 and 4 handle the magic part for the p-dimensional magic hypercubes. A simple magic hypercube is one in which each row and main diagonal have the same sum. A row is a set of points where all coordinates in all points from the set are the same, except for one coordinate which is different for all points in the row. Rows themselves can have different names, examples of this are columns and pillars. A row is called a column when the second coordinate, so $$i_2$$, is different for all points in the row. A row is called a pillar when $$i_3$$ is different for all points in the row. Instead of naming these special types of rows by name each time, from now on all different types of rows will just be referred to as a row. In the proof of the magic constant it was shown that this is only possible when they are equal to the so-called magic constant. Therefore the formulas create magic hypercubes when the row and diagonal sums of the created magic hypercubes equal the magic constant.

So, if all requirements are followed by a formula, than the formula will always create a simple consecutive magic hypercube.There however still exists the possibility that a formula creates magic hypercubes that are more than just simple, proof for these extra special properties always existing, however , will not be given.