Solution (source code)

= Solution

For normalized vector representatives in the same <Hilbert space>, two <pure states> are $\varepsilon$-close in <pure-state norm distance> when
$$
\boxed{\bigl\||\psi\rangle-|\phi\rangle\bigr\|_2\leq\varepsilon.}
$$
Here $\|\cdot\|_2$ is the <Euclidean norm> of the coefficient vector in any <orthonormal basis>. Equivalently, $2-2\operatorname{Re}\langle\psi|\phi\rangle\leq\varepsilon^2$. If the convention identifies vector representatives differing by a <global phase>, first minimize over that phase, giving $\min_\gamma\||\psi\rangle-e^{i\gamma}|\phi\rangle\|_2=\sqrt{2-2|\langle\psi|\phi\rangle|}$; the vector-norm convention above specifies the representatives.