MATHEMATICS

Selasa, 19 April 2011

Magic squares of type n-by-n

I wrote a small program that can generate a magic square for any size of a matrix. The idea is that this program can support me in my quest to generate some particular normal magic squares. The ideas I got thus far were too computationally intensive though. It remains an interesting enough playground for me, a challenging enough problem that I might solve one day. - I have read that you need some sort of portfolio of problems on which you can work alternately depending on how you feel, think, etc. on a given moment.

$$
\left(
\begin{array}{ccc}
9 & 6 & 3 \\
0 & 6 & 12 \\
9 & 6 & 3
\end{array}
\right)
$$
$$
\left(
\begin{array}{cccc}
9 & 6 & -1 & -4 \\
5 & -6 & 3 & 8 \\
-8 & 7 & 6 & 5 \\
4 & 3 & 2 & 1
\end{array}
\right)
$$
$$
\left(
\begin{array}{ccccc}
40 & 30 & -46 & 8 & -2 \\
40 & -43 & 30 & -11 & 14 \\
-52 & 26 & 24 & 22 & 10 \\
-8 & 9 & 16 & 7 & 6 \\
10 & 8 & 6 & 4 & 2
\end{array}
\right)
$$
$$
\left(
\begin{array}{cccccc}
165 & 118 & -86 & -79 & -59 & -38 \\
84 & -187 & 48 & 46 & 8 & 22 \\
-113 & 42 & 20 & 19 & 36 & 17 \\
-78 & 32 & 15 & 14 & 26 & 12 \\
-43 & 11 & 20 & 18 & 8 & 7 \\
6 & 5 & 4 & 3 & 2 & 1
\end{array}
\right)
$$
$$
\left(
\begin{array}{ccccccc}
344 & 272 & -144 & -180 & -124 & -66 & -46 \\
228 & -391 & 70 & 68 & 66 & -17 & 32 \\
-202 & 62 & 30 & 58 & 28 & 54 & 26 \\
-194 & 50 & 48 & 46 & 44 & 42 & 20 \\
-94 & 38 & 18 & 34 & 16 & 30 & 14 \\
-40 & 13 & 24 & 22 & 20 & 9 & 8 \\
14 & 12 & 10 & 8 & 6 & 4 & 2
\end{array}
\right)
$$
$$
\left(
\begin{array}{cccccccc}
795 & 644 & -283 & -272 & -261 & -250 & -213 & -124 \\
493 & -890 & 96 & 94 & 92 & 90 & 17 & 44 \\
-406 & 86 & 42 & 82 & 80 & 39 & 76 & 37 \\
-329 & 72 & 70 & 34 & 33 & 64 & 62 & 30 \\
-252 & 58 & 56 & 27 & 26 & 50 & 48 & 23 \\
-175 & 44 & 21 & 40 & 38 & 18 & 34 & 16 \\
-98 & 15 & 28 & 26 & 24 & 22 & 10 & 9 \\
8 & 7 & 6 & 5 & 4 & 3 & 2 & 1
\end{array}
\right)
$$

Tidak ada komentar:

Posting Komentar