Why do I only get one answer when evaluating $x^2=2x$? What this question is not about

*

*I know to expect two answers $\{2,0\}$, (I can test them, by plugging them into the equation).

*I know how to get them graphically.

*I know how to get the algebraically:

*

*$x^2 = 2x$

*$x^2 - 2x = 0$

*$(x-2)(x-0)=0$

*$(x-2)(x)=0$

*$x=0, x=2$
However
My first attempt got only one answer, and I see nothing else wrong with it.

*

*$x^2 = 2x$

*$x = 2$ (by dividing by $x$)

What am I doing wrong? How can I detect this error early? I can catch this error at the end, as I expect two answers. In this case there is little difference between the point of error and the end, but in more complex problems there may be a long time between them, so I would like to catch this earlier. How do I know where I went wrong?
 A: $$x^2=2x$$
If $x \neq 0$, we can divide by $x$:
$$x=2$$
And you should check what happens if $x=0$. Similarly: 
$$(x-2)(x-3)x=2x(x-2)$$
If $x-2 \neq 0$ we can divide by $x-2$:
$$x(x-3)=2x$$
If $x \neq 0$ we can divide by $x$:
$$x-3=2$$
$$x=5$$
And we should go back and check what happens if $x=0$ or $x-2=0$.
A: I relate pretty hard to this question because I remember struggling with this in my early algebra classes.

The reason that your approach doesn't get the entire solution set is this... So we have $x^2 = 2x$. Suppose we're blind to the reality of what these roots are. We can tell there's two at least, certainly.
Can we divide by $x$, though?
Initially, it would seem so, right? There's a factor on each side, they just "cancel".
But then as you noticed - one of the roots is $0$. More explicitly, $x=0$.
So when you divide by $x$ on both sides, you're dividing by the roots of the equation - that is, you're dividing by $0$ when you consider one particular root. That's not kosher as you probably know, and is why this method is not foolproof. Since one of the roots isn't zero, you can get that root, at least, but not the zero root.
A: When you begin solving the equation $x^2=2x$, $x$ potentially can be any number (or numbers). You have no idea because you obviously haven't yet solved the equation. Suppose one of the numbers that makes that equation true is zero:
$$
x\cdot x=2\cdot x\\
0\cdot 0=2\cdot 0\\
0\cdot\frac{0}{0}=2\cdot\frac{0}{0}\implies
0=2
$$
You get a nonsensical result because you just violated one of the basic principles in mathematics: you can't divide by zero because division by zero is an undefined operation in mathematics. As soon as you're attempting to divide something by zero, you're dong anything, but mathematics because in mathematics, strictly speaking, there is no such operation as division by zero.
Why is division by zero meaningless? Let me quote Wikipedia on this:

In ordinary arithmetic, the expression $\frac{a}{0}$ has no meaning, as there is no number which, when multiplied by 0, gives a (assuming a ≠ 0), and so division by zero is undefined. Since any number multiplied by zero is zero, the expression $\frac{0}{0}$ is also undefined.

You still could divide by $x$ on the condition that $x\ne 0$:
$$
x^2=2x\\
\frac{x^2}{x}=\frac{2x}{x}\\
x=2
$$
And then you would have to separately check if $x=0$ is also a root of that equation:
$$
x^2=2x\\
0^2=2\cdot 0\\
0=0
$$
So, it turns out that $x=0$ is also a solution. Therefore, your solution set consists of two numbers: $2$ and $0$.
A: When doing a division by $x$, you're implictly assuming that $x\neq 0$. Otherwise, you would be dividing by zero, which is undefined.
But this assumption is something you've introduced in your calculation process. In the original equation, $x^2 = 2x$, there was nothing telling you that $x$ must be non-zero.
Therefore, you have to check manually that the inserted assumption doesn't remove any of the solutions from the original equation. In this case, this means that you must manually check if $x = 0$ is a solution.
Here is a demonstration of what is going on, made explicit. We start with the equation
$$x^2 = 2x $$
Now we say, if (an assumption) the value of $x$ is non-zero, then we have that
$$\frac{x^2}{x} = \frac{2x}{x} $$
which simplifies to
$$x = 2. $$
But let's go back, what if it is not non-zero? Or said more simply, what if it is zero? 
Then $x^2 = 0^2 = 0$ and $2x = 2\cdot 0 = 0$. These expressions are equal to each other (both are equal to zero), hence $x=0$ also satisfies the original equation. We conclude that $x = 0$ and $x = 2$ are the solutions.
(It is worth noting that we first find all solutions when $x\neq 0$ and then when $x = 0$. This exhausts all real numbers, so we know that no real number other than $0$ and $2$ can be solutions.)
