Solution (source code)

= Solution

The <Born rule> gives the probability of $E_n$ as the squared coefficient of the initial state in the <energy eigenstate> basis. Direct integration gives
$$
c_n=\int_0^{a/2}\sqrt{\frac2a}\,\psi_n(x)\,dx
=\frac2{n\pi}\left(1-\cos\frac{n\pi}2\right).
$$
The strict energy cutoff corresponds to $n^2<5$, so only $n=1,2$ contribute. Both coefficients equal $2/\pi$, and therefore
$$
\boxed{\mathbb P\!\left(E<\frac{5\hbar^2\pi^2}{2ma^2}\right)=\frac8{\pi^2}.}
$$
The discontinuous initial <wavefunction> is a legitimate normalized $L^2$ state for this spectral probability calculation, although it is not in the Hamiltonian's differentiability domain; finite mean energy is not required to compute this probability.