Linear Variational Method#
What you need to know
The variational method is a powerful method that can be used to determine upper bounds and approximations for ground state energies of numerous quantum mechanical problems.
The variational method is used heavily in electronic structure theories such as Hartree Fock.
The linear varaation method is seeking solutions to Schrodinger equation by expressing trial wavefunctions as linear combinations of easy to compute functions like gaussians or exponential.
The linear variational method converts Schrodinger equation into linear algebra problem of finding eigenvalues (energies) and eigenvectors (coefficients in linear combination)
Linearizing the pproblem#
How does this help us in practice? In a typical QM problem, we are attempting to solve for the wavefunction(s) and energy(ies) for a given Hamiltonian. If the Hamiltonian is such that solving the problem exactly is too challenging (e.g. any two or more electron problem) we can expand the wavefunction in a basis and attempt to solve the problem that way. We start with
Truncating this expansion at any finite \(n\) leads to an approximate solution. Also, what the variational principle tells us is that we can minimize the energy with respect to variational paramters \({c_n}\) and still have \(E_\phi \geq E_0\).
Smallest example#
We will illustrate this idea and the general matrix construction with a simple example of two basis functions (\(N=2\))
There is currently no need to define these functions explicitly so we will leave them as generic functions \(f_1\) and \(f_2\). We now solve for the energy
Let’s investigate the numerator and denomenator separately. We start with the numerator
We note that \(c_i\) are real and thus \(c_1^*c_1=c_1^2\) and \(c_1c_2=c_2c_1\) thus
Finally we recognize that since \(\hat{H}\) is Hermitian, we have \(\langle f_2|\hat{H}|f_1\rangle = \langle f_1|\hat{H}|f_2\rangle\) yielding
We will refer to the integrals above as matrix elements with, generically, \(H_{ij} = \langle f_i|\hat{H}|f_j\rangle\). We now consider the denominator of the energy equation above and we utilize similar algebra for the numerator to get
where \(S_{ij}\) is another matrix element but this time referred to as the basis function overlap.Now we have that the energy of the trial wavefunction is
Eigenvalue problem#
Since \(E_\phi \geq E_0\) for any function \(\phi\) we can minimize the energy, \(E_\phi\), with respect to variational paramters \(c_1\) and \(c_2\). We start by minimizing with respect to \(c_1\) which equates to differentiating the energy with respect to \(c_1\) and setting that derivative to zero
Similarly, minimizing with respect to \(c_2\) we get
We can rewrite the above two coupled linear equations as a matrix equation
We can rewrite the left most matrix as a difference of two matrices and then add to both sides:
or, written in more general matrix notation,
If we now left multiply both sides of the above equation by \(\mathbf{S}^{-1}\) we see that we have an eigenvalue-eigenvector problem
Thus the minimum energies are the eigenvalues of \(\mathbf{S}^{-1}\mathbf{H}\) and the variational parameters that minimize the energies are the eigenvectors of \(\mathbf{S}^{-1}\mathbf{H}\).
Example: Particle in a Box#
Let’s consider a free particle in 1D bounded to \(0\leq x\leq a\). The Hamiltonian for such a system is simply the kinetic energy operator
While we can (/have) solved this problem analytically, it will be instructive to see how the variational solution works. We start by approximating \(\psi(x)\) as an expansion in two basis functions
where the basis functions are \(f_1(x) = x(a-x)\) and \(f_2(x) = x^2(a-x)^2\) and \(c_1\) and \(c_2\) are the variational parameters (/linear coefficients of basis functions). In order to solve for the variational energies and wavefunctions given this expansion we must construct the Hamiltonian matrix, \(\mathbf{H}\), and the basis function overlap matrix, \(\mathbf{S}\). We will then compute and diagonlize the \(\mathbf{S}^{-1}\mathbf{H}\) matrix. Recall,
and
In this problem, we have two basis functions
and
Computing the matrix elements:#
where the last equality holds because the second derivative of \(x\) with respect to x is zero. Let’s now investigate each of these integrals
Similarly we should get
Thus
We can now complete the Hamiltonian matrix, \(\mathbf{H}\),
It can also be shown that \(\mathbf{S}\) is
Show code cell source
import numpy as np
from scipy.linalg import eig, inv, eigh
# Lets adopt simpler units
a = 1.0
hbar = 1.0
m = 1.0
S = np.array([[1.0/30.0, 1.0/140.0],[1.0/140.0,1.0/630.0]])
H = np.array([[1.0/6.0,1.0/30.0],[1.0/30.0,1.0/105.0]])
e, v = eig(inv(S) @ H) #e, v = eigh(H, S) #Same values eigh is for hermitian matrices
print("Eigenvalues:", e)
print("First eigenvector:", v[:,0])
Eigenvalues: [ 4.93487481+0.j 51.06512519+0.j]
First eigenvector: [-0.66168489 -0.74978204]
So we see that the smallest energy in this basis is
How does this compare to the analytic solution? We need to recall that for particle in a box we have:
Plugging in for the ground state, \(n=1\), and \(a=1\) since that is what we used numerically above we get
So we can see that our variational solution worked out well for the energy. Now how about the wavefunction?
Show code cell source
# plot wavefunction
import matplotlib.pyplot as plt
from scipy import integrate
%matplotlib inline
# x values
x = np.arange(0,1,0.01)
# exact wavefunction
psi1Exact = np.sqrt(2)*np.sin(np.pi*x)
plt.plot(x,psi1Exact,'k-',label="Exact",lw=3)
# variational basis function wavefunction
psi1Var = v[0,0]*x*(1-x) + v[1,0]*x**2*(1-x)**2
norm = np.sqrt(integrate.simps(np.power(psi1Var,2),x))
plt.plot(x,-psi1Var/norm,'r--', label="Variational")
plt.legend()
<matplotlib.legend.Legend at 0x7f9083657a90>