# What ring's spectrum corresponds to the affine scheme that is the inverse image of a morphism between two affine schemes?

Giving morphism of schemes $$\pi$$ : $$\operatorname{Spec}A \rightarrow \operatorname{Spec}B$$, by definition we have $$\pi^{-1}\mathscr{O}_{\operatorname{Spec}B}$$ is a sheaf of rings on $$\operatorname{Spec}A$$, i.e., $$(\operatorname{Spec}A, \pi^{-1}\mathscr{O}_{\operatorname{Spec}B}$$) is a ringed space. With $$\pi$$ being a mophism of schemes rather than just of ringed spaces, $$(\operatorname{Spec}A, \pi^{-1}\mathscr{O}_{\operatorname{Spec}B}$$) is also an affine scheme, by argument similar in For a morphism of affine schemes, the inverse of an open affine subscheme is affine. Then it shoud have form $$(\operatorname{Spec}C, \mathscr{O}_{\operatorname{Spec}C}$$)

Algebraically, which ring is the ring $$C$$ under the morphism $$B \rightarrow A$$ ? Considering an example like $$\operatorname{Spec}k[x]/(x) \to \operatorname{Spec}k[x]$$, I suspect that $$C$$ is the localization of $$B$$ with multiplicative set $$\pi^{-1}(U(A))$$, where $$U(A)$$ means the units of $$A$$. But I failed to give a proof of it.

And is there any geometric view point for it?

Let $$X$$ be a scheme and $$x \in X$$ any point. Then we have a morphism of schemes $$\pi:\mathrm{Spec}(\kappa(x)) \to X$$, where $$\kappa(x)$$ is the residue field at $$x$$. Now consider the ringed space $$(\mathrm{Spec}(\kappa(x)),\pi^{-1} \mathscr O_X)$$. What is the structure sheaf? Our underlying space has only one element, so we just need to compute global sections. We get that $$\pi^{-1}\mathscr O_X(\mathrm{Spec}(\kappa(x)))=\varinjlim\limits_{U \subset X, x \in U}\mathscr O_X(U)=\mathscr O_{X,x}$$. If $$\mathscr{O}_{X,x}$$ has more than one prime ideal, this ringed space is not a scheme.

You're misunderstanding the statement of the linked question: for a morphism of affine schemes $$f:X \to Y$$ and an affine open $$U \subset Y$$, we get that $$(f^{-1}(U),\mathscr O_X|_{f^{-1}(U)})$$ is an affine scheme. This is what is meant by saying that "the inverse of an open affine subscheme is affine".