TITLE: The set of all matrix with rank $n-1$ is a hypersurface.
QUESTION [6 upvotes]: Prove that the set $M$ of $n\times n$ matrices with rank $n-1$ is a hypersurface in $\mathbb{R}^{n²}$ and find the tangent space at $A=(a_{ij})$ where $a_{ij}=\begin{cases}
 \delta_{ij} \ \text{if} \ (i,j)\neq(n,n) \\ 
 0 \ \ \ \text{if} \  (i,j)=(n,n)
\end{cases}$

The teacher left this problem along with others to study for the test (a graduate course in multivariable calculus).  If I find a function $f:\mathbb{R}^{n²} \rightarrow \mathbb{R}\in C^1$ such that $M=f^{-1}(c)$ and $grad \ f(x)\neq 0 \  (\forall x;f(x)=c$) do the problem becomes a merely computation but I can't find such function.
Can anybody help me?
Thanks in advance.

REPLY [2 votes]: Consider the determinant function $\det\colon \mathbb{R}^{n\times n} \to \mathbb{R}$.  I claim that an $n\times n$ matrix $A$ has rank $n-1$ if and only if

$\det(A) = 0$, and 
$A$ is a regular point of $\det$.

It follows that the set of such matrices is a smooth hypersurface.
To prove this, suppose first that $A$ has rank $n-1$.  Let $B$ be a nonsingular matrix whose entries are the same as $A$ except for one row.  Then
$$
\frac{d}{dt}\biggl[\det\bigl((1-t)A+tB\bigr)\biggr] \;=\; \frac{d}{dt}\biggl[(1-t)\det A + t \det B\biggr] \;=\; \frac{d}{dt}\biggl[t \det B\biggr] \;=\; \det B \;\ne\;0
$$
which proves that the directional derivative of $\det$ is nonzero in the direction of $B-A$.  (In the first step of the equation above, we have used the fact that determinant is linear with respect to each row of a matrix.)
For the converse, suppose that $A$ has rank less than $n-1$.  Then every collection of $n-1$ rows in $A$ are linearly dependent, so the determinant of $A$ remains $0$ if we change any one entry of $A$.  It follows that all $n^2$ partial derivatives of $\det$ are zero at $A$, so $A$ is a critical point for $\det$.
Finally, the tangent space to $M$ at the given matrix consists of all matrices $B=(b_{ij})$ for which $b_{nn}=0$, since changing $b_{nn}$ makes the matrix nonsingular, but changing any other entry of the matrix does not affect the determinant.