If $M$ is a full rank $n$ by $n$ binary matrix over $\mathbb{F}_2$, how much larger or smaller can the number of $1$s in $M^{-1}$ be, compared to the number of $1$s in $M$?
Clearly the identity matrix is an example where the number of ones doesn’t change at all.
This is a question just for mathematical interest. I am trying to understand the properties of matrices over $\mathbb{F}_2$.
Examples
For $n=6$ there are 251610 inequivalent binary matrices (up to row and column permutations). Taking only the full rank matrices from this set, these are the max differences in the number of ones between a matrix and its inverse. The first number is the number of ones in the matrix and the second is the max absolute difference for matrices with that number of ones.
6 0
7 0
8 1
9 3
10 6
11 10
12 9
13 16
14 10
15 16
16 10
17 12
18 9
19 9
20 9
21 10
22 9
23 10
24 11
25 12
26 13
27 14
28 15
29 16
30 15
31 16
An equivalent set of results for $n=7$ is:
7 0
8 0
9 1
10 3
11 6
12 10
13 15
14 16
15 25
16 18
17 25
18 18
19 24
20 17
21 19
22 16
23 17
24 15
25 16
26 13
27 14
28 15
29 15
30 16
31 16
32 17
33 18
34 19
35 20
36 21
37 22
38 21
39 24
40 25
41 24
42 25
43 24
The first six max absolute differences are the same as the $n=6$ case.
Are there provable bounds for this relationship for general $n$?
(Previously asked at math.se unsuccessfully.)
Added examples by request
For n=3
3 0
4 0
5 1
6 1
7 0
For n=4
4 0
5 0
6 1
7 3
8 1
9 4
10 3
11 2
12 3
13 4
For n=5
5 0
6 0
7 1
8 3
9 6
10 4
11 9
12 4
13 8
14 5
15 6
16 5
17 6
18 7
19 8
20 9
21 8
For $n=4$, with $2n+1$ ones there is one equivalence that gives a difference of $(n-2)^2$. The canonical matrix is:
0 0 1 1
0 1 0 1
1 0 0 1
1 1 1 0
with inverse
1 1 0 1
1 0 1 1
0 1 1 1
1 1 1 1
For $n=5$, with $2n+1$ ones there is one equivalence class that gives a difference of $(n-2)^2$. The canonical matrix is:
0 0 0 1 1
0 0 1 0 1
0 1 0 0 1
1 0 0 1 0
1 1 1 0 0
with inverse
0 1 1 0 1
1 1 0 1 1
1 0 1 1 1
0 1 1 1 1
1 1 1 1 1
For $n=6$, with $2n+1$ ones there is one equivalence class that gives a difference of $(n-2)^2$. The canonical matrix is:
0 0 0 0 1 1
0 0 0 1 0 1
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
with inverse
1 0 1 1 0 1
0 1 1 0 1 1
1 1 0 1 1 1
1 0 1 1 1 1
0 1 1 1 1 1
1 1 1 1 1 1
For $n=7$, with $2n+1$ ones there is one equivalence class that gives a difference of $(n-2)^2$. The canonical matrix is:
0 0 0 0 0 1 1
0 0 0 0 1 0 1
0 0 0 1 0 0 1
0 0 1 0 0 1 0
0 1 0 0 1 0 0
1 0 0 1 0 0 0
1 1 1 0 0 0 0
with inverse
1 1 0 1 1 0 1
1 0 1 1 0 1 1
0 1 1 0 1 1 1
1 1 0 1 1 1 1
1 0 1 1 1 1 1
0 1 1 1 1 1 1
1 1 1 1 1 1 1