Solution (source code)

= Solution

Take the <dot product> of the <orthogonal basis> expansion with $\mathbf u_j$. All terms except the $j$th vanish by <orthogonality>, leaving
$$
\mathbf u_j\cdot\mathbf x=\alpha_j\,\mathbf u_j\cdot\mathbf u_j.
$$
Therefore
$$
\boxed{\alpha_i=\frac{\mathbf u_i\cdot\mathbf x}{\mathbf u_i\cdot\mathbf u_i}}.
$$
The <basis> is not assumed normalized, so its squared lengths must remain in the denominators. Applying $S$ and using $S\mathbf u_i=\lambda_i\mathbf u_i$ gives
$$
S\mathbf x=\sum_i\lambda_i\alpha_i\mathbf u_i,
\qquad
\boxed{\beta_i=\lambda_i\frac{\mathbf u_i\cdot\mathbf x}{\mathbf u_i\cdot\mathbf u_i}}.
$$