Processing math: 100%
Ask Your Question
2

How one can find a matrix with given condition?

asked 4 years ago

Jaakko Seppälä gravatar image

updated 4 years ago

slelievre gravatar image

I found the following recreational mathematics problem too hard for me. Can anyone give me hints how to find a solution?

Consider a 4×4 matrix with integer coefficients. Let its elements be ai,j for 1i,j4. Now form four sets A1, A2, A3, A4. Say that A1 is the set of elements ai,j. Also, A2 is the set of elements ai,j+ai+1,j+ai,j+1+ai+1,j+1 i.e. the set of sums of elements of 2×2-subsquares of the matrix. Similarly, denote by A3 the set of sums of 3×3-submatrices and A4 the set containing the sum of all elements of the given 4×4-matrix.

Now, I heard a rumor that one can give an example of 16 integers ai,j such that all integers from 1 to 25 belong to A1A2A3A4. How can one find such an example? It is easy to see that at least some of the elements ai,j must satisfy 1ai,j25 but there are still so many elements that finding such a matrix by brute force seems impossible. I was wondering if genetic algorithms or simulated annealing work for such a problem but I don't have enough experience to implement that.

The best I know is that getting all integers from 1 to 24 is possible, for instance using the matrix:

-42  22  23   7
 13  11 -32  14
-23  16  15   8
 19   9 -22   1
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

Max Alekseyev gravatar image

updated 4 years ago

Here is a matrix you want:

-21 -20 20 11 
6 2 8 -25 
5 4 9 15 
1 12 -22 16

I found it by first selecting at which 25 squares we get values {1,2,,25} (there are (3025)=142506 ways to make such a selection), and then by solving an Integer Linear Programming problem.

In our ILP, we introduce integer variables au,v (u,v=1,2,3,4) denoting the matrix elements, and let Si be the sums of those elements in the i-th selected square (i=1,,25). Essentially we want (S1,S2,,S25) be a permutation of {1,2,,25}. For this purpose, we introduce binary indicator variables pi,j (i,j=1,,25) telling whether Si=j, and constraints: {Si=25j=1pi,jj,25j=1pi,j=1,for i=1,2,,25 and 25i=1pi,j=1for j=1,2,,25. The solution above was obtained on the 1617-th selection of squares, within just a few minutes of running my Sage code.

PS. Another solution:

9 3 6 5 
8 1 4 10 
11 2 16 -23 
19 -15 12 13

PS2. There even exists a matrix delivering sums {0,1,2,,25}, for example:

0 6 21 4 
9 7 -24 17 
14 -25 11 8 
16 15 1 3

However, the sums {1,2,3,,26} are not possible to obtain.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 729 times

Last updated: Feb 26 '21