The $$n\equiv 1 (mod\, 2)$$ formula

The explanation of the formula

The formula for calculating magic hypercubes which follow the condition $$n\equiv 1 (mod\, 2)$$ is:

(4)$$\textbf{m}(i_1,...,i_p) = \sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k) + 1$$

where

(5)$$m_k(i_1,...,i_p) = ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

in which

(6)$$C_k = (-1)^{k+1}(p-k-(k+1)(mod \, 2))\frac{n+1}{2}-1$$

To show how the formula works the calculation for the point $$\textbf{m}(2,1,3,2)$$ in $$M^4_3$$ will be shown.

To show how the formula works the calculation for the point $$\textbf{m}(2,1)$$ in $$M^2_3$$ will be shown.

Filling in points $$\textbf{m}(2,1)$$ into formula (4) gives:

$$\textbf{m}(2,1) = \sum_{k=0}^{2-1}(m_k(2,1)3^k) + 1$$

$$= \sum_{k=0}^{1}(m_k(2,1)3^k) + 1$$

$$=(m_0(2,1)3^0)+(m_1(2,1)3^1) + 1$$

$$=(m_0(2,1)*1)+(m_1(2,1)*3) + 1$$

Filling in $$m_0(2,1)$$ in formula (5) gives:

$$m_0(2,1) = ( \sum_{x=1}^{0}((-1)^{x-1}i_x) + (-1)^0 \sum_{x=0+1}^{2}(i_x) + C_0)(mod \, 3)$$

$$m_0(2,1) = ( \sum_{x=1}^{0}((-1)^{x-1}i_x) + 1*\sum_{x=1}^{2}(i_x) + C_0)(mod \, 3)$$

$$m_0(2,1) = ( 0+ 1*((i_1)+(i_2)) + C_0)(mod \, 3)$$

$$= ( 1*((2)+(1))) + C_0)(mod \, 3)$$

$$= ( 3 + C_0)(mod \, 3)$$

Filling in C_0 in formula (6) gives:

$$C_0 = (-1)^{0+1}(2-0-(0+1)(mod \, 2))\frac{3+1}{2}-1$$

$$= (-1)^{1}(2-(1)(mod \, 2))\frac{4}{2}-1$$

$$= (-1)(2-1)*2-1$$

$$= (-1)(1)*2-1 = -2-1=-3$$

Which gives:

$$m_0(2,1)=(3 + C_0)(mod \, 3) = (3 - 3)(mod \, 3)= (0)(mod \, 3) = 0 $$

Filling in $$m_1(2,3)$$ in formula (5) gives:

$$m_1(2,1) = ( \sum_{x=1}^{1}((-1)^{x-1}i_x) + (-1)^1 \sum_{x=2}^{2}(i_x) + C_1)(mod \, 3)$$

$$m_1(2,1) = ( \sum_{x=1}^{1}((-1)^{x-1}i_x) -1 \sum_{x=2}^{2}(i_x) + C_1)(mod \, 3)$$

$$m_1(2,1) = ((-1)^{1-1}i_1 -1(i_2) + C_1)(mod \, 3)$$

$$m_1(2,1) = ((-1)^{0}i_1 -i_2 + C_1)(mod \, 3)$$

$$m_1(2,1) = (1*i_1 -i_2 + C_1)(mod \, 3)$$

$$= (2 - 1 + C_1)(mod \, 3) = (1 + C_1)(mod \, 3)$$

Filling in $$C_1$$ in formula (6) gives:

$$C_1 = (-1)^{1+1}(2-1-(1+1)(mod \, 2))\frac{3+1}{2}-1$$

$$= (-1)^{2}(1-(2)(mod \, 2))\frac{4}{2}-1$$

$$= (1)(1-0)*2-1$$

$$= (1)(1)*2-1 = 2-1 = 1$$

Which gives:

$$m_1(2,1)=(1 +1)(mod \, 3) = (2)(mod \, 3)= 2$$

Filling in $$m_0(2,1)= 0$$ and $$m_1(2,1)= 2$$

back in gives:

$$\textbf{m}(2,1)=(m_0(2,1)*1)+(m_1(2,1)*3) + 1$$

$$=(0*1)+(2*3) + 1$$

$$=6 + 1 = 7$$

Thus in the magic hypercube $$M^2_3$$ point $$\textbf{m}(2,1) = 7$$.

The proof of formula $$n\equiv 1 (mod\, 2)$$

To prove that the $$n\equiv 1 (mod\, 2)$$ formula always creates a simple magic hypercube filled with consecutive numbers starting from 1, the following 4 requirements have to be proven:

  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

The following 4 sub-chapters named proof for requirements 1 through 4 will show proof for each of these requirements.

Proof For Requirement 1

For requirement 1, it has to be proven that each coordinate within $$M^p_n$$ has a value that is a number in $$\{ 1,...,n^p\}$$. This is achieved through the construction of formula (5) $$m_k(i_1,...,i_p) = ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

as the result of formula (5) is any integer in the set $$\{0,...,n-1\}$$. This is due to the $$(mod \, n)$$ at the end of the equation. All results from formula (5) are always integers as there are no decimal numbers filled in for the variables $$i_x$$, $$p$$ and $$n$$ and the only division in the formula takes place in formula (6)

$$C_k = (-1)^{k+1}(p-k-(k+1)(mod \, 2))\frac{n+1}{2}-1$$

of which the result is always an integer. This is because in the division $$\frac{n+1}{2}$$, $$n+1$$ will always be even as n is an odd number and an odd number plus 1 is even.

If the result of formula (5), which is represented as $$m_k(i_1,...,i_p)$$ in formula (4), is always 0, which is the lowest option possible according to the interval $$\{0,...,n-1\}$$ , then the value of formula (4) will be as follows:

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k) + 1$$

$$=\sum_{k=0}^{p-1}(0(n^k)) + 1$$

$$=\sum_{k=0}^{p-1}(0) + 1 = p*(0) + 1 = 0 + 1=1$$

and if formula (5), again represented as $$m_k(i_1,...,i_p)$$, is always equal to its maximum $$n-1$$ according to the number set $$\{0,...,n-1\}$$ then the result of formula (4) will be:

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k) + 1$$

$$ = \sum_{k=0}^{p-1}((n-1)n^k) + 1$$

$$ = \sum_{k=0}^{p-1}(n^{k+1}-n^k) + 1$$

$$ = n^p - 1 + 1= n^p$$

As the result of formula (5) fluctuates between the values of the set $$\{0,...,n-1\}$$ the value of formula (4) changes with it, but it will never go lower than 1 and higher than n^p, therefore, requirement 1 has been proven to work for this formula.

Proof For Requirement 2

To prove requirement 2, it has to be shown that no 2 points within $$M^p_n$$ with different coordinates have the same value. In Marián Trenkler’s proof for the formula he shows that no two points in a magic hypercube have the same value by showing that if two random points have the same value they must have the same coordinates. So take the point $$\textbf{m}(i_1,...,i_p)$$ and another random point $$\textbf{m}(i'_1,...,i'_p)$$ both in the same magic square $$M^p_n$$. If their value is the same then the result of their value calculation in formula (4) must be the same.

So

$$\textbf{m}(i_1,...,i_p) = \textbf{m}(i'_1,...,i'_p)$$

Filling in formula (4) gives

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k) + 1 = \sum_{k=0}^{p-1}(m_k(i'_1,...,i'_p)n^k) + 1$$

hence,

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k) - \sum_{k=0}^{p-1}(m_k(i'_1,...,i'_p)n^k) + 1 - 1= 0$$

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k) - \sum_{k=0}^{p-1}(m_k(i'_1,...,i'_p)n^k) = 0$$

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k - (m_k(i'_1,...,i'_p)n^k)) = 0$$

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p) - m_k(i'_1,...,i'_p))n^k = 0$$

Since the maximum value of $$m_k(i_1,...,i_p)$$ and $$m_k(i'_1,...,i'_p)$$ is $$n-1$$ and the minimum 0, $$m_k(i_1,...,i_p) -m_k(i'_1,...,i'_p) = 0$$ has to be true for the summation above. If $$m_k(i_1,...,i_p) -m_k(i'_1,...,i'_p) = 1$$ for instance, which is the closest value this subtraction can equal to 0 (besides 0, of course) and 1, then the summation could only be true if the previous k values before this k together equal $$n^k$$. That this is impossible can be shown through the use of the finite geometric series summation formula, which is the following:

$$\textbf{S}_t = \frac{a_1(1-r^t)}{1-r}$$

In which t is the number of terms, $$a_1$$ the first term and r the common ratio. If all k values before the value of k when $$m_k(i_1,...,i_p) -m_k(i'_1,...,i'_p) = 1$$ would give the result $$m_k(i_1,...,i_p) -m_k(i'_1,...,i'_p) = -n+1$$ which is the maximum value possible for the subtraction, then $$t = k-1+1 = k$$, $$a_1 = -n+1$$ and $$r = n$$. $$r = n$$ as at the end of each subtraction in the summation there is the term $$n^k$$. Filling these values in gives:

$$\textbf{S}_{k} = \frac{(-n+1)(1-n^{k})}{1-n} $$

$$= 1-n^{k}$$

Therefore, the $$n^k$$ offset caused by $$m_k(i_1,...,i_p) -m_k(i'_1,...,i'_p) = 1$$ can not be undone by lower values for k, as $$n^k + 1 - n^k = 1$$ and thus

$$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p) - m_k(i'_1,...,i'_p))n^k \neq 0$$ in that case.

Producing $$-n^k$$ with higher values for k will also not work, as any addition of higher values of k will always result in a number lower than $$-n^k$$. Given for instance $$m_{k+1}(i_1,...,i_p) - m_{k+1}(i'_1,...,i'_p) = n-1$$ and $$m_{k+2}(i_1,...,i_p) - m_{k+2}(i'_1,...,i'_p) = -1$$ then the result of the addition of their values after the corresponding multiplication with either $$n^{k+1}$$ or $$n^{k+2}$$ will be the following:

$$(m_{k+1}(i_1,...,i_p) - m_{k+1}(i'_1,...,i'_p)) * n^{k+1} + (m_{k+2}(i_1,...,i_p) - m_{k+2}(i'_1,...,i'_p)) * n^{k+2}$$

$$ = (n-1) * n^{k+1} + (-1)* n^{k+2}$$

$$ = n * n^{k+1} -1* n^{k+1} -n^{k+2}$$

$$ = n * n^{k+1} -1* n^{k+1} -n^{k+2}$$

$$ = n^{k+2} - n^{k+1} -n^{k+2} = - n^{k+1}$$

Which is too large to cancel out the $$n^k$$. Using even more k values and repeating the same process done with $$k+1$$ equalling $$n-1$$ and $$k+2$$ equalling 1, but only now making all values bigger than k equal to $$n-1$$ except for the last value which still will be equal to 1. Then the result will get close to the value of $$-n^k$$, but will never quite reach it.

Which shows that if $$m_k(i_1,...,i_p) -m_k(i'_1,...,i'_p) \neq 0$$, $$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p) - m_k(i'_1,...,i'_p))n^k \neq 0$$

and thus $$\sum_{k=0}^{p-1}(m_k(i_1,...,i_p) - m_k(i'_1,...,i'_p))n^k = 0$$ when $$m_k(i_1,...,i_p) -m_k(i'_1,...,i'_p) = 0$$ which gives:

$$m_k(i_1,...,i_p) = m_k(i'_1,...,i'_p)\, for \,all\, 0 \leq k \leq p-1$$

Given two consecutive values for k, $$k_1 = h$$ and $$k_2 = h+1$$.

Adding $$m_{h}(i_1,...,i_p)$$ and $$m_{h+1}(i_1,...,i_p)$$ gives

$$m_h(i_1,...,i_p) + m_{h+1}(i_1,...,i_p)$$

$$ = ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^h \sum_{x=h+1}^{p}(i_x) + C_h)(mod \, n) + ( \sum_{x=1}^{h+1}((-1)^{x-1}i_x) + (-1)^{h+1} \sum_{x=h+1+1}^{p}(i_x) + C_{h+1})(mod \, n)$$

The first part of a summation can be taken out by adding 1 to the lower part of a summation and the last part can be taken out of a summation by subtracting 1 of its upper limit, which gives:

$$ ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^h( \sum_{x=h+1 + 1}^{p}(i_x) + i_{h+1}) +C_h)(mod \, n) + ( \sum_{x=1}^{h+1-1}((-1)^{x-1}i_x) + (-1)^{h+1-1}*i_{h+1}+ (-1)^{h+1} \sum_{x=h+2}^{p}(i_x) + C_{h+1})(mod \, n)$$

$$ ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^h \sum_{x=h+2}^{p}(i_x) + (-1)^h*i_{h+1} +C_h)(mod \, n) + ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^{h}*i_{h+1}+ (-1)^{h+1} \sum_{x=h+2}^{p}(i_x) + C_{h+1})(mod \, n)$$

$$ = ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^h \sum_{x=h+2}^{p}(i_x) + (-1)^h * i_{h+1} +C_h)(mod \, n) + ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^{h}*i_{h+1}+ (-1)^1*(-1)^{h} \sum_{x=h+2}^{p}(i_x) + C_{h+1})(mod \, n)$$

$$ = ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^h \sum_{x=h+2}^{p}(i_x) + (-1)^h * i_{h+1} +C_h)(mod \, n) + ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^{h}*i_{h+1}-(-1)^{h} \sum_{x=h+2}^{p}(i_x) + C_{h+1})(mod \, n)$$

$$ = ( \sum_{x=1}^{h}((-1)^{x-1}i_x) + \sum_{x=1}^{h}((-1)^{x-1}i_x) + (-1)^h \sum_{x=h+2}^{p}(i_x) -(-1)^{h} \sum_{x=h+2}^{p}(i_x) + (-1)^h * i_{h+1} +(-1)^{h}*i_{h+1} +C_h + C_{h+1})(mod \, n)$$

$$ = (2*( \sum_{x=1}^{h}((-1)^{x-1}i_x)+2*(-1)^h * i_{h+1} + C_h + C_{h+1})(mod \, n)$$

So if $$m_k(i_1,...,i_p) = m_k(i'_1,...,i'_p)$$ then

$$m_h(i_1,...,i_p) + m_{h+1}(i_1,...,i_p) = m_h(i'_1,...,i'_p) + m_{h+1}(i'_1,...,i'_p)$$

Which gives

$$(2*( \sum_{x=1}^{h}((-1)^{x-1}i_x)+2*(-1)^h * i_{h+1} + C_h + C_{h+1})(mod \, n) = (2*( \sum_{x=1}^{h}((-1)^{x-1}i'_x)+2*(-1)^h * i'_{h+1} + C_h + C_{h+1})(mod \, n)$$

filling in h = 0 gives

$$ (2*( \sum_{x=1}^{0}((-1)^{x-1}i_x)+2*(-1)^0 * i_{0+1} + C_0 + C_{0+1})(mod \, n= (2*( \sum_{x=1}^{0}((-1)^{x-1}i'_x)+2*(-1)^0 * i'_{0+1} + C_0 + C_{0+1})(mod \, n) $$

$$ (0+2*(-1)^0 * i_{1} + C_0 + C_{1})(mod \, n) = (0+2*(-1)^0 * i'_{1} + C_0 + C_{1})(mod \, n) $$

$$ (2 * i_{1} + C_0 + C_{1})(mod \, n) = (2 * i'_{1} + C_0 + C_{1})(mod \, n) $$

thus

$$2 * i_{1} + C_0 + C_{1} = 2 * i'_{1} + C_0 + C_{1}$$

Since any value for $$C_k$$ is not influenced by the coordinates of points, they are the same and therefore, can be equalled out.

$$2 * i_{1}= 2 * i'_{1} $$

$$i_{1}= i'_{1} $$

Thus for two points to have the same value, the first coordinate needs to be the same. The $$(mod \, n)$$ suggest a possibility where $$i'_1 = i_1 + \frac{1}{2} * n $$ or $$i'_1 = i_1 + \frac{1}{2} * -n $$ as in the first case, the result would then be:

$$ (2 * i_{1} + C_0 + C_{1})(mod \, n) = (2 * i'_{1} + C_0 + C_{1})(mod \, n) $$

$$ (2 * i_{1} + C_0 + C_{1})(mod \, n) = (2 * (i_1 + \frac{1}{2} * n) + C_0 + C_{1})(mod \, n) $$

$$ (2 * i_{1} + C_0 + C_{1})(mod \, n) = (2*i_1 + n + C_0 + C_{1})(mod \, n) $$

$$ (2 * i_{1} + C_0 + C_{1})(mod \, n) = 2*i_1 + C_0 + C_{1}$$

Which would be true. This is not possible, however, because n is always an odd number. Dividing an odd number by 2 gives a number with decimals and a coordinate be a non-integer number. $$i'_1 = i_1 + \frac{1}{2} * -n $$ would also give a number with decimals. Therefore, $$i_{1}= i'_{1} $$has to be true for the points to have the same value.

Filling in h = 1 gives

$$ (2*( \sum_{x=1}^{1}((-1)^{x-1}i_x)+2*(-1)^1 * i_{1+1} + C_1 + C_{1+1})(mod \, n) = (2*( \sum_{x=1}^{1}((-1)^{x-1}i'_x)+2*(-1)^1 * i'_{1+1} + C_1 + C_{1+1})(mod \, n) $$

$$ (2*(-1)^{1-1}*i_1*+2*(-1)^1 * i_{2} + C_1 + C_{2})(mod \, n) = (2*(-1)^{1-1}*i'_1+2*(-1)^1 * i'_{2} + C_1 + C_{2}))(mod \, n) $$

$$ (2*(-1)^{0}*i_1*+2*-1 * i_{2} + C_1 + C_{2})(mod \, n) = (2*(-1)^{0}*i'_1+2*(-1)^1 * i'_{2} + C_1 + C_{2}))(mod \, n) $$

$$ (2*1*i_1*-2 * i_{2} + C_1 + C_{2})(mod \, n) = (2*1*i'_1+2*(-1)^1 * i'_{2} + C_1 + C_{2}))(mod \, n) $$

thus

$$ 2*i_1-2 * i_{2} + C_1 + C_{2} = 2*i'_1-2 * i'_{2} + C_1 + C_{2}$$

$$ 2*i_1-2 * i_{2} = 2*i'_1-2 * i'_{2} $$

$$ i_1- i_{2} = i'_1- i'_{2} $$

As proven when filling in h = 0, $$i_1 = i'_1$$ thus

$$ i_1- i_{2} = i_1- i'_{2} $$

$$ i_{2} = i'_{2} $$

Therefore, for 2 points to be equal, also the second coordinate needs to be the same. Here the same proof as in h = 0 applies for $$i'_2 = i_2 + \frac{1}{2} * n $$ or $$i'_2 = i_2 + \frac{1}{2} * -n $$ being impossible.

The last value that will be shown is h = 2 which gives

$$ (2*( \sum_{x=1}^{2}((-1)^{x-1}i_x)+2*(-1)^2 * i_{2+1} + C_2 + C_{2+1})(mod \, n) = (2*( \sum_{x=1}^{2}((-1)^{x-1}i'_x)+2*(-1)^2 * i'_{2+1} + C_2 + C_{2+1})(mod \, n) $$

$$ (2*((-1)^{1-1}i_1+(-1)^{2-1}i_2)+2*(-1)^2 * i_{3} + C_2 + C_{3})(mod \, n) = (2*((-1)^{1-1}i'_1)+(-1)^{2-1}i'_2)+2*(-1)^2 * i'_{3} + C_2 + C_{3})(mod \, n) $$

$$ (2*(-1)^{0}i_1+2*(-1)^{2}i_2+2*(-1)^2 * i_{3} + C_2 + C_{3})(mod \, n) = (2*(-1)^{0}i'_1+2*(-1)^{1}i'_2+2*(-1)^2 * i'_{3} + C_2 + C_{3})(mod \, n) $$

thus

$$ 2*(-1)^{0}i_1+2*(-1)^{1}i_2+2*(-1)^2 * i_{3} + C_2 + C_{3} = 2*(-1)^{0}i'_1+2*(-1)^{1}i'_2+2*(-1)^2 * i'_{3} + C_2 + C_{3}$$

$$ 2*1*i_1+2*-1*i_2+2*1 * i_{3} = 2*1*i'_1+2*-1*i'_2+2*1* i'_{3}$$

$$ i_1-i_2+i_{3} = i'_1-i'_2+i'_{3}$$

It was previously proven that $$i_1 = i'_1$$ and $$i_2 = i'_2$$ so

$$ i_1-i_2+i_{3} = i_1-i_2+i'_{3}$$

$$ i_{3} = i'_{3}$$

By continuing the increasing of h up until $$h = p-1$$ with a step of 1 each time, a new coordinate can be proven to have to be equal for the points $$m_k(i_1,...,i_p)$$ and $$m_k(i'_1,...,i'_p)$$. Thus there exist no two different points with the same value and requirement 2 is proven.

Proof For Requirement 3

To prove requirement 3 it has to be shown that each row in the magic hypercube $$M^p_n$$ has the same sum, which equals the magic constant. A line within the magic hypercube $$M^p_n$$ is a set of n points $$m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)$$ where all points have the same coordinates except for coordinate $$i_j$$. This coordinate is different for all points on the line and will be equal to all values from the set $$\{1,...,n\}$$. Since all points within a line have the same coordinates except for the coordinate $$i_j$$ which will be equal to all values from the interval $$\{1,...,n\}$$, the sum of a line can be represented as follows:

$$\sum_{i_j=1}^{n}(\textbf{m}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p))$$

To calculate the value of each $$\textbf{m}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)$$, the value of $$m_k(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)$$ has to be calculated according to formula

(4) $$\textbf{m}(i_1,...,i_p) = \sum_{k=0}^{p-1}(m_k(i_1,...,i_p)n^k) + 1$$.

The relation of the value of j to k in formula (4) is important, as it changes the required proof for formula (5)

$$m_{k}(i_1,...,i_p) = ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

due to the 2 different summations in this formula. There are three possibilities j < k, j > k and j = k, which will all be shown.

If $$j < k$$ in formula (4) than the calculation of $$m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)$$ with formula (5) is as follows.

$$m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p) = ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{j}((-1)^{x-1}i_x) + \sum_{x=j+1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

$$=( \sum_{x=1}^{j-1}((-1)^{x-1}i_x) + (-1)^{j-1}i_j+\sum_{x=j+1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

Since $$ \sum_{x=1}^{j-1}((-1)^{x-1}i_x), \sum_{x=j+1}^{k}((-1)^{x-1}i_x), (-1)^k \sum_{x=k+1}^{p}(i_x)\, and\, C_k$$ are all constant when the value of $$i_j$$ alternates as all coordinates of the points in a line stay the same except for $$i_j$$, only $$(-1)^{j-1}*i_j$$ changes. Because $$i_j$$ takes the value of each integer of the set $$\{1,...,n\}$$ and because there is a (mod n) at the end of the equation of formula (5), the result of formula (5) will always result in all values of the set $$\{0,...,n-1\}$$. Therefore, the sum of all values of $$m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)$$ for one line can be written as:

$$ \sum_{i_j=1}^{n}m_k(i_1,...,i_p) = \frac{n*(n-1-0)}{2} = \frac{n*(n-1)}{2}$$

The last step is possible with the use of the formula of Gauss which works as follows:

$$(amount\, of\, elements)*\frac{last\, element - \, first \, element}{2}$$

Where the amount of elements in the set $$\{0,...,n-1\}$$= n, the value of the last element = n-1 and the first element = 0.

The formula of Gauss only works with arithmetic series.

The proof for j > k is as follows:

$$m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)$$

$$ = ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{j}(i_x) + (-1)^k \sum_{x=j+1}^{p}(i_x) + C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{j-1}(i_x) + (-1)^ki_x + (-1)^k \sum_{x=j+1}^{p}(i_x) + C_k)(mod \, n)$$

Since $$ \sum_{x=1}^{k}((-1)^{x-1}i_x), (-1)^k \sum_{x=k+1}^{j-1}(i_x), (-1)^k \sum_{x=j+1}^{p}(i_x) \, and \, C_k$$ are all constant again for all points in the line and only the value of $$(-1)^ki_x$$ changes the same proof as for j < k holds true.

Lastly when j = k

$$m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p) = ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{j}((-1)^{x-1}i_x) + (-1)^j \sum_{x=j+1}^{p}(i_x) + C_j)(mod \, n)$$

$$= ( \sum_{x=1}^{j-1}((-1)^{x-1}i_x) + (-1)^{j-1}i_j + (-1)^k \sum_{x=j+1}^{p}(i_x) + C_j)(mod \, n)=$$

Here $$\sum_{x=1}^{j-1}((-1)^{x-1}i_x), (-1)^k \sum_{x=j+1}^{p}(i_x) \, and \, C_j$$ are constant again and the same proof stand for jk again.

Therefore,

$$ \sum_{i_j=1}^{n}m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p) = \frac{n*(n-1)}{2} \,for \,all \, 1\leq j \leq p \, and \,for \,all \, 1\leq k \leq p $$

So the sum of all points in a line is

$$\textbf{m}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p) = \sum_{i_j=1}^{n}( \sum_{k=0}^{p-1}(m_k(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p) n^k) + 1)$$

$$ = \sum_{i_j=1}^{n}( \sum_{k=0}^{p-1}(m_k(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)n^k))+\sum_{i_j=1}^{n}(1)$$

Since $$ \sum_{i_j=1}^{n}m_{k}(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p) = \frac{n*(n-1)}{2}$$:

$$ \sum_{i_j=1}^{n}( \sum_{k=0}^{p-1}(m_k(i_1,...,i_{j-1},i_j,i_{j+1},...,i_p)n^k))+\sum_{i_j=1}^{n}(1) = \sum_{k=0}^{p-1}(\frac{n*(n-1)}{2}n^k) + n$$

$$ = \sum_{k=0}^{p-1}(\frac{n^2-n}{2}n^k) + n $$

$$= \sum_{k=0}^{p-1}(\frac{n^{k+2}-n^{k+1}}{2}) + n$$

$$ = \frac{n^{p+1}-0}{2} + n $$

$$= \frac{n^{p+1}}{2} + \frac{n}{2} $$

$$= \frac{n^{p+1} + n}{2} = \frac{n(n^{p} + 1)}{2}$$

which is equal to the magic constant and completes the proof for requirement 3 by showing that each row in the magic hypercube $$M^p_n$$ has the same sum, which equates to the magic constant.

Proof For Requirement 4

Just like with the proof of requirement 4 for the formula $$n\equiv 0 (mod\, 4)$$, pairs will be made of $$\textbf{m}(i_1,...,i_p)$$ and $$\textbf{m}(\bar{i}_1,...,\bar{i}_p)$$ to prove that each main diagonal in the magic hypercube $$M^p_n$$ made with the $$n\equiv 1 (mod\, 2)$$ formula has the same sum as that of its rows and also equals the magic constant. To show that for each diagonal all numbers add up to the magic constant 4, the values of the pair $$\textbf{m}(i_1,...,i_p)$$ and $$\textbf{m}(\bar{i}_1,...,\bar{i}_p)$$ will be added. Here $$\bar{i}_x = n-i_x+1$$ again. the addition gives the following:

$$\textbf{m}(i_1,...,i_p) + \textbf{m}(\bar{i}_1,...,\bar{i}_p)$$

$$ = \sum_{k=0}^{p-1} (m_k(i_1,...,i_p)n^k) + 1 + \sum_{k=0}^{p-1}(m_k(\bar{i}_1,...,\bar{i}_p)n^k) + 1$$

$$= \sum_{k=0}^{p-1} (m_k(i_1,...,i_p)n^k + m_k(\bar{i}_1,...,\bar{i}_p)n^k) + 2$$

$$ = \sum_{k=0}^{p-1} ((m_k(i_1,...,i_p) + m_k(\bar{i}_1,...,\bar{i}_p))n^k) + 2$$

So the value of the addition of $$\textbf{m}(i_1,...,i_p)$$ and $$\textbf{m}(\bar{i}_1,...,\bar{i}_p)$$ relies on the addition of $$m_k(i_1,...,i_p)$$ and $$m_k(\bar{i}_1,...,\bar{i}_p)$$ which gives the following when calculated with formula (5).

$$m_k(i_1,...,i_p) + m_k(\bar{i}_1,...,\bar{i}_p)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n) + ( \sum_{x=1}^{k}((-1)^{x-1}\bar{i}_x) + (-1)^k \sum_{x=k+1}^{p}(\bar{i}_x) + C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k)(mod \, n) + ( \sum_{x=1}^{k}((-1)^{x-1}(n-i_x+1)) + (-1)^k \sum_{x=k+1}^{p}(n-i_x+1) + C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + (-1)^k \sum_{x=k+1}^{p}(i_x) + C_k + \sum_{x=1}^{k}((-1)^{x-1}(n-i_x+1)) + (-1)^k \sum_{x=k+1}^{p}(n-i_x+1) + C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}i_x) + \sum_{x=1}^{k}((-1)^{x-1}(n-i_x+1)) + (-1)^k \sum_{x=k+1}^{p}(i_x) + (-1)^k \sum_{x=k+1}^{p}(n-i_x+1) + 2*C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}(i_x + n-i_x+1)) + (-1)^k \sum_{x=k+1}^{p}(i_x + n-i_x+1)+ 2*C_k)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}(n+1)) + (-1)^k \sum_{x=k+1}^{p}(n+1)+ 2*C_k)(mod \, n)$$

Now filling in formula (6) in the place of $$C_k$$ gives the following

$$( \sum_{x=1}^{k}((-1)^{x-1}(n+1)) + (-1)^k \sum_{x=k+1}^{p}(n+1)+ 2*((-1)^{k+1}(p-k-(k+1)(mod\,2))\frac{n+1}{2}-1))(mod \, n)$$

$$=( \sum_{x=1}^{k}((-1)^{x-1}(n+1)) + (-1)^k \sum_{x=k+1}^{p}(n+1)+ (-1)^{k+1}(p-k-(k+1)(mod\,2))(n+1)-2)(mod \, n)$$

The $$(mod \, n)$$ at the end of the equation means that the n in the (n+1) part of the summations can be removed, therefore:

$$( \sum_{x=1}^{k}((-1)^{x-1}(1)) + (-1)^k \sum_{x=k+1}^{p}(1)+ (-1)^{k+1}(p-k-(k+1)(mod\,2))(1)-2)(mod \, n)$$

$$=( \sum_{x=1}^{k}((-1)^{x-1}(1)) + (-1)^k (p-k)+ (-1)^{k+1}(p-k-(k+1)(mod\,2))-2)(mod \, n)$$

$$=( \sum_{x=1}^{k}((-1)^{x-1}(1)) + (-1)^k (p-k)+ (-1)^{k+1}(p-k-(k+1)(mod\,2))-2)(mod \, n)$$

$$=( \sum_{x=1}^{k}((-1)^{x-1}(1)) + (-1)^k*p - (-1)^k * k -1*(-1)^{k}(p-k-(k+1)(mod\,2))-2)(mod \, n)$$

$$=( \sum_{x=1}^{k}((-1)^{x-1}(1)) + (-1)^k*p - (-1)^k * k -(-1)^{k}*p+(-1)^{k}*k+(-1)^{k}*(k+1)(mod\,2))-2)(mod \, n)$$

$$=( \sum_{x=1}^{k}((-1)^{x-1})+(-1)^{k}*(k+1)(mod\,2))-2)(mod \, n)$$

If k is odd then

$$\sum_{x=1}^{k}((-1)^{x-1}) = 1 \, and \, (-1)^{k}*(k+1)(mod\,2) = 0$$

because if k = 3 for instance

$$\sum_{x=1}^{3}((-1)^{x-1}) = (-1)^{1-1} + (-1)^{2-1} + (-1)^{3-1} = (-1)^{0} + (-1)^{1} + (-1)^{2} = 1 - 1 + 1 = 1$$

and

$$(-1)^{3}*(3+1)(mod\,2) = (-1)^{3}*(4)(mod\,2) = (-1)^3*0 = 0$$

And if k is even then

$$\sum_{x=1}^{k}((-1)^{x-1}) = 0 \, and \, (-1)^{k}*(k+1)(mod\,2) = 1$$

because if k = 4 for instance

$$\sum_{x=1}^{4}((-1)^{x-1}) = (-1)^{1-1} + (-1)^{2-1} + (-1)^{3-1} + (-1)^{4-1}= (-1)^{0} + (-1)^{1} + (-1)^{2} + (-1)^{3} = 1 - 1 + 1 - 1 = 0$$

and

$$(-1)^{4}*(4+1)(mod\,2) = (-1)^{4}*(5)(mod\,2) = (-1)^4*1 = 1$$

Thus for every k

$$\sum_{x=1}^{k}((-1)^{x-1}) + (-1)^{k}*(k+1)(mod\,2) = 1$$

so

$$( \sum_{x=1}^{k}((-1)^{x-1})+(-1)^{k}*(k+1)(mod\,2))-2)(mod \, n)$$

$$=(1-2)(mod \, n)$$

$$=(-1)(mod \, n)$$

$$=n-1$$

Therefore,

$$\textbf{m}(i_1,...,i_p) + \textbf{m}(\bar{i}_1,...,\bar{i}_p) = \sum_{k=0}^{p-1}((m_k(i_1,...,i_p) + m_k(\bar{i}_1,...,\bar{i}_p))n^k) + 2$$

$$ = \sum_{k=0}^{p-1}((n-1)n^k) + 2$$

$$ = \sum_{k=0}^{p-1}(n^{k+1}-n^k) + 2$$

$$ = n^p - 1 + 2$$

$$ = n^p + 1 $$

Meaning that the addition of each coordinate pair $$m_k(i_1,...,i_p)$$ and $$m_k(\bar{i}_1,...,\bar{i}_p)$$ is equal to $$n^p + 1$$

There are $$\frac{n-1}{2}$$ of those pairs, as there is no pair possible for the middle point of the magic hypercube. This is due to the fact that there is an odd amount of points in a line because this formula is used when $$n\equiv 1 (mod\, 2)$$. The middle point is always the following$$\textbf{m}(\frac{n+1}{2},\frac{n+1}{2},...,\frac{n+1}{2},\frac{n+1}{2})$$. The other point of the pair of the middle point would be $$\textbf{m}(\bar{i}_1,...,\bar{i}_p) = \textbf{m}(n-\frac{n+1}{2}+1,n-\frac{n+1}{2}+1,...,n-\frac{n+1}{2}+1,n-\frac{n+1}{2}+1)$$

$$=\textbf{m}(\frac{2n}{2}-\frac{n+1}{2}+\frac{2}{2},\frac{2n}{2}-\frac{n+1}{2}+\frac{2}{2},...,\frac{2n}{2}-\frac{n+1}{2}+\frac{2}{2},\frac{2n}{2}-\frac{n+1}{2}+\frac{2}{2})$$

$$=\textbf{m}(\frac{2n-n-1+2}{2},\frac{2n-n-1+2}{2},...,\frac{2n-n-1+2}{2},\frac{2n-n-1+2}{2})$$$$=\textbf{m}(\frac{n+1}{2},\frac{n+1}{2},...\frac{n+1}{2},\frac{n+1}{2})$$

Thus the corresponding point is the same as the original middle point and ,therefore, no pair is possible.

The value of point is calculated with formula (4) which gives

$$\textbf{m}(\frac{n+1}{2},\frac{n+1}{2},...,\frac{n+1}{2},\frac{n+1}{2})$$

$$= \sum_{k=0}^{p-1}(m_k(\frac{n+1}{2},\frac{n+1}{2},...,\frac{n+1}{2},\frac{n+1}{2})n^k) + 1$$

formula (5) gives

$$= ( \sum_{x=1}^{k}((-1)^{x-1}\frac{n+1}{2}) + (-1)^k \sum_{x=k+1}^{p}(\frac{n+1}{2}) + C_k)(mod \, n)$$

and formula (6)

$$= ( \sum_{x=1}^{k}((-1)^{x-1}\frac{n+1}{2}) + (-1)^k \sum_{x=k+1}^{p}(\frac{n+1}{2}) + (-1)^{k+1}(p-k-(k+1)(mod \, 2))\frac{n+1}{2}-1)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}\frac{n+1}{2}) + (-1)^k \sum_{x=k+1}^{p}(\frac{n+1}{2}) + ((-1)^{k+1}*p-(-1)^{k+1}*k-(k+1)(mod \, 2)*(-1)^{k+1})\frac{n+1}{2}-1)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}\frac{n+1}{2}) + (-1)^k*(p-k)*\frac{n+1}{2} + (-(-1)^{k}*p+(-1)^{k}*k-(k+1)(mod \, 2)*(-1)^{k+1})\frac{n+1}{2}-1)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}\frac{n+1}{2}) + (-1)^k*p*\frac{n+1}{2} - (-1)^k*k*\frac{n+1}{2} +-(-1)^{k}*p*\frac{n+1}{2}+(-1)^{k}*k*\frac{n+1}{2}-(k+1)(mod \, 2)*(-1)^{k+1}*\frac{n+1}{2}-1)(mod \, n)$$

$$= ( \sum_{x=1}^{k}((-1)^{x-1}\frac{n+1}{2})-(k+1)(mod \, 2)*(-1)^{k+1}*\frac{n+1}{2}-1)(mod \, n)$$

$$= ( (\sum_{x=1}^{k}((-1)^{x-1})-((k+1)(mod \, 2)*(-1)^{k+1}))\frac{n+1}{2}-1)(mod \, n)$$

$$= ( (\sum_{x=1}^{k}((-1)^{x-1})+((k+1)(mod \, 2)*(-1)^{k}))\frac{n+1}{2}-1)(mod \, n)$$

Just like before

If k is odd then

$$\sum_{x=1}^{k}((-1)^{x-1}) = 1 \, and \, (-1)^{k}*(k+1)(mod\,2) = 0$$

And if k is even then

$$\sum_{x=1}^{k}((-1)^{x-1}) = 0 \, and \, (-1)^{k}*(k+1)(mod\,2) = 1$$

So again

$$\sum_{x=1}^{k}((-1)^{x-1}) + (-1)^{k}*(k+1)(mod\,2) = 1$$

Therefore,

$$= ( (\sum_{x=1}^{k}((-1)^{x-1})+((k+1)(mod \, 2)*(-1)^{k}))\frac{n+1}{2}-1)(mod \, n)$$

$$= ( (1)\frac{n+1}{2}-1)(mod \, n)$$

$$= (\frac{n+1}{2}-1)(mod \, n)$$

$$= (\frac{n+1}{2}-\frac{2}{2})$$

$$= (\frac{n+1-2}{2})$$

$$= (\frac{n-1}{2})$$

Thus $$m_k(\frac{n+1}{2},\frac{n+1}{2},...,\frac{n+1}{2},\frac{n+1}{2}) = (\frac{n-1}{2})$$

So

$$\textbf{m}(\frac{n+1}{2},\frac{n+1}{2},...,\frac{n+1}{2},\frac{n+1}{2})$$

$$= \sum_{k=0}^{p-1}(m_k(\frac{n+1}{2},\frac{n+1}{2},...,\frac{n+1}{2},\frac{n+1}{2})n^k) + 1$$

$$= \sum_{k=0}^{p-1}((\frac{n-1}{2})n^k) + 1$$

$$= \sum_{k=0}^{p-1}((\frac{n^{k+1}-n^k}{2})) + 1$$

$$= \frac{n^{p}-1}{2} + 1$$

$$= \frac{n^{p}-1}{2} + \frac{2}{2}$$

$$= \frac{n^{p}-1+2}{2} $$

$$= \frac{n^{p}+1}{2} $$

So the diagonal sum is $$ n^p + 1 $$ times the the amount of pairs which is $$\frac{n-1}{2}$$ plus the value of the middle location of the magic hypercube which is $$ \frac{n^{p}+1}{2} $$, so each diagonal sum is:

$$(n^p + 1) * \frac{n-1}{2} +\frac{n^{p}+1}{2}$$

$$ =\frac{(n^p + 1)*(n-1)}{2} +\frac{n^{p}+1}{2}$$

$$ =\frac{n^{p+1} + n - n^p - 1}{2} +\frac{n^{p}+1}{2}$$

$$ =\frac{n^{p+1} + n - n^p + n^{p} - 1 + 1}{2}$$

$$ =\frac{n^{p+1} + n}{2}$$

$$ =\frac{n(n^{p} +1)}{2}$$

Which is the magic constant which completes both the proof for requirement 4 by showing that each main diagonal is equal to the magic constant and that the formula follows all 4 requirements and therefore, is proven.