Skip to main content
Heliyon logoLink to Heliyon
. 2022 Nov 29;9(1):e12046. doi: 10.1016/j.heliyon.2022.e12046

Construction of a repetitive magic square with Ramanujan's number as its product

Prasantha Bharathi Dhandapani a, Víctor Leiva b,, Carlos Martin-Barreiro c,d
PMCID: PMC9853301  PMID: 36685409

Abstract

In this article, we build a repetitive magic square by multiplying four elements. This square is a matrix with its corresponding elements. The elements of this matrix that take different values allow us to obtain Ramanujan's number 1729 as its multiplicative magic constant. The additive magic constant of the square is the number 40. The elements of these magic constants form an arithmetic progression. An algorithm to build magic squares is also proposed.

Keywords: Arithmetic progression, Diophantine equation, Latin square, Magic elements, Sequences, Square matrix

1. Introduction

Magic or Latin squares have been studied for 4,000 years. Loh-Shu's square is the oldest known, and its invention is attributed to Fuh-Hi, the founder of the Chinese civilization.

A magic square is a matrix with the same number of rows and columns [1]. The symbols of this matrix (that is, the elements of the matrix that take different values) are used to obtain the addition or multiplication along each row, column, and diagonal, whose result must be the same [2]. Then, the values associated with such addition or multiplication are called magic constants [3]. Subsequently, we use the words symbols and elements interchangeably.

Applications of square matrices have been widely considered. In particular, in [13], an optimized timely system matrix applied to improve image quality was studied. The usage of matrices to formulate the Maxwell and Dirac equations was stated in [16]. Different authors have constructed magic squares [4], [5], [6], [7], [8], [9]. To get the magic constant, one often adds the elements of any row or column of the square. Instead of adding, one can also multiply the elements, but this alternative is not so common. Ramanujan [4] constructed different magic squares of the same size but with different magic constants. For instance, he constructed an even square of 4×4 with magic constants equal to 34 and 35. For an odd order, Ramanujan constructed a 5×5 square with magic constants equal to 65 and 66. Ramanujan [4] built 7×7 squares with magic sums 170 and 175 in two different problems. He also constructed magic rectangles.

To the best of our knowledge, works as those proposed in the objective indicated next are unavailable in the literature. The objective of the present work is to construct a repetitive magic square as an application of a matrix by multiplying four elements. These elements permit us to obtain Ramanujan's number 1729 as multiplicative magic constant, whereas the associated additive magic constant is the number 40. The elements of these magic constants form an arithmetic progression. Furthermore, we propose an algorithm to build repetitive magic squares of the fourth order.

The rest of this work is organized as follows. Section 2 motivates our investigation and provides background on the topic. In Section 3, we present magic squares of different kinds, whereas some examples are stated in Section 4. Section 5 details the method for constructing a repetitive magic square with magic product 1729 and magic sum 40. In Section 6, we study some unique features of the obtained repetitive magic square. Section 7 proposes an algorithm to build 4×4 repetitive magic squares with elements in an arithmetic progression. Finally, Section 8 discusses our results and conclusions.

2. Background

Srinivasa Ramanujan was an Indian mathematician born on 22 December 1887 in Erode and died on 26 April 1920 in Kumbakonam, India. Ramanujan dedicated his life to mathematics. In biology, he is known for the Hardy-Weinberg principle, a fundamental law of population genetics. The Ramanujan number 1729 identifies the taxi when Hardy1 visits Ramanujan. Hardy was spontaneously warned by Ramanujan indicating that 1729 is the smallest number expressed as the sum of two cubes in two different ways as 1729=103+93=123+13. The repetitive square we propose has as its magic product this number 1729, whereas its magic sum equals 40.

Let n be a positive integer. A Latin square of order n is an n×n array such that every row and every column are a permutation of an n-dimensional set. A transversal in a Latin square of order n is a set of n cells, one from each row and column, containing each of the n symbols exactly once. A Latin square is diagonal if its main and back diagonals are both transversals. Two Latin squares of order n are called orthogonal if each symbol in the first square meets each symbol in the second square exactly once when they are superposed. The following result is obvious.

Theorem 1

( [1] ). If there exists a pair of diagonal orthogonal Latin squares of order n, then there exists a magic square of order n.

Clearly, a diagonal Latin square is a repetitive additive-multiplicative magic square. For example, the array stated as

A=(1234432121433412)

is a repetitive additive-multiplicative magic square. Let

B=(abcddcbabadccdab),

where a, b, c, and d are any integer numbers.

Note that the array B is a repetitive additive-multiplicative magic square. This is a very traditional and efficient method of constructing magic squares using diagonal Latin squares or orthogonal diagonal Latin squares. For some results on diagonal Latin squares, the reader can consult [10], [11], [12].

3. Magic squares of different kinds

The magic squares can be constructed in several ways and classified into three types:

  • (i)

    Additive magic square (standard form): Its elements are arranged in such a way that they add to give a magic sum (S) along rows, columns, and diagonals.

  • (ii)

    Multiplicative magic square: Its elements are arranged to multiply, giving a magic product (P) along rows, columns, and diagonals.

  • (iii)

    Additive-multiplicative magic square: Its elements are arranged to add and multiply to give S and P, respectively, along rows, columns, and diagonals.

Based on the elements involved in a magic square, it can be classified into two kinds as follows:

  • (i)

    Non-repetitive magic square: Its elements are all distinct and are not repeated. This is equal to any standard magic square. In this kind of magic square, we have: number of elements = number of rows × number of columns.

  • (ii)
    Repetitive magic square: All its elements must be used in all rows, columns, and diagonals, with no element employed more than once in a row, column, and diagonal. In this kind of magic square, we get:
    • (ii.a)
      number of elements = number of rows = number of columns.
    • (ii.b)
      number of elements < number of rows × number of columns.

Regarding the order of a magic square, it may be classified as:

  • (i)

    Magic square of even order: Its rows and columns are equal, and it is of order n=2k, with k2.

  • (ii)

    Magic square of odd order: Its rows and columns are equal, and it is of order n=3k, with k1.

4. Examples

In Section 3, different kinds of magic squares were discussed. Next, we provide some examples to understand those kinds of magic squares from which the reader can quickly get an idea about them.

Example 4.1

After understanding a 3×3 magic square, one could do the following additive square of 5×5 with magic sum 65:

17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9

Example 4.2

[14] A 3×3 multiplicative square with magic product 4096 is given by:

128 1 32
4 16 64
8 256 2

Example 4.3

[7] An additive-multiplicative magic square of order 8 with S=840 and P=2,058,068,231,856,000 is stated as:

46 83 117 102 15 76 200 203
19 60 232 175 54 69 153 78
216 1617 17 52 171 90 58 75
135 114 50 87 184 189 13 6
150 261 45 38 91 136 92 27
119 104 108 23 174 225 57 30
116 25 133 120 51 26 162 203
39 34 138 243 100 29 105 152

Example 4.4

A familiar non-repetitive 3×3 square with magic sum 15 is established as:

8 1 6
3 5 7
4 9 2

Example 4.5

A repetitive magic square of the fifth order, whose elements are not in arithmetic progression with magic sum 30, is presented as:

9 6 3 5 7
6 7 5 9 3
5 3 6 7 9
7 5 9 3 6
3 9 7 6 5

Example 4.6

[3] An even-order magic square of the fourth order, with magic sum 34, is given by:

1 14 11 8
12 7 2 13
6 9 16 3
15 4 5 10

Example 4.1, Example 4.2, Example 4.4, Example 4.5 are related to an odd order, whereas Example 4.3, Example 4.6 are of an even order. Example 4.3 is a non-repetitive additive-multiplicative magic square of even order.

5. Method for constructing repetitive magic squares

Next, we apply the concepts involved in additive, multiplicative, repetitive, and even order magic squares. The only difference between the well-known Devi magic square [15] and our magic square is that our elements are in arithmetic progression. Thus, the sum of the elements in any row, column, or diagonal is equal to S=40, and the product of the elements in any row, column, or diagonal is equal to P=1729.

Since we are proposing a repetitive magic square, it is enough to satisfy the conditions according to the sum of elements or the product of elements. To build a 4×4 magic square, suppose that, in the first row of the square, we put the four elements of an arithmetic progression, where the first term is a, whereas d is the common difference of successive members.

Therefore, we have that S=a+(a+d)+(a+2d)+(a+3d)=4a+6d. Hence, we get P=a(a+d)(a+2d)(a+3d). The method of construction is given below. Consider the 4×4 magic square given in Table 1.

Table 1.

4 × 4 magic square (MS) to build with fixed elements in the first row.

5.

The other elements of the 4×4 magic square are chosen according to Table 2. Note that when adding the elements of any row, column, or diagonal, the result is 4a+6d.

Table 2.

4 × 4 magic square (MS) to build with all elements fixed.

5.

Now, we arrange the elements a, a+d, a+2d, and a+3d in Table 1 to satisfy all the abovementioned conditions. For convenience, we transform the magic square given in Table 1 as the magic square given in Table 3.

Table 3.

4 × 4 magic square (MS) with the proposed notation.

5.

The sub-index of each element of the magic square in Table 3 is a 1×3 vector. The first two entries of that vector have the following meaning:

  • (t,l)

    It arranges the elements from top to bottom and left to right (simultaneously).

  • (t,r)

    It arranges the elements from top to bottom and right to left (simultaneously).

  • (b,l)

    It arranges the elements from bottom to top and left to right (simultaneously).

  • (b,r)

    It arranges the elements from bottom to top and right to left (simultaneously).

The third entry of the vector indicates the element in the arithmetic progression. If the value of the third input is 1, then we must carry out the sorting starting from the element a; if it is 2, we use the element a+d; if it is 3, we start with the element a+2d; and, if the value of the third input of the vector is 4, we carry out the sorting starting from the element a+3d. To understand the above notation, we break the magic square MS1 into four 2×2 squares (denoted by A, B, C and D), as displayed in Table 4.

Table 4.

Partition the 4 × 4 magic square (MS) into four 2 × 2 squares.

5.

Using the proposed method, the squares A, B, C, and D are the following:

5.

Combining squares A, B, C and D, the 4×4 magic square that we see in Table 2 is reached. If a=1 and d=6, then we obtain the 4×4 magic square presented in Table 5.

Table 5.

The 4 × 4 magic square (MS) built.

5.

The resulting 4×4 magic square has repeated elements 1, 7, 13, and 19. These elements define an arithmetic progression and, in addition, constitute (except the first element) the unique prime decomposition of Ramanujan's number, that is, 1729=1×7×9×13, as we can see in Table 5. Therefore, in this square, the magic sum and product are 40 and 1729, respectively. Note that no other combination of integer numbers produces this magic square.

6. Special features of the obtained repetitive magic square

Next, we provide some unique features of the obtained repetitive magic square. The elements we use to construct the magic square are the number 1 (which is not prime or composite) and the prime factors of the number 1729 (that is, the numbers 7, 13, and 19). These elements are in arithmetic progression with the first element a=1, common difference d=6, and last element l=19. The element corresponding to the number 1 plays an essential role in this magic square. The reader may think that the number 1 is not necessary to get the magic product 1729 and that, if the number 1 is not used, it produces a 3×3 repetitive square matrix with sum and product 39 and 1729, respectively. However, this is not the case because, after several attempts, we conjecture that 4×4 is the smallest array size for a repetitive magic square. We test 2×2 and 3×3 matrices, which were generated using 3×3 and 4×4 matrices, respectively, with an additional element corresponding to the number 1 and 2×2, 3×3 matrices.

We explain the reason for doing this conjecture after the following discussion. Note that the number 1 is unavoidable and very important for making a 4×4 repetitive magic square, allowing us to obtain the desired magic product corresponding to the number 1729. Hence, the unique features of the obtained repetitive magic square can be summarized as follows: (i) the order 4×4 is the smallest matrix size of this square; (ii) its magic elements are in arithmetic progression; and (iii) all the elements other than the number 1 are the only possible prime factors of Ramanujan's number 1729.

The reason for the 4×4 magic square to be the smallest possible one is that we must first recall the definition of a magic square. This definition indicates that the sum along the row, column, and each diagonal should be the same. Otherwise, it is not a magic square. We have taken a repetitive magic square, that is, its elements can be repeated. Nonetheless, such elements should be equal to the order of the magic square, which is our conjecture.

By the definition of a repetitive magic square, as mentioned, all its elements must be used in all rows, columns, and diagonals, with no element being employed more than once in a row, column, and diagonal. In this kind of magic square, as also mentioned, we have the conditions that the number of its elements must be equal to the number of rows and also to the number of columns; as well as the number of its elements must be less than the number of rows multiplied by the number of columns. Due to these conditions, we do not consider

(2222)

or

(333333333)

as repetitive magic squares. Also, if we suppose to take our repetitive magic square with elements 1, 7, 13, and 19 as an example, we see what would happen if we omit the number 1. In that case, the matrix is

(713191319719713)

Note that this matrix may look like a magic square, but we see in the back diagonal that 19, 19, and 19 have 57 as the magic sum, while the remaining rows, columns, and another diagonal arrive at the number 39 as the magic sum. This contradicts the fact that a magic square does not have more than one magic sum.

7. Construction of 4×4 repetitive magic squares

Next, we propose an algorithm to build 4×4 repetitive magic squares with four elements in arithmetic progression.

From a magic sum S, we must choose two integers a and d for 4a+6d=S. The necessary and sufficient condition for the linear Diophantine equation 4a+6d=S to have a solution is that GCD(4,6)|S2|S, that is, the greatest common divisor (GCD) between 4 and 6 divides S indicating S must be even. If S=2m and m is an integer number, then the general solution of the linear Diophantine equation is a=3km and b=2k+m, where k is any integer number. For example, the magic square of Table 5 is obtained if m=20 (S=40) and k=7. Algorithm 1 summarizes our procedure.

Algorithm 1.

Algorithm 1

Procedure to build a 4 × 4 repetitive magic square.

As an illustration, if S=100 and k=18, we obtain the repetitive magic square of Table 6, and if S=50 and k=10, we obtain the repetitive magic square of Table 7. This last magic square also has the particularity that it is built with the first four positive multiples of the number 5. The products of the magic squares are, respectively, P=105,984 and P=15,000.

Table 6.

The 4 × 4 magic square (MS) built with S = 100 and k = −18.

7.

Table 7.

The 4 × 4 magic square (MS) built with S = 50 and k = −10.

7.

8. Conclusions

In this article, we have provided some unique features of repetitive magic or Latin squares. We have used the number 1 and the prime factors, corresponding to the numbers 7, 13, and 19 of the number 1729, to construct our magic square. These numbers are in arithmetic progression. The number 1 has played an essential role in this magic square. We have conjectured that 4×4 is the smallest matrix size for a repetitive magic square. Thus, the number 1 is unavoidable and very important for making a 4×4 repetitive magic square, obtaining the desired magic product corresponding to the number 1729. We have tested 2×2 and 3×3 matrices, which were generated using 3×3 and 4×4 matrices, respectively, with an additional element corresponding to the number 1, and 2×2, 3×3 matrices, which was justified in Section 6.

Therefore, the following points summarize the results obtained in the present work:

  • (i)

    We have constructed a repetitive 4×4 square with Ramanujan's number 1729 as its magic product.

  • (ii)

    The magic sum of the constructed square is equal to 40.

  • (iii)

    The order 4×4 is the smallest matrix size of the repetitive magic square.

  • (iv)

    Its magic elements are in arithmetic progression.

  • (v)

    All the elements different from the number 1 are the only possible prime factors of Ramanujan's number 1729.

  • (vi)

    We have detected that any repetitive magic square, whether the elements are in arithmetic progression or not, gives both magic sum and product.

  • (vii)

    We have proposed an algorithm to construct 4×4 repetitive magic squares using a Diophantine equation.

A limitation of this work is that it requires at least a magic square of the fourth order with several elements that should be equal to the matrix order. The number 1 used here does not make any sense in the product. However, if it is not used, the unique magic sum will not be attained to convert a matrix into a repetitive magic square.

This study also restricts the one-element repetitive matrix as the magic square. For example, the matrix given by

(2222)

is repetitive. Nevertheless, we cannot accept the restriction that the number of its elements must be equal to the order of the matrix. Here, the number 2 is the only element. Therefore, the number of elements is equal to 1, but its order is equal to 2, so this matrix is not accepted as a repetitive magic square.

Declarations

Author contribution statement

Prasantha Bharathi Dhandapani, Victor Leiva, and Carlos Martin-Barreiro conceived, designed, and performed the formulations and experiments; analyzed and interpreted the results; and wrote the present article.

Funding statement

The research of Victor Leiva was partially funded by National Agency for Research and Development (ANID) of the Chilean government under the Ministry of Science, Technology, Knowledge and Innovation [grant FONDECYT 1200525].

Data availability statement

No data were used for the research described in the article.

Declaration of interests statement

The authors declare no conflict of interest.

Additional information

No additional information is available for this paper.

Footnotes

1

G.H. Hardy was an English mathematician known for his achievements in number theory and mathematical analysis.

Contributor Information

Prasantha Bharathi Dhandapani, Email: d.prasanthabharathi@gmail.com, prasanthabharathi.d@sece.ac.in.

Víctor Leiva, Email: victorleivasanchez@gmail.com.

Carlos Martin-Barreiro, Email: cmmartin@espol.edu.ec.

References

  • 1.Kudrle J.M., Menard S.B. In: The CRC Handbook of Combinatorial Designs. Colbourn C.J., Dinitz J.H., editors. CRC Press; Boca Raton, FL, US: 2006. Magic squares; pp. 524–528. [Google Scholar]
  • 2.Behforooz H. On constructing 4 by 4 magic squares with pre-assigned magic sum. J. Math. Spectrum. 2008;40:127–134. [Google Scholar]
  • 3.Borkovitz D., Hwang F.K. Multiplicative magic squares. Discrete Math. 1983;47:1–11. [Google Scholar]
  • 4.Berndt B.C. Springer; New York: 1985. Ramanujan's Notebooks. Part I. [Google Scholar]
  • 5.Horner W.W. Addition-multiplication magic squares. Scr. Math. 1952;18:300–303. [Google Scholar]
  • 6.Sim K.A., Wong K.B. Magic square and arrangement of consecutive integers that avoids k-term arithmetic progressions. Mathematics. 2021;9:2259. [Google Scholar]
  • 7.Horner W.W. Addition-multiplication magic square of order 8. Scr. Math. 1955;21:23–27. [Google Scholar]
  • 8.Karpenko V. Two thousand years of numerical magic squares. Endeavour. 1994;18:147–152. [Google Scholar]
  • 9.Ku Y.H., Chen N.X. On systematic procedures for constructing magic squares. J. Franklin Inst. 1986;321:337–350. [Google Scholar]
  • 10.Zhang Y., Li W., Lei J. Existence of weakly pandiagonal orthogonal Latin squares. Acta Math. Sin. 2013;29:1089–1094. [Google Scholar]
  • 11.Du B. The existence of orthogonal diagonal Latin squares with subsquares. Discrete Math. 1996;148:37–48. [Google Scholar]
  • 12.Cao H., Li W. Existence of strong symmetric self-orthogonal diagonal Latin squares. Discrete Math. 2011;311:841–843. [Google Scholar]
  • 13.Moslemi V., Erfanian V., Ashoor M. Estimation of optimized timely system matrix with improved image quality in iterative reconstruction algorithm: a simulation study. Heliyon. 2020;6 doi: 10.1016/j.heliyon.2020.e03279. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • 14.Arnauld A. Savreux; Paris, France: 1667. Nouveaux Elements de Geometrie. [Google Scholar]
  • 15.Devi S. Book of numbers. Orient Paperbacks; New Delhi, India; 2006. [Google Scholar]
  • 16.Bocker R.P., Frieden B.R. A new matrix formulation of the Maxwell and Dirac equations. Heliyon. 2018;4 doi: 10.1016/j.heliyon.2018.e01033. [DOI] [PMC free article] [PubMed] [Google Scholar]

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

No data were used for the research described in the article.


Articles from Heliyon are provided here courtesy of Elsevier

RESOURCES