Trigonometric equation with parameter 
Find $p$ for which $\cos^2(x) - \cos(x) + p + 1 = 0$ has EXACTLY two solutions for $0 \le x \le 2\pi$

I tried to substitute $t = \cos(x)$ and then I got two solutions, but I don't know what to do next. 
$t_1 = \frac{1 + \sqrt{-3 - 4p}}{2}$
$t_2 = \frac{1 - \sqrt{-3 - 4p}}{2}$
 A: Since $\cos x=T$ has at most two real solutions in $0\le x\le 2\pi$ for a given real constant $T$, we have three cases.
(1) $\cos x=t_1$ has no solution and $\cos x=t_2$ has two solutions.
(2) $\cos x=t_1$ has exactly one solution and $\cos x=t_2$ has exactly one solution.
(3) $\cos x=t_1$ has two solutions and $\cos x=t_2$ has no solution.
Note here that 


*

*$\cos x=T$ has no solution in $0\le x\le 2\pi$ if and only if $|T|\gt 1$. 

*$\cos x=T$ has exactly one solution in $0\le x\le 2\pi$ if and only if $T=-1$. 

*$\cos x=T$ has two solutions in $0\le x\le 2\pi$ if and only if $-1\lt T\le 1$.
So, noting that (2) does not occur, the answer is
$$\{p\mid -3-4p=0\}\cup \left\{p\mid -3-4p\gt 0,\frac{1+\sqrt{-3-4p}}{2}\gt 1,-1\lt\frac{1-\sqrt{-3-4p}}{2}\le 1\right\}\cup \left\{p\mid -3-4p\gt 0,-1\lt \frac{1+\sqrt{-3-4p}}{2}\le 1,\frac{1-\sqrt{-3-4p}}{2}\lt -1\right\},$$
i.e.
$$\color{red}{p=-\frac 34\quad\text{or}\quad -3\lt p\lt -1}.$$
A: You don't have to use the resolution formulae to solve this problem. This raises difficulties, as there are roots and squaring can introduce parasitic solutions.
We can use Vieta's formulae instead. Setting $t=\cos x$ we get a quadratic equation:
$$p(t)=t^2-t+p+1=0$$
which we require to have two solutions, $t0$ and $t_1$, between $-1$ and $1$. This means:


*

*There are two solutions, i.e. $\Delta=-(4p+3)>0\iff p<-\dfrac34$.

*$-1$  and $1$ are on either side of the interval $(t_0,t_1)$, which equivalent to
$$\begin{cases}p(1)=p+1\ge 0\\p(-1)=p+3\ge 0\\ \dfrac{t_0+t_1}2=\frac12\in [-1,1]
\end{cases}$$
The last condition is always satisfied, so the problem has solutions in $\cos x$ if ond only if
$$-1\le p<-\dfrac34. $$


For $2$ solutions in $x$ in the interval $[0,2\pi]$, we must have only one solution in $t=\cos x$. This means:


*

*either $\Delta=0\iff p=-\dfrac34$. In this case, the double root is 
$$\cos x=\frac12\iff x=\frac\pi3,\frac{5\pi}3.$$

*or $\Delta>0\iff p<-\dfrac34$, and only $1$ root lies in $[-1,1]$. This meansone of $-1,1$ separates $t_0$ and $t_1$, the other does not. In other words only one of $p(-1),\, p(1)$ is negative. This translates as 
$$p(-1)p(1)=(p+1)(p+3)<0\iff -3<p<-1$$

*or $\Delta>0$ and $p(-1)p(1)=0\iff p=-1\enspace \text{or}\enspace p=-3$. If $p=-1$, the equation is $t^2-t=0$: it has $2$ roots in $[-1,1]$.  If $p=-3$, the equation is $t^2-t-2=0$: it has $2$ roots: $-1$ and $2$. Only one is in $[-1,1]$, but it corresponds to only one solution for $x$ (in $[0,2\pi]$).


Summing up, we conclude the equation has exactly two roots in $[0,2\pi]$ if
$$\color{red}{-3<p<-1}\enspace \text{or}\enspace\color{red}{p=-\frac34}.$$
A: Apart from $-3-4p>0,$ we also need $$-1\le\dfrac{-1\pm\sqrt{-3-4p}}2\le1$$
$$\iff-1\le\pm\sqrt{-3-4p}\le3\  \ \ \ (1)$$
Now $\sqrt{-3-4p}\ge0$
$(1)\implies\sqrt{-3-4p}\le3\iff-3-4p\le9\iff4p\ge6$
and $-1\le-\sqrt{-3-4p}\iff1\ge\sqrt{-3-4p}\iff1\ge-3-4p\iff4p\le-3+1$
