The variational principle and the quantum mechanical particle-in-a-box

Question P8.4.4

Consider a one-dimensional quantum mechanical particle in a box ($-1\le x \le 1$) described by the Schrödinger equation: $$ -\frac{\mathrm{d}^2\psi}{\mathrm{d}x^2} = E\psi, $$ in energy units for which $\hbar^2/(2m) = 1$ with $m$ the mass of the particle. The exact solution for the ground state of this system is given by $$ \psi = \cos\left(\frac{\pi x}{2}\right), \quad E = \frac{\pi^2}{4}. $$ An approximate solution may be arrived at using the variational principle by minimizing the expectation value of the energy of a trial wavefunction, $$ \psi_\mathrm{trial} = \sum_{n=0}^N a_n\phi_n(x) $$ with respect to the coefficients $a_n$. Taking the basis functions to have the following symmetrized polynomial form, $$ \phi_n = (1-x)^{N-n+1}(x+1)^{n+1}, $$ use scipy.optimize.minimize and scipy.integrate.quad to find the optimum value of the expectation value (Rayleigh-Ritz ratio): $$ \mathcal{E} = \frac{\langle \psi_\mathrm{trial} | \hat{H} | \psi_\mathrm{trial} \rangle}{\langle \psi_\mathrm{trial} | \psi_\mathrm{trial} \rangle} = -\frac{\int_{-1}^1\psi_\mathrm{trial}\frac{\mathrm{d}^2}{\mathrm{d}x^2}\psi_\mathrm{trial}\;\mathrm{d}x}{\int_{-1}^1\psi_\mathrm{trial}\psi_\mathrm{trial}\;\mathrm{d}x}. $$ Compare the estimated energy, $\mathcal{E}$, with the exact answer for $N=1,2,3,4$.

[Hint: Use np.polynomial.Polynomial objects to represent the basis and trial wavefunctions].


To access solutions, please obtain an access code from Cambridge University Press at the Lecturer Resources page for my book (registration required) and then sign up to providing this code.