Deciding if a polynomial can be expressed as a rational function of other polynomials Let $R = \mathbb{C}[x_1,x_2,x_3,x_4]$ be a polynomial ring and consider the polynomials $f_i = (x_i-x_{i+1})^2, i = 1,2,3$ and $f_4 = (x_4 - x_1)^2$ in $R$. Also, let $f = (x_1 - x_3)^2$.
I want to prove that $f$ is in the subfield $\mathbb{C}(f_1,f_2,f_3,f_4)$ of $\text{Frac}(R) = \mathbb{C}(x_1,x_2,x_3,x_4)$. I can show this geometrically: let $V \subseteq \mathbb{C}^4$ be the Zariski closure of the image of $\mathbb{C^4}$ under $(f_1,f_2,f_3,f_4)$ (viewed as a polynomial map) and similarly let $V'\subseteq \mathbb{C}^5$ be the closure of the image of $\mathbb{C}^4$ under $(f_1,f_2,f_3,f_4,f)$. These are irreducible varieties. Now we can consider the projection $\pi : V' \rightarrow V$. I can show that this is generically one-to-one, which (as far as I know) implies that the varieties are birational, so they have the same function fields, and this is equivalent to what we wanted to show.
I wonder if there is an algebraic way to show this. I'm not a hundred percent sure what I want "algebraic" to mean here - as a first approximation, I'm looking for a proof that does not use the notion of a variety. Also, as far as I can tell, the above proof does not explicitly give me a rational function $g$ with $f = g(f_1,f_2,f_3,f_4)$. (Well, it is possibly hidden in the proof of "generically one-to-one -> birational", but I feel there should be an easier way to find $g$ in this case.)

How can we find a rational function $g$ with $f = g(f_1,f_2,f_3,f_4)$?

I would prefer a proof which is an example of a general method, rather than an "ad-hoc" or "tricky" solution that only works in this particular case, though I would also be interested in the latter.

What kind of "algebraic" tools are there to show that a given polynomial is in the field of rational functions generated by some other polynomials? Can we use somehow the fact that in this case the polynomials are homogenous of degree two?

 A: In this case $$ f = \frac{(f_1-f_2+f_3-f_4)(f_1 - f_2 - f_3 + f_4)}{2(f_1+f_2-f_3-f_4)}.$$
This is obtained as one of the elements (as denominator times $f$ minus numerator) in a Gröbner basis of the ideal $$(f_1-(x_1–x_2)^2, \ldots, f_4-(x_4-x_1)^2, f-(x_1-x_3)^2)$$ where $f_1, \ldots, f_4, f$ are treated as indeterminates with a (lexicographical) ordering $$\{f_1, \ldots, f_4\} < f < \{x_1, \ldots, x_4\}.$$
A: The theory of system of equations in polynomial rings is only a little more complicated than the theory of linear equations.
In the linear world, you choose a "free system" of "basic variables" (the most suitable for your needs) and express all non-basic variables in terms of the basic  variables. The dimension is the number of basic variables.
In polynomial rings, the number of basic variables is called the transcendence degree (of the field extension generated by the variables) and the added complexity is that a non-basic variable will in general not be expressible as a rational function of the basic variables, but will be merely algebraic over the field generated by the basic variables, and a variable will be described by its minimal polynomial over the "basic" field.
If (as if often needed and natural) you insist that the minimal polynomials be irreducible, then you will have a finite union of cases, similar to the decomposition of an algebraic variety into irreducible varieties.
From a computational perspective, all that is involved is addition, multiplication, resultants and factorization of multivariate polynomials, although of course the details of the computation quickly become painful when the number of variables grows. The fundamental result is that if two variables $a,b$ satisfy two different equations
$F(a,b)=G(a,b)=0$, then taking resultants wrt to $a$ and $b$ you may find the minimal polynomial of $a$ over $K(b)$, or $b$ over $K(a)$ according to your needs, where $K$ is the field generated by the other variables. You can iterate this to adapt it to any number of variables or equations.
Here, you may simplify a little bit your initial system by removing a superfluous variable : put $r_k=x_{k+1}-x_k$ for $1\leq k \leq 3$. Then your system can be rewritten as $r_1^2=f_1,r_2^2=f_2,r_3^2=f_3,(r_1+r_2+r_3)^2=f_4$, and you wish to express $f=(r_1+r_2)^2$ in terms of $f_1,f_2,f_3,f_4$.
Here, I choose the following ordering of the variables (we want to express the "last" variables in terms of the "first" ones) : $f_1,f_2,f_3,r_1,r_2,r_3,f_4,g$.
Let $F={\mathbb Q}(f_1,f_2,f_3)$, then $F/{\mathbb Q}$ is a purely transcendental extension (so $f_1,f_2,f_3$ are "basic variables"). On the other hand, $r_1,r_2,r_3$ are clearly all algebraic (of degree $2$) over $F$. Then $f_4$ which is a polynomial in the $r_k$ must also be algebraic over $F$. In fact, one can compute that the minimal polynomial of $f_4$ over $F$ is given by
$$
M_{f_4}=\sum_{ }f_i^4-4\sum_{}f_i^2f_j+6\sum_{}(f_if_j)^2+4\sum_{}f_i^2f_jf_k-40f_1f_2f_3f_4
$$
Finally, $f=(r_1+r_2)^2$ is algebraic over $F$, and a fortiori over $F(f_4)$. Omitting here the ugly, long and boring details of the computation (which I did partly using PARI-GP), one obtains that
$$ f = \frac{(f_1-f_2+f_3-f_4)(f_1 - f_2 - f_3 + f_4)}{2(f_1+f_2-f_3-f_4)}$$
(see WimC's answer for a very elegant derivation of this identity). Note that
$$
\begin{array}{lcl}
f_1-f_2+f_3-f_4 &=& 2(x_3-x_1)(x_2-x_4) \\
f_1-f_2-f_3+f_4 &=& 2(x_3-x_1)(x_2-x_1+x_4-x_3) \\
f_1+f_2-f_3-f_4 &=& 2(x_2-x_4)(x_2-x_1+x_4-x_3) \\
\end{array}
$$
