Help with finding tangent to curve at a point 
Find an equation for the tangent to the curve at $P\left( \dfrac{\pi}{2},3 \right )$ and the horizontal tangent to the curve at $Q.$ 
  $$y=5+\cot x-2\csc x$$

$y\prime=-\csc ^2 x -2(-\csc x \cot x)$
$y\prime= 2\csc x \cot x - \csc ^2 x\implies$ This is the equation of the slope.  
Now I find the slope at $x=\dfrac{\pi}{2}:$
$$y^{\prime}=2\csc \left( \frac{\pi}{2} \right) \cot \left( \frac{\pi}{2} \right)- \csc ^2 \left( \frac{\pi}{2} \right)$$ $$y^{\prime}= -1$$ 
Equation for the tangent to the curve at $P$:
$$y-3=-1\left( x-\frac{\pi}{2} \right)$$ $$y=-x+\frac{6+\pi}{2}$$ 
Then I found the horizontal tangent at $Q$, which is where the slope is $0.$ So I set the slope equation equal to $0:$ 
$$y^{\prime}= 2\csc x \cot x - \csc ^2 x=0$$ $$-\csc ^2 x = -2\csc x \cot x$$ 
$$-\frac{1}{\sin^2 x}=-2\left( \frac{1}{\sin x} \frac{\cos x}{\sin x} \right )$$ 
$$\cos x = \frac{1}{2}$$

I don't know how to proceed from here. Since $\cos x = \dfrac{1}{2}$, $\cos^{-1}\left (\dfrac{1}{2}\right)=\dfrac{\pi}{3}$.
Plugging this into the equation would give the $y$ value, and I'd be able to find the equation of the tangent line, but I'm confused because there is not just one $x$ to consider, since $x=2n \pm \dfrac{\pi}{3}$. 
The answer for equation of tangent at $Q$ is $y=5-\sqrt{3}$, and I don't know how to get this. 
Can you please show how to work this last part in details? Thank you. 

The first part looks good. For the second part as you see the solution to the equation gives
$$2 \cot x \csc x - \csc^2 x = 0 \Rightarrow x=2n \pi \pm\frac{\pi}{3}.$$
Choose $x=\frac{\pi}{3}$ as it is one such solution. We find the point on $y$ to be
$$5+\cot\left( \frac{\pi}{3} \right)-2\csc\left( \frac{\pi}{3} \right)=5-\sqrt{3},$$
And so $y=5-\sqrt{3}$ is indeed a horizontal tangent line, in particular the horizontal tangent line at $x=\frac{\pi}{3}$. You can verify this in WA.
