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?
 A: 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]$.
A: Rewrite
$$f(x) = 1 + \frac{(a-1)x}{x^2+x+1}$$
and note that $f(x) \in [0,2]$ is equivalent to $(a-1)\frac{x}{x^2+x+1} \in [-1,1]$.
Notice that $\frac{x}{x^2+x+1} \in [-1,1]$:
$$\frac{x}{x^2+x+1} \le 1 \iff 0 \le x^2+1$$
$$\frac{x}{x^2+x+1} \ge -1 \iff 0 \le x^2+2x + 1$$
Now, if $a \in [0,2]$ then $|a-1| \le 1$ so
$$|a-1|\underbrace{\left|\frac{x}{x^2+x+1}\right|}_{\le 1} \le 1, \forall x \in \mathbb{R}$$
Conversely, if $(a-1)\frac{x}{x^2+x+1} \in [-1,1], \forall x \in \mathbb{R}$ then in particular for $x = -1$ we get $1-a \in [-1,1]$ which implies $a \in [0,2]$.
We conclude $f(x) \in [0,2], \forall x \in \mathbb{R}$ if and only if $a \in [0,2]$.
A: The derivative of $f(x)$ is equal to $\dfrac{(a-1)(x^2-1)}{(x^2+x+1)^2}$ so the extremes  are independent of a and taken at $x=\pm 1$. This extremes are $\dfrac{2\pm a}{3}$ It follows $0\le a\le 2$
A: You're doing well. The derivative is
$$
f'(x)=-\frac{(a-1)(x^2-1)}{(x^2+x+1)^2}=(1-a)\frac{(x^2-1)}{(x^2+x+1)^2}
$$
Leaving aside $1-a$, the fraction is negative for $|x|<1$.
If $1-a>0$, the function has a maximum at $-1$ and a minimum at $1$. The situation is reversed for $1-a<0$. For $a=1$ the function is constant and satisfies the requirement.
Since $\lim_{x\to\pm\infty}f(x)=1$, we just need to compute
$$
f(-1)=2-a
\qquad
f(1)=\frac{2+a}{3}
$$
Thus we must have
$$
\begin{cases}
1-a>0 \\[4px]
2-a\le2 \\[4px]
2+a\ge0
\end{cases}
\qquad\text{or}\qquad
\begin{cases}
1-a<0 \\[4px]
2-a\ge0 \\[4px]
2+a\le6
\end{cases}
\qquad\text{or}\qquad a=1
$$
Solving this gives $0\le a\le 2$.
