Showing posts with label magic constant. Show all posts
Showing posts with label magic constant. Show all posts

Friday, 26 April 2024

Perimeter Magic Polygons

My previous post was titled Anti-Magic Squares Revisited in which I mentioned heterosquares. Only today however, I came across the concept of a perimeter magic square that is an example of a perimeter magic polygon or PMP to use an acronym. The definition is:

A PMP is defined to be a regular polygon with the consecutive positive integers from 1 to N placed along the perimeter in such a way that the sums of the integers on each side are constant. The order of a polygon refers to the number of integers along each side. The examples in Figures 1, 2 and 3 show a 4th-order triangle, and a 3rd-order square and pentagon. The magic constants are given inside the figures. Source.

Let's look at some perimeter magic triangles to begin with. To quote from Wikipedia:
A magic triangle or perimeter magic triangle is an arrangement of the integers from 1 to \(n\) on the sides of a triangle with the same number of integers on each side, called the order of the triangle, so that the sum of integers on each side is a constant, the magic sum of the triangle. Unlike magic squares, there are different magic sums for magic triangles of the same order. Any magic triangle has a complementary triangle obtained by replacing each integer \(x\) in the triangle with \(1 + n − x\). See Figure 4.


Figure 4

The author of this paper comes up to two sets of formula in which \(C\) is the magic constant,  \(n\) is the order of the polygon and \(k\) is the number of sides. Figures 5 and 6 show these.

Figure 5 shows the formulae for the case of \(n\) even or both \(n\) and \(k\) odd.


Figure 5

Figure 6 shows the formulae for the case of \(n\) is odd and \(k\) is even.


Figure 6

To quote from the article:
With these formulas one can now begin to construct PMPs of any order and number of sides. One word of caution is still in order. There are times when a solution is not possible for certain values of C. The formulas only serve to indicate where solutions may be found, and that there is no need to look elsewhere. However, luck is still with the solver. Based on this author's experience, there are only two cases where solutions cannot be made with values obtained from the formulas. These are 4th-order triangles with \(C \) = 18 and 22, and 3rd-order pentagons with \( C \) = 15 and 18.

By controlling certain of the variables, one can discover some interesting patterns that permit the rapid construction of special PMPs. For example, for 3rd-order PMPs with an odd number of sides, it can be proved that a solution s always possible for the minimum \(C \). And it can be further demonstrated (to the amazement of your friends) that you can produce the solution just as rapidly as it takes to write the \(N\) integers. Rather than present the proof here, two examples will be given, and you can easily note the pattern for yourself.

Figure 7 shows the two examples. 14 is the minimum value of \(C\) for \(n\) = 3 and \(k\) = 5. 19 is the minimum value for \(n\) = 3 and \(k\) = 7.


Figure 7

The pattern in easily perceived once you look at the numbers closely. The article goes further into how to create various PMPs and reference should be made to that for further examples. 

I stumbled upon this topic by way of the number associated with my diurnal age today, 27417. This number is a member of OEIS A135503 for the case where \(n\) = 38.


 A135503

\( \text{a} (n) = \dfrac{n \cdot (n^2 - 1)}{2} \)



The initial members of the sequence are:

0, 0, 3, 12, 30, 60, 105, 168, 252, 360, 495, 660, 858, 1092, 1365, 1680, 2040, 2448, 2907, 3420, 3990, 4620, 5313, 6072, 6900, 7800, 8775, 9828, 10962, 12180, 13485, 14880, 16368, 17952, 19635, 21420, 23310, 25308, 27417, 29640, 31980, 34440

The OEIS comments state that for \(n\) > 2, a(\(n\)) is the maximum value of the magic constant in a perimeter-magic \(n\)-gon of order \(n \). For the case of \(n\) = 38, \(n\) is even and so the formula in Figure 5 applies. Substituting in \(n\) = 38 and \(k\) = 38 does indeed give the maximum value of the magic constant as 27417.

Monday, 4 September 2023

Magic Constants Involving Prime Numbers

I recently turned 27180 days old and one of the properties of this number qualifies it for membership in OEIS A192087:


  A192087

Potential magic constants of a 10 X 10 magic square composed of consecutive primes.


The members of this sequence are (permalink):

2862, 3092, 3500, 4222, 4780, 5608, 7124, 10126, 10198, 11212, 11426, 12140, 12212, 12284, 12356, 12428, 12714, 12854, 12924, 15270, 16252, 16476, 18594, 18672, 18750, 18828, 19214, 20764, 21150, 23752, 24214, 24598, 24828, 27180, 27342, 27424, 27916, 28666, 29406, 29568

The OEIS comments are:
For a 10 X 10 magic square composed of 100 consecutive primes, the sum of these primes must be a multiple of 20. This sequence consists of even integers equal the sum of 100 consecutive primes divided by 10. It is not known whether each such set of consecutive primes can be arranged into a 10 X 10 magic square but it looks plausible. Actual magic squares were constructed for all listed magic constants less than or equal to 11212.

 Here are the confirmed magic squares:

S = 2862

23 179 409 373 263 137 461 457 523 37

193 353 443 199 317 109 337 397 131 383

71 73 389 251 593 167 439 449 233 197

571 293 101 229 29 557 271 31 379 401

127 419 283 241 269 239 547 89 181 467

491 433 223 113 41 577 43 311 563 67

281 97 163 587 191 313 149 509 421 151

307 499 227 431 103 83 59 479 211 463

277 359 257 331 569 541 53 79 47 349

521 157 367 107 487 139 503 61 173 347

 

S = 3092

41 491 599 487 373 229 541 73 79 179

397 101 137 167 461 127 557 523 263 359

449 251 383 107 197 149 191 521 401 443

569 139 587 479 83 317 181 241 257 239

601 367 109 89 509 157 43 593 277 347

193 463 467 389 281 607 113 97 379 103

163 547 409 499 59 439 223 173 311 269

71 53 61 211 571 563 433 131 577 421

271 613 293 233 227 353 307 283 199 313

337 67 47 431 331 151 503 457 349 419

 

S=3500

71 211 257 223 587 643 443 313 613 139

379 653 491 293 167 227 503 97 439 251

191 563 137 409 569 269 353 523 113 373

521 101 271 617 431 367 73 557 173 389

383 131 311 179 401 359 397 547 283 509

157 499 577 337 233 541 83 347 619 107

421 109 229 197 599 151 419 103 641 631

263 601 457 479 307 239 281 331 193 349

467 433 163 317 79 241 487 593 149 571

647 199 607 449 127 463 461 89 277 181

 

S = 4222

131 149 443 607 647 619 521 499 257 349

139 431 547 293 137 587 523 389 467 709

701 317 359 379 263 577 197 227 571 631

617 509 653 251 673 503 421 151 277 167

191 593 229 449 179 661 397 719 457 347

223 419 269 641 401 601 563 233 463 409

599 479 383 271 613 173 541 461 491 211

557 311 367 659 193 181 199 733 283 739

337 331 281 433 677 157 487 569 643 307

727 683 691 239 439 163 373 241 313 353

 

S = 4780

179 227 617 479 571 599 541 463 331 773

491 311 523 661 251 487 313 691 433 619

439 653 263 701 719 397 751 353 211 293

709 449 257 277 521 683 613 223 587 461

769 641 421 181 733 419 349 431 457 379

271 347 743 337 563 673 191 199 809 647

569 797 317 283 383 241 643 557 601 389

443 757 307 727 409 269 281 787 607 193

233 359 739 373 401 503 467 499 547 659

677 239 593 761 229 509 631 577 197 367

 

S=5608

251 281 809 491 661 619 263 631 863 739

409 857 571 641 593 599 479 389 283 787

659 587 557 577 547 683 827 317 541 313

353 601 347 821 257 769 859 743 509 349

761 431 271 269 331 653 727 773 569 823

379 677 643 673 487 383 719 523 373 751

883 521 881 359 421 563 367 401 709 503

797 439 757 449 647 293 467 733 607 419

839 877 311 499 811 433 443 397 691 307

277 337 461 829 853 613 457 701 463 617

 

S=7124

389 457 853 751 857 809 709 811 719 769

431 773 1013 733 877 971 739 401 677 509

563 823 467 409 421 997 547 887 977 1033

1009 859 587 1021 499 397 617 967 521 647

443 577 727 827 1039 937 593 821 487 673

991 659 439 449 613 881 541 941 691 919

1031 743 619 641 571 503 911 479 1019 607

983 757 829 1049 701 599 797 419 433 557

653 523 929 601 863 569 787 491 761 947

631 953 661 643 683 461 883 907 839 463

 

S=10126

661 829 683 1013 907 1171 1181 1217 1187 1277

1291 1237 809 1279 1063 797 743 1201 883 823

1039 733 857 1307 1097 827 1259 937 709 1361

821 859 1327 953 971 1297 769 1129 1249 751

1049 1019 1321 991 1109 1163 967 727 1103 677

1367 1231 1117 739 887 1087 673 853 1021 1151

701 1093 1009 787 947 977 1229 1319 1303 761

997 1153 1193 983 811 839 1373 863 691 1223

911 941 929 773 1051 1091 1213 1123 1061 1033

1289 1031 881 1301 1283 877 719 757 919 1069

 

S=10198

673 853 1009 859 1123 1063 971 1163 1103 1381

1069 1109 677 809 937 997 1213 1373 1187 827

1171 1193 907 1259 757 701 1249 911 743 1307

1327 1021 1097 863 761 1217 1229 881 709 1093

1087 821 1223 1291 1361 953 787 887 769 1019

857 811 1297 1129 1049 1301 929 1151 991 683

1367 1303 967 829 983 1031 877 941 1061 839

1051 691 719 1201 1277 1237 739 733 1319 1231

773 1117 1013 1039 797 947 1321 1181 1283 727

823 1279 1289 919 1153 751 883 977 1033 1091

 

S = 11212

769 863 1171 967 859 1381 1237 1459 1289 1217

1163 953 797 1297 1049 1021 1303 977 1423 1229

809 1277 1153 937 1151 1409 1291 839 1249 1097

1429 1231 1193 1451 1061 829 821 1361 823 1013

1453 997 947 1091 1321 887 1283 941 811 1481

1069 1201 1427 1129 907 919 1373 1039 1117 1031

1009 1123 1301 1093 1367 1483 911 1051 1087 787

991 1109 1279 877 1223 929 1187 1433 1327 857

1213 1439 1063 971 1447 883 773 1259 983 1181

1307 1019 881 1399 827 1471 1033 853 1103 1319

In the case of 27180, the primes to be organised into the 10 x 10 magic square are:

2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121

Friday, 12 November 2021

Ultramagic Squares

Here is a definition of an ultramagic square:

A magic square is associative if the sum of any two elements symmetric about its center is the same. A magic square is pandiagonal if the sum of the numbers in any broken diagonal equals the magic constant. A magic square is ultramagic if it is associative and pandiagonal. Ultramagic squares exist for orders n>=5. Source.

Using this as a starting point, let's understand what is meant by a pandiagonal magic square. Here is a definition taken from a most useful website:

Pandiagonal magic squares are magic squares, where also the broken diagonals sum to the magic constant. This means when you go off of one edge on a diagonal, continue (wrap-around) to the corresponding cell on the opposite edge. These squares are considered as one of the top classes of magic squares.

Figures 1 and 2 show clearly what is meant by a "broken diagonal" and show a 5 x 5 magic square that is pandiagonal. 


Figure 1


Figure 2

The magic square in Figures 1 and 2 however, is not associative. Using the central square (24) as a reference point, we note that, up-down 3 + 12 = 15 but left-right 20 + 6 = 26. These must be equal for a magic square to be associative. Figure 3 shows a 5 x 5 magic square that is both pandiagonal and associative, and thus ultramagic.

Figure 3

The magic constant for this square is 65 and it can be seen that all rows, columns, main diagonals and broken diagonals all add to this number. Furthermore, the up-down 6 + 20 = 26 and the left-right 2 + 24 = 26 are this time equal as are all the other symmetric pairs of elements.

Figure 3 shows a 7 x 7 ultramagic square:


Figure 4: source

Figures 5, 6 and 7 show 6 x 6, 7 x 7 and 8 x 8 prime ultramagic squares with magic constants of 990, 4613 and 2040 respectively:
Figure 5: source


Figure 6: source


Figure 8: source

These magic constants (990, 4613 and 2040) are the lowest possible and form part of OEIS A257316:


 A257316

Smallest magic constant of ultramagic squares of order \(n\) composed of distinct prime numbers.


The sequence runs 3505, 990, 4613, 2040 with 3505 being the magic constant (not shown) for the 5 x 5 ultramagic square with minimal magic constant. The following bounds for the next terms are known:
  • 12249 <=a(9) <=13059
  • 4200 <=a(10) <=46150
  • a(11) >= 26521
  • a(12) >= 8820
  • a(13) >= 49439
  • a(14) >= 16170
  • a(15) >= 74595
  • a(16) >= 21840
My attention was attracted to the topic because today I turned 26521 days old and this number happens to be the lower bound for the 11 x 11 prime ultramagic square with minimal magic constant. The exact composition of such a square is presumably still not known.

My earlier posts on Magic Squares are:

Monday, 17 May 2021

Prime Semi-Magic Squares

 I've posted about magic squares (and cubes) before, specifically:

Yesterday, I turned 26339 days old and one of the properties of this prime number is that it's a member of OEIS A270865:


 A270865

Smallest primes of 4 X 4 semi-magic squares formed from consecutive primes. 
 

A semi-magic square has all its rows and columns adding to a constant number, but not its diagonals. Up to 26339, the OEIS sequence runs:
5, 19, 29, 31, 37, 47, 53, 79, 397, 409, 599, 787, 1229, 1381, 1439, 1993, 2087, 2767, 4003, 4159, 4931, 5791, 5981, 8117, 9293, 9349, 9833, 10939, 10979, 11213, 12553, 12907, 14557, 16361, 18047, 21089, 21557, 21577, 25903, 26339

In the OEIS comments for the sequence, examples are shown for 5 and 19:$$\begin{array}{|c|c|c|c|}

\hline 5 & 7 & 53 & 59 \\

\hline 29 & 61 & 23 & 11\\

\hline 43 & 37 & 31 & 13\\

\hline 47 & 19 & 17 & 41 \\

\hline

\end{array}$$ $$\begin{array}{|c|c|c|c|}

\hline 19 & 23 & 79 & 83 \\

\hline 53 & 67 & 37 & 47\\

\hline 61 & 41 & 59 & 43 \\

\hline 71 & 73 & 29 & 31 \\

\hline


\end{array}$$In the magic square beginning with 5, the 16 primes (5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61) total 496 and every row and column totals 496 ÷ 4 = 124 which is the magic constant of the square. The sum total of the primes must always be a multiple of 4. We know the next set of primes starts with 19 so what happens if we use a set of primes starting with 7, 11, 13 and 17:

  • 7 gives a total of 558 which is not divisible by 4
  • 11 gives a total of 662 which is not divisible by 4
  • 13 gives a total of 684 which is divisible by 4 to give 171
  • 17 gives a total of 750 which is not divisible by 4
From this we can see that divisibility of the prime sum by 4 is a necessary but not sufficient condition for ensuring that a semi-magic square can be created. 13 serves as a reminder of this. A little thought reveals that for an \(n \times n \) magic square, not only must the sum of the terms be divisible by \(n\), the quotient must be even when \(n\) is even and odd when \(n\) is odd. As can be seen, if we start with 13 as the first consecutive prime, the quotient is odd. The reason is that in the case of a 4 x 4 magic square, each column and row consists of four odd primes that when added together must produce an even total.

In the case of 26339, the primes are:

26339, 26347, 26357, 26371, 26387, 26393, 26399, 26407, 
26417, 26423, 26431, 26437, 26449, 26459, 26479, 26489

These primes total 422584 and thus the magic constant is 105646. The problem is how to arrange these primes into a semi-magic square. As can be seen, the pattern of the placement of primes is different between the semi-magic square beginning with 5 and the one beginning with 19. It seems as if each arrangement of numbers might be unique. I tried using the same pattern as found in Durer's famous 4 x 4 magic square but no luck. There are a staggering 20,922,789,888,000 or over twenty trillion ways to form a 4 x 4 grid of 16 numbers  and even SageMathCell cannot search through all these possibilities. What I'm looking for is a method to populate a 4 x 4 semi-magic square with 16 non-consecutive elements.

The number of groups of primes making up the 4 x 4 semi-magic squares are relatively rare. 26339 marks the first member of the 40th such group. Not surprisingly, the number of groups of primes making up 4 x 4 fully magic squares are ever rarer. The following sequence begins 31, 37, 1229, 4931, 12553, 3259909, 3324329, 9291521, ...


 A260673

Smallest primes of 4 X 4 magic squares formed from consecutive primes.   


Here is the magic square of consecutive primes beginning with 37. It has a magic constant of 258:$$\begin{array}{|c|c|c|c|}\hline 37 & 83 & 97 & 41 \\
\hline 53 & 61 & 71 & 73\\

\hline 89 & 67 & 59 & 43\\

\hline 79 & 47 & 31 & 101 \\

\hline

\end{array}$$This of course doesn't solve my problem of how to arrange the primes in my 4 x 4 semi-magic square with its magic constant of 105646. One thing to consider would be the gaps between the primes. These average of these gaps is 10 and the actual gaps are:

26339 to 26347 is a gap of 08 with total of 008
26347 to 26357 is a gap of 10 with total of 018
26357 to 26371 is a gap of 14 with total of 032
26371 to 26387 is a gap of 16 with total of 048
26387 to 26393 is a gap of 06 with total of 054
26393 to 26399 is a gap of 06 with total of 060
26399 to 26407 is a gap of 08 with total of 068
26407 to 26417 is a gap of 10 with total of 078
26417 to 26423 is a gap of 06 with total of 084
26423 to 26431 is a gap of 08 with total of 092
26431 to 26437 is a gap of 06 with total of 098
26437 to 26449 is a gap of 12 with total of 110
26449 to 26459 is a gap of 10 with total of 120
26459 to 26479 is a gap of 20 with total of 140
26479 to 26489 is a gap of 10 with total of 150

The reason I've listed these gaps between the primes is that a lot of importance seems placed on numbers been in arithmetic progression. At this location on Quora, there is a method shown for filling the traditional 4 x 4 magic square with the numbers from 1 to 16. See Figure 1.

Figure 1: source

I tried this using my prime numbers with 26339 replacing 1, 26347 replacing 2 etc. but it didn't work. So my search continues but along the way I've discovered new types of magic squares. For example, bimagic means a magic square remaining magic after each of its numbers have been squared. The smallest possible 4×4 semi-bimagic square of prime numbers begins with 29 and is shown in Figure 2:
Figure 2: source

For this magic square, the magic constant is 1190 and when the terms are squared, the magic constant becomes 549100. Lots of interesting information on magic squares to be found at the source site listed in Figure 2.

The knight's tour often comes up in the construction of magic squares as can be seen in this initial populating of the squares in Figure 3. A knight's tour is only possible on a board with an even number of squares. However, it is apparently not possible on a 4 x 4 board. In fact, the 5 x 6 and 3 x 10 boards are the smallest rectangular boards that have knight's tours. Source.

Figure 3: source

From the same source as listed in Figure 3, the method shown in Figure 4 is suggested as a way to arrange 16 elements into a 4 x 4 magic square:

Figure 4: source

I'm wondering if this strategy might be successful if used with the gaps that I've listed between the primes. I don't have four of every \(a,b,x,y\) but my magic square only needs to be semi-magic. In Figure 2, the knight moves can be seen in the path between \(a\) and \(a+x\), \(b\) and \(b+x\) etc. So far though no luck. I'll keep trying and add to this post when I succeed.

It can be noted that 26339, the first prime in the set of 16 primes that I'm trying to arrange into a semi-magic square, is a Luhn prime of the first order because 26339 + 93362 = 119701 which is a prime number. This is the property that defines a Luhn prime, namely that the prime number itself when added to its reverse, produces a new prime. I posted about Luhn Primes in a post on my birthday, April 3rd 2021. However, this property of 26339 doesn't seem to help in solving my problem.

One approach is to subtract 26339 from every term so that the sequence starts with zero. This gives: 0, 8, 18, 32, 48, 54, 60, 68, 78, 84, 92, 98, 110, 120, 140, 150 and these terms have a median of 73. If we subtract 73 from each we get:

-73, -65, -55, -41, -25, -19, -13, -5, 5, 11, 19, 25, 37, 47, 67, 77

The magic constant for this set of numbers is -2. If I subtract 72, the magic constant is 2, so a magic constant of zero isn't possible. Perhaps it will be easier to work with these smaller numbers. If I come up with a semi-magic square for these numbers, then I simply need to add 26339 + 73 = 21412 to the numbers above.

Monday, 21 September 2020

Magic Squares

This post was inspired by my daily number analysis of my diurnal age. I was struggling to find something of interest about 26102 when I discovered that a \(4 \times 4 \) magic square could be created in which 26102 was the magic constant. This got me thinking about what numbers could be represented in this way as magic squares.

A \(n \times n \) magic square has its \(n^2\) cells filled with the numbers from \(1 \text{ to } n^2 \) in such a way that the sums of all rows, columns and main diagonals are the same. This sum is called the magic constant:$$ \frac{n(n^2+1)}{2}$$The \(3 \times 3 \) magic square contains the numbers from 1 to 9 and all rows, columns and main diagonals add up to 15. Thus the magic constant is 15.$$


\begin{array}{|c|c|c|}

\hline 8 & 1 & 6 \\

\hline 3 & 5 & 7\\

\hline 4 & 9 & 2 \\

\hline

\end{array}

$$If we add 1 to each element of the above magic square, we get the next magic square and this has a magic constant of 18:$$\begin{array}{|c|c|c|}

\hline 9 & 2 & 7 \\

\hline 4 & 6 & 8\\

\hline 5 & 10 & 3 \\

\hline

\end{array}$$All subsequent \(3 \times 3 \) magic squares will have magic constants that are multiples of 3. Thus the number 26097 = 3 x 8699 can be represented as:$$\begin{array}{|c|c|c|}

\hline 8702 & 8695 & 8700 \\

\hline 8697 & 8699 & 8701\\

\hline 58698 & 8703 & 8696 \\

\hline

\end{array}$$We could represent the various matrices in terms of a subscript for their size and a superscript for their magic sum. This is purely my own invention but it means we would have: M\(_3^{15}\), M\(_3^{18}\) and M\(_3^{26097} \) where M is any matrix that satisfies the condition of being magic and having a particular size and magic sum. The \(4 \times 4\) magic square containing the numbers 1 to 15 has a magic sum of 34:$$\begin{array}{|c|c|c|c|}

\hline 16 & 2 & 3 & 13 \\

\hline 5 & 11 & 10 & 8\\

\hline 9 & 7 & 6 & 12 \\


\hline 4 & 14 & 15 & 1 \\

\hline

\end{array}$$It would be designated as M\(_4^{34}\) in my system. The subsequent magic sums that are possible are 38, 42, 46, 50 and so on. To test whether a number can be the magic constant for a \(4 \times 4\) magic square, simply subtract 34 from the number and test whether the result is divisible by 4. In the case of 26102, it is and so we have:$$\begin{array}{|c|c|c|c|}\hline 6533 & 6519 & 6520 & 6530 \\


\hline 6522 & 6528 & 6527 & 6525\\

\hline 6526 & 6524 & 6523 & 6529 \\


\hline 6521 & 6531 & 6532 & 6518 \\

\hline

\end{array}$$This magic square can be designated M\(_4^{26102}\). Figures 1 and 2 shows the magic squares together with their magic sums and associated planet or luminary.

Figure 1: source


Figure 2: source

The \(5 \times 5 \) magic square has a constant of 65 and so any subsequent multiples of 5 will be representable as \(5 \times 5 \) magic squares. The \(6 \times 6 \) magic square has a constant of 111 which is 3 x 37. This means that 117, 123, 129 etc. can be represented as \(6 \times 6 \) magic squares but these numbers are not multiples of 6. To determine whether a number can be the magic constant for a \(6 \times 6 \) magic square, the 111 must first be subtracted and the result tested for divisibility by 6. This is like the \(4 \times 4 \) case.

For the \(7 \times 7 \) magic square, the constant is 175 = 7 x 25 and so any multiple of 7 can be represented by a \(7 \times 7 \) magic square. For the \(8 \times 8 \) magic square, the constant is 260 = 4 x 65 which is not divisible by 8 and the situation is as the same as with 4 and 6. For the \(9 \times 9 \) magic square, the constant is 369 = 9 x 41 so all multiples of 9 above 369 qualify.

Figure 3 shows the magic constants for larger magic squares:


Figure 3: source

So generally, excluding 2, the prime factorisation of a number will quickly tell us what magic squares it can serve as a constant for. For example, 910 = 2 * 5 * 7 * 13 and so it can be represented by magic squares of side 5, 7 and 13. It can also be represented as a magic square with a composite number of sides but a little testing is required. For example, it can be represented as a \(4 \times 4 \) magic square but not \(8 \times 8 \). This site is great for such testing.

on May 14th 2021

Saturday, 16 February 2019

Magic Cubes

I had a dream some nights ago in which I dreamt of the number 42. I hadn't been reading or thinking about The Hitchhiker's Guide to the Galaxy but I was prompted by the dream to investigate some of the properties of this number. As I discovered, it's a pronic number or a product of consecutive digits, in this case 6 and 7. It's also a partition number since it is equal to the number of partitions of 10. For information about its being the sum of three cubes, see this blog post of mine. The number is also associated with the 3 x 3 x 3 magic cube as shown in Figure 1:

Figure 1: dissection of a 3 x 3 x 3 magic cube
Source: https://mathematicscentre.com/taskcentre/174magic.htm

In such a cube, all the rows and columns in each of the three square "slices" shown in Figure 1 add to 42. It would be the same if we sliced in other similar ways. The long diagonals (19, 14, 9 for example) also add to 42 but the diagonals within the slices do not. Figure 2 shows another possible configuration:

Figure 2: source 

9 rows, such as 1 - 17 - 24, sum to 42.
9 columns, such as 1 - 15 - 26, sum to 42.
9 Pillars, such as 1 - 23 - 18, sum to 42.
4 triagonals, such as 26 - 14 - 2 sum to 42.
 
Some of the squares may have diagonals summing to 42, but this is not a requirement. In fact, order-8 is the smallest cube for which it is possible for all the diagonals to sum correctly. 
What is required is that the 4 triagonals or 3-agonals, such as 1 - 14 - 27 sum to 42. 
There are four different basic pure (using numbers 1 to 27) magic cubes. Each of these have 48 equivalents due to rotations and/or reflections.
To quote from Wikipedia:
In mathematics, a magic cube is the 3-dimensional equivalent of a magic square, that is, a number of integers arranged in a \(n × n × n \) pattern such that the sums of the numbers on each row, on each column, on each pillar and on each of the four main space diagonals are equal to the same number, the so-called magic constant of the cube, denoted \(M_3(n)\). It can be shown that if a magic cube consists of the numbers \(1, 2, ..., n^3\), then it has magic constant (sequence A027441 in the OEIS):
$$
M_3(n) = \frac{n(n^3+1)}{2}
$$The OEIS sequence runs:
0, 1, 9, 42, 130, 315, 651, 1204, 2052, 3285, 5005, 7326, 10374, 14287, 19215, 25320, 32776, 41769, 52497, 65170, 80010, 97251, 117139, 139932, 165900, 195325, 228501, 265734, 307342, 353655, 405015, 461776, 524304, 592977, 668185, 750330, 839826, 937099
Of course, the formula above for 3 dimensions can be generalised to any number of dimensions. To quote again from Wikipedia:
In mathematics, a magic hypercube is the k-dimensional generalisation of magic squares, magic cubes and magic tesseracts; that is, a number of integers arranged in an \(n × n × n × ... × n\) pattern such that the sum of the numbers on each pillar (along any axis) as well as the main space diagonals is equal to a single number, the so-called magic constant of the hypercube, denoted \(M_k(n)\). It can be shown that if a magic hypercube consists of the numbers \(1, 2, ..., n^k\), then it has magic number: 
$$
M_k(n) = \frac{n(n^k+1)}{2}
$$For \(n=4\), the OEIS sequence A021003 is:
0, 1, 17, 123, 514, 1565, 3891, 8407, 16388, 29529, 50005, 80531, 124422, 185653, 268919, 379695, 524296, 709937, 944793, 1238059, 1600010, 2042061, 2576827, 3218183, 3981324, 4882825, 5940701, 7174467, 8605198, 10255589, 12150015
This whole topic leads in all sort of interesting directions but I'll have to leave off there and pursue some of these directions at another time.