Solution (source code)

= Solution

<Integration by parts> and the zero endpoint values turn the <Rayleigh quotient> into a positive <kinetic energy> integral:
$$
\begin{aligned}
\widetilde E&=\frac{\hbar^2}{2m}\int_0^a|\widetilde\psi'(x)|^2\,dx\\
&=\frac{\hbar^2}{2m}\frac{30}{a^5}\int_0^a(a-2x)^2\,dx
=\boxed{\frac{5\hbar^2}{ma^2}}.
\end{aligned}
$$
This is the <parabolic variational trial for a particle in a box>. The <potential energy> vanishes inside the box.