TITLE: Degree of the variety of singular points
QUESTION [9 upvotes]: Let $V\subset \mathbb{A}^n$ be an irreducible affine variety. The set of singular points of $V$ is a subvariety $W$ of $V$; denote its components by $W_i$. How may we bound $\sum_i \deg(W_i)$ in terms of $\deg(V)$ and $n$?
I am satisfied if we can find a proper subvariety $Z$ of $V$ containing $W$
and a bound for $\sum_i \deg(Z_i)$, where the $Z_i$'s are the components of $Z$.
The one way I can see is what I take to be the obvious one. We can define $V$ by $n+1$ polynomials $F_1,\dotsc,F_{n+1}$ of degree $\leq \deg V$ (by J. Heintz, "Definability and fast quantifier elimination...", MR0716823; thanks to Simon Rydin Myerson for the reference). Then the singular points of $V$ are those in which the Jacobian of $(F_1,\dotsc,F_{n+1})$ has rank less than $n-\dim(V)$.
Since $W$ is a proper subvariety of $V$, there must be some $(n-\dim(V))$-by-$(n-\dim(V))$ minor of the Jacobian that does not vanish on all of $V$. Its intersection with $V$ defines a proper subvariety $Z$ of $V$. By B\'ezout, its degree is at most $\deg(V)^{n+1-\dim(V)}$.
That may be far from tight, however. Can one do better?

REPLY [5 votes]: Edit.  As the OP points out, for his purpose it suffices to take the zero locus of a single (nonzero) partial derivative.  So the OP produces a proper closed subset of $V$ containing the singular locus and having degree bounded by $(\text{deg}(V)-1)\text{deg}(V)$.  Although this is not what the OP asks, there are cases where we need an upper bound on the degree of the singular locus (or at least the union of all components of the singular locus that have the maximum dimension).  This often occurs for bounding the set of "bad characteristic" for some property of schemes over a field of (possibly) finite characteristic.  The answer below gives an upper bound on the degree of the singular locus.
I am just rewriting the proof of Lemma 4.2.5 of the following as one answer.  I learned of this from Fedor Bogomolov.
Jan Gutt 
Hwang–Mok rigidity of cominuscule homogeneous varieties in positive characteristic 
PhD. thesis, 2013 
https://arxiv.org/pdf/1305.5296.pdf
The original statement is for projective varieties, but the result for affine varieties follows by intersecting with affine space (a Zariski open subset of projective space).
Lemma [Jan Gutt, 2013 thesis, Lemma 4.2.5] For a purely $r$-dimensional closed subscheme $V$ of projective space $\mathbb{P}^n_k$ with degree $D>1$, if the zero scheme $S$ of the $r^\text{th}$ Fitting ideal of $\Omega_{V/k}$ has dimension $m$, then the corresponding $m$-cycle of $S$ has degree no greater than $D(D-1)^{r-m}$.
Proof. When $m$ equals $r$, then this just says that the $m$-dimensional cycle of $S$ has degree no greater than the degree of the $m$-dimensional cycle of $V$.  Thus, without loss of generality, assume that $r>m$.  Also, it suffices to prove the result when $k$ is algebraically closed.  The proof uses Theorem 1.1 of the following.
MR0282975 (44 #209) 
Mumford, David 
Varieties defined by quadratic equations. 1970 Questions on Algebraic Varieties  
(C.I.M.E., III Ciclo, Varenna, 1969) pp. 29–100 Edizioni Cremonese, Rome 
http://www.dam.brown.edu/people/mumford/alg_geom/papers/1970a--CIME-QuadEqns-DAM.pdf
Mumford proves that the ideal sheaf $I$ of $V$ is generated in degree $d$.  More precisely, the linear system $H^0(\mathbb{P}^n_k,I(d))$ of sections $g$ of $\mathcal{O}(d)$ on $\mathbb{P}^n_k$ that vanish on $V$ has base locus that equals $V$ set-theoretically and that equals $V$ scheme-theoretically, at least on the dense open subset $V\setminus S$ of $V$.
Thus, the common zero scheme in $V$ of the set of partial derivatives, $\partial g/\partial t$ (for varying homogeneous coordinates $t$) is contained in $S$ set-theoretically, and contains $S$ scheme-theoretically (since the Fitting ideal contains these partial derivatives, locally).
By Bertini’s theorem, for $r-m$ general polynomials $g = (g_1 , \dots , g_{r-m})$ in this linear system, for a general choice of homogeneous coordinates on $P^n_k$ and for a choice $t = (t_1 , \dots , t_{r-m} )$ of $r-m$ of these coordinates, the common zero scheme in $V$ of the $r-m$ partial derivative polynomials $\partial g_i /\partial t_i$ is $m$-dimensional and contains $S$. Since these partial derivatives are global sections of $\mathcal{O}(D − 1)$, the degree bound follows.
QED.
Will Sawin's Examples.  Let $V$ be a subvariety that spans a linear subspace $\mathbb{P}^{r+1}_k \subset \mathbb{P}^n_k$ and that equals a degree-$D$ hypersurface in this linear space with defining polynomial $g=t_{m+1}^D + \dots + t_{r+1}^D$.  Assume that the integer $D$ is nonzero in $k$.  The Fitting ideal is precisely defined by $t_{m+1}^{D-1},\dots,t_{r+1}^{D-1}$ and the linear polynomials $t_{r+2},\dots,t_n$.  Thus, the degree equals $(D-1)^{r+1-m}$, which is close to $(D-1)^{r-m}D$.