"Spin measurement" cp = cos(theta/2) cm = sin(theta/2) exp(i phi) s = (cp,cm) xp = (1,1) / sqrt(2) xm = (1,-1) / sqrt(2) yp = (1,i) / sqrt(2) ym = (1,-i) / sqrt(2) zp = (1,0) zm = (0,1) check(mag(dot(conj(xp),s))^2 == 1/2 + 1/2 sin(theta) cos(phi)) check(mag(dot(conj(xm),s))^2 == 1/2 - 1/2 sin(theta) cos(phi)) check(mag(dot(conj(yp),s))^2 == 1/2 + 1/2 sin(theta) sin(phi)) check(mag(dot(conj(ym),s))^2 == 1/2 - 1/2 sin(theta) sin(phi)) check(mag(dot(conj(zp),s))^2 == 1/2 + 1/2 cos(theta)) check(mag(dot(conj(zm),s))^2 == 1/2 - 1/2 cos(theta)) "ok"
Run