We give a lower bound for the energy of a quantum particle in the infinite square well. We show that the bound is exact and identify the well-known element that fulfils the equality. Our approach is not directly dependent on the Schrödinger equation and illustrates an example where the wavefunction is obtained directly by energy minimization. The derivation presented can serve as an example of a variational method in an undergraduate level university course in quantum mechanics.