Proving that all roots of a particular polynomial are real 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.
 A: 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).
A: 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$.
A: You have that $P$ is the sum of two polinomials (given by those products) $A$ and $B$. These polynomials have simple zeroes at $a_k$ and $b_k$ respectively and therefore they will alter sign there.
This means that for consecutive $b_k$, $P(b_k) = A(b_k)$ will have oposite signs and therefore a zero inbetween. This means that $P$ has at least $n-1$ real roots, that is at most one non-real root. Having real coefficient will mean that for any root the conjugate will also be a root, which means that non-real roots must be even numbered which rules them out because they're at most one.
