# Can I Convert a Qubit in complex form to polar form?

Let's say I have a qubit
$$\left| \psi \right> = (\alpha_1 + i\alpha_2 ) \left|0\right> + (\beta_1 + i\beta_2 )\left|1\right>$$

Can I able convert this to polar form $$|\psi \rangle = \cos\big(\frac{\theta}{2}\big) |0\rangle + e^{i\varphi} \sin\big(\frac{\theta}{2}\big) |1\rangle$$

and is it possible to convert back the polar form to complex form?

In polar form we have, $$\alpha_1 + i\alpha_2 = r_1e^{i\phi_1}$$, and $$\beta_1 + i\beta_2 = r_2e^{i\phi_2}$$

So,

$$|\psi\rangle = r_1e^{i\phi_1} |0\rangle + r_2e^{i\phi_2} |1\rangle = e^{i\phi_1}(r_1 |0\rangle + r_2e^{i(\phi_2 - \phi_1)} |1\rangle)$$

Lets, $$\varphi = \phi_2 - \phi_1$$ then,

$$|\psi\rangle = e^{i\phi_1}(r_1 |0\rangle + r_2e^{i\varphi} |1\rangle)$$

Assuming that $$|\psi\rangle$$ is a normalized quantum state (that is, $$r_1^2 + r_2^2 = 1$$) we can find an angle $$\theta$$ such that $$\cos(\frac{\theta}{2}) = r_1$$ and $$\sin(\frac{\theta}{2}) = r_2$$. That means,

$$|\psi\rangle = e^{i\phi_1}(\cos{\small(\theta/2)} |0\rangle + e^{i\varphi} \sin{\small(\theta/2)} |1\rangle)$$

And $$\phi_1$$ is a global phase.

This code snippet calculates $$\theta$$ and $$\varphi$$ given two complex numbers $$z_1=\alpha_1 + i\alpha_2$$ and $$z_2=\beta_1 + i\beta_2$$

import math, cmath

r1, phi1 = cmath.polar(z1)
r2, phi2 = cmath.polar(z2)

theta = 2 * math.acos(r1)
phi = phi2 - phi1

print('θ =', theta)
print('φ =', phi)


Yes, if you can accept that states are equivalent up to a global phase. The second equation assumes that the $$|0\rangle$$ coefficient is real. We can fix the first equation by adding a global phase so that the $$|0\rangle$$ coefficient is also real.

If you can make the assumption that the coefficient $$(\alpha_1 + i\alpha_2)$$ is a real number, i.e. $$\alpha_2 = 0$$, then there will always be a solution for $$\theta$$ and $$\varphi$$

• So if say that I cant make $\alpha_2 = 0$, it has to be complex then the conversion is not possible? Can I use any normal technique to convert the existing complex form of amplitudes into polar form and use those as $\theta and \gamma$ Commented May 16, 2022 at 18:30
• The point is you always can, because states are equivalent up to a global phase change. If for some reason you don't want this, then its not possible, since $\cos(x)$ is always real, and $(\alpha_1 + i\alpha_2)$ is not. Commented May 16, 2022 at 18:42