This question is somewhat related to a previous question of mine, but appeared in a different context.
Suppose given two morphisms of $S$-schemes $f,g:X \to Y$. Intuitively, I am interested on the locus of points of $X$ in which these two morphisms coincide. A schematic approach to that, would be to consider $Z$ as the pullback of the diagonal $\Delta: Y \to Y\times_S Y$ by the morphism $(f,g): X \to Y\times_S Y$.
Then, for example, if $Y\to S$ is separated ("Hausdorff"), then $Z \to X$ is a closed immersion, which makes sense.
Also, the composition of $Z \to X$ with $f$ and $g$ are the same (by the commutativity of the cartesian diagram defining $Z$). Hence, I would expect that the scheme $Z$ is what I'm searching.
But one could also take a naive, set-theoretic, approach (which we know is usually inappropriate when dealing with schemes) and define the set $A=\{x\in X \mid f(x)=g(x)\}$.
My question is: what is the relation between $Z$ and $A$?
The most strange thing is that $A$ can be empty, but $Z$ seems to be always well defined. In this case (when $A$ is empty), how this information is "captured" in the scheme $Z$?
If you want to revert to a set theoretic product, the way to do it is via functor of points. Note that for the functor of points of $X\times_Y X,$ defined by $h_{X\times_Y X}(W)=\operatorname{Hom}_S(W,X\times_Y X)$ for any $S$-scheme $W,$ we have $h_{X\times_Y X}(W)=\{(f',g')|f':W\to X,g':W\to X, f'\circ f=g'\circ g\}\subseteq h_X(W)\times h_X(W).$
Examples 4.1,2 from this note display the pathological relationship between products of schemes and products of their underlying points. Another simple example to think about is the relationship between $\Bbb A^1\times_k\Bbb A^1\cong\Bbb A^2$ over $\operatorname{Spec}(k)$ and its underlying set of points.