# Counting The Number of Non-invertible matrices [duplicate]

I am asked to count the total number of matrices in $GL_2(F_p)$, where $F$ is a field and $p$ is a prime number, denoting the number of its elements, by first computing the total number of matrices over $F_p$, and then subtracting the total number of non-invertible matrices, which is the total number of matrices whose one row is a multiple of the other.

Clearly there are $p^4$ total matrices over $F_p$. Now, let us consider non-invertible. There are two general cases, either the first row is [0 0] or it is not. If it is, then for the second row [a b], there are $p$ possibilities for $a$ and $p$ possibilities for $b$. Hence, a total of $p^2$ possibilities under this case.

Now, if the first row [x y] is not zero, then either $x \neq 0$, $y \neq 0$, or $x$ and $x$ are not equal to zero. Note, our second row is of the form [kx ky], so that it is a multiple of the first. If $x \neq 0$, then there are $(p-1)$ possibilities for $x$, $p$ for $y$, and $p$ for $k$. Hence, a total of $(p-1) \cdot p \cdot p = p^3 - p^2$. We get the same number of the $y \neq 0$ case. Finally, if $x \neq 0$ and $y \neq 0$, then $(p-1)$ choices for $x$ and $y$, and $p$ choices for $k$, totaling to $(p-1)(p-1)p = p^3 - 2p^2 + p$.

However, this does sum to $p^3 + p^2 + p$, which is the answer. What did I do wrong? I have been working on this all day; combinatorics comes very difficult for me.

## marked as duplicate by lulu, Did, Claude Leibovici, Watson, loup blancSep 14 '16 at 12:52

• Specific to $GL_2$, this question might be more directly relevant. – lulu Sep 14 '16 at 1:06
• The idea is: to count the invertible matrices, there are $p^2-1$ non-zero ways to fix the first column. Then there are $p^2-p$ ways to choose the second so that it's not a multiple of the first. Thus $(p^2-1)(p^2-p)$. – lulu Sep 14 '16 at 1:10
• Okay, I understand $p^2 -1$: $p^2$ corresponds total number in (1-1) and (1-2) entry, minus $1$ for zero row. But $p^2 -p$ I don't quite understand: again, $p^2$ corresponds to total number in (2-1) and (2-2) entry, and we have to subtract off p, but what does p represent? Maybe it would make more sense to me if we wrote $p^2 - p = p(p-1)$, where $p$ total number for (2-1) and $p-1$ total number for (2-2) entry. But again, why are we subtracting off $1$? – user193319 Sep 14 '16 at 1:22
• There are $p^2$ total vectors. There are $p$ multiples of the first column. – lulu Sep 14 '16 at 1:23
If the first row is $[0,0]$, the matrix is always non-invertible.
If the first row is not $[0,0]$, the matrix is non-invertible iff the second row is a scalar multiple of the first row. The number of possible scalars is $p$.