TITLE: Proving that all roots of a particular polynomial are real
QUESTION [5 upvotes]: I'm trying to show that given real numbers $a_{0}<b_{0}<a_{1}<....<a_{n}<b_{n}$, a polynomial $P$ defined as
$P(x)= \prod_{k=0}^{n} (x+a_{k})+2\prod_{k=0}^{n} (x+b_{k})$
has only real roots.
I believe something like this could happen
$P(a_{0})<P(b_{0})<...<P(b_{n})$ if n is even and $P(a_{0})>P(b_{0})>...>P(b_{n})$ if n is odd. Then the intermediate value theorem might help but I haven't being able to make much progress at all.

REPLY [3 votes]: Hint. We first notice that the degree of $P$ is $n$. Then, for $i=0,\dots,n$, we have that 
$$P(-a_i)=\prod_{k=0}^{n} (-a_i+a_{k})+2\prod_{k=0}^{n} (-a_i+b_{k})\\=0+2\underbrace{(-a_i+b_0)}_{<0}\dots \underbrace{(-a_i+b_{i-1})}_{<0}\cdot\underbrace{(-a_i+b_{i})\dots (-a_i+b_n)}_{>0}
$$
that is the same sign of $(-1)^i$.
Morever
$$P(-b_i)=\prod_{k=0}^{n} (-b_i+a_{k})+2\prod_{k=0}^{n} (-b_i+b_{k})\\=\underbrace{(-b_i+a_0)}_{<0}\dots \underbrace{(-b_i+a_{i})}_{<0}\cdot\underbrace{(-b_i+a_{i+1})\dots (-b_i+a_n)}_{>0}+0$$
that is the same sign of $(-1)^{i+1}$.
Now it remains to apply the the intermediate value theorem (as you already noted in your question).

REPLY [2 votes]: Hint
Note that $$P(-a_m)=2\prod_{k=0}^n (b_k-a_m)=2\prod_{k=0}^{m-1} (b_k-a_m)\prod_{k=m}^n (b_k-a_m)$$which is positive when $m$ is even and negative when $m$ is odd. Also$$P(-b_m)=\prod_{k=0}^n (a_k-b_m)=\prod_{k=0}^{m} (a_k-b_m)\prod_{k=m+1}^n (a_k-b_m)$$which is positive for odd $m$ and negative for even $m$.