TITLE: Is taking modulus on both sides of an equation valid?
QUESTION [10 upvotes]: This might look like a copy of another question, but what I'm about to propose here is new. There's this question,

Find the least positive integral value of n for which $(\frac{1+i}{1-i})^n = 1$

While solving, if we multiply what is within the bracket, by the conjugate of denominator and divide by the same thing, we get $i$ in the bracket, that means, the question boils down to

$i ^ n= 1$

We know that the least positive value $n$ can have is $4$, for $i^n$ to be $1$.
Done.
Now,
IF I were to solve it by taking mod on both sides of the given equation,
I would get

$\Big(\frac{|1+i|}{|1-i|}\Big)^n = |1|$
$\Big(\frac{\sqrt{2}}{\sqrt{2}}\Big)^n = 1$
$1^n = 1$

NOTE that the least positive value of $n$ changes from $4$ to $1$.
Why is it so?
I read an answer on stack exchange, that it is valid to do anything with the equation until it maintains the equality. I didn't destroy the equality, so why does the answer vary?
Is there any restriction as to where to use the "taking-mod-both-sides" thing?

REPLY [18 votes]: I'm sure you have learned that when solving equations, if you square both sides you can introduce spurious solutions. The point is that
$$A = B \implies A^2 = B^2
$$
but the converse can fail. That's why we teach algebra students to check their answers back in the original equation.
Taking the modulus on both sides of the equation has the same effect:
$$A = B \implies |A| = |B|
$$
but the converse can fail, for example $|i|=|1|$ but $i \ne 1$. 
When you took the modulus on both sides of your equation, you introduced spurious solutions. So you have to check each solution to see if it satisfies the original equation.