I was working on $\frac{1+\cos x}{\sin x}=-1$. Solving for $x$ algebraically gave me three solutions $x=\frac{\pi}{2},\pi,\frac{3\pi}{2}$. However, graphically, as well as substituting these solutions to the original equation, only $x=\frac{3\pi}{2}$ is an actual solution. I realized that the other false solutions show up when i square both sides after multiplying by $\sin x$ on both sides.
So when would $f(x)=g(x)$ and $f(x)^2=g(x)^2$ have the same solution sets where I would not have to worry about extraneous solutions?