If $z=\cos\theta+i\sin\theta$, where $\theta$ is real, show that $\frac{1}{1-z}= \frac{1}{2}\left(1 + i\cot(\theta/2)\right)$ 
Question.(source) If $z=\cos\theta+i\sin\theta$, where $\theta$ is real, show that
$$\frac{1}{1-z}= \frac{1}{2}\left( 1+ i\cot\frac{\theta}{2}\right)$$

I have been trying to rearrange the right-hand-side in order to make it look like the required form, but have been struggling to do so and want to see if anyone is able to show me what steps need to be taken to solve this question.
 A: Hint:
Rewrite the expression, using the exponential notation:
\begin{align}
\frac{1}{1-z}&= \frac{1}{1-\mathrm e^{i\theta}}= \frac{1-\mathrm e^{-i\theta}}{(1-\mathrm e^{i\theta})(1-\mathrm e^{-i\theta})}\\
&= \frac{1-\mathrm e^{-i\theta}}{(2-\mathrm e^{i\theta}-\mathrm e^{-i\theta})}
== \frac{1-\mathrm e^{-i\theta}}{2(1-\cos\theta)}\\
&=\frac{1-\cos\theta}{2(1-\cos\theta)}+i\,\frac{\sin\theta}{2(1-\cos\theta)}
\end{align}
continue with the duplication formulæ.
A: Here is a fun trick I learned when I saw this question for the first time.
$$\frac{1}{1-e^{i\theta}} = \frac{e^{-i\theta/2}}{e^{-i\theta/2} - e^{i\theta/2}} = \frac{\cos\tfrac12\theta - \sin\tfrac12\theta}{-2i\sin\tfrac12\theta} = \ldots$$
A: Note that $e^{i\theta}=\cos\theta+i\sin\theta$.
$$\frac{1}{1-e^{i\theta}}$$
$$=\frac{1}{2}\times \frac{-2}{e^{i\theta}-1}$$
$$=\frac{1}{2}\times \frac{e^{i\theta}-1-(e^{i\theta}+1)}{e^{i\theta}-1}$$
$$=\frac{1}{2}\times \left(1-\frac{e^{i\theta}+1}{e^{i\theta}-1}\right)$$
Note that $e^{i\theta}+1=e^{\frac{i\theta}{2}}\cdot 2\cos(\frac{\theta}{2})$ and $e^{i\theta}-1=e^{\frac{i\theta}{2}}\cdot 2i\sin (\frac{\theta}{2})$.
Plug in these results above,
$$\frac{1}{1-e^{i\theta}}=\frac{1}{2}\times \left(1-\frac{\cot(\frac{\theta}{2})}{i}\right)$$
$$=\frac{1}{2}\times \left(1-\frac{i\cot(\frac{\theta}{2})}{i^2}\right)$$
$$\fbox{$\huge{\dfrac{1}{1-e^{i\theta}}=\frac{1}{2}\times \left(1+i\cot\left(\frac{\theta}{2}\right)\right)}$}$$
I used some results above. See how I got it below.
$$e^{i\theta}+1=\cos \theta+i\sin \theta+1$$
$$=2\cos^2 \frac{\theta}{2}-1+2i\sin\frac{\theta}{2} \times \cos\frac{\theta}{2}+1$$
$$=2\cos\frac{\theta}{2}\cdot e^{\frac{i\theta}{2}}$$
The other result:
$$e^{i\theta}-1=\cos \theta+i\sin \theta-1$$
$$=1-2\sin^2 \frac{\theta}{2}+2i\cos\frac{\theta}{2}\cdot \sin\frac{\theta}{2}-1$$
$$=2i\sin\frac{\theta}{2}\left(\frac{-\sin\frac{\theta}{2}}{i}+\cos\frac{\theta}{2}\right)$$
$$=2i\sin\frac{\theta}{2}\cdot e^{\frac{i\theta}{2}}$$
