Having trouble finding the range of this function. $$f(x)=\frac{e^{2x}-e^x+1}{e^{2x}+e^x+1}$$
Let, $e^x=t$ . Then,
$$f(x)=\frac{t^{2}-t+1}{t^{2}+t+1}=y\quad where,\ t>0$$
$$(y-1)t^2+(y+1)t+(y-1)=0$$
so from the discriminent of the quadratic equation of $t$ I get,
$$(y+1)^2-4(y-1)^2\ge0$$
$$(3y-1)(y-3)\le0$$
$$\frac{1}{3}\le y\le 3$$
But from the graph I can see the range is, $$\frac{1}{3}\le y<1$$

So how can I calculate the range?

Note that
$$h(t)=\frac{t^{2}-t+1}{t^{2}+t+1}=1-\frac{2t}{t^{2}+t+1}=1-\frac{2}{t+\frac{1}{t}+1}$$
Now by AGM inequality, for $t=e^x>0$, $t+\frac{1}{t}\in [2,+\infty)$ and therefore 
$$f(\mathbb{R})=h((0,+\infty))=[1/3,1).$$
P.S. By solving the quadratic equation 
$$(1-y)t^2-(1+y)t+(1-y)=0$$
(for $y=1$, we have that $t=0$), we get
$$t=\frac{1+y\pm \sqrt{-3+10y-3y^2}}{2(1-y)}$$
where the discriminant is non-negative when $\frac{1}{3}\le y\le 3$, but you should remember that $t=e^x$ has to be POSITIVE. 
If, for example, for $y=3$, we get $t=-1<0$.  So we have a further condition: at least one of the real solutions is positive. 
Since their product is $1$, such condition is equivalent to the positivity of their sum, i. e. $(1+y)/(1-y)>0$, or $-1<y<1$.
Again we find that $y\in [1/3,1).$
