0

Given the 2x2 density matrix of a qubit, how do I compute the point on the Bloch sphere that represents the qubit?

For example, the state |0⟩-|1⟩ has a density matrix of [[0.5,-0.5],[-0.5,0.5]] and should end up along the X axis. But the density matrix [[0.5, 0], [0, 0.5]] isn't biased in any direction and should end up at the origin.

npocmaka
  • 55,367
  • 18
  • 148
  • 187
Craig Gidney
  • 17,763
  • 5
  • 68
  • 136

1 Answers1

1

The conversion depends on a couple arbitrary choices:

  • Do you want |0⟩ at the top or the bottom?
  • Do you want the coordinate system to be right-handed or left-handed?

Assuming you answer those with "at the bottom" and "right-handed", then this method will do it:

def toBloch(matrix):
    [[a, b], [c, d]] = matrix
    x = complex(c + b).real
    y = complex(c - b).imag
    z = complex(d - a).real
    return x, y, z

You switch to other choices by picking and choosing which outputs to negate.

Testing it out:

print(toBloch([[1, 0],
               [0, 0]])) #Off, Z=-1
# (0.0, 0.0, -1.0)

print(toBloch([[0, 0],
               [0, 1]])) #On, Z=+1
# (0.0, 0.0, 1.0)

print(toBloch([[0.5, 0.5],
               [0.5, 0.5]])) #On+Off, X=-1
# (-1.0, 0.0, 0.0)

print(toBloch([[0.5, 0.5j],
               [-0.5j, 0.5]])) #On+iOff, Y=-1
# (0.0, -1.0, 0.0)

print(toBloch([[0.5, 0.0],
               [0.0, 0.5]])) #maximally mixed state, X=Y=Z=0
# (0.0, 0.0, 0.0)
Craig Gidney
  • 17,763
  • 5
  • 68
  • 136