Multimagic formulas
How do we know what the theoretical values should be of sums of rows, columns and diagonals of multimagic squares?
Start with the single magic square. It is known, and easy to demonstrate (…except for an 8year old child like Gauss who is supposed to have demonstrated at this age at school…), that the sum of the first integer numbers from 1 to N is:
N(N+1)/2
A nth order magic square contains all the numbers from 1 to n². So, the sum of the first integer numbers from 1 to n² is:
n²(n²+1)/2
Since this square has n rows, it is sufficient to divide by n in order to know the magic sum S1 of each row, column or diagonal, so:
For the bimagic square, the sum of the squares of the first integers from 1 to N is:
N(N+1)(2N+1)/6
Replacing N by n², then dividing by n, we get the sum S2 of each row, column or diagonal, so:
For the trimagic square, the sum of the cubes:
For the tetramagic, Fermat gave as early as 1636, in a letter sent to Roberval, the solution for the sum of the integers from 1 to N to the 4thpower. Here is Fermat's formula after replacing N by n², then dividing by n:
S4 = ((4n² + 2)*n*S1²  S2) / 5
Replacing (4n² +2) * S1 by 6S2, we can write an easier formula than Fermat:
For the pentamagic (sum of 5thpower):
If we prefer to develop Sp, here is the following generous table, which permits us to calculate the sums of the future hexa, hepta or octomagic squares:

In order to calculate Sp when the nth order pmultimagic square contains the integers from 0 to n²1 (instead of 1 to n²), it is sufficient to put a  sign (instead of the + red) in the 2nd column above. You may remark that the first column of Sp is equal to (1/(p+1)) n^(2p+1). This feature has been known since the middle of the XVIIth century, thanks to Pascal who wrote a Treatise on the subject. Jacques Bernoulli later took an interest in this question of the sum of integer powers. After his Ars conjectandi published posthumously at the beginning of the XVIIIth century, the numbers used in this development have been called Bernoulli numbers (1/6, 1/30, 1/42, 1/30, 5/66, …).
Here are the formulas for some norders of pmultimagic squares, containing numbers from 1 to n². Here we find the sums of Pfeffermann's 8thorder bimagic square, Pfeffermann's 9thorder bimagic square, and William Benson's 32th order trimagic square:
Sp 
3rdorder 
4thorder 
5thorder 
6thorder 
7thorder 
8thorder 
9thorder 
... 
32thorder 
S1 
15 
34 
65 
111 
175 
260 
369 
... 
16400 
S2 
95 
374 
1105 
2701 
5775 
11180 
20049 
... 
11201200 
S3 
675 
4624 
21125 
73926 
214375 
540800 
1225449 
... 
8606720000 
And here are the formulas of some norders of pmultimagic squares, containing numbers from 0 to n²1. Here we find the sums of our record 512thorder tetramagic and 1024thorder pentamagic squares:
Sp 
32ndorder 
512thorder 
1024thorder 
S1 
16368 
67108608 
536870400 
S2 
11168432 
11728056920832 
375299432076800 
S3 
8573165568 
2305825417061203968 
295147342229667840000 
S4 
7019705733392 
483565716171561366524160 
247587417561640996243120640 
S5 
5987221633671168 
105636341097042573844228866048 
216345083469423421673932062720000 
Bibliography
For more details about the sum of powers, see the excellent chapter 14 « Sommation des puissances numériques », book II of the Théorie des Nombres by Edouard Lucas, Librairie Blanchard, Paris.
Return to the home page http://www.multimagie.com