TITLE: Number of matrices with determinant value $0$
QUESTION [8 upvotes]: A $3 \times 3$ matrix is formed using the elements from the set $\{-1,0,1\}$. How many matrices will have determinant value $0$.
Let matrix is \begin{bmatrix}
p & q & r\\
x & y & z \\
a & b &c
\end{bmatrix}
So total matrices formed will be $3^9$ and determinant is given by $\Delta=pyc+rxb+qza-rya-qxc-pzb$
Making some combinations I deduced that determinant value will go from $-4$ to $4$ but what approach should I follow to get number of determinants having value $0$?

REPLY [2 votes]: Forgive me for writing a second answer but math.SE gets very laggy when you try to make a single answer too long.
We can indeed solve the problem by counting lattice points. Let $C = \{ -1, 0, 1 \}^3 \subsetneq \mathbb{Z}^3$ be the cube I mentioned; we want to count the number of ordered triples of points $v_1, v_2, v_3$ in $C$, not necessarily distinct, which are linearly dependent (over $\mathbb{R}$ or equivalently $\mathbb{Z}$), or equivalently such that $\dim \text{span}(v_1, v_2, v_3) \le 2$. We'll do this by considering each possible dimension of the span in turn.
Dimension 0: This is easy, $v_1 = v_2 = v_3 = 0$ is the only possibility so there is $\boxed{1}$ triple in this case.
Dimension 1: Every line passing through the origin and a nonzero point in $C$ passes through exactly two nonzero points, some point $v$ and its negative $-v$, so there are $\frac{3^3 - 1}{2} = 13$ such lines. (Note that this matches up with the number of points in the projective plane $|\mathbb{P}^2(\mathbb{F}_3)| = 1 + 3 + 3^2$ as expected.)
Among the $3$ points $\{ -v, 0, v \}$ on such a line there are $3^3$ triples of points and the only one that doesn't span the line is $0, 0, 0$, so there are $3^3 - 1 = 26$ triples that do span the line, giving
$$13 \cdot 26 = \boxed{338}$$
triples in the dimension $1$ case.
Dimension 2: This is the tough one. I missed a few cases here for quite awhile. It turns out that there are $25$ different planes (passing through the origin) spanned by the points of $C$ (I thought that there were $13$ for hours, then $21$ briefly). My mistake was assuming that every plane passing through the points of $C$ could be described as the plane normal to another vector in $C$ (this is only true $\bmod 3$). I'll just state how it goes for now: there are

$9$ planes passing through $9$ points (including the origin), arranged in a square or rectangle,
$4$ planes passing through $7$ points, arranged in a hexagon, and
$12$ planes passing through $5$ points, arranged in a rhombus (these are the ones I missed).

Among the $n$ points on a plane there are $n^3$ triples and the ones that span the plane are the ones that aren't either $0, 0, 0$ or the ones that span one of the $\frac{n-1}{2}$ lines. As in the count above, for each line there are $26$ triples of points spanning it, so in total there are
$$n^3 - 13(n-1) - 1$$
triples of points spanning an $n$-point plane. This gives
$$9 \cdot 624 + 4 \cdot 264 + 12 \cdot 72 = \boxed{7536}$$
triples in the dimension 2 case, and hence
$$1 + 338 + 7536 = \boxed{7875}$$
triples total, in agreement with my other answer and the Python scripts (although jeez it took awhile).