Let $X$, $Y$ be integral separated schemes of finite type over $\mathbb{C}$, $Y$ be normal, $f:X\rightarrow Y$ be a surjective morphism of schemes. Can the nonflat locus of $f$ be nonempty and have codimension $\geq 2$ in $X$?
4 Answers
Let $Y$ be a cone over a smooth projective variety which is a product and projectively normal (so $Y$ is normal). For example let $Y$ be the cone over $\mathbb P^1\times \mathbb P^1\subseteq \mathbb P^3$. In general, say $Y$ is a cone over $V\times W$.
Next let $H\subseteq W$ be an effective Cartier divisor (In the $\mathbb P^1\times \mathbb P^1$ example, $H$ is simply a point) and let $H'=V\times H$. Finally, let $f:X\to Y$ be the blow up of $Y$ along its subscheme $Z$ which is the cone over $H'$. Then $f$ is an isomorphism (and hence flat) outside $Z$. Since $Z$ is a Weil divisor, which is Cartier except at the vertex, $f$ is a small morphism, so it is an isom outside a codimension $2$ subset.
Addendum: Here is an example with $Y$ smooth. Start with the above example with $V=\mathbb P^1$ and $W=\mathbb P^n$ with $n>1$ and $V\times W$ embedded with the Segre embedding. Construct the same (and for the sake of avoiding confusion, let's denote it differently) $f_0:X_0\to Y_0$ and let $v\in Y_0$ denote the vertex of the cone. Then a relatively simple computation shows that then $f^{1}(v)\simeq V=\mathbb P^1$ (for the actual computation see Prop 3.3 of this paper. Note that this means that the exceptional set of $f$ is $1$dimensional. Another simple calculation shows that $X_0$ is smooth (this is where the choice of $V$, $W$ and the embedding matters).
Now let $f:X\colon =X_0\times _{Y_0}X_0\to Y\colon=X_0$. Then $f:X\to Y$ is birational (because of the dimensions there is only one component) and it's exceptional set (on $X$) is $2$dimensional. From the construction and by the assumption that $n>1$ we obtain that $\dim X=\dim X_0= n+2>3$. Hence $f$ is an isomorphism (in particular, flat) outside a codimension $2$ subset of $X$ (but it is obviously not flat along the exceptional set).

$\begingroup$ what happens if $Y$ is smooth? $\endgroup$– user137767Apr 5, 2019 at 18:03

$\begingroup$ @StepanBanach: I added an example where $Y$ is smooth $\endgroup$ Apr 7, 2019 at 2:15

$\begingroup$ The second example ($X$ and $Y$ smooth, $f$ iso away from a curve in $X$) seems to contradict van den Waerden's theorem. What am I missing? $\endgroup$ Apr 7, 2019 at 3:00

$\begingroup$ @PiotrAchinger: I didn't claim that $X$ was smooth. $\endgroup$ Apr 7, 2019 at 3:36

1$\begingroup$ if I understand correctly, for a surjective birational morphism between connected smooth schemes of finite type over $\mathbb{C}$, the nonflat locus can not be nonempty of codimension $\geq 2$. Is it true that the nonflat locus of a surjective morphism between connected smooth schemes of finite type over $\mathbb{C}$ can not be nonempty of codimension $\geq 2$? $\endgroup$– user74900Apr 7, 2019 at 8:44
Let $n \ge 2$, $X = \mathbb{A}^n$, $Y = \mathbb{A}^n/\{\pm 1\}$ and $f \colon X \to Y$ the quotient morphism. The nonflat locus of $f$ is the point $f(0) \in Y$.
Yes. Let $Y$ be $\mathrm{Spec} \ k[w,x,y,z]/(wzxy)$. Let $X$ be $\mathrm{Proj} \ k[w,x,y,z, s,t]/(wzxy,\ wtxs,\ ytzs)$ where $w$, $x$, $y$ and $z$ are in degree $0$ and $s$ and $t$ are in degree $1$. Then $Y$ is three dimensional with a singularity at $w=x=y=z=0$. The map $X \to Y$ is a resolution of this singularity; it is an ismorphism (and hence flat) away from the singularity and the fiber over the singularity is $\mathbb{P}^1$, so the nonflat locus is $1$dimensional inside the $3$fold $X$.
This is a special case Sándor Kovács example, namely, it is what happens when you blow up the cone on $\mathbb{P}^1 \times (\mathrm{point})$ inside the cone on $\mathbb{P}^1 \times \mathbb{P}^1$.
Try $Y=\mathrm{Spec}\,\mathbb{C}[x^4, x^3y, xy^3, y^4]$ and $X$ its normalization.

3$\begingroup$ isn't the normalization of a normal scheme the identity morphism (whose nonflat locus is empty)? $\endgroup$– user137767Apr 5, 2019 at 17:21

1$\begingroup$ @StepanBanach You did not mention normal in your question. $\endgroup$– MohanApr 5, 2019 at 18:28