Solution (source code)

= Solution

For hard-wall confinement, the stationary spatial modes and energies are
$$
\boxed{\phi_n(x)=\sqrt{2/a}\sin(n\pi x/a),\qquad
E_n=\frac{n^2\pi^2\hbar^2}{2ma^2},\quad n=1,2,\ldots.}
$$
Their stationary time dependence is $e^{-iE_nt/\hbar}$. The correct triple-angle identity is $\sin3\theta=3\sin\theta-4\sin^3\theta$; the printed hint has its right side reversed in sign. Thus the specified initial state expands as
$$
\boxed{\psi=\frac3{\sqrt{10}}\phi_1-\frac1{\sqrt{10}}\phi_3.}
$$
The coefficients have squared moduli summing to one. The first requested energy is $E_1$, so its <probability> is $\boxed{9/10}$. The other requested energy is $2E_1$, which is not $n^2E_1$ for any positive <integer> $n$, so its <probability> is $\boxed{0}$. The occupied excited energy is instead $E_3=9E_1$, with <probability> $1/10$.