## Variational Integral

$$ \frac{\int \phi^{*}\hat{H}\phi d \tau}{\int \phi^{*}\phi d \tau} \geqslant E_1 $$

This page follows Levine's text *Quantum Chemistry, 7th Ed*, Section 8.1, page 199. On that page, the author describes how to use a trial wavefunction to solve for an approximate energy for a 1-dimensional particle in a box. In this post, I implement the solution using SymPy to evaluate the approximate energy level.

## Our system: A one-dimensional particle in a box

### Exact solution

The exact wavefunction and energy levels for the 1-dimensional particle in a box are:

$$ \psi_{n}(x) = \sqrt{\frac{2}{l}} \sin\Bigl(\frac{n \pi x}{l}\Bigr) $$

$$ E_n = \frac{n^2 h^2}{8 m l^2} $$

$$ n = 1, 2, 3, \dots $$

$$ 0 \leqslant x \leqslant l $$

Where \\(E_n\\) is entirely kinetic and incorporates no potential energy. At the ground state of \\(n = 1\\), the energy is:

$$ E_1 = \frac{h^2}{8 m l^2} $$

### Exact Hamiltonian

The Hamiltonian for the 1-dimensional particle in a box is:

$$ \hat{H} = -\frac{\hbar^2}{2 m} \frac{d^2}{dx^2} $$

### Trial Variation Function

$$ \phi = x(l - x) $$

Where \\(\phi\\) is not normalized.

### Note about SymPy notation

In its notation SymPy is going to denote \\(\hbar\\) by \\(h_{bar}\\)

## Evaluate the variational integral

### Denominator of the variational integral

Because our trial is real variation function \\(x(l - x)\\), the denominator of our variational integral is:

$$ \int \phi^{*} \phi d \tau = \int_{0}^{l} [x(l - x)]^2 dx $$

As evaluated with SymPy:


```python
from sympy import Symbol, symbols, oo, diff, Function, integrate
x, l, h_bar, m = symbols('x l h_bar m')
denominator = integrate((x*(l-x))**2, (x, 0, l))
denominator
```




$\displaystyle \frac{l^{5}}{30}$



### Numerator of the variational integral

The numerator is more complicated because of the Hamiltonian operator \\(\hat{H}\\):

$$ \int \phi^{*}\hat{H}\phi d \tau = -\frac{\hbar^2}{2 m} \int_{0}^{l} x(l-x) \Biggl[\frac{d^2}{dx^2} x (l-x)\Biggr] dx $$

As evaluated with SymPy:


```python
numerator = (-h_bar**2 / (2*m)) * integrate((x*(l - x)) * diff(x*(l - x), x, 2), (x, 0, l))
numerator
```




$\displaystyle \frac{h_{bar}^{2} l^{3}}{6 m}$



### Putting it all together and simplifying

$$ \frac{\int \phi^{*}\hat{H}\phi d \tau}{\int \phi^{*}\phi d \tau} = \frac{-\frac{\hbar^2}{2 m} \int_{0}^{l} x(l-x) \bigl[\frac{d^2}{dx^2} x (l-x)\bigr] dx}{\int_{0}^{l} [x(l - x)]^2 dx} = \frac{\hbar^2 l^3 / 6 m}{l^5 / 30} = \frac{5 \hbar^2}{l^2 m} $$

As evaluated with SymPy:


```python
numerator / denominator
```




$\displaystyle \frac{5 h_{bar}^{2}}{l^{2} m}$



## Comparing variational energy with exact energy

### Variational energy

Recalling that \\(\hbar = h / 2 \pi\\), and with some refactoring, we can rewrite the expression as:

$$ \frac{5 \hbar^2}{l^2 m} = \frac{5}{4 \pi^2} \frac{h^2}{m l^2} = 0.127 \frac{h^2}{m l^2} $$

### Exact energy

$$ \frac{h^2}{8 m l^2} = \frac{1}{8} \frac{h^2}{m l^2} = 0.125 \frac{h^2}{m l^2} $$


```python

```

4626b597bee3aa5d270afa9020f8181bba6ae5c7
ipynb
Jupyter Notebook
notebooks/variational-1d-pib-v2.ipynb
akey7/basic-quantum-models
b2f7edd2fdd15b6f85ee3708f8c2dae24686fd07
BSD-2-Clause
notebooks/variational-1d-pib-v2.ipynb
akey7/basic-quantum-models
b2f7edd2fdd15b6f85ee3708f8c2dae24686fd07
BSD-2-Clause
2021-07-12T15:49:00.000Z
2021-07-12T15:54:55.000Z
notebooks/variational-1d-pib-v2.ipynb
akey7/basic-quantum-models
b2f7edd2fdd15b6f85ee3708f8c2dae24686fd07
BSD-2-Clause
Qwen/Qwen-72B
1. YES
2. YES