Factorising $x^2-x+1$ I attempted to factorise $x^2-x+1$, which seemed fairly straightforward:
$$ 
\begin{align}
x^2-x+1 &= (x+1)^2-3x \\
        &= (x+1-\sqrt{3x})(x+1+\sqrt{3x}) \\
        &= (x-\sqrt{3x}+1)(x+\sqrt{3x}+1)
\end{align}$$
Technically neither $(x-\sqrt{3x}+1)$ nor $(x+\sqrt{3x}+1)$ are linear functions, which is why I didn't get the "correct" answer:
$$(x-\frac{1}{2}-i\frac{\sqrt{3}}{2})(x-\frac{1}{2}+i\frac{\sqrt{3}}{2})$$
But I am curious as to why Desmos only considers the positive cases of $x$? If $(x-\sqrt{3x}+1)(x+\sqrt{3x}+1)$ does expand perfectly into $x^2-x+1$, why isn't it graphed the same way?
 A: Desmos interprets it as a real function $\Bbb R\to\Bbb R$, and the square root - which is included in your formula - isn't defined for negative values (when $3x<0$ i.e. $x<0$).
For the quadratic: when you pull out, half the coefficient of $x$:
$$x^2-\underline1\cdot x+1=(x-\underline{1/2})^2+\dots$$
A: The function $(x+1-\sqrt{3x})(x+1+\sqrt{3x})$ is only defined for $x \ge 0$, therefore it is not the same function as $x^2-x-1$, which is defined on $\forall x \in \mathbb{R}$. Why? Think about how the square root is defined. 
For $x < 0$, you have $|x|=-x$, hence this factorization becomes
$$ x^2 - x + 1 = (x+1)^2 + 3|x| = \left(x+1-i\sqrt{3|x|}\right)\left(x+1+i\sqrt{3|x|}\right) $$
and you no longer have real values.

For the "correct" answer, you need to complete the square
$$ x^2 - x + 1 = \left(x-\frac12\right)^2 + \frac34 = \left(x-\frac12 -
 i\frac{\sqrt3}{2}\right)\left(x+\frac12 + i\frac{\sqrt3}{2}\right) $$
A: What you propose is not a polynomial factorisation. The polynomial function $x^2-x+1$ is defined for all $x$, whereas your ‘factorisation’ requires $x\ge 0$.
Anyway, since the roots of $x^2+x+1$ are the non-real cubic roots of unity $j$ and $j^2$, the roots of $x^2-x+1$ are $-j$ and $-j^2$n, whence the factorisation
$$x^2-x+1=(x+j)(x+j^2).$$
