Solutions of sin(x) = cos(x)

I know that the solutions to the equation $$\sin(x) = \cos(x)$$ are :

$$x= \frac{\pi}{4}$$ (45°) ; $$x= \frac{5 \pi}{4}$$ (225°)

However when I try to solve it algebraically I get the following :

$$\sin x = \cos x$$ $$\sin^2 x = \cos^2 x$$ $$\sin^2 = 1 - \sin^2 x$$ $$2\sin^2 x = 1$$ $$sin^2 x = \frac{1}{2}$$ $$\sqrt {sin^2 x} = \sqrt{\frac{1}{2}}$$ $$\sqrt {sin^2 x} = \sqrt{\frac{1}{2}}$$ $$\sin x= \lvert\frac{1}{\sqrt2}\rvert$$ $$\sin x= \frac{\sqrt2}{2} ; \sin x= -\frac{\sqrt2}{2}$$

So if I look for all the values of $$x$$ that solve the above I should get not only $$x= \frac{\pi}{4}$$ (45°) ; $$x= \frac{5 \pi}{4}$$ (225°) but also $$x= \frac{3\pi}{4}$$ (135°) ; $$x= \frac{7 \pi}{4}$$ (315°).

What am I doing wrong?

• math.stackexchange.com/questions/55445/… Commented Apr 5, 2019 at 3:36
• $\sqrt{\sin^2 x}=|\sin x|$ Commented Apr 5, 2019 at 3:39
• $\sin^2x=\cos^2x$ when $\sin x=-\cos x$ Commented Apr 5, 2019 at 3:40
• Neither squares or trig function are 1 to 1. Commented Apr 5, 2019 at 3:40
• Thanks @labbhattacharjee, in your link is explained very clearly the concept I was missing! Commented Apr 5, 2019 at 13:36

The issue :

when you write out $$\sin x = \cos x$$ implies $$\sin^2 x = \cos^2 x$$, there is no problem with the implication. However, an implication leads to a weaker statement, which may admit "extraneous" solutions. For example, the above implication is got by squaring both sides, but then that ends up including the case when $$\sin x = -\cos x$$.

Therefore you need to ensure that your implications are both ways, so that the solutions of both equations are retained, or you have to eliminate extraneous solutions once you reach the end.

The two extraneous solutions $$\frac{3\pi}4 , \frac{7\pi}4$$ obtained are of the equation $$\sin x = -\cos x$$, which got included as solutions of the equation $$\sin^2 x = \cos^2 x$$ when you moved to this statement from the one you were given.

A better alternative would be to do the following: \begin{aligned}\sin x&=\cos x\\\tan x&=1\\x&=\arctan 1\\ x&=\dfrac{\pi}{4}+\pi n, n\in \mathbb{Z}\end{aligned}

• Strictly speaking this solution is incomplete. Before dividing both sides by $\cos x$ you need to ascertain that no value of $x$ that makes $\cos x=0$ is a solution to the equation. It doesn't make a difference in this case, but it would make a huge difference, for instance, in solving $\sin x = \tan x$ where division makes one "lose" solutions. Commented Apr 5, 2019 at 14:09

The problem is a pretty generic one. By squaring both sides of the equation earlier on, you introduced extraneous solutions. It's sort of like how in solving the equation

$$x+\sqrt{x+9} = 2$$

you can get to

$$\sqrt{x+9} = 2-x$$

and then square both sides to get

$$x+9 = 4 - 4x + x^2 \implies x^2 - 5x - 5 = 0$$

You should get

$$x = \frac{5 \pm 3\sqrt 5}{2}$$

Not the cleanest expression, but you'll notice that, if you substitute the positive root into the original equation, it won't work, though the negative root does. This applies beyond the context of polynomials. For example, if we have

$$x = x$$

we can square and get

$$x^2 = x^2$$

Obvious, right? But a problem: if you wanted to work backward, how would you know whether either is positive or negative? After all, $$x^2 = (-x)^2$$ in the usual arithmetic. Same problem here:

$$(\sin(x))^2 = (-\sin(x))^2 = (\cos(x))^2 = (-\cos(x))^2$$

Extra solutions galore.

This doesn't make your method of solution invalid, necessarily, but you have to be conscious of extraneous solutions, and always substitute each solution back in to check its validity. In fact, substituting both $$x=3\pi/4$$ and $$x = 7\pi/4$$ into the original equation, you should notice that the two differ by $$\sqrt 2$$ and $$-\sqrt 2$$, respectively, so you don't have equality in those cases!

$$\cos x=\sin x=\cos\left(\frac{\pi}{2}-x\right)$$ thus $$x=\frac{\pi}{2}-x \bmod [2\pi]$$ or $$x=-\frac{\pi}{2}+x \bmod [2\pi]$$. The first equation has $$\pi/4$$ as solution and the second does not provide a solution.