Is there any better way of finding the required value If $$z=\cos\theta+i\sin\theta$$ find the value of $$\frac{1+z}{1-z}$$

The solution that I have is this
$$z=\cos\theta+i\sin\theta \implies$$
$$\frac{1+z}{1-z}=\frac{1+(\cos\theta+i\sin\theta)}{1-(\cos\theta+i\sin\theta)}=\frac{(1+\cos\theta)+i\sin\theta}{(1-\cos\theta)+i\sin\theta}$$
$$=\frac{2\cos^2\frac{\theta}{2}+i\:\:2\sin\frac{\theta}{2}\cos\frac{\theta}{2}}{2\cos^2\frac{\theta}{2}-i\:\:2\sin\frac{\theta}{2}\cos\frac{\theta}{2}}=\frac{\cos\frac{\theta}{2}}{\sin\frac{\theta}{2}}\cdot \frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\sin\frac{\theta}{2}-i\cos\frac{\theta}{2}}$$
$$=\cot\frac{\theta}{2}\cdot\frac{\color{red}{i}}{\color{red}{i}}×\frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\sin\frac{\theta}{2}-i\cos\frac{\theta}{2}}$$
$$=\color{red}{i}\cot\frac{\theta}{2}\cdot\frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\color{red}{i}\sin\frac{\theta}{2}-\color{red}{i}i\cos\frac{\theta}{2}}$$
$$=\color{red}{i}\cot\frac{\theta}{2}\cdot\frac{\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}}{\cos\frac{\theta}{2}+\color{red}{i}\sin\frac{\theta}{2}}$$
$$=\color{red}{i}\cot\frac{\theta}{2}$$
Now how on earth one will imagine the steps written in red. I am looking for an easy and a logical answer to this question. The solution that I have is impractical as you all can see. I tried it doing by $e^{i\theta}$ but no good happen.
Any help is greatly appreciated.
 A: Rather than have to guess to use a special trick like multiplying by $\frac{i}{i}$, just multiply top and bottom by the conjugate of the denominator. This can be done in trig form, or exponential form, or just like this:
$$\frac{1+z}{1-z}\times\frac{1-\bar{z}}{1-\bar{z}}$$
$$=\frac{1+z-\bar{z}-z\bar{z}}{1-z-\bar{z}+z\bar{z}}$$
$$=\frac{1+2i\sin\theta-1}{1-2\cos\theta+1}$$
Now use the half-angles:
$$=\frac{4i\sin\frac{\theta}{2}\cos\frac{\theta}{2}}{4\sin^2\frac{\theta}{2}}$$
$$=i\cot\frac{\theta}{2}$$
A: Observe that $$\dfrac{\cos t+i\sin t}{\cos t-i\sin t}=\cos2t+i\sin2t$$
If $\dfrac z1=\cos2t+i\sin2t=\dfrac{\cos t+i\sin t}{\cos t-i\sin t}$
Using Componendo and Dividendo
$$\dfrac{1+z}{1-z}=\cdots=?$$
A: Observe that $\begin{cases}\cos(t)=\dfrac {e^{it}+e^{-it}}2\\ \sin(t)=\dfrac{e^{it}-e^{-it}}{2i}\end{cases}\quad$ leads to $\tan(t)=\dfrac 1i\cdot\dfrac{e^{it}-e^{-it}}{e^{it}+e^{-it}}$
Here you are given $z=e^{i\theta}$, therefore the expression $\dfrac{1+z}{1-z}=\dfrac{1+e^{i\theta}}{1-e^{i\theta}}$
Considering the formula for $\tan(t)$ given above, you want in fact to make the half angle appear by factoring $e^{i\theta/2}$.
$$\dfrac{e^{i\theta/2}\Big(e^{-i\theta/2}+e^{i\theta/2}\Big)}{e^{i\theta/2}\Big(e^{-i\theta/2}-e^{i\theta/2}\Big)}$$
I agree this is still some magical appearance of a quantity in the style $1=\frac xx$, but I think it is a bit more natural than the solve you presented.
See it as introducing the middle point between $0$ and $\theta$, i.e. between $1=e^{i0}$ and $e^{i\theta}$ in order to "homogenize" the expression.
A: I don't think the question is really accurate in the first place, the value of $\frac{1+z}{1-z}$ can just be determined by plugging in the expression for $z$. To bring it in the final form is a matter of taste, I believe it mostly comes from the experience and knowing which result you want to get. Multiplying by $1$ and adding $0$ are among the most common tricks, but I don't think there exists any universal method.
