Some weird results in complex number computing The question I met is to show that if $z=\cos (\theta)+i\sin(\theta)$ with $i=\sqrt{-1}$,then $ Re(\frac{z-1}{z+1})=0$
In the normal way, we found that: $$\frac{z-1}{z+1}=\frac{\cos(\theta)-1+i\sin(\theta)}{\cos(\theta)+1+i\sin(\theta)}\\
=\frac{\bigl(\cos(\theta)-1+i\sin(\theta)\bigl)\bigl(\cos(\theta)+1-i\sin(\theta)\bigl)}{\bigl(\cos(\theta)+1\bigl)^2+\sin^2(\theta)}\\
=\frac{\cos^2(\theta)+\cos(\theta)-\cos(\theta)-1+\sin^2(\theta)+2i\sin(\theta)}{\bigl(\cos(\theta)+1\bigl)^2+\sin^2(\theta)}\\
=\frac{2i\sin(\theta)}{\bigl(\cos(\theta)+1\bigl)^2+\sin^2(\theta)}$$
So $Re(\frac{z-1}{z+1})=0$
If we do it in another way:
$$
\frac{\cos(\theta)-1+i\sin(\theta)}{\cos(\theta)+1+i\sin(\theta)}=\frac{-2\sin^2(\frac{\theta}{2})+2i\cos(\frac{\theta}{2})\sin(\frac{\theta}{2})}{2cos^2(\frac{\theta}{2})+2i\sin(\frac{\theta}{2})\cos(\frac{\theta}{2})}\\
=-\tan(\frac{\theta}{2})\frac{\sin(\frac{\theta}{2})-i\cos(\frac{\theta}{2})}{\cos(\frac{\theta}{2})+i\sin(\frac{\theta}{2})}\\
=-\tan(\frac{\theta}{2})\frac{\cos\bigl(-(\frac{\theta}{2}+\frac{\pi}{2})\big)+i\sin\bigl(-(\frac{\theta}{2}+\frac{\pi}{2})\big)}{\cos(\frac{\theta}{2})+i\sin(\frac{\theta}{2})}\\
=-\tan(\frac{\theta}{2})\bigl(\cos(-\theta-\frac{\pi}{2})+i\sin(-\theta-\frac{\pi}{2})\bigl)
$$
So the real part of it will be $-\tan(\frac{\theta}{2})\cos(-\theta-\frac{\pi}{2})$ which is not $0$.
Which step I made mistake or they are equivalent?
 A: You should be more careful when applying transformations of sines into cosines.
It's much easier than that:
$$
\sin\frac{\theta}{2}-i\cos\frac{\theta}{2}=
i\left(\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}\right)
$$
You could write this in trigonometric form
$$
=\left(\cos\frac{\pi}{2}+i\sin\frac{\pi}{2}\right)
 \left(\cos\frac{\theta}{2}+i\sin\frac{\theta}{2}\right)
=\cos\left(\frac{\theta}{2}+\frac{\pi}{2}\right)+
 i\sin\left(\frac{\theta}{2}+\frac{\pi}{2}\right)
$$
and now you can go and chase for your mistake.
Another way to do the same: the conjugate of your number $w=\frac{z-1}{z+1}$ is
$$
\bar{w}=\frac{\bar{z}-1}{\bar{z}+1}
$$
but, since $|z|=1$, we have $\bar{z}=z^{-1}$; therefore
$$
\bar{w}=\frac{z^{-1}-1}{z^{-1}+1}=\frac{1-z}{1+z}=-w
$$
From $\bar{w}=-w$ it follows that $\operatorname{Re}(w)=0$.
If you want to find the imaginary part in term of $\theta$, you can consider $z=u^2$, where $u=\cos(\theta/2)+i\sin(\theta/2)$; then
$$
w=\frac{z-1}{z+1}=\frac{u^2-1}{u^2+1}=\frac{u-u^{-1}}{u+u^{-1}}
=\frac{u-\bar{u}}{u+\bar{u}}=
\frac{2i\sin(\theta/2)}{2\cos(\theta/2)}=i\tan\frac{\theta}{2}
$$
A: We have
$$
\sin\left(\frac\theta2\right) - i\cos\left(\frac\theta2\right) = -\sin\left(-\frac\theta2\right) - i\cos\left(\frac\theta2\right)\\
= -\cos\left(-\frac\theta2-\frac\pi2\right) - i\sin\left(\frac\theta2 + \frac\pi2\right)\\
= -\left(\cos\left(\frac\theta2 + \frac\pi2\right) + i\sin\left(\frac\theta2 + \frac\pi2\right)\right) 
$$
so you have a sign error in the numerator between line 2 and line 3 of your alternate approach.
