Hartshorne exercise about sheaves on $\mathbb{P}^1$ I've been stuck on Exercise II.1.21(e) from Hartshorne's book for quite a while. It concerns the projective line $\mathbb{P}^1$ over an algebraically closed field $k$: write $\mathscr{H}$ for the constant sheaf with values in the function field $K$ and $\mathcal{O}$ for the structure sheaf. The content of the exercise is that map on global sections $\Gamma(X,\mathscr{H}) \to \Gamma(X,\mathscr{H}/\mathcal{O})$ is surjective. In the previous subexercise one shows that $\mathscr{H}/\mathcal{O} \cong \bigoplus_{p \in \mathbb{P}^1} i_p(K/\mathcal{O}_p)$ where $i_p$ is the skyscraper sheaf construction at $p$.
So the following will suffice: given $f \in K$ and $p \in \mathbb{P}^1$, we need to produce $g \in K$ such that $f - g \in \mathcal{O}_p$ and $g \in \mathcal{O}_q$ for all $q \neq p$. But I'm at a loss as to how to do such a thing. I assume the first step is to remove some point besides $p$, so $\mathbb{A}^1 \subset \mathbb{P}^1$ is what's left over, and write $f$ explicitly in terms of the coordinate on $\mathbb{A}^1$. Could someone point me in the right direction? I would especially grateful for a more conceptual/less ad hoc hint or explanation.
 A: Fix $f\in K$ and $P\in\mathbb P^1$. You are looking for a $g\in K$ such that


*

*$g\in\mathcal O_Q$ for all $Q\neq P$, and

*$f-g\in\mathcal O_P$.
The first condition means that $g$ has poles only possibly at $P$. The second, that the difference $f-g$ does not have poles at $P$. In other words, $g$ is the singular part of $f$ at $P$. So to construct $f$ we may write the partial fraction decomposition of $f$ and drop all terms with a pole at a point different from $P$.
A: Here's what my solution was when I took the course:
We know that $\Gamma(X,\mathcal{O})=\mathcal{O}(X) = k$ by Theorem I.3.4; we also have $\Gamma(X,K) = K(X) = k(x)$, also by Theorem I.3.4. Finally, again by Theorem I.3.4, with $k(x)/k[x^{-1}]_{(x^{-1})}$ corresponding to the point at infinity, we have
$$\Gamma(X,K/\mathcal{O}) = k(x)/k[x^{-1}]_{(x^{-1})} \oplus \bigoplus_{\alpha\in k}k(x)/k[x]_{(x-\alpha)}.$$
The claim is that
$$0\to k\to k(x) \to k(x)/k[x^{-1}]_{(x^{-1})}\oplus\left(\bigoplus_{\alpha\in k} k(x)/k[x]_{(x-\alpha)}\right)\to 0$$
is exact; and this just means showing the last map is surjective.
Note: The basic idea was okay, but it was poorly phrased here. Part of it seems to have been some previous exercises in that homework. I'm rephrasing.
Fix $P$ and let $f+\mathcal{O}_{P}\in K/\mathcal{O}_{P}$ be a nonzero entry. Using a partial fraction decomposition we can write
$$f + \mathcal{O}_P = \sum_{i=1}^n f_i + \mathcal{O}_P$$
where each $f_i$ is such that
$$\frac{1}{f_i} = \lambda_i\pi^{n_i}$$
with $\lambda_i\in K$, $\pi$ a uniformizer of $\mathcal{O}_P$,
and $n_i\gt 0$. E.g., for $\mathcal{O}_0$, you can find scalars $a_0,\ldots,a_k$ such that $f+\mathcal{O}_p = \frac{a_0}{x} + \cdots + \mathcal{a_k}{n^k} + \mathcal{O}_p$.
Now let 
$$ g = \sum_{i=1}^n \frac{1}{\lambda_i}\pi_i^{-n_i}\in K(X).$$
Then $g$ maps to $0$ in $K/\mathcal{O}_Q$ for any $Q\neq P$, and since
$$\lambda_i\pi_i^{-n_i} = \frac{1}{f_i}$$
then
$$g\equiv \sum_{i=1}^n f_i \equiv f\pmod{\mathcal{O}_p}$$
so $g\in K(x)$ maps to the element that has $f$ in the $P$-component, and zeroes elsewhere. Since these elements generate 
$$k(x)/k[x^{-1}]_{(x^{-1})}\oplus\left(\bigoplus_{\alpha\in k} k(x)/k[x]_{(x-\alpha)}\right)$$
this shows the last map is surjective.
