# How to get Bloch sphere Cartesian coordinates from density matrix

I am vexed by a particular derivation. Given a state $$\psi$$ and corresponding density matrix $$\rho = |\psi\rangle \langle \psi|$$, or $$\rho = \begin{bmatrix} a & c \\ b & d \end{bmatrix}$$, I can compute the Bloch sphere coordinates as the following (in Python):

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


This code works, but - how? I fail to properly derive it. Any hints or pointers are appreciated.

• First, decompose the density matrix $\rho$ into the form $\rho = \dfrac{I + \vec{r} \cdot \vec{\sigma} }{2}$ where $I$ is the 2 by 2 idenity matrix and $\vec{\sigma} = \langle X, Y, Z \rangle$ where $X,Y,Z$ are Pauli matrices. The vector $\vec{r}$ is the coordinate you are looking for. – KAJ226 Apr 21 at 6:50
• see also quantumcomputing.stackexchange.com/a/4121/55. In the density matrix formalism, you just need to change $\langle\psi|\sigma_i|\psi\rangle$ into $\mathrm{Tr}(\rho \sigma_i)$ for $i=x,y,z$ – glS Apr 21 at 10:35

The point $$(x, y, z)\in\mathbb{R}^3$$ corresponds to the state
$$\rho = \frac{I + xX + yY + zZ}2 = \frac12\begin{bmatrix} 1+z & x-iy \\ x+iy & 1-z \end{bmatrix},$$
see also definition in Wikipedia. Therefore, if $$\rho = \begin{bmatrix}a & c \\ b & d\end{bmatrix}$$, then
$$2a = 1 + z \\ 2b = x + i y$$
$$x = 2\,\mathrm{Re}(b) \\ y = 2\,\mathrm{Im}(b) \\ z = 2a - 1.$$