The sum of all real roots of the equation $$|x-2|^2 + |x-2| - 2 = 0$$ is?
I tried this problem by taking two cases $x<2$ and $x>2$ and solving the corresponding equations and I got $8$ as the answer, but in my book the author solves it by taking this equation as a quadratic in $x-2$ and gets $4$ as the answer. What's wrong with my way of solving this problem?
When $x < 2$, the equation becomes $$ x^2 - 4x + 4 + 2 - x - 2 = 0, $$ or $x^2-5x+4=0$. This gets solutions $x = 4$ or $x = 1$, but since $x < 2$ we only take $x = 1$.
When $x > 2$, we have $$ x^2 - 4x + 4 + x - 2 - 2 = 0, $$ or $x^2 - 3x = 0$. This gets solutions $x = 0$ or $x = 3$, but since $x > 2$ we only take $x = 3$.
EDIT: the book's way is probably nicer though. Let $y = |x-2|$, then $y^2 - y + 2 = 0$ and $y = -2$ or $y = 1$. Since $y \geq 0$, we only take $|x-2| = y = 1$, which again gets $x = 3$ or $x = 1$.