Theorem 3.2, Chapter 1, of Hartshorne's Algebraic Geometry This is regarding a question about Theorem 3.2 in Chapter I of Hartshorne's Algebraic Geometry.
Let $Y \subset \mathbb{A}^n$ be an affine variety with affine coordinate ring $A(Y)$. The final item (d) in the statement is
(d) $K(Y)$, the function field of $Y$, is isomorphic to the quotient field of $A(Y)$....
The argument is given as " From (c) it follows that the quotient field of $A(Y)$ is isomorphic to the quotient field of $\mathcal{O}_P$ for every $P$, and this is equal to $K(Y)$, because every rational function is actually in some $\mathcal{O}_P$."
Could somebody explain this statement in detail? How is the quotient field of $\mathcal{O}_P$ isomorphic to $K(Y)$, and how does this follow as explained in "because every rational function is actually in some $\mathcal{O}_P$. It is true that $\bigcup_{P \in Y} \mathcal{O}_P = K(Y)$, but how does taking the quotient field of ONE $\mathcal{O}_P$ gives us $K(Y)$?
Thanks for the help.
 A: 
but how does taking the quotient field of ONE $\mathcal{O}_P$ [give] us K(Y)?

I stumbled on this (year-old) post because I had the same question, which is not directly addressed in the answer by hm2020, so I figured I would address it here in case anyone else finds themselves in this situation.
I think the key is that Hartshorne has already proven that $A(Y)_{\mathfrak{m}_P} \cong \mathcal{O}_P$ for any $P$, and that we can identify $A(Y)$ with a subring of $\mathcal{O}(Y)$, giving inclusions $A(Y) \subset \mathcal{O}(Y) \subset \mathcal{O}_P \subset K(Y)$ for each $P$. Under these identifications we have $\operatorname{Frac}(A(Y)) = \operatorname{Frac}(A(Y)_{\mathfrak{m}_P}) = \operatorname{Frac}(\mathcal{O}_P)$ for any $P$. In particular, $\operatorname{Frac}(\mathcal{O}_P)$ is independent of $P$. So identifying $\mathcal{O}_P$ as a subring of $K(Y)$ for all $P$, we have that if $\operatorname{Frac}(\mathcal{O}_P) \neq K(Y)$, then there is some element of $K(Y)$ outside of every $\mathcal{O}_P$. But this can't happen because, as you stated, $K(Y) = \bigcup_{P \in Y} \mathcal{O}_P$.
A: Question: "Could somebody explain this statement in detail?"
Answer: Let $A:=A(Y)$ be the coordinate ring of $Y$, which is an integral domain. There is for every $V \subseteq Y \subseteq Y$ pair of open subsets, canonical maps $\rho_{Y,U}: A(Y) \rightarrow \mathcal{O}(U)$ commuting with the restriction map
$$\mathcal{O}(U) \rightarrow \mathcal{O}(V).$$
Here $\mathcal{O}(U)$ is the ring of regular functions on $U$. For any element $f \in\mathcal{O}(U)$ it follows the equivalence class $<U,f> \in K(Y)$ (this is the notation in HH, CH.I.3). In particular we get a canonical map
$$\rho: A(Y) \rightarrow K(Y)$$
defined by
$$\rho(s):=<Y,s> \in K(Y).$$
if $s\neq 0$ it follows $Z(s) \subsetneq Y$ is a strict closed subset and $U:=Y-Z(s) \subseteq Y$ is a non-empty open set. It follows $<U,1/s>\in K(Y)$ hence $\rho(s)\in K(Y)$ is invertible and there is an induced sequence of injections
$$A(Y) \rightarrow K(A(Y)) \rightarrow^{\eta} K(Y)$$
hence $K(A(Y)) \subseteq K(Y)$ is an inclusion. Given any element $<U,f>\in K(Y)$ and a point $p\in U$ there is an open subset $p \in U_p \subseteq U$ and regular functions $g,h\in A(Y)$ with $h \neq 0$ on $U_p$ and $<U,f> \cong <U_p,g/h>$ in $K(Y)$. It follows $g/h \in K(A(Y))$ and $\eta(g/h)=<U,f>.$
Hence the map $\eta: K(A(Y)) \rightarrow K(Y)$ is surjective. This implies the inclusion $K(A(Y)) \subseteq K(Y)$ is an isomorphism.
