For all real values of $x$, the minimum value of $\frac{1-x+x^{2}}{1+x+x^{2}}$ is
(A) 0 (B) 1
(C) 3 (D) $\frac{1}{3}$
Let $f(x)=\frac{1-x+x^{2}}{1+x+x^{2}}$
$\therefore f^{\prime}(x)=\frac{\left(1+x+x^{2}\right)(-1+2 x)-\left(1-x+x^{2}\right)(1+2 x)}{\left(1+x+x^{2}\right)^{2}}$
$=\frac{-1+2 x-x+2 x^{2}-x^{2}+2 x^{3}-1-2 x+x+2 x^{2}-x^{2}-2 x^{3}}{\left(1+x+x^{2}\right)^{2}}$
$=\frac{2 x^{2}-2}{\left(1+x+x^{2}\right)^{2}}=\frac{2\left(x^{2}-1\right)}{\left(1+x+x^{2}\right)^{2}}$
$\therefore f^{\prime}(x)=0 \Rightarrow x^{2}=1 \Rightarrow x=\pm 1$
Now, $f^{\prime \prime}(x)=\frac{2\left[\left(1+x+x^{2}\right)^{2}(2 x)-\left(x^{2}-1\right)(2)\left(1+x+x^{2}\right)(1+2 x)\right]}{\left(1+x+x^{2}\right)^{4}}$
$=\frac{4\left(1+x+x^{2}\right)\left[\left(1+x+x^{2}\right) x-\left(x^{2}-1\right)(1+2 x)\right]}{\left(1+x+x^{2}\right)^{4}}$
$=\frac{4\left[x+x^{2}+x^{3}-x^{2}-2 x^{3}+1+2 x\right]}{\left(1+x+x^{2}\right)^{3}}$
$=\frac{4\left(1+3 x-x^{3}\right)}{\left(1+x+x^{2}\right)^{3}}$
And, $f^{\prime \prime}(1)=\frac{4(1+3-1)}{(1+1+1)^{3}}=\frac{4(3)}{(3)^{3}}=\frac{4}{9}>0$
Also, $f^{\prime \prime}(-1)=\frac{4(1-3+1)}{(1-1+1)^{3}}=4(-1)=-4<0$
$\therefore$ By second derivative test, $f$ is the minimum at $x=1$ and the minimum value is given by $f(1)=\frac{1-1+1}{1+1+1}=\frac{1}{3}$.
The correct answer is D.