Answer
a. $y=-x+\frac{\pi}{2}+2$
b. $y=4-\sqrt 3$
Work Step by Step
a. Step 1. Given $y=4+cot(x)-2csc(x)$, we have $y'=-csc^2x+2csc(x)cot(x)$
Step 2. At point $P(\frac{\pi}{2},2)$, $y'==-csc^2(\frac{\pi}{2})+2csc((\frac{\pi}{2})cot((\frac{\pi}{2})=-1+2(1)(0)=-1$,
The tangent line equation is $y-2=-(x-\pi/2)$ or $y=-x+\frac{\pi}{2}+2$
b. At point $Q$, $y'=0$, we have $-csc^2x+2csc(x)cot(x)=0$ which gives $csc(x)=0$ (no solution) and $2cot(x)=csc(x)$ or $cos(x)=1/2$ which gives a solution as $x=\pi/3$, and we can get $y=4+cot(\pi/3)-2csc(\pi/3)=4+\frac{\sqrt 3}{3}-2(\frac{2\sqrt 3}{3})=4-\sqrt 3$.
Thus the tangent line equation is $y=4-\sqrt 3$