<s>[INST] Extraneous solutions without performing squaring operation 
Solve in $[0, 2\pi]$ $$\sec x+\tan x=2\cos x$$

My mind boggled while solving the trigonometric equation in two different ways:
Method $1.$
Assuming $x\ne \frac{\pi}{2},\frac{3\pi}{2}$
We have:
$$\sec x+\tan x=2\cos x$$
$\implies$
$$\sec x-\tan x=\frac{1}{2\cos x}$$
Adding both we get
$$2\sec x=2\cos x+\frac{1}{2\cos x}$$
$\implies$
$$\frac{3}{2\cos x}=2\cos x$$
$\implies$
$$\cos x=\frac{\pm \sqrt{3}}{2}$$
which gives four solutions in $[0,2\pi]$ which are $\frac{\pi}{6},\frac{11\pi}{6},\frac{5\pi}{6},\frac{7\pi}{6}$ but only two of them which are $\frac{\pi}{6}, \frac{5\pi}{6}$ satisfying the original equation.
Method $2.$
Writing the given equation as
$$\frac{1}{\cos x}+\frac{\sin x}{\cos x}=2\cos x $$
Then we get
$$1+\sin x=2(1-\sin^2 x)$$
$\implies$
$$2\sin^2 x+\sin x-1=0$$
$\implies$
$$\sin x=-1, \sin x=\frac{1}{2}$$
Since $x\ne \frac{\pi}{2},\frac{3\pi}{2}$ we can ignore $\sin x=-1$. Thus we have
$\sin x=\frac{1}{2}$ which gives the two solutions $\frac{\pi}{6}, \frac{5\pi}{6}$
My question is why am i getting two extraneous solutions in Method $1$ even though they are in the domain of $\sec x$ and $\tan x$?
 [/INST] Note that this is not limited to trigonometric equations.
You obtained $\sec(x)-\tan(x)=\frac 1{2\cos(x)}$ by taking the inverse of both sides of the equation.
Let examine the very simple case $x=2\iff \dfrac 1x=\dfrac 12$
Notice that when summing these two equations $x+\dfrac 1x=\dfrac 52$ you now end up with two solutions $2$ and $\frac 12$.
This happens because you symmetrized the equation to $S(x,\frac 1x)=0$, therefore whenever $x$ is solution, $\frac 1x$ is solution too and the extraneous $\frac 12$ appears.
This is more or less the same issue here, but of course because we are dealing with trigonometric functions, the extraneous solutions are not just the inverses, but the principle is the same.
</s>