Solution (source code)

= Solution

For $X\subseteq\mathbb A^n$ and $P\in X$, the <Zariski tangent space> is
$$
T_{X,P}=\{v\in k^n:
\sum_{i=1}^n\frac{\partial h}{\partial x_i}(P)v_i=0
\text{ for every }h\in I(X)\}.
$$
Equivalently, it is the kernel of the Jacobian of generators of $I(X)$ at $P$. With the tangent-space definition used here,
$$
\dim X=\min_{P\in X}\dim T_{X,P},
$$
and $P$ is smooth when $\dim T_{X,P}=\dim X$.

Now let $X=Z(f)$. Write $g$ for the square-free product of the distinct irreducible factors of $f$. Hilbert's Nullstellensatz gives
$$
I(X)=\sqrt{(f)}=(g).
$$
Thus $T_{X,P}=\ker(dg_P)$, whose dimension is at least $n-1$. There is some $P\in X$ with $dg_P\ne0$. Otherwise every partial derivative of $g$ would vanish on $X$, hence belong to $(g)$ by the Nullstellensatz. Its degree is smaller than $\deg g$, so every partial derivative would be zero; in characteristic zero this would make $g$ constant, a contradiction. At such a point the tangent space has dimension $n-1$, and therefore
$$
\boxed{\dim Z(f)=n-1.}
$$

Next suppose $f$ is irreducible of degree at least two and $P$ is smooth. Translate $P$ to the origin and write
$$
\ell=df_P.
$$
Then $H=T_{X,P}=Z(\ell)$ is a hyperplane. The restriction $f|_H$ is nonzero: otherwise $\ell$ would divide $f$, contradicting irreducibility and $\deg f\geq2$. Since $f(P)=0$, the restriction is nonconstant, so the first part gives
$$
\dim(X\cap H)=n-2.
$$
For the natural intersection cut out by $(f,\ell)$, the two differentials at $P$ are $df_P=\ell$ and $d\ell=\ell$. Hence they impose only one independent tangent equation and
$$
T_{X\cap H,P}=H,
\qquad
\dim T_{X\cap H,P}=n-1>n-2.
$$
Therefore $X\cap T_{X,P}$ is singular at $P$.

Finally, represent $\varphi:\mathbb A^2\to\mathbb A^3$ by
$$
A=\begin{pmatrix}
x_1&x_2\\x_3&x_4\\x_5&x_6
\end{pmatrix}.
$$
It is not injective exactly when $\operatorname{rank}A\leq1$, equivalently when all its $2\times2$ minors vanish. Thus
$$
Y=Z(I),
\qquad
I=(x_1x_4-x_2x_3,\ x_1x_6-x_2x_5,\ x_3x_6-x_4x_5),
$$
an ideal generated by three quadrics. By the stated assumption this is the full radical ideal of $Y$.

Every nonzero point of $Y$ has rank one. The action of $GL_3(k)\times GL_2(k)$ by row and column operations is transitive on rank-one matrices, so it suffices to compute at
$$
A_0=\begin{pmatrix}1&0\\0&0\\0&0\end{pmatrix}.
$$
At $A_0$, the differentials of the three minors are respectively
$$
dx_4,\qquad dx_6,\qquad0.
$$
Hence $\dim T_{Y,A_0}=6-2=4$, and the same holds at every rank-one point. At the zero matrix all three quadrics have zero differential, so $T_{Y,0}=\mathbb A^6$ has dimension six. It follows that
$$
\boxed{\dim Y=4,\qquad \operatorname{Sing}(Y)=\{0\}.}
$$