Introduction
Suppose I have the expression $\sqrt{(a-b)^2}$. There is no restriction on the nature of $a$ and $b$. Now what is the value of this expression?
Is it $a-b$? But I can also write it as $\sqrt{(-1)^2(a-b)^2}$ or $b-a$. I guess it's fair because we have a quadratic involved, which leads to two roots.
But suppose we have that expression as a part of another larger expression. And there is only one answer given. If I put one of these final expressions, I get the correct answer, but I get a different answer entirely when I put the other expression.
Where I encountered this problem
In my book, there is an example problem (with solution):
$\int\sqrt{1- \sin{2x}}dx$
I simplified the expression (before Integration) to $(\sin x - \cos x)$ where as they simplified it to $(\cos x - \sin x)$. After Integration, I got $-\cos x -\sin x + C$ and they got $\sin x + \cos x + C$. I have differentiated both these expressions and they both yield the original expression.
So my question is, what do I do when I encounter such questions and only one answer is accepted? And also when is it safe to swap the terms is such cases?
The notation $\sqrt{x}$ denotes the principal square root, or the positive value of the square root. So, $\sqrt{(a-b)^2}=\left|{a-b}\right|$.
So $\sqrt{1-\sin{2x}}=\left|\sin{x}-\cos{x}\right|$. At $x=0$, $\cos{x}-\sin{x}$ is the positive one, which is why I guess your book wrote that one, but unless there were bounds of integration you should really integrate $\left|\sin{x}-\cos{x}\right|$.