## Basis functions

The grid method is nice, since it is quite general: you could imagine taking just about any system, one-dimensional or not, and discretizing the space in a similar way. Indeed, some codes work by doing just this (called the finite-difference method). However, one unfortunate aspect is the tremendous number of points required to discretize the space. The bigger the system, the more points we need, and the more complicated our matrix diagonalization becomes. In some sense, discretizing space in this way is robust and general, but also a "dumb man's game", since it includes no information about the system under study.

However, if we do know something about the system, we might consider a different method: the use of basis functions. This means expressing the wave function in terms of some known functions, so that

\begin{align} \psi (x) = \sum _{i=1}^N c_i \phi _i (x) \end{align}Here, the \( c_i \) are the parameters to be solved, and the \( \phi \)s are the basis functions. If the functions \(\phi (x) \) can be chosen appropriately so that they model the solution \(\psi (x) \) well, it is intuitively obvious that this results in much smaller number of parameters to be solved than just discretizing the space would. (In the trivial case, if one of our basis functions happens to be the real solution, so that \(\psi = \phi _i \), we can just set \(c_i =1, c_{i\neq j}=0\) \)

Suppose we want to use the basis functions and we have a Hamiltonian in mind, and we want to solve the Schrödinger equation

\begin{align} \hat{H}\psi (x) = E \psi (x) \end{align}We now use our basis functions:

\begin{align} \hat{H}\sum _{i=1}^N c_i \phi _i (x) = E \sum _{i=1}^N c_i \phi_i(x) \label{schrdbas} \end{align}Now, since we have N parameters \(c_1 .. c_N \) to be solved, our Hamiltonian should be a NxN matrix. Say our Hamiltonian is \( \hat{H} = \frac{-1}{2}\frac{d^2}{dx^2} +V(x) \) - how do we find these components in terms of our new basis functions? After all, \(V(x) \) is defined on the real numbers, of which there are infinitely many in any given interval, and we already said we don't want to discretize the space for this purpose!

Let us recall to mind some elementary geometry. Suppose we have a point in a x-y plane, say, the vector (0.5, 0.5). In
Euclidean geometry, we typically use the *basis vectors* (1,0) and (0,1). How do we find the component
along the first basis vectors? Generally, by the dot product:

This is called a "projection": we get the length of our vector along the basis vector. Now, we may apply a similar notion to our quantum mechanics problem. In our case, the "basis vectors" are our basis functions, which are of course infinite-dimensional, as they are defined on the real numbers (so you need to specify their value on an infinite number of points!) Thus, our projection won't have a simple sum of components: rather, we use an integral. So by a projection of \(\psi \) along the basis vector \(\phi _i \), which we write as \(\langle \phi _i | \psi \rangle \), we mean:

\begin{align} \langle \phi _i | \psi \rangle = \int _{0}^L \phi _i (x) \psi (x) \mathrm{d}x \end{align}Great! What does this mean for our Schr\"{o}dinger equation? Well, let's suppose our basis functions are orthonormal so that \(\langle \phi _i | \phi _j \rangle = 0, i\neq j \). We must take the projections of \(\hat{H}\) along different vectors, by applying our projection to the Schrödinger equation \eqref{schrdbas}:

\begin{align} \int ^L_0\phi _j (x)\hat{H}\sum_{i=1}^N c_i\phi _i (x) \mathrm{d}x= E c_j \\ \int ^L_0\phi _j (x)\sum_{i=1}^N c_i\hat{H}\phi _i (x) \mathrm{d}x = E c_j\label{basisint}\\ \end{align}Now, on the left hand side we just have a matrix \(\hat{H}\) which contains one element for each combination \(\{ \phi _i (x),\phi _j(x) \}\). Hence, our problem has been transformed in to the form

\begin{align} \sum _{i=1}^N H_{ji}c_i = Ec_j \end{align}which is again an eigenvalue problem. So, to solve our Schrödinger equation, we need to first calculate the matrix elements in our chosen basis, and then find the eigenvectors and eigenvalues of that matrix --- which is just what we did with the discrete grid as well. The difference is that now the eigenvectors consist of the coefficients \(c_i\), and the solution can be computed by multiplying the coefficients with our basis functions, that is:

\begin{align} \psi (x) = \sum _i c_i \phi _i (x). \end{align}Why would we want to do this, rather than just using a grid? As I said before, you can get away with a much smaller matrix \(\hat{H}\) while not sacrificing any accuracy. For example, if you add one atom to a system, in a finite-difference code you might have to add tens of thousands of points, which would enormously increase the size of the matrix; by contrast, you might only have to add a couple of new basis functions per atom.

Also, with basis functions, often integrals of the type \eqref{basisint} can be calculated by hand ahead of time, so you don't even need to waste (that much) computational resources on them. We now redo the previous example of the Kronig-Penney model with basis functions.