TITLE: What do epimorphisms of (commutative) rings look like?
QUESTION [113 upvotes]: (Background: In any category, an epimorphism is a morphism $f:X\to Y$ which is "surjective" in the following sense: for any two morphisms $g,h:Y\to Z$, if $g\circ f=h\circ f$, then $g=h$. Roughly, "any two functions on $Y$ that agree on the image of $X$ must agree." Even in categories where you have underlying sets, epimorphisms are not the same as surjections; for example, in the category of Hausdorff topological spaces, $f$ is an epimorphism if its image is dense.)
What do epimorphisms of (say commutative) rings look like? It's easy to verify that for any ideal $I$ in a ring $A$, the quotient map $A\to A/I$ is an epimorphism. It's also not hard to see that if $S\subset A$ is a multiplicative subset, then the localization $A\to S^{-1}A$ is an epimorphism. Here's a proof to whet your appetite.

If $g,h:S^{-1}A\to B$ are two homomorphisms that agree on $A$, then for any element $s^{-1}a\in S^{-1}A$, we have
  $$g(s^{-1}a)=g(s)^{-1}g(a)=h(s)^{-1}h(a)=h(s^{-1}a)$$

Also, if $A\to B_i$ is a finite collection of epimorphisms, where the $B_i$ have disjoint support as $A$-modules, then $A\to\prod B_i$ is an epimorphism.
Is every epimorphism of rings some product of combinations of quotients and localizations? To put it another way, suppose $f: A\to B$ is an epimorphism of rings with no kernel which sends non-units to non-units and such that $B$ has no idempotents. Must $f$ be an isomorphism?

REPLY [14 votes]: A special case where epimorphisms are surjective is the category of finite-dimensional commutative $k$-algebras where $k$ is a field. See for example this page in the Stacks Project. 
This may come in handy on occasion; I was trying to convince myself this morning that monomorphisms between cocommutative $k$-coalgebras are those whose underlying functions are injective, and needed the result above as a lemma (first check the result on finite-dimensional cocommutative $k$-coalgebras by taking linear duals on the result above, and then use the fact that every coalgebra is the directed colimit of the system of finite-dimensional subcoalgebras and inclusions between them).