Solving the following trigonometric equation: $\sin x + \cos x = \frac{1}{3} $ I have to solve the following equation:
$$\sin x + \cos x = \dfrac{1}{3} $$
I use the following substitution:
$$\sin^2 x + \cos^2 x = 1  \longrightarrow \sin x = \sqrt{1-\cos^2 x}$$
And by operating, I obtain:
$$ \sqrt{(1-\cos^2 x)} = \dfrac{1}{3}-\cos x$$
$$ 1 - \cos^2 x = \dfrac{1}{9} + \cos^2 x - \dfrac{2}{3}\cos x$$
$$ -2\cos^2 x + 2/3\cos x +\dfrac{8}{9}=0$$
$$ \boxed{\cos^2 x -\dfrac{1}{3}\cos x -\dfrac{4}{9} = 0}$$
Can I just substitute $\cos x$ by $z$ and solve as if it was a simple second degree equation and then obtain $x$ by taking the inverse cosine? I have tried to do this but I cannot get the right result. If I do this, I obtain the following results:
$$ z_1 = -0.520517 \longrightarrow  x_1 = 121.4º\\
z_2= 0.8538509 \longrightarrow x_2 = 31.37º$$
I obtain $x$ from $z$ by taking the inverse cosine.
The correct result should be around 329º which corresponds to 4.165 rad. My question is if what I am doing is wrong because I have tried multiple times and I obtain the same result (or in the worst case, I have done the same mistake multiple times).

You can approach this problem with the substitution
$$
\begin{cases}
X=\cos x\\[4px]
Y=\sin x
\end{cases}
$$
that transforms the equation into
$$
\begin{cases}
X+Y=\dfrac{1}{3} \\[6px]
X^2+Y^2=1
\end{cases}
$$
Rewriting the second equation as $(X+Y)^2-2XY=1$, we can substitute and get
$$
\begin{cases}
X+Y=\dfrac{1}{3} \\[6px]
XY=-\dfrac{4}{9}
\end{cases}
$$
that leads to the solving equation
$$
z^2-\frac{1}{3}z-\frac{4}{9}=0
$$
(finding two numbers knowing their sum and product). After rewriting it as $9z^2-3z-4=0$, we find the roots
$$
\frac{1-\sqrt{17}}{6},\qquad \frac{1+\sqrt{17}}{6}
$$
The solutions to the original problem are therefore
$$
\begin{cases}
\cos x=\dfrac{1-\sqrt{17}}{6},\\[6px]
\sin x=\dfrac{1+\sqrt{17}}{6}
\end{cases}
\qquad
\begin{cases}
\cos x=\dfrac{1+\sqrt{17}}{6},\\[6px]
\sin x=\dfrac{1-\sqrt{17}}{6}
\end{cases}
$$
We can express the solutions in terms of the arctangent by noting that in the first case the (principal) angle is in the interval $(\pi/2,\pi)$ and its tangent is
$$
\frac{1+\sqrt{17}}{1-\sqrt{17}}=-\frac{9+\sqrt{17}}{8}
$$
so the corresponding solution is
$$
\pi-\arctan\frac{9+\sqrt{17}}{8}+2k\pi
$$
In the second case the (principal) angle is in the interval $(-\pi/2,0)$ and its tangent is
$$
\frac{1-\sqrt{17}}{1+\sqrt{17}}=\frac{\sqrt{17}-9}{8}
$$
so the corresponding solution is
$$
\arctan\frac{\sqrt{17}-9}{8}+2k\pi
$$

There is another procedure that doesn't introduce extraneous solutions: remember the relations
$$
\cos x=\frac{1-t^2}{1+t^2},\sin x=\frac{2t}{1+t^2}
$$
where $t=\tan\dfrac{x}{2}$.
This is possible because $x=\pi$ is not a solution of the equation. Then you get
$$
\frac{1-t^2}{1+t^2}+\frac{2t}{1+t^2}=\frac{1}{3}
$$
that simplifies into
$$
2t^2-3t-1=0
$$
so you get
$$
\tan\frac{x}{2}=\frac{3+\sqrt{17}}{4}
\qquad\text{or}\qquad
\tan\frac{x}{2}=\frac{3-\sqrt{17}}{4}
$$
and so
$$
x=2\arctan\frac{3+\sqrt{17}}{4}+2k\pi
\qquad\text{or}\qquad
x=2\arctan\frac{3-\sqrt{17}}{4}+2k\pi
$$
In degrees, the first solution corresponds to $\approx121.367^\circ$ and the second one to $\approx-58.633^\circ$
