# Finding the polar and azimuthal angles of the Bloch vector corresponding to $\frac1{\sqrt2}(1-i)|0\rangle-\frac i{\sqrt2}|1\rangle$ [duplicate]

I need to find the polar angles and azimuthal angles of the following bloch vector:

$$\frac{1-i}{2}|0\rangle - \frac{i}{\sqrt{2}}|1\rangle$$

I just couldn't figure it out, and I could also not find out how I could factor out the global phase, can anyone here please help?

I got to the point where I knew that $$\cos(\frac{\theta}{2}) = \frac{1-i}{2}$$ and $$\sin (\frac{\theta}{2}) e^{i\phi} = -\frac{i}{\sqrt{2}}$$, I'm guessing I have to factor out some global phase here and ignore it in order to solve the equations, but I couldn't figure it out. I've tried looking elsewhere for methods on how to solve this, but could not find it.

Start by writing your amplitudes in polar form $$\frac{1}{\sqrt{2}}e^{-i\pi/4}|0\rangle+\frac{1}{\sqrt{2}}e^{-i\pi/2}|1\rangle.$$ This makes it easy to pull out the global phase, as you suggest. What should you pick? The one that makes the amplitude in front of $$|0\rangle$$ real. In other words, $$e^{-i\pi/4}\left(\frac{1}{\sqrt{2}}|0\rangle+\frac{e^{-i\pi/4}}{\sqrt{2}}|1\rangle\right).$$ Now you can set $$\cos\frac{\theta}{2}=\frac{1}{\sqrt{2}}$$ and $$\sin\frac{\theta}{2}e^{i\phi}=\frac{1}{\sqrt{2}}e^{-i\pi/4}.$$ In other words, $$\theta=\pi/2$$ and $$\phi=-\pi/4$$.

Let's assume you were able to compute the $$x, y, z$$ coordinates of the state on the Bloch sphere (where $$r = 1$$), then there is the standard conversion of cartesian coordinates $$(x, y, z)$$ to spherical coordinates $$(r, \theta, \phi)$$: $$\cos \theta = \frac{z}{r}$$ $$\cos \phi = \frac{x}{\sqrt{x^2 + y^2}}$$

To compute the cartesian coordinates $$x, y, z$$ for a state $$\psi$$ you first make a density matrix by computing the outer product of the state with itself: $$\rho = |\psi\rangle\langle\psi|$$ and then compute something equivalent to this code:

def density_to_cartesian(rho: np.ndarray) -> Tuple[float, float, float]:
"""Compute Bloch sphere coordinates from 2x2 density matrix."""

a = rho[0, 0]
b = rho[1, 0]
x = 2.0 * b.real
y = 2.0 * b.imag
z = 2.0 * a - 1.0