TITLE: How to show x and y are equal?
QUESTION [5 upvotes]: I'm working on a proof to show that f: $\mathbb{R} \to \mathbb{R}$ for an $f$ defined as $f(x) = x^3 - 6x^2 + 12x - 7$ is injective. Here is the general outline of the proof as I have it right now:
Proof: For a function to be injective, whenever $x,y \in A$ and $x\neq y$, then $f(x) \neq f(y)$, i.e., where $A$, $B$ are finite sets, every two elements of $A$ must have distinct images in $B$, which also implies that there must be at least as many elements in $B$ as in $A$ such that the cardinality of $A$ is less than or equals the cardinality of $B$.
We shall prove the contra-positive: If $\exists$ $f(x) = f(y)$, then $x=y.$
Let $x^3 - 6x^2 + 12x - 7 = y^3 - 6y^2 + 12y - 7$.
Then by addition and some algebra, we get $x(x^2 - 6x + 12) = y(y^2 - 6y + 12)$

This feels dumb to ask but how do I continue to finally get the result that $x = y$?

REPLY [3 votes]: Hint $\rm\,\ 0 = f(x)\!-\!f(y) = (\color{#C00}{x\!-\!y})\,\left(\left(\color{blue}{y\!-\!2}\ +\dfrac{\color{#0A0}{x\!-\!2}}2\right)^2\! + 3\,\left(\dfrac{\color{#0A0}{x\!-\!2}}{2}\right)^2\right)\iff \begin{eqnarray}\rm \color{#C00}{x=y}\quad \ or\\\rm\  \color{#0A0}{x=2}\ \ and\ \ \color{blue}{y = 2}\end{eqnarray}$
Remark $\ $ This approach doesn't require noticing that $\rm\:f(x) = (x-2)^3\!+1.\:$ Rather, we use only  $\rm\:x\!-\!y\:|\:f(x)\!-f(y)\:$ (Factor Theorem), and we complete the square in the quadratic cofactor.