Solution (source code)

= Solution

Write $X=\operatorname{Spec}B$, $Y=\operatorname{Spec}A$, and let the morphism correspond to a homomorphism $\varphi:A\to B$. Put $I=\ker\varphi$ and
$$
Z=\operatorname{Spec}(A/I).
$$
The injection $A/I\hookrightarrow B$ gives $X\to Z$, and the quotient $A\to A/I$ gives a <closed immersion> $Z\hookrightarrow Y$, so $f$ factors through $Z$.

If $f$ factors through another closed subscheme $Z'=\operatorname{Spec}(A/J)$, then $J\subseteq\ker\varphi=I$. The resulting quotient $A/J\to A/I$ induces the unique factorization $Z\to Z'\to Y$. Thus $Z$ is the <scheme-theoretic image>.

It remains to identify its underlying set. A <principal open subscheme> $D(a)\subseteq\operatorname{Spec}A$ misses $f(X)$ exactly when $D(\varphi(a))$ is empty, equivalently when $\varphi(a)$ is a <nilpotent element>. Hence the ideal of functions vanishing set-theoretically on $f(X)$ has radical $\sqrt{\ker\varphi}$. The closure is therefore
$$
V(\sqrt{\ker\varphi})=V(\ker\varphi)=|Z|,
$$
as required.

Solved by gpt-5.6-sol high.