Atiyah & Macdonald, Problem 3.24 I am working on the following exercise in Atiyah & Macdonald's commutative algebra text:
Let $(U_i)_{i \in I}$ be a covering of $X = Spec(A)$ by basic open sets. For each $i \in I$ let $s_i \in A(U_i)$ be such that, for each pair of indices $i$,$j$, the images of $s_i$ and $s_j$ in $A(U_i \cap U_j)$ are equal. Then there exists a unique $s \in A$ ($= A(X)$) whose image in $A(U_i)$ is $s_i$, for all $i \in I$. (Here, a basic open set $U$ of $Spec(A)$ is of the form $U = X_f$, the set of prime ideals of $A$ that contain $f$, for some $f \in A$. Further, $A(U) = A_f$ denotes the localization $S^{-1}A$, where $S = \{f^n\}_{n \geq 0}$ for $f \in A$.)
Below is a rephrasing of a proof that I found here.
For each $i \in I$, let $U_i = X_{f_i}$ for $f_i \in A$ and let $s_i = \frac{x_i}{f_i^{m_i}}$ for some $x_i \in A$ and some $m_i \geq 0$. Since $s_i = s_j$ in $A(U_i \cap U_j)$, for each $i$ and $j$, there exists $n_{ij} \geq 0$ such that $(f_if_j)^{n_{ij}}(x_if_j^{m_j} - x_jf_i^{m_i}) = 0$ in $A$. Since $X$ is quasi-compact, there exists $k$ such that $\sum_{i=1}^k (f_i) = (1)$. This yields $\sum_{i=1}^k a_if_i^{m_i} = 1$ for some $a_1,...,a_k \in A$. Define $s = \sum_{i=1}^k a_ix_i$. Then, in $A(U_j)$, we have
$$\begin{align*}
s &= \sum_{i=1}^k a_ix_i \\
&= a_js_jf_j^{m_j} + \sum_{i \neq j} a_ix_i\\
&= s_j(1-\sum_{i \neq j} a_if_i^{m_i}) + \sum_{i \neq j} a_ix_i = s_j + \sum_{i \neq j} a_i(x_i - s_jf_i^{m_i}) \\
&= s_j + \frac{1}{f_j^{m_j}}\sum_{i \neq j} a_i(x_if_j^{m_j} - x_jf_i^{m_i})\\
&= s_j\tag{***}
\end{align*}$$
for $j = 1,...,k$.
Now, let $i \in I$ be arbitrary. For each $j = 1,...,k$, $s = s_i = s_j$ in $A(U_i \cap U_j)$. Thus, there exists $n \geq 0$ such that $(f_i^{m_i}s - x_i)(f_if_j)^n = 0$ in $A$ for each $j$. In the same manner we obtained the equation $\sum_{i=1}^k a_if_i^{m_i} = 1$, we obtain $\sum_{j=1}^k b_jf_j^n = 1$ for some $b_1,...,b_k \in A$. Note that $b_j(f_i^{m_i}s - x_i)(f_if_j)^n = 0$ for each $j$. Summing these equations over $j$ in $A$, we have $(f_i^{m_i}s - x_i)(f_i)^n = 0$. Therefore, $s = s_i$ in $A(U_i)$.
Now, suppose that $s' \in A$ also has image $s_i$ in $A(U_i)$ for every $i \in I$. Given the $f_1,...,f_k$ as before, we obtain the system of equations $(s-s')f_j^n = 0$ for $j = 1,..,k$. Multiplying each of our equations by $b_j$, summing our equations over $j$ and using that $\sum_{j=1}^k b_jf_j^n = 1$, we get $s = s'$.
My only question about this solution is the last equality in $($***$)$. That is, why does it hold that $\frac{1}{f_j^{m_j}}\sum_{i \neq j} a_i(x_if_j^{m_j} - x_jf_i^{m_i}) = 0$?
Thanks!
 A: I think the  proof is (a little) faulty...
As a counter-example to the argument (but not to the result!), take $$A= k[f_1, f_2, x_1,x_2],$$ subject to the constraints
$$f_1+ f_2 =1 \text{ and } f_1f_2( x_1f_2 - x_2f_1) = 0.$$
Then, $U_1 \cup U_2 = X$, where $U_i = \mathop{\text{spec}} A_{f_i}$, as $f_1 + f_2 =1$.
By construction, if $s_i =x_i/f_i$, $s_1/1 = s_2/1$ in $A_{f_1f_2}$.
Following the notation of the proof, we can take $$a_i=1\in A,$$ and likewise for the exponents: $$m_1=m_2=n_{12}=1.$$
The argument suggests that one set $s= x_1 + x_2$,
and argues (it looks erroneously) that $s/1 = s_1 \in A_{f_1}$:
$$\begin{align*}
s/1 &= x_1/1 + x_2/1\\
&= s_1f_1 + x_2/1 \\
&= s_1 + (x_2/1 - f_2s_1)\\
&= s_1 + 1/f_1 \Big(x_2f_1 - f_2x_1\Big).\\
\end{align*} $$
So, as you say, for $s/1= s_1 \in A_{f_1}$, that means that
$$ f_1^n (x_2f_1 -f_2x_1) = 0 \in A, 
\text{ for some }n,$$
which is not implied by the defining relations.
But! In this example,
$$ f_1f_2(x_1f_2-x_2f_1 ) =(x_1f_1) f_2^2 - (x_2f_2)f_1^2 = 0 \in A.$$
Furthermore,
$$s_i= x_i/f_i= x_if_i/ f_i^2\in A_{f_i},$$
and there are $a_1,a_2\in A$, such that $a_1f_1^2+ a_2f_2^2=1$, and proceeding with $s = a_1 (x_1f_1)  + a_2 (x_2f_2)$ does work...
Now, in general:
First, to hide exponents, write the $s_i= x_i/f^{m_i}_i$ as $ x_i/g_i$, with $g_i = f_i^{m_i}$.
Then  - bearing in mind that $A_{f_i}=  A_{g_i}$ - the $U_i= \mathop{\text{spec}}A_{g_i}$ constitute the same cover of $X$, and we can continue with $g_i$ in place of $f_i$.
By quasi-compactness, (i.e., only consider the $i$ and $j$ from a finite cover), there exists a fixed $n$, sufficiently large, such that
$$ (g_ig_j)^n(x_ig_j - x_jg_i)= (g_i^nx_i)g_j^{n+1}- (g_j^nx_j)g_i^{n+1} = 0.$$
Relabel again to ease notation/algebra: write $s_j = y_j/h_j$, with $y_j=x_jg_j^n$, and $h_j=g_j^{n+1}$.
Then the previous displayed equation gives $$ y_ih_j-y_jh_i = 0 \in A.$$
With $a_j \in A$ chosen so that $ a_1h_1+ \cdots + a_kh_k = 1$, take
$$ s = a_1y_1 + \cdots a_ky_k \in A.$$
The steps of the argument (as in the original question) show that
$$s/1 = s_i \in A_{f_i}=A_{h_i},$$
as desired.
