Is $\int_{\mathbb R} f(\sum_{k=1}^n\frac{1}{x-x_k})dx$ independent of $x_k$'s for certain $f$? My question below arises from the linked question $ \int\limits_{-\infty}^{+\infty}\frac{(p'(x))^2}{(p'(x))^2+(p(x))^2}\,dx \leq n^{3/2}\pi$ and the comments by jack and David Speyer under that question.
Let $p(x)=\prod_{k=1}^n(x-x_k)$, where $n\ge 1$ and $x_1,\dots,x_n\in\mathbb R$. Then for $f(t)=\frac{t^2}{1+t^2}$, the integral appearing in the linked question can be rewritten as
$$\int_{-\infty}^{+\infty}f\left(\frac{p'(x)}{p(x)}\right)dx= \int_{-\infty}^{+\infty}f\left(\sum_{k=1}^n\frac{1}{x-x_k}\right)dx. $$
Then as noted by jack and David Speyer, the first question is: for $f(t)=\frac{t^2}{1+t^2}$, how to prove
$$\int_{-\infty}^{+\infty}f\left(\sum_{k=1}^n\frac{1}{x-x_k}\right)dx=\int_{-\infty}^{+\infty}f\left(\frac{n}{x}\right)dx \tag{$*$} $$
always hold for every $n\ge 2$? 
Moreover, it seems that $(*)$ also holds for more general form of $f$. Then the second  question comes: for what $f$, $(*)$ holds for every $n\ge 2$? 
Any  suggestion is appreciated. Thanks in advance.
 A: I know what is happening now. Here is the general result:
Let $f(z)$ be a rational function with real coefficients and no real poles which vanishes to order $2$ at $x=\infty$. Let $a_1 < b_1 < a_2 < b_2 < \cdots < a_{n-1} < b_{n-1} < a_n$ be real numbers and set $r(x) = c \frac{\prod(x-a_i)}{\prod(x-b_i)}$ for $c>0$. Then
$$\int_{x=-\infty}^{\infty} f(r(x)) dx = \int_{x=-\infty}^{\infty} f(cx).$$
In particular, we can take $r(x) = p(x)/p'(x)$, in which case the inequalities on the $a$'s and $b$'s are a consequence of Rolle's theorem, and take $f(z) = 1/(1+z^2)$.  (In this case, $c$ will be $1/n$.)
Proof: We first note that the integral makes sense at all. Since $f(z)$ has no real poles (including at $z=\infty$), the integrand has no real poles. As $x \to \infty$, we have $r(x) \sim x$ so $f(r(x)) = O(x^{-2})$, and thus the integral is convergent.
As observed before, $\int_{\infty}^{\infty} f(r(x))$ is $2 \pi i$ times the sum of the residues of the poles of $f(r(x))$ in the upper half plane. We have $f(r(x)) = \infty$ if and only if $r(x)$ is a pole of $f$. Since $f$ has no real poles, the poles of $f$ come in conjugate pairs $(\alpha_i, \overline{\alpha_i})$, where we always take $\alpha_i$ to lie in the upper half plane. So the poles of $f(r(x))$ are the solutions to $r(x) = \alpha_i$ or $\overline{\alpha_i}$.
Lemma For all $x \in \mathbb{C}$, the imaginary part of $r(x)$ has the same sign as the imaginary part of $x$.
Proof: Since $c>0$, this is true for $x=iT$ with $T$ large. Therefore, if it ever fails, there must be some $x_0 \not \in \mathbb{R}$ for which $r(x)$ is real. Suppose $r(x_0) = s \in \mathbb{R}$ and, without loss of generality, take $s>0$. 
The function $r$ increases from $0$ to $\infty$ on each of the intervals $(a_1, b_1)$, $(a_2, b_2)$, ..., $(a_{n-1}, b_{n-1})$ and $(a_n, \infty)$. So there are already $n$ real roots of the equation $r(x) = s$, as well as the additional root $n+1$. But, clearing denominators, $r(x)=s$ is a polynomial of degree $n$, so it can only have $n$ roots. $\square$
We see that the poles of $f(r(x))$ in the upper half plane are precisely the solutions to $r(x) = \alpha_i$. 
Write $f(x)$ in partial fraction expansion as $\sum \frac{\beta_i}{x-\alpha_i} + \frac{\overline{\beta}_i}{x-\overline{\alpha}_i}$ and set $g(x) = \sum \frac{\beta_i}{x-\alpha_i}$. So the poles of $f(r(x)) dx$ in the upper half plane are the same as the poles of $g(r(x)) dx$ in the entire complex plane, and with the same residues. The sum of the residues of a meromorphic differential form over the whole Riemann sphere is $0$, so the sum of the residues of $g(r(x))$ at $x \in \mathbb{C}$ is negative the residue of $g(r(x)) dx$ at $\infty$. 
Using the same argument to study $\int f(cx) dx$, we are reduced to showing that $g(r(x)) dx$ and $g(cx) dx$ have the same residue at $\infty$. Note that $g$ vanishes at $\infty$ and $dx$ has a double pole at $\infty$, so we are talking about a differential with a simple pole. So this follows from the fact that $r(x) = cx+O(1)$ near $\infty$. $\square$.
