Search for a tool
Magic Square

Tool to generate magic squares size N, kind of matrices composed of distinct integers set such as the sum of any row or column are equal.

Results

Magic Square -

Tag(s) : Number Games, Fun/Miscellaneous, Arithmetics

Share
Share
dCode and more

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Magic Square' tool for free! Thank you!

Magic Square

Magic Square Generator




Magic Square Solver


Loading...
(if this message do not disappear, try to refresh this page)




Answers to Questions (FAQ)

What is a magic square? (Definition)

A magic square is a grid of numbers arranged so that the sum of each row, each column and its diagonals are all equal to the same value, called the magic sum (or magic constant).

Magic squares are popular for their simplicity and mathematical properties.

How to create a magic square?

A magic square arranges numbers so that their placement follows construction rules that ensure that the sums of rows, columns, and diagonals equal the magic sum.

Construction methods vary depending on the order of the square (number of rows/columns).

How to create a magic square of odd order?

The creation of magic squares of size (3,5,7 etc.) is possible by several methods, the simplest is the so-called Loubère method (staircase method):

Place 1 in the center of the first line, then the following numbers in the box located diagonally at the top left. If the box is outside the square, imagine that the square wraps around itself and continue on the other end (as if the left column were to the right of the right column, and the bottom line, at the above the top line). If the target square is occupied, then continue directly below the last filled square.

Example: Staircase method generating a magic square of order 3:

816
357
492

Example: Staircase method generating a magic square of order 5 :

17241815
23571416
46132022
101219213
11182529

How to create a magic square of even order?

Creating magic squares of even order (4,6,8, etc.) is more complicated and the methods are not universal.

Symmetry method for squares of size 4:

— Place the numbers naturally from 1 at the top left to 16 at the bottom right.

— Replace the numbers on the sides (2, 3, 5 and 9) by their central symmetry (relative to the center of the square).

Example:

1234
5678
9101112
13141516
becomes
115144
12679
810115
133216

Other methods generally rely on creating odd subsquares.

How to solve a magic square?

The magic way to solve magic squares is to set the equations that govern each row and column, with unknowns. The constraints being that the unknowns are all different positive integers (distinct including numbers already placed).

Example: The magic square of magic value $ X $

abc
def
ghi
translates into equations: $ a+b+c = X \\ d+e+f = X \\ g+h+i = X \\ a+d+g = X \\ b+e+h = X \\ c+f+i = X \\ a+e+i = X \\ c+e+g = X $

The equations obtained sometimes have several solutions.

What are the minimal possible sums (magic values)?

The constant values $ M $ of the sums of the magic squares have a minimum value (for non-zero integer positive values).

$$ M = n(n^2+1)/2 $$

For a size 3x3, the minimum constant is 15, for 4x4 it is 34, for 5x5 it is 65, 6x6 it is 111, then 175, 260, …

Any lower sum will force the use of either negative numbers or fractions (not whole numbers) to solve the magic square.

What are the maximal possible sums (magic values)?

The values can be as large as you want, so the maximum magic sum/value is infinity.

What is a panmagic square?

A panmagic square, also called a pandiagonal square, is a special type of magic square. Unlike traditional magic squares, where only rows, columns, and major diagonals have equal sums, a panmagic square has an additional property: the sums of the numbers along all its diagonals (including minor diagonals) are equal. also equal to the magic sum.

Is there a Magic Square in 3D (Magic Cube)?

Yes, there are magic cubes, their magic value is $$ M = n(n^3+1)/2 $$ (which may or may not have magic diagonals)

Example:

19176
52116
18420
15126
25143
22713
82410
12723
22119

What is the Franklin Square?

Franklin's square, published in 1769 by Benjamin Franklin, is a semi-panmagic square with a magic constant of 260.

Example:

526141320293645
143625146353019
536051221283744
116595443382722
555871023263942
98575641402524
506321518313447
161644948333217

What is the Lo-Shu Magic Square?

This is a 3x3 magic square used in Feng Shui which is represented as well

4
Wealth
9
Fame
2
Relationship
3
Family
5
Health
7
Children
8
Wiseness
1
Career
6
Help/Friends

What is the Kaldor Magic Square?

Kaldor's magic square is a square used in economics, which has nothing to do with digits or numbers of mathematics but rather with concepts from economic policy.

Source code

dCode retains ownership of the "Magic Square" source code. Except explicit open source licence (indicated Creative Commons / free), the "Magic Square" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Magic Square" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Magic Square" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.

Cite dCode

The copy-paste of the page "Magic Square" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Magic Square on dCode.fr [online website], retrieved on 2024-11-15, https://www.dcode.fr/magic-square

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Magic Square' tool for free! Thank you!


https://www.dcode.fr/magic-square
© 2024 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.
 
Feedback