Visualizing Qubits on the Bloch Sphere Surface

In Section 2.1.2 of the text we introduced the Bloch sphere representation of a qubit. In it, a qubit |ψ⟩ is represented by a matrix that is parameterized by the quantities 0 ≤ θ ≤ π,  0 ≤ ϕ ≤ 2π, so that


|ψ⟩ = (({{cos[θ/2]}, {((e )^(I ϕ))sin[θ/2]}}))

(up to an overall complex phase)

On the Bloch sphere surface, shown below, each point on the surface (except for the poles)  is characterized by a unique value of θϕ. Therefore, we can represent the ket  |ψ ⟩  by a vector ( the red arrow shown in the figure below). In the visualization, you can adjust the levers to the desired values for θ,ϕ in order to graph the corresponding ket. In the figure the numerical value (up to an overall complex phase) is shown.

ClearAll["Global`*"]
ket[θ_,ϕ_]:=Format[(({{Chop[Cos[θ/2]]}, {Exp[I ϕ]Sin[θ/2]}})),TraditionalForm]
vector[θ_,ϕ_]:=Arrow[Tube[{{0,0,0},{Cos[ϕ]Sin[θ],Sin[θ]Sin[ϕ],Cos[θ]}},0.025]]

bloch[θ_,ϕ_]:=Show[Graphics3D[{Specularity[White,100],Lighting->{{"Point",Cyan,{1,0,1}}},Opacity[0.2],Sphere[{0,0,0}]}],Graphics3D[{Red,vector[θ,ϕ],Inset[ket[θ,ϕ],{0,0,-0.5}]}],Boxed->False,ViewPoint->{Infinity,0,0}]

Manipulate[bloch[θ,ϕ],{θ,0,Pi},{ϕ,0,2Pi},SaveDefinitions->True]