In the Stern–Gerlach experiment, an unpolarized beam of neutral particles of spin 1/2 is directed through an inhomogeneous magnetic field (blue and red magnet), which produces separated beams of spin-up and spin-down particles. For simplicity, only the outgoing spin-up beam is shown in the graphic. This beam is then directed through a second magnet, for which the polarization can be rotated by an angle from the original. This further splits the beam (except when or ) into spin-up and spin-down beams with respect to the new polarization direction. Again, only the spin-up component is shown. The probability for a particle to emerge with spin-up (↑) or spin-down (↓) is given by and , respectively. The resulting probabilities of ↑ and ↓ are shown for five selected angles.
The results of the Stern–Gerlach experiment can be simulated by a quantum computer. The qubits and correspond to the spin states ↑ and ↓, respectively. The initial state corresponds to the polarized beam leaving the first magnet. By an appropriate sequence of quantum gates, the results of the beam passing through the second magnet, with polarization angle , can be simulated. The statistical results are verified after a large number of runs on the quantum computer.