Hartshorne, Exercise III 4.2 (a): A morphism $\mathcal{O}^r \to f_* \mathscr{M}$ that is an iso over the generic point. I'm having some trouble with Exercise III 4.2 a) in Hartshorne's Algebraic geometry. It is

Let $f: X \to Y$ be a finite surjective morphism of integral noetherian schemes. Show that there is a coherent sheaf $\mathscr{M}$ on $X$, and a morphism of sheaves $\alpha: \mathcal{O}^r_Y \to f_* \mathscr{M}$ for some $r > 0$, such that $\alpha$ is an isomorphism at the generic point.

I solved the affine case: If $Y = \text{Spec } A$, then $X = \text{Spec }B$ and $f$ comes from a homomorphism of integral domains $A \to B$, where $B$ is finitely generated as an $A$-algebra. This means there is a surjection $A^n \to B$ of $A$-modules. Localizing is exact, so at the generic point this is still a surjection $Q(A)^n \to B_{(0)}$. But $Q(A)$ is a field, so we can choose a basis $Q(A)^r \subset Q(A)^n$, which gives an isomorphism $Q(A)^r \to B_{(0)}$. The corresponding map $A^r \to B$ is the desired morphism.
So the "obvious" generalization would be to take the structure sheaf  $\mathscr{M} = \mathcal{O}_X$. But this cannot work, as the following counterexample illustrates:
Consider $f: \mathbb{P}^1 \to \mathbb{P}^1$, defined by $[x:y] \mapsto [x^2:y^2]$. Giving a morphism $\alpha: \mathcal{O}_Y^r \to f_* \mathscr{M}$ is the same as choosing $r$ elements from $\Gamma(X, \mathscr{M})$. But $\Gamma(X, \mathcal{O}_X) = k$, so we can only choose $k$-linearly dependent elements. No morphism $\mathcal{O}_Y^r \to f_*\mathcal{O}_X$ can give an isomorphism at the generic point $\eta$, because $(f_*\mathcal{O}_X)_\eta \cong \mathcal{O}_{Y,\eta}^2$, and the image of $\mathcal{O}_Y^r \to f_*\mathcal{O}_X $ will only be $1$-dimensional at $\eta$.
I'm a bit clueless at this point. Maybe one has to glue the affine case together and yields an invertible sheaf $\mathscr{M}$? But I don't think that replacing $\mathcal{O}_X$ by $\mathcal{O}_X(d)$ really changes anything in the example. How to proceed here?
 A: Copied from my answer on mathoverflow:
Suppose we can solve the problem for affine schemes, and choose an open affine $j: V \hookrightarrow Y$ and let $i: U \hookrightarrow X$ be its preimage. Suppose we have a morphism
$$ \alpha_V:  \mathcal{O}_V^n \to (f|_U)_*\mathcal{O}_U$$
which is an isomorphism at the generic point $\eta$ of $Y$.
The problem is that $i_* \mathcal{O}$ is not in general coherent on $X$. But $\alpha_V$ chooses $n$ global sections $s_1,\dotsc,s_n \in \Gamma(X, i_* \mathcal{O}_U) = \Gamma(U, \mathcal{O}_U)$, which can be used to define a morphism $\alpha_X: \mathcal{O}_X^n \to i_* \mathcal{O}_U$. Let $\mathscr{G}$ be the image of this morphism. Then $\mathscr{G}$ is coherent, because for every open affine $\text{Spec }A = W \subset X$, $\mathscr{G}(W) \subset (i_*\mathcal{O}_U)(W)$ is the $A$-submodule generated by $s_1|_W,\dotsc,s_n|_W$.
This allows us to define the morphism
$$ \alpha_Y: \mathcal{O}_Y^n \to f_* \mathscr{G} \subset (f i)_* \mathcal{O}_U$$
by takting the same global sections $s_1,\dots,s_n \in \Gamma(Y, f_* \mathscr{G})$. At the generic point this yields
$$
\mathcal{O}^n_{Y, \eta} \xrightarrow{\alpha_{Y, \eta}} (f_*\mathscr{G})_\eta \hookrightarrow ((fi)_* \mathcal{O}_U)_\eta,
$$
and the composition is $\alpha_{U, \eta}$ which is an isomorphism. Hence $\alpha_{Y, \eta}$ is an isomorphism as well.

This is not a full answer, I just think that in the example $f: \mathbb{P}^1 \to \mathbb{P}^1, [x_0:x_1] \mapsto [x_0^2:x_1^2]$ the morphism $\alpha: \mathcal{O}_{\mathbb{P}^1}^2 \to f_*(\mathcal{O}_{\mathbb{P}^1}(1))$, which chooses the two generators of $\Gamma(\mathbb{P}^1, \mathcal{O}(1))$ does in fact work:
To differentiate the two instances of $\mathbb{P}^1$, let $x_0, x_1$ be the coordinates on the domain $X$ of $f$, and let $y_0, y_1$ be the coordinates on the image $Y = \mathbb{P}^1$. Then $\Gamma(X, \mathcal{O}(1)) = \langle x_0, x_1 \rangle_k$, and $\alpha: \mathcal{O}_{\mathbb{P}^1}^2 \to f_* \mathcal{O}_{\mathbb{P}^1}(1)$ is defined on global sections by sending the generator $e_i$ to $x_i$.
Choosing $U = D_+(y_1) \subset Y$, a principle open affine, we have $V = f^{-1}(U) = D_+(x_1)$. We want to study $\alpha$ restricted to $U$. Thus $U = \text{Spec } k\left[\frac{y_0}{y_1}\right]$, and $V = \text{Spec } k\left[\frac{x_0}{x_1}\right]$. The homomorphism of rings determining $f: V \to U$ is given by
$$ \frac{y_0}{y_1} \mapsto \left(\frac{x_0}{x_1}\right)^2.$$
The restriction $\langle x_0, x_1 \rangle_k = \Gamma(X, \mathcal{O}(1)) \to \Gamma(V, \mathcal{O}(1)|_V) = k\left[\frac{x_0}{x_1}\right]$ is given by mapping $x_0 \mapsto \frac{x_0}{x_1}$, and $x_1 \mapsto 1$.
If we consider $k\left[\frac{x_0}{x_1}\right]$ as a $k\left[\frac{y_0}{y_1}\right]$-module we see that it has two generators, namely $1$ and $\frac{x_0}{x_1}$. This is because with the $k\left[\frac{y_0}{y_1}\right]$-action we only hit the even degrees (or odd degrees, depending where you start).
Both generators are hit by $\alpha|_U$, which is therefor surjective on $U$-sections (I think it even is an isomorphism).
