Solution (source code)

= Solution

Let $T$ be the <isometry>. Since $T(0)=0$, it preserves <norms>, and the <polarization identity> applied to distances gives $\langle T(x),T(y)\rangle=\langle x,y\rangle$. For an <orthonormal basis> $e_1,e_2,e_3$, the vectors $T(e_i)$ are again an <orthonormal basis>, and
$$
\langle T(x),T(e_i)\rangle=\langle x,e_i\rangle.
$$
Expanding in that <basis> proves $T(x)=\sum_i\langle x,e_i\rangle T(e_i)$. Hence $T$ is a <linear map> represented by an <orthogonal matrix> $Q$.

A <reflection in a hyperplane> with nonzero normal $v$ is $H_v(x)=x-2\langle x,v\rangle v/\langle v,v\rangle$. If $Qe_1\ne e_1$, choose $v=Qe_1-e_1$. Because $\|Qe_1\|=\|e_1\|$, substitution shows $H_vQe_1=e_1$. If they agree, no <reflection> is needed. The resulting <orthogonal transformation> fixes $e_1$ and preserves its <orthogonal complement>. Apply the same construction there to fix $e_2$; the second normal is perpendicular to $e_1$, so the first vector remains fixed. Finally the restriction to the remaining line is either the identity or negation; in the latter case a third <reflection>, normal to $e_3$, fixes it. Reversing these steps writes $Q$ as a product of at most three <reflections>, each in a plane through the origin. This proves the three-dimensional case of the <Cartan–Dieudonné theorem>.

\b[Three reflections are sometimes necessary.] The map $-I$ is the product of the three coordinate-plane <reflections>. Its <determinant> is $-1$, excluding zero or two <reflections>. A single plane <reflection> fixes a two-dimensional <vector subspace>, whereas $-I$ fixes only zero, excluding one. Thus the bound is sharp.