You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example of how to run the program with $K=10$, $N=17$ and $L=11$, where we use P=19 amount of points between $0$ and $L$ for the numerical integration:
K = 10 | N = 17 | L = 11.0
| State | Actual Energy | Approximate Energy | Error % |
|--------|---------------|--------------------|------------|
| n = 1 | 0.5 | 0.50000000 | 0.00000 |
| n = 2 | 1.5 | 1.50000000 | 0.00000 |
| n = 3 | 2.5 | 2.50000000 | 0.00000 |
| n = 4 | 3.5 | 3.50000071 | 0.00002 |
| n = 5 | 4.5 | 4.50000105 | 0.00002 |
| n = 6 | 5.5 | 5.50006228 | 0.00113 |
| n = 7 | 6.5 | 6.50007180 | 0.00110 |
| n = 8 | 7.5 | 7.50208028 | 0.02774 |
| n = 9 | 8.5 | 8.50218462 | 0.02570 |
| n = 10 | 9.5 | 9.52911177 | 0.30644 |
N vs. L plot
The additional program N_vs_L.py plots a graph showing good combinations of $N$ and $L$.
Example of how to run the program with $K=10$, where we check all combinations of $N \in [K, 50]$ and $L \in [1, 35]$ (with dL = 0.1 between all $L$ values) that gives all first $K$ energies with less than E = 1.0 % error. Higher values of $L$ generally requires higher integration precision, so we have here set P=200.
NOTE: GitHub does not have the best renderer for LaTeX. I recommend viewing this in VSCode's markdown previewer.
We assume we can express the wavefunction of the Harmonic Oscillator $\psi$ in a
basis spanned by the solutions $\phi_n$ to the TISE of the Infinite Square Well:
$$\psi(x) = \sum_n a_n \phi_n$$
We are essentially imagining that we are placing the Harmonic Oscillator potential in the middle of a Infinite Square Well potential.
We then multiply both sides by the complex conjugate of an arbitrary solution to the TISE of the Infinte Square Well (denoted by $\phi_m^*$ where $m \neq n$):
Since $\phi_n$ and $\phi_n$ are different solutions to the TISE of the Infinite Square Well, the we have that $\int_0^L\phi_m^*\phi_n dx = \delta_{m n}$, thus we have
$$\sum_n a_n \int_0^L\phi_m^*\mathrm{H}\phi_n dx = E a_m$$
The Hamiltonian operator kan be written as the sum of the kinetic energy operator $\mathrm{T}$ and the potential energy operator $\mathrm{V}$, thus:
$$\sum_n a_n \left(\int_0^L\phi_m^*\mathrm{T}\phi_n dx + \int_0^L\phi_m^*\mathrm{V}\phi_n dx\right) = E a_m$$
Now, let's solve the potential energy integral. Note that we assume that the Harmonic Oscillator potential is placed in the middle of the Infinite Square Well potential, this the potential energy operator becomes:
The index $m$ came from a arbitrary solution to the TISE of the Infinte Square Well. Now, there are literally infinite solutions to the TISE of the Infinte Square Well, so we actually have infinitely many such equations:
This can actually be express as a matrix equation! Let's define $\mathbf{T}$ as the matrix whose components are $T_{mn}$, and $\mathbf{V}$ as the matrix whose components are $V_{mn}$.
where $\mathbf{a}$ is a column vector whose components are $a_1$, $a_2$, $a_3$, ...
Important to note! The value $m$ thus represents the row number index in the matrix sum, and the number $n$ represents the column number in the matrix sum.
Kinetic energy matrix
The $\mathbf{T}$ matrix can actually be expressed more simply. Since its components are
$$T_{mn} = \frac{\pi^2}{2L^2}n^2 \delta_{m n}$$
we know that whenever $m \neq n$ it's zero. So, $\mathbf{T}$ has non-zero values only along its diagonal where $m = n$. Thus, we have
$$\mathbf{T} = \mathrm{diag}(\mathbf{t})$$
where $\mathbf{t}$ is vector whose $n$-th component is
What we can do, is to approximate the integral as a Riemann sum. The best basic Riemann sum is that which uses the "midpoint rule" (i.e. it uses the midpoint value in each sub interval).
Let $\Delta x$ be the width of each sub-interval from $0$ to $L$ used in the Riemann sum. We then define the column vector $\mathbf{x}$ whose $i$-th component is
$$x_i = (2i - 1)\frac{\Delta x}{2}$$
In other words, $\mathbf{x}$ contains all the midpoints of each sub-interval. Note that $\mathbf{x}$ is finite, and its last value is $L - \frac{\Delta x}{2}$.
Okay, that should be easy to implement in code with a nested for-loop, however, that would not utilize our computation power to its fullest. In the world of computation, matrices and vectors are the kings and queens when it comes to performance. So let's give the computer the food it loves!
The S matrix
If we had a matrix $\mathbf{S}$ whose elements were
where $\mathbf{t}$ is vector whose $n$-th component is
$$\frac{\pi^2}{2L^2}n^2$$
And
$$\mathbf{V} \approx \frac{1}{L} \cdot \mathbf{S}^\mathrm{T}\,\mathbf{S} \cdot \Delta x \\$$$$
where $\mathbf{S}$ is a matrix whose $in$-th component is
$$\sin\left(\frac{\pi}{L}nx_i\right)(x_i - L/2)$$
and $\Delta x$ is defined such that
$$\Delta x = x_{i+1} - x_{i} \quad \forall i$$
Finding eigenenergies
If we let the total energy matrix $\mathbf{H}$ be written as the sum of the kinetic energy matrix $\mathbf{T}$ and the potential energy matrix $\mathbf{V}$, we see that we still are looking at a eigenvalue equation
$$\mathbf{H} \mathbf{a} = E \mathbf{a}$$
Note that $\mathbf{H}$ is hermitian since $\mathbf{T}$ is a diagonal matrix, and $\mathbf{V}$ is symmetric.
Now, what is the size of $\mathbf{H}$? It is theoretically infinite in size, since its dimensions is equal to the amount of wave functions $\phi_n$ that solve the TISE for the Infinite Square well, which is, well, an infinite amount.
What we can do, is limit the values of $n$ to be in the interval $[1, N]$, where $N$ is some finite positive integer. Thus the size of $\mathbf{H}$ is $N \times N$, and the size of $\mathbf{a}$ is $N \times 1$.
So, we are looking at $N$ eigenvalues of $E$. If, for example, we had $N=2$, our eigenvalue matrix equation would be equal to the equations
and the approximated first energy would be $E_1$, and the approximated second energy would be $E_2$.
Thankfully, effective and performant functions for finding the eigenvalues of matrix eigenvalue equations are implemented in a lot of programming libraries, so we need not worry more about it here. In this code, the function eigenvalsh() form the Python module NumPy is used.
About
Using known eigenstates of Infinite Square Well to approximate eigenenergies of Harmonic Oscillator