Find $a\in\mathbb{R}$ such that the image of $f(x)=\frac {x^2+ax+1}{x^2+x+1}$ is included in $[0,2]$. 
Find $a\in\mathbb{R}$ such that the image of $f(x)=\frac {x^2+ax+1}{x^2+x+1}$ is included in $[0,2]$.

My attempt:
We have: $f'(x)=-\frac{(a-1)(x^2-1)}{(x^2+x+1)^2}\implies x = 1$ and $x = -1$ points of extrema.
then for $a\geq 1$:

so then $$2-a=0\implies a=2$$ and $$\frac {a+2}3=2\implies a=4.$$
and for $a\leq1:$

so then $$2-a=3\implies a=-1$$ and $$\frac {a+2}3=0\implies a=-2.$$
Now my answers are in the type of interval. How do I know which interval to choose?

Lemma: If $x^2+mx+n\geq 0$ for all $x$ then discriminant $m^2-4n \leq 0$.

First note that $x^2+x+1>0$ for all $x$ (since discriminant =$-3$)
$$0\leq f(x)\leq 2 \implies 0\leq x^2+ax+1\leq 2x^2+2x+2$$


*

*From $0\leq x^2+ax+1$ we get $a^2-4\leq 0$ so $|a|\leq 2$ so $\boxed{-2\leq a\leq 2}$.

*From $x^2+ax+1\leq 2x^2+2x+2$ we have $0\leq x^2+(2-a)x+1$ so $(a-2)^2-4\leq 0$ so $|a-2|\leq 2$ so $\boxed{0\leq a\leq 4}$. 


Thus $a\in[0,2]$.
