Question: Let $M$ be a $n\times n$ matrix whose coefficients depend on some parameters (the number of parameters does not really matter). For some values of the parameters, $M$ is non-singular. Enforcing $\mathrm{rank}(M)\leq n-1$ requires solving a single equation: $\det M =0$. 

My question is, how many equations are needed to enforce $\mathrm{rank}(M)\leq n-2$ (and which ones)? I would say that necessarily, the four $(n-1)\times (n-1)$ submatrices should be singular, which gives four equations. But it does not seem to be a sufficient condition.

Answer: 
For real matrices, the answer is one, because any set of $k$ polynomial equations $p\_1=\cdots=p\_k=0$ is equivalent to the single equation $p\_1^2+\cdots+p\_k^2=0$. Yet, we can explicitly construct the polynomial equation we need here:

> 
> When $n\ge2$, a real $n\times n$ matrix $A$ has rank $\le n-2$ if and only if its entries satisfy the polynomial equation
>  $$
> \operatorname{tr}\left(\operatorname{adj}(A^TA)\right) = 0.
> $$
> 
> 
> 

This follows easily from the following facts:

* $A$ and $A^TA$ have identical ranks.
* A matrix has rank $\le n-2$ if and only if its adjugate is zero.
* The adjugate matrix of a positive semidefinite matrix is positive semidefinite.
* A real positive semidefinite matrix is zero if and only if it has zero trace.
In the paper

> 
> [W. Bruns and R. Schwänzl. The number of equations defining a determinantal variety. Bull. London Math. Soc. 22 (1990), no. 5, 439-445.](http://www.home.uni-osnabrueck.de/wbruns/brunsw/pdf-article/NumbEqDet.published.pdf)
> 
> 
> 

you will find that over an algebraically closed field, the set of $n \times n$ matrices of rank $< t$, for $1 \le t \le n$, can be defined by $n^{2} - t^{2} + 1$ equations, and no less.

So in your case, with $t = n-1$, you need $2 n$ equations.