I have a trigonometric equation that is defined as:
$\sin(\alpha) - \cos(\alpha) = \frac{1}{2}$
Solving this equation by mathematica will yield $\alpha = 65.70 $ and $\alpha = -155.705 $
But As I solve it analytically, I will obtain different results:
First I exponentiate both sides to the power of two:
$(\sin(\alpha) - \cos(\alpha))^2 = \frac{1}{2}^2$
Now I expand the expressions:
$\sin(\alpha)^2 - 2 \sin(\alpha) \cos(\alpha) + \cos(\alpha)^2 = \frac{1}{4}$
As $\sin(\alpha)^2 + \cos(\alpha)^2 = 1$, I will have:
$1 - 2 \sin(\alpha) \cos(\alpha) = \frac{1}{4}$
Again if I put $2 \sin(\alpha) \cos(\alpha) = \sin(2\alpha)$ I will be left with:
$\sin(2 \alpha) = \frac{3}{4}$
Which will readily give $\alpha = 24.3$
So, why I am having different results? I don't understand.



If you square, you also get the solutions of $$ \sin\alpha-\cos\alpha=-\frac{1}{2} $$
In general, if you have an equation of the form $f(x)=g(x)$ and square both sides, you get, after rearranging, $$ f(x)^2-g(x)^2=0 \tag{*} $$ that can be rewritten $$ (f(x)-g(x))(f(x)+g(x))=0 $$ so the solutions of (*) are the solutions of $f(x)-g(x)=0$ (the original equation) together with the solutions of $f(x)+g(x)=0$.
A safer way to solve your equation is to set $t=\tan(\alpha/2)$, so the equation becomes $$ \frac{2t}{1+t^2}-\frac{1-t^2}{1+t^2}=\frac{1}{2} $$ that reduces to $$ t^2+4t-3=0 $$ with solutions $$ -2+\sqrt{7}\qquad\text{or}\qquad -2-\sqrt{7} $$ The first solutions corresponds to $$ \alpha=2\arctan(\sqrt{7}-2)\approx 65.7^\circ $$ and the second one to $$ \alpha=-2\arctan(\sqrt{7}+2)\approx-155.7^\circ $$ or $\approx204.3^\circ$ if you want a value between $0$ and $360$.