Problem: Let $A = A(x,y)$ and $B = B(x,y)$ be
two-variable polynomials with real coefficients.
Suppose that $A(x,y)/B(x,y)$ is a polynomial in $x$
for infinitely many values of $y$,
and a polynomial in $y$ for infinitely many values of $x$.
Prove that $B$ divides $A$, meaning there exists a third polynomial $C$
with real coefficients such that $A = B \cdot C$.

Solution: This is essentially an application of the division algorithm,
but the details require significant care.

First, we claim that $A/B$ can be written as a polynomial in $x$
whose coefficients are rational functions in $y$.
To see this, use the division algorithm to get
\[ A = Q \cdot B + R \qquad Q,R \in (\RR(y))[x] \]
where $Q$ and $R$ are polynomials in $x$
whose coefficients are rational functions in $y$,
and moreover $\deg_x B > \deg_x R$.

Now, we claim that $R \equiv 0$.
Indeed, we have by hypothesis that for infinitely many values of $y_0$
that $B(x,y_0)$ divides $A(x, y_0)$,
which means $B(x,y_0) \mid R(x,y_0)$ as polynomials in $\RR[x]$.
Now, we have $\deg_x B(x,y_0) > \deg_x R(x,y_0)$
outside of finitely many values of $y_0$ (but not all of them!);
this means for infinitely many $y_0$ we have $R(x,y_0) \equiv 0$.
So each coefficient of $x^i$ (in $\RR(y)$)
has infinitely many roots, hence is a zero polynomial.

Consequently, we are able to write $A / B = F(x,y) / M(y)$
where $F \in \RR[x,y]$ and $M \in \RR[y]$ are each polynomials.
Repeating the same argument now gives
\[ \frac AB = \frac{F(x,y)}{M(y)} = \frac{G(x,y)}{N(x)}. \]
Now, by unique factorization of polynomials in $\RR[x,y]$,
we can discuss GCD's.
So, we tacitly assume $\gcd(F,M) = \gcd(G,N) = (1)$.
Also, we obviously have $\gcd(M,N) = (1)$.
But $F \cdot N = G \cdot M$, so $M \mid F \cdot N$,
thus we conclude $M$ is the constant polynomial.
This implies the result.

\begin{remark*} This fact does not generalize to arbitrary functions that are separately polynomial:
see e.g. \url{http://aops.com/community/c6h523650p2978180}. \end{remark*}