# Numerically solving the Schrodinger Equation

This python notebook will show a simple method to find solutions to the Schrodinger equation using what is called the shooting method. Recall that the Schrodinger equation can be written as:

$$ -\frac{\hbar^2}{2 m} \frac{\partial^2 \psi}{\partial x^2} +(V(x)- E) \psi =0 $$

where $V(x)$ is the potential and both the energy $E$ and the wavefunction $\psi$ are unknown.
The fact that we do not know the eigenvalue $E$ means that we have to use trial and error to guess a value for $E$ and the numerically solve Schrodinger's equation to find $\psi(x)$. We will know if our solution is correct if the wavefunction approaches 0 for large $x$.

To proceed we first change our units so that $\hbar= m=1$ and then add in a new variable $\phi$ which represents the derivative of $\psi$ to give us the set of first order differential equations:

$$ \begin{align}
    \frac{d \psi}{d x} &= \phi(x) \\
    \frac{d \phi}{d x} &= 2(V(x)-E) \psi(x)
    \end{align} $$

Recall that we did the same trick in the Cyclotron Motion notebook to convert the 2nd order differential equations into a set of first order differential equations. This means that we can use the inbuilt functions such as 'odeint' to automatically solve the equations for us.

So first as usual we import the required libraries


```python
from modules.schrodinger import splitdf

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.integrate import odeint
import pandas as pd
```

Next we define the range over which we want to find the solutions. For the example below this is taken to be between $-20< x <20$ and we split it up into 2000 points.


```python
start_position = -20.0
end_position   =  20   # set this to be the correct end point.
space_steps    =  2000
step           =  (end_position-start_position)/(space_steps-1)
space          =  np.linspace(start_position, end_position, space_steps)
```

Next we define our potential function. This can be an arbitrary function but here I have taken it to be a square well with a negative depth and lying symmetrically about $x=0$.


```python
def potential(x, depth, width):  # square well potential
    pot = 0.0
    if abs(x) <= width/2:
        pot = depth
    else:
        pot = 0.0
    return pot
```

Lets plot the potential so that we know what it looks like.


```python
potfun = np.zeros(space_steps)
for ii in range(0, space_steps):
    potfun[ii] = potential(space[ii], -4, 30)

plt.figure()
plt.plot(space, potfun, linewidth=3, label='potential')
plt.legend()
plt.show()
```

Now we define the derivatives functions for the equations above. These are the equations that we want to solve.


```python
def shoot(yin, position, depth, width, energy):
    return np.array([yin[1], 2.0 * (potential(position, depth, width) - energy) * yin[0]])
```

Now we still don't know the initial values for $\psi(-20)$ and $\phi(-20)$ since we don't know the energy eigenvalue. However the Schrodinger equation is linear which means that we are free to set $\psi(-20)=1$ since if $\psi(x)$ is a solution so is $\alpha \psi(x)$ for any complex number $\alpha$. We also know that $\psi(x)$ decays exponentially if the energy is less than the potential and that the rate of decay is given by $V(x)-E$. Thus we can approximate the derivative of $psi(x)$ (i.e. $\phi(x)$) as $\phi(x) \approx (V(x)-E) \psi(x)$.

We then guess an energy level $E_g$ which means that the initially
$\phi(-20)=(V(-20)-E_g)$. Since for the square well potential $V(-20)=0$ this just becomes $\phi(-20)=-E_g$.

The Shooting method thus involves guessing an initial value of the energy and integrating the equations to see if it that value is correct. To see this in action let us use a potential well with a depth of -5 and a width of 30. This ensures that there are plenty of solutions to the Schrodinger equation. Our first guess will be that E=-4.9896. 


```python
energy_guess = -3.999  # this is our initial guess.
start        = np.array([1.0, -np.sqrt(-energy_guess)])

xout     = odeint(shoot, start, space, args=(-4.0, 30, energy_guess))
xt       = np.transpose(xout)
psi      = xt[0]
psiprime = xt[1]

# Create the matplotlib figure and plot functions
plt.figure()
plt.plot(space, psi,      linewidth = 3, label = 'wavefunction')
plt.plot(space, psiprime, linewidth = 3, label = 'derivative')
plt.legend()
plt.show()
```

Notice that the solution is clearly wrong since it heads towards $\infty$ for large $x$. So
we can amend our guess of the energy for something larger and try again.


```python
energy_guess = -3.99 # this is our second guess.
start        = np.array([1.0,-np.sqrt(-energy_guess)])

xout     = odeint(shoot, start, space, args=(-4.0, 30, energy_guess))
xt       = np.transpose(xout)
psi      = xt[0]
psiprime = xt[1]

# Create the matplotlib figure and plot functions
plt.figure()
plt.plot(space, psi,      linewidth = 3, label = 'wavefunction')
plt.plot(space, psiprime, linewidth = 3, label = 'derivative')
plt.legend()
plt.show()
```

Now the solution is still wrong but it heads towards $-\infty$ for large $x$. We can thus say that the correct value for the energy must lie between our two solutions and all we have to do is find it. Trial and error leads to the solution below.


```python
energy_guess = -3.9947665559297138316  # this is ground state
start        =  np.array([1.0, np.sqrt(-energy_guess)])

xout     = odeint(shoot, start, space, args=(-4.0, 30, energy_guess))
xt       = np.transpose(xout)
psi      = xt[0]
psiprime = xt[1]

# Create the matplotlib figure and plot functions
plt.figure()
plt.plot(space, psi,      linewidth = 3, label = 'wavefunction')
plt.plot(space, psiprime, linewidth = 3, label = 'derivative')
plt.legend()
plt.show()
```

Note that as expected the ground state wavefunction has a single maximum and goes to zero as the distance from the well increases. It is clear however that the wavefunction is not normalised i.e. the integral of $|\psi(x)|^2 \neq 1$. However since this is just a number we can easily calculate the integral of the solution above and divide through by that to normalise everything.





```python
def normalise(y, step):  # a quick and dirty integrator that is good enough.
    out = 0.0
    for ii in range(0, len(y)):
        out = out + y[ii] ** 2
    return np.sqrt(out * step)
```


```python
result   = normalise(psi, step)

psi      = psi / result
psiprime = psiprime / result

# Create the matplotlib figure and plot functions
plt.figure()
plt.plot(space, psi,      linewidth = 3, label = 'wavefunction')
plt.plot(space, psiprime, linewidth = 3, label = 'derivative')
# Show the potential well as well
plt.plot(space, potfun/8+0.5, linewidth = 1, label = 'scaled potential') 
plt.legend()
plt.show()
```

A bit more trial and error leads to the next guess for the energy of the first higher order state.


```python
energy_guess = -3.9790668560912517  # this is first higher order state
start        =  np.array([1.0, np.sqrt(-energy_guess)])

xout     = odeint(shoot, start, space, args=(-4.0, 30, energy_guess))
xt       = np.transpose(xout)
psi      = xt[0]
psiprime = xt[1]
result   = normalise(psi, step)

psi      = psi / result
psiprime = psiprime / result

# Create the matplotlib figure and plot functions
plt.figure(figsize = [5,5])
plt.plot(space, psi,      linewidth = 3, label = 'wavefunction')
plt.plot(space, psiprime, linewidth = 3, label = 'derivative')
# Show the potential well as well
plt.plot(space, potfun/8+0.5, linewidth = 1, label = 'scaled potential') 
plt.legend()
plt.show()
```

It very quickly gets complicated to continually bisect the interval to find new
solutions. However it is fairly easy to write a program that does that for us. There are lots of different ways of doing so since it is the same as finding the zero of a function but this is perhaps the simplest. We start with two values $E_1$ and $E_2$ which have the property that
the solution to the equation goes to $\pm \infty$ for the two values and then we look at the
sign of the solution at the midpoint.

If the sign of the solution at the midpoint is the same value as $E_1$ we replace $E_1$ by
$(E_1+E_2)/2$ and start again. Otherwise we replace $E_2$ by the midpoint and start again. 
Each time we do this the size of the interval decreases by a factor of 2 so we can continue doing it for as long as we like. In practice we stop when we run out of numerical precision.



```python
def find(start,stop): 
    """Finds where our system of equations are satisfied by a wavefunction
        with an energy between start and stop through the bisection method.
    
    Make sure that the solution goes in different directions for the two values of start and stop.
    
    Parameters:
    -----------
        start : float64
            A lower bound for energy.
        stop  : float64
            An upper bound for energy.
            
    Prints:
    -----------
        output : pandas dataframe
            This stores the values of out1, out2 and out3 as the code iterates,
            The pandas dataframe allows for aesthetic printing of values.
            
    Returns:
    -----------
        guess : float64
            A guess as to what value the function shoot will return zero.
            This will be between the values of "start" and "stop".
    """
    # out1 is the final value of our trial solution for the guess Energy = start
    # the element [-1][0] picks the last element in the array.
    # out2 is the final value of our trial solution for the guess Energy = stop.
    # guess is the midpoint of the interval.
    # out3 is the final value of the trial solution for the guess Energy = guess.
    
    
    
    def step(start, stop, output, count):
        """Runs for each step of this method"""
        out1  = odeint(shoot, np.array([1.0, np.sqrt(-start)]), space, args = (-4.0, 30, start))[-1][0]
        out2  = odeint(shoot, np.array([1.0, np.sqrt(-stop)]),  space, args = (-4.0, 30, stop ))[-1][0]
        guess = (stop + start) / 2.0
        out3  = odeint(shoot, np.array([1.0, np.sqrt(-guess)]), space, args = (-4.0, 30, guess))[-1][0]
        
        output.iloc[count] = [out1, out2, out3, start, stop, guess]
        
        # Assigning the new start and stop values
        if np.sign(out1) == np.sign(out3):
            start = guess
        else:
            stop  = guess
        
        return start, stop, output
    
    
    
    output = pd.DataFrame(columns = ['out1','out2','out3', 'start', 'stop', 'guess'], index = range(50))
    
    for count in range(50):
        start, stop, output = step(start, stop, output, count)
    
    return output
```

Let us see it in action


```python
splitdf(find(-3.95, -3.979), n=2)
```


<table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>-1.74497e+12</td>
      <td>1.05633e+11</td>
      <td>7.29901e+12</td>
      <td>-3.95</td>
      <td>-3.979</td>
      <td>-3.9645</td>
    </tr>
    <tr>
      <th>1</th>
      <td>-1.74497e+12</td>
      <td>7.29901e+12</td>
      <td>2.95391e+12</td>
      <td>-3.95</td>
      <td>-3.9645</td>
      <td>-3.95725</td>
    </tr>
    <tr>
      <th>2</th>
      <td>-1.74497e+12</td>
      <td>2.95391e+12</td>
      <td>4.71129e+11</td>
      <td>-3.95</td>
      <td>-3.95725</td>
      <td>-3.95363</td>
    </tr>
    <tr>
      <th>3</th>
      <td>-1.74497e+12</td>
      <td>4.71129e+11</td>
      <td>-6.86147e+11</td>
      <td>-3.95</td>
      <td>-3.95363</td>
      <td>-3.95181</td>
    </tr>
    <tr>
      <th>4</th>
      <td>-6.86147e+11</td>
      <td>4.71129e+11</td>
      <td>-1.18073e+11</td>
      <td>-3.95181</td>
      <td>-3.95363</td>
      <td>-3.95272</td>
    </tr>
    <tr>
      <th>5</th>
      <td>-1.18073e+11</td>
      <td>4.71129e+11</td>
      <td>1.74115e+11</td>
      <td>-3.95272</td>
      <td>-3.95363</td>
      <td>-3.95317</td>
    </tr>
    <tr>
      <th>6</th>
      <td>-1.18073e+11</td>
      <td>1.74115e+11</td>
      <td>2.73871e+10</td>
      <td>-3.95272</td>
      <td>-3.95317</td>
      <td>-3.95295</td>
    </tr>
    <tr>
      <th>7</th>
      <td>-1.18073e+11</td>
      <td>2.73871e+10</td>
      <td>-4.55053e+10</td>
      <td>-3.95272</td>
      <td>-3.95295</td>
      <td>-3.95283</td>
    </tr>
    <tr>
      <th>8</th>
      <td>-4.55053e+10</td>
      <td>2.73871e+10</td>
      <td>-9.0993e+09</td>
      <td>-3.95283</td>
      <td>-3.95295</td>
      <td>-3.95289</td>
    </tr>
    <tr>
      <th>9</th>
      <td>-9.0993e+09</td>
      <td>2.73871e+10</td>
      <td>9.13389e+09</td>
      <td>-3.95289</td>
      <td>-3.95295</td>
      <td>-3.95292</td>
    </tr>
    <tr>
      <th>10</th>
      <td>-9.0993e+09</td>
      <td>9.13389e+09</td>
      <td>1.47511e+07</td>
      <td>-3.95289</td>
      <td>-3.95292</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>11</th>
      <td>-9.0993e+09</td>
      <td>1.47511e+07</td>
      <td>-4.54302e+09</td>
      <td>-3.95289</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>12</th>
      <td>-4.54302e+09</td>
      <td>1.47511e+07</td>
      <td>-2.26418e+09</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>13</th>
      <td>-2.26418e+09</td>
      <td>1.47511e+07</td>
      <td>-1.12479e+09</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>14</th>
      <td>-1.12479e+09</td>
      <td>1.47511e+07</td>
      <td>-5.54889e+08</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>15</th>
      <td>-5.54889e+08</td>
      <td>1.47511e+07</td>
      <td>-2.7001e+08</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>16</th>
      <td>-2.7001e+08</td>
      <td>1.47511e+07</td>
      <td>-1.27639e+08</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>17</th>
      <td>-1.27639e+08</td>
      <td>1.47511e+07</td>
      <td>-5.6375e+07</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>18</th>
      <td>-5.6375e+07</td>
      <td>1.47511e+07</td>
      <td>-2.08418e+07</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>19</th>
      <td>-2.08418e+07</td>
      <td>1.47511e+07</td>
      <td>-2.95322e+06</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>20</th>
      <td>-2.95322e+06</td>
      <td>1.47511e+07</td>
      <td>5.85131e+06</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>21</th>
      <td>-2.95322e+06</td>
      <td>5.85131e+06</td>
      <td>1.4098e+06</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>22</th>
      <td>-2.95322e+06</td>
      <td>1.4098e+06</td>
      <td>-829766</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>23</th>
      <td>-829766</td>
      <td>1.4098e+06</td>
      <td>291807</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>24</th>
      <td>-829766</td>
      <td>291807</td>
      <td>-242102</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
  </tbody>
</table style="display:inline"><table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>25</th>
      <td>-242102</td>
      <td>291807</td>
      <td>-11372.5</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>26</th>
      <td>-11372.5</td>
      <td>291807</td>
      <td>114727</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>27</th>
      <td>-11372.5</td>
      <td>114727</td>
      <td>71947.8</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>28</th>
      <td>-11372.5</td>
      <td>71947.8</td>
      <td>-39667.4</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>29</th>
      <td>-39667.4</td>
      <td>71947.8</td>
      <td>108635</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>30</th>
      <td>-39667.4</td>
      <td>108635</td>
      <td>74172.2</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>31</th>
      <td>-39667.4</td>
      <td>74172.2</td>
      <td>60265.4</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>32</th>
      <td>-39667.4</td>
      <td>60265.4</td>
      <td>3203.8</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>33</th>
      <td>-39667.4</td>
      <td>3203.8</td>
      <td>53773.8</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>34</th>
      <td>-39667.4</td>
      <td>53773.8</td>
      <td>84760.7</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>35</th>
      <td>-39667.4</td>
      <td>84760.7</td>
      <td>41847.2</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>36</th>
      <td>-39667.4</td>
      <td>41847.2</td>
      <td>5387.08</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>37</th>
      <td>-39667.4</td>
      <td>5387.08</td>
      <td>82474.2</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>38</th>
      <td>-39667.4</td>
      <td>82474.2</td>
      <td>51537.8</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>39</th>
      <td>-39667.4</td>
      <td>51537.8</td>
      <td>41437.4</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>40</th>
      <td>-39667.4</td>
      <td>41437.4</td>
      <td>107459</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>41</th>
      <td>-39667.4</td>
      <td>107459</td>
      <td>137273</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>42</th>
      <td>-39667.4</td>
      <td>137273</td>
      <td>-7134.26</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>43</th>
      <td>-7134.26</td>
      <td>137273</td>
      <td>51572.7</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>44</th>
      <td>-7134.26</td>
      <td>51572.7</td>
      <td>87407.5</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>45</th>
      <td>-7134.26</td>
      <td>87407.5</td>
      <td>48176.3</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>46</th>
      <td>-7134.26</td>
      <td>48176.3</td>
      <td>-7134.26</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>47</th>
      <td>-7134.26</td>
      <td>48176.3</td>
      <td>-7134.26</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>48</th>
      <td>-7134.26</td>
      <td>48176.3</td>
      <td>-7134.26</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
    <tr>
      <th>49</th>
      <td>-7134.26</td>
      <td>48176.3</td>
      <td>-7134.26</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
      <td>-3.9529</td>
    </tr>
  </tbody>
</table style="display:inline">



```python
def plot_wavefunctions(energy_guess):
    start = np.array([1.0, np.sqrt(-energy_guess)])

    xout     = odeint(shoot, start, space, args=(-4.0, 30, energy_guess))
    xt       = np.transpose(xout)
    psi      = xt[0]
    psiprime = xt[1]
    result   = normalise(psi, step)

    psi      = psi / result
    psiprime = psiprime / result

    # Plotting
    plt.figure()
    plt.plot(space, psi,      linewidth = 3, label = 'wavefunction')
    plt.plot(space, psiprime, linewidth = 3, label = 'derivative')
    plt.plot(space, potfun/10 + 0.5, linewidth = 1, label = 'scaled potential') # show the potential well as well
    plt.legend()
    plt.show()
    
energy_guess = -3.952902809182185  # this is 2nd higher order state
plot_wavefunctions(energy_guess)
```


```python
splitdf(find(-2.80, -2.90), n=2)
```


<table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>-8.62729e+09</td>
      <td>2.74826e+10</td>
      <td>1.04639e+10</td>
      <td>-2.8</td>
      <td>-2.9</td>
      <td>-2.85</td>
    </tr>
    <tr>
      <th>1</th>
      <td>-8.62729e+09</td>
      <td>1.04639e+10</td>
      <td>-2.13682e+08</td>
      <td>-2.8</td>
      <td>-2.85</td>
      <td>-2.825</td>
    </tr>
    <tr>
      <th>2</th>
      <td>-2.13682e+08</td>
      <td>1.04639e+10</td>
      <td>4.98109e+09</td>
      <td>-2.825</td>
      <td>-2.85</td>
      <td>-2.8375</td>
    </tr>
    <tr>
      <th>3</th>
      <td>-2.13682e+08</td>
      <td>4.98109e+09</td>
      <td>2.32748e+09</td>
      <td>-2.825</td>
      <td>-2.8375</td>
      <td>-2.83125</td>
    </tr>
    <tr>
      <th>4</th>
      <td>-2.13682e+08</td>
      <td>2.32748e+09</td>
      <td>1.04055e+09</td>
      <td>-2.825</td>
      <td>-2.83125</td>
      <td>-2.82812</td>
    </tr>
    <tr>
      <th>5</th>
      <td>-2.13682e+08</td>
      <td>1.04055e+09</td>
      <td>4.09075e+08</td>
      <td>-2.825</td>
      <td>-2.82812</td>
      <td>-2.82656</td>
    </tr>
    <tr>
      <th>6</th>
      <td>-2.13682e+08</td>
      <td>4.09075e+08</td>
      <td>9.65752e+07</td>
      <td>-2.825</td>
      <td>-2.82656</td>
      <td>-2.82578</td>
    </tr>
    <tr>
      <th>7</th>
      <td>-2.13682e+08</td>
      <td>9.65752e+07</td>
      <td>-5.88381e+07</td>
      <td>-2.825</td>
      <td>-2.82578</td>
      <td>-2.82539</td>
    </tr>
    <tr>
      <th>8</th>
      <td>-5.88381e+07</td>
      <td>9.65752e+07</td>
      <td>1.87975e+07</td>
      <td>-2.82539</td>
      <td>-2.82578</td>
      <td>-2.82559</td>
    </tr>
    <tr>
      <th>9</th>
      <td>-5.88381e+07</td>
      <td>1.87975e+07</td>
      <td>-2.0039e+07</td>
      <td>-2.82539</td>
      <td>-2.82559</td>
      <td>-2.82549</td>
    </tr>
    <tr>
      <th>10</th>
      <td>-2.0039e+07</td>
      <td>1.87975e+07</td>
      <td>-624096</td>
      <td>-2.82549</td>
      <td>-2.82559</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>11</th>
      <td>-624096</td>
      <td>1.87975e+07</td>
      <td>9.08421e+06</td>
      <td>-2.82554</td>
      <td>-2.82559</td>
      <td>-2.82556</td>
    </tr>
    <tr>
      <th>12</th>
      <td>-624096</td>
      <td>9.08421e+06</td>
      <td>4.23032e+06</td>
      <td>-2.82554</td>
      <td>-2.82556</td>
      <td>-2.82555</td>
    </tr>
    <tr>
      <th>13</th>
      <td>-624096</td>
      <td>4.23032e+06</td>
      <td>1.80274e+06</td>
      <td>-2.82554</td>
      <td>-2.82555</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>14</th>
      <td>-624096</td>
      <td>1.80274e+06</td>
      <td>589213</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>15</th>
      <td>-624096</td>
      <td>589213</td>
      <td>-18639.8</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>16</th>
      <td>-18639.8</td>
      <td>589213</td>
      <td>285735</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>17</th>
      <td>-18639.8</td>
      <td>285735</td>
      <td>134035</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>18</th>
      <td>-18639.8</td>
      <td>134035</td>
      <td>57845.7</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>19</th>
      <td>-18639.8</td>
      <td>57845.7</td>
      <td>20734.2</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>20</th>
      <td>-18639.8</td>
      <td>20734.2</td>
      <td>188.17</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>21</th>
      <td>-18639.8</td>
      <td>188.17</td>
      <td>-8644.17</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>22</th>
      <td>-8644.17</td>
      <td>188.17</td>
      <td>-4285.05</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>23</th>
      <td>-4285.05</td>
      <td>188.17</td>
      <td>-969.274</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>24</th>
      <td>-969.274</td>
      <td>188.17</td>
      <td>847.168</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
  </tbody>
</table style="display:inline"><table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>25</th>
      <td>-969.274</td>
      <td>847.168</td>
      <td>-1451.03</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>26</th>
      <td>-1451.03</td>
      <td>847.168</td>
      <td>990.846</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>27</th>
      <td>-1451.03</td>
      <td>990.846</td>
      <td>-463.534</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>28</th>
      <td>-463.534</td>
      <td>990.846</td>
      <td>-877.195</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>29</th>
      <td>-877.195</td>
      <td>990.846</td>
      <td>-862.498</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>30</th>
      <td>-862.498</td>
      <td>990.846</td>
      <td>-274.765</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>31</th>
      <td>-274.765</td>
      <td>990.846</td>
      <td>-166.624</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>32</th>
      <td>-166.624</td>
      <td>990.846</td>
      <td>-660.485</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>33</th>
      <td>-660.485</td>
      <td>990.846</td>
      <td>-116.454</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>34</th>
      <td>-116.454</td>
      <td>990.846</td>
      <td>-770.484</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>35</th>
      <td>-770.484</td>
      <td>990.846</td>
      <td>-723.286</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>36</th>
      <td>-723.286</td>
      <td>990.846</td>
      <td>-975.331</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>37</th>
      <td>-975.331</td>
      <td>990.846</td>
      <td>-327.776</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>38</th>
      <td>-327.776</td>
      <td>990.846</td>
      <td>-101.524</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>39</th>
      <td>-101.524</td>
      <td>990.846</td>
      <td>-825.575</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>40</th>
      <td>-825.575</td>
      <td>990.846</td>
      <td>-912.438</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>41</th>
      <td>-912.438</td>
      <td>990.846</td>
      <td>-1300.87</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>42</th>
      <td>-1300.87</td>
      <td>990.846</td>
      <td>556.133</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>43</th>
      <td>-1300.87</td>
      <td>556.133</td>
      <td>-630.457</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>44</th>
      <td>-630.457</td>
      <td>556.133</td>
      <td>-571.854</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>45</th>
      <td>-571.854</td>
      <td>556.133</td>
      <td>19.0422</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>46</th>
      <td>-571.854</td>
      <td>19.0422</td>
      <td>-74.267</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>47</th>
      <td>-74.267</td>
      <td>19.0422</td>
      <td>-74.267</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>48</th>
      <td>-74.267</td>
      <td>19.0422</td>
      <td>-74.267</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
    <tr>
      <th>49</th>
      <td>-74.267</td>
      <td>19.0422</td>
      <td>-74.267</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
      <td>-2.82554</td>
    </tr>
  </tbody>
</table style="display:inline">



```python
energy_guess = -2.825538679175513  # which state is this?
plot_wavefunctions(energy_guess)
```

## Simple Harmonic Potential

In class we have also looked at a harmonic potential well defined by

$$ V(x) =\frac{x^2}{w^2} $$

where $w$ defines the steepness of the well. We can easily adapt our code to find the wavefunctions for this case as well.  


```python
def potential2(x, width):  # harmonic potential well
    return x ** 2 / (width ** 2)

potfun2 = np.zeros(space_steps)

for ii in range(0, space_steps):
    potfun2[ii] = potential2(space[ii], 10)
    
def shoot2(yin, position, width, energy):
    return np.array([yin[1], 2.0 * (potential2(position, width) - energy) * yin[0]])
```


```python
def find_harmonic(start, stop, width): 
    """Finds where the function shoot has the value 0 through the bisection method.
    
    Make sure that the solution goes in different directions for the two values of start and stop.
    
    Parameters:
    -----------
        start : float64
            A lower bound.
        stop  : float64
            An upper bound.
            
    Prints:
    -----------
        output : pandas dataframe
            This stores the values of out1, out2 and out3 as the code iterates,
            The pandas dataframe allows for aesthetic printing of values.
            
    Returns:
    -----------
        guess : float64
            A guess as to what value the function shoot will return zero.
            This will be between the values of "start" and "stop".
    """
    # out1 is the final value of our trial solution for the guess Energy = start
    # the element [-1][0] picks the last element in the array.
    # out2 is the final value of our trial solution for the guess Energy = stop.
    # guess is the midpoint of the interval.
    # out3 is the final value of the trial solution for the guess Energy=guess.
    
    def step(start, stop, width, output, count):
        out1  = odeint(shoot2, np.array([1.0, np.sqrt(potential2(-20, width) - start)]), space, args=(width, start))[-1][0]
        out2  = odeint(shoot2, np.array([1.0, np.sqrt(potential2(-20, width) - stop )]), space, args=(width, stop ))[-1][0]
        guess = (stop + start) / 2.0
        out3  = odeint(shoot2, np.array([1.0, np.sqrt(potential2(-20, width) - guess)]), space, args=(width, guess))[-1][0]

        output.iloc[count] = [out1, out2, out3, start, stop, guess]
        
        if np.sign(out1) == np.sign(out3):
            start = guess
        else:
            stop = guess
        return start, stop, width, output, count
    
    
    output = pd.DataFrame(columns = ['out1','out2','out3', 'start', 'stop', 'guess'], index = range(50))
    
    for count in range(50):
        start, stop, width, output, count = step(start, stop, width, output, count)
        
    return output
```


```python
splitdf(find_harmonic(0, 0.2, 10), n = 2)
```


<table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>4.46476e+24</td>
      <td>-8.23049e+20</td>
      <td>-4.95874e+22</td>
      <td>0</td>
      <td>0.2</td>
      <td>0.1</td>
    </tr>
    <tr>
      <th>1</th>
      <td>4.46476e+24</td>
      <td>-4.95874e+22</td>
      <td>2.33367e+23</td>
      <td>0</td>
      <td>0.1</td>
      <td>0.05</td>
    </tr>
    <tr>
      <th>2</th>
      <td>2.33367e+23</td>
      <td>-4.95874e+22</td>
      <td>-1.92456e+22</td>
      <td>0.05</td>
      <td>0.1</td>
      <td>0.075</td>
    </tr>
    <tr>
      <th>3</th>
      <td>2.33367e+23</td>
      <td>-1.92456e+22</td>
      <td>5.87244e+22</td>
      <td>0.05</td>
      <td>0.075</td>
      <td>0.0625</td>
    </tr>
    <tr>
      <th>4</th>
      <td>5.87244e+22</td>
      <td>-1.92456e+22</td>
      <td>1.11243e+22</td>
      <td>0.0625</td>
      <td>0.075</td>
      <td>0.06875</td>
    </tr>
    <tr>
      <th>5</th>
      <td>1.11243e+22</td>
      <td>-1.92456e+22</td>
      <td>-5.87695e+21</td>
      <td>0.06875</td>
      <td>0.075</td>
      <td>0.071875</td>
    </tr>
    <tr>
      <th>6</th>
      <td>1.11243e+22</td>
      <td>-5.87695e+21</td>
      <td>2.13105e+21</td>
      <td>0.06875</td>
      <td>0.071875</td>
      <td>0.0703125</td>
    </tr>
    <tr>
      <th>7</th>
      <td>2.13105e+21</td>
      <td>-5.87695e+21</td>
      <td>-1.99109e+21</td>
      <td>0.0703125</td>
      <td>0.071875</td>
      <td>0.0710938</td>
    </tr>
    <tr>
      <th>8</th>
      <td>2.13105e+21</td>
      <td>-1.99109e+21</td>
      <td>3.98347e+19</td>
      <td>0.0703125</td>
      <td>0.0710938</td>
      <td>0.0707031</td>
    </tr>
    <tr>
      <th>9</th>
      <td>3.98347e+19</td>
      <td>-1.99109e+21</td>
      <td>-9.83084e+20</td>
      <td>0.0707031</td>
      <td>0.0710938</td>
      <td>0.0708984</td>
    </tr>
    <tr>
      <th>10</th>
      <td>3.98347e+19</td>
      <td>-9.83084e+20</td>
      <td>-4.73499e+20</td>
      <td>0.0707031</td>
      <td>0.0708984</td>
      <td>0.0708008</td>
    </tr>
    <tr>
      <th>11</th>
      <td>3.98347e+19</td>
      <td>-4.73499e+20</td>
      <td>-2.17302e+20</td>
      <td>0.0707031</td>
      <td>0.0708008</td>
      <td>0.070752</td>
    </tr>
    <tr>
      <th>12</th>
      <td>3.98347e+19</td>
      <td>-2.17302e+20</td>
      <td>-8.88513e+19</td>
      <td>0.0707031</td>
      <td>0.070752</td>
      <td>0.0707275</td>
    </tr>
    <tr>
      <th>13</th>
      <td>3.98347e+19</td>
      <td>-8.88513e+19</td>
      <td>-2.45378e+19</td>
      <td>0.0707031</td>
      <td>0.0707275</td>
      <td>0.0707153</td>
    </tr>
    <tr>
      <th>14</th>
      <td>3.98347e+19</td>
      <td>-2.45378e+19</td>
      <td>7.6411e+18</td>
      <td>0.0707031</td>
      <td>0.0707153</td>
      <td>0.0707092</td>
    </tr>
    <tr>
      <th>15</th>
      <td>7.6411e+18</td>
      <td>-2.45378e+19</td>
      <td>-8.45018e+18</td>
      <td>0.0707092</td>
      <td>0.0707153</td>
      <td>0.0707123</td>
    </tr>
    <tr>
      <th>16</th>
      <td>7.6411e+18</td>
      <td>-8.45018e+18</td>
      <td>-4.04997e+17</td>
      <td>0.0707092</td>
      <td>0.0707123</td>
      <td>0.0707108</td>
    </tr>
    <tr>
      <th>17</th>
      <td>7.6411e+18</td>
      <td>-4.04997e+17</td>
      <td>3.61794e+18</td>
      <td>0.0707092</td>
      <td>0.0707108</td>
      <td>0.07071</td>
    </tr>
    <tr>
      <th>18</th>
      <td>3.61794e+18</td>
      <td>-4.04997e+17</td>
      <td>1.60644e+18</td>
      <td>0.07071</td>
      <td>0.0707108</td>
      <td>0.0707104</td>
    </tr>
    <tr>
      <th>19</th>
      <td>1.60644e+18</td>
      <td>-4.04997e+17</td>
      <td>6.00715e+17</td>
      <td>0.0707104</td>
      <td>0.0707108</td>
      <td>0.0707106</td>
    </tr>
    <tr>
      <th>20</th>
      <td>6.00715e+17</td>
      <td>-4.04997e+17</td>
      <td>9.78573e+16</td>
      <td>0.0707106</td>
      <td>0.0707108</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>21</th>
      <td>9.78573e+16</td>
      <td>-4.04997e+17</td>
      <td>-1.53571e+17</td>
      <td>0.0707107</td>
      <td>0.0707108</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>22</th>
      <td>9.78573e+16</td>
      <td>-1.53571e+17</td>
      <td>-2.78567e+16</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>23</th>
      <td>9.78573e+16</td>
      <td>-2.78567e+16</td>
      <td>3.50003e+16</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>24</th>
      <td>3.50003e+16</td>
      <td>-2.78567e+16</td>
      <td>3.57176e+15</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
  </tbody>
</table style="display:inline"><table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>25</th>
      <td>3.57176e+15</td>
      <td>-2.78567e+16</td>
      <td>-1.21425e+16</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>26</th>
      <td>3.57176e+15</td>
      <td>-1.21425e+16</td>
      <td>-4.28537e+15</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>27</th>
      <td>3.57176e+15</td>
      <td>-4.28537e+15</td>
      <td>-3.56803e+14</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>28</th>
      <td>3.57176e+15</td>
      <td>-3.56803e+14</td>
      <td>1.60748e+15</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>29</th>
      <td>1.60748e+15</td>
      <td>-3.56803e+14</td>
      <td>6.25338e+14</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>30</th>
      <td>6.25338e+14</td>
      <td>-3.56803e+14</td>
      <td>1.34268e+14</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>31</th>
      <td>1.34268e+14</td>
      <td>-3.56803e+14</td>
      <td>-1.11268e+14</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>32</th>
      <td>1.34268e+14</td>
      <td>-1.11268e+14</td>
      <td>1.15001e+13</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>33</th>
      <td>1.15001e+13</td>
      <td>-1.11268e+14</td>
      <td>-4.98838e+13</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>34</th>
      <td>1.15001e+13</td>
      <td>-4.98838e+13</td>
      <td>-1.91921e+13</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>35</th>
      <td>1.15001e+13</td>
      <td>-1.91921e+13</td>
      <td>-3.84581e+12</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>36</th>
      <td>1.15001e+13</td>
      <td>-3.84581e+12</td>
      <td>3.82744e+12</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>37</th>
      <td>3.82744e+12</td>
      <td>-3.84581e+12</td>
      <td>-9.11549e+09</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>38</th>
      <td>3.82744e+12</td>
      <td>-9.11549e+09</td>
      <td>1.90913e+12</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>39</th>
      <td>1.90913e+12</td>
      <td>-9.11549e+09</td>
      <td>9.49859e+11</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>40</th>
      <td>9.49859e+11</td>
      <td>-9.11549e+09</td>
      <td>4.70165e+11</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>41</th>
      <td>4.70165e+11</td>
      <td>-9.11549e+09</td>
      <td>2.30581e+11</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>42</th>
      <td>2.30581e+11</td>
      <td>-9.11549e+09</td>
      <td>1.10669e+11</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>43</th>
      <td>1.10669e+11</td>
      <td>-9.11549e+09</td>
      <td>5.07153e+10</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>44</th>
      <td>5.07153e+10</td>
      <td>-9.11549e+09</td>
      <td>2.08232e+10</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>45</th>
      <td>2.08232e+10</td>
      <td>-9.11549e+09</td>
      <td>5.77114e+09</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>46</th>
      <td>5.77114e+09</td>
      <td>-9.11549e+09</td>
      <td>-2.06435e+09</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>47</th>
      <td>5.77114e+09</td>
      <td>-2.06435e+09</td>
      <td>1.75553e+09</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>48</th>
      <td>1.75553e+09</td>
      <td>-2.06435e+09</td>
      <td>-7.30428e+07</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
    <tr>
      <th>49</th>
      <td>1.75553e+09</td>
      <td>-7.30428e+07</td>
      <td>8.57382e+08</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
      <td>0.0707107</td>
    </tr>
  </tbody>
</table style="display:inline">



```python
def plot_wavefunctions2(energy_guess, scale = 10, ylims = None):
    start    = np.array([1.0, np.sqrt(potential2(-20, 10) - energy_guess)])
    xout     = odeint(shoot2, start, space, args = (10, energy_guess))
    xt       = np.transpose(xout)
    psi      = xt[0]
    psiprime = xt[1]
    result   = normalise(psi, step) 
    psi      = psi / result       # again we normalise the solution.
    psiprime = psiprime / result

    plt.figure()
    plt.plot(space, psi,       linewidth=3, label = 'wavefunction')
    plt.plot(space, psiprime,  linewidth=3, label = 'derivative')
    plt.plot(space, potfun2/scale, linewidth=1, label = 'scaled potential') #show the potential well as well
    if ylims != None:
        plt.ylim(*ylims)
    plt.legend()
    plt.show()
    
energy_guess = 0.07071067758588272  #this is a higher order state
plot_wavefunctions2(energy_guess)
```

It can be seen that this looks like the ground state solution to Schrodinger's equation. It is symmetric about $x=0$ and has a single maximum. Note that as before we normalise the solution.

If our method works then we should be able to find the next solution which will be anti-symmetric with $\psi(0)=0$ and have two extrema. So lets try a new guess.


```python
splitdf(find_harmonic(0.1, 0.5, 10), n = 2)
```


<table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>-4.95874e+22</td>
      <td>1.08366e+17</td>
      <td>1.55763e+20</td>
      <td>0.1</td>
      <td>0.5</td>
      <td>0.3</td>
    </tr>
    <tr>
      <th>1</th>
      <td>-4.95874e+22</td>
      <td>1.55763e+20</td>
      <td>-8.23049e+20</td>
      <td>0.1</td>
      <td>0.3</td>
      <td>0.2</td>
    </tr>
    <tr>
      <th>2</th>
      <td>-8.23049e+20</td>
      <td>1.55763e+20</td>
      <td>5.17976e+20</td>
      <td>0.2</td>
      <td>0.3</td>
      <td>0.25</td>
    </tr>
    <tr>
      <th>3</th>
      <td>-8.23049e+20</td>
      <td>5.17976e+20</td>
      <td>4.09213e+20</td>
      <td>0.2</td>
      <td>0.25</td>
      <td>0.225</td>
    </tr>
    <tr>
      <th>4</th>
      <td>-8.23049e+20</td>
      <td>4.09213e+20</td>
      <td>1.72681e+19</td>
      <td>0.2</td>
      <td>0.225</td>
      <td>0.2125</td>
    </tr>
    <tr>
      <th>5</th>
      <td>-8.23049e+20</td>
      <td>1.72681e+19</td>
      <td>-3.3274e+20</td>
      <td>0.2</td>
      <td>0.2125</td>
      <td>0.20625</td>
    </tr>
    <tr>
      <th>6</th>
      <td>-3.3274e+20</td>
      <td>1.72681e+19</td>
      <td>-1.42144e+20</td>
      <td>0.20625</td>
      <td>0.2125</td>
      <td>0.209375</td>
    </tr>
    <tr>
      <th>7</th>
      <td>-1.42144e+20</td>
      <td>1.72681e+19</td>
      <td>-5.87665e+19</td>
      <td>0.209375</td>
      <td>0.2125</td>
      <td>0.210938</td>
    </tr>
    <tr>
      <th>8</th>
      <td>-5.87665e+19</td>
      <td>1.72681e+19</td>
      <td>-1.98587e+19</td>
      <td>0.210938</td>
      <td>0.2125</td>
      <td>0.211719</td>
    </tr>
    <tr>
      <th>9</th>
      <td>-1.98587e+19</td>
      <td>1.72681e+19</td>
      <td>-1.07606e+18</td>
      <td>0.211719</td>
      <td>0.2125</td>
      <td>0.212109</td>
    </tr>
    <tr>
      <th>10</th>
      <td>-1.07606e+18</td>
      <td>1.72681e+19</td>
      <td>8.15041e+18</td>
      <td>0.212109</td>
      <td>0.2125</td>
      <td>0.212305</td>
    </tr>
    <tr>
      <th>11</th>
      <td>-1.07606e+18</td>
      <td>8.15041e+18</td>
      <td>3.55084e+18</td>
      <td>0.212109</td>
      <td>0.212305</td>
      <td>0.212207</td>
    </tr>
    <tr>
      <th>12</th>
      <td>-1.07606e+18</td>
      <td>3.55084e+18</td>
      <td>1.24078e+18</td>
      <td>0.212109</td>
      <td>0.212207</td>
      <td>0.212158</td>
    </tr>
    <tr>
      <th>13</th>
      <td>-1.07606e+18</td>
      <td>1.24078e+18</td>
      <td>8.32673e+16</td>
      <td>0.212109</td>
      <td>0.212158</td>
      <td>0.212134</td>
    </tr>
    <tr>
      <th>14</th>
      <td>-1.07606e+18</td>
      <td>8.32673e+16</td>
      <td>-4.96224e+17</td>
      <td>0.212109</td>
      <td>0.212134</td>
      <td>0.212122</td>
    </tr>
    <tr>
      <th>15</th>
      <td>-4.96224e+17</td>
      <td>8.32673e+16</td>
      <td>-2.06402e+17</td>
      <td>0.212122</td>
      <td>0.212134</td>
      <td>0.212128</td>
    </tr>
    <tr>
      <th>16</th>
      <td>-2.06402e+17</td>
      <td>8.32673e+16</td>
      <td>-6.15561e+16</td>
      <td>0.212128</td>
      <td>0.212134</td>
      <td>0.212131</td>
    </tr>
    <tr>
      <th>17</th>
      <td>-6.15561e+16</td>
      <td>8.32673e+16</td>
      <td>1.08616e+16</td>
      <td>0.212131</td>
      <td>0.212134</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>18</th>
      <td>-6.15561e+16</td>
      <td>1.08616e+16</td>
      <td>-2.53437e+16</td>
      <td>0.212131</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>19</th>
      <td>-2.53437e+16</td>
      <td>1.08616e+16</td>
      <td>-7.24087e+15</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>20</th>
      <td>-7.24087e+15</td>
      <td>1.08616e+16</td>
      <td>1.81042e+15</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>21</th>
      <td>-7.24087e+15</td>
      <td>1.81042e+15</td>
      <td>-2.71521e+15</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>22</th>
      <td>-2.71521e+15</td>
      <td>1.81042e+15</td>
      <td>-4.52397e+14</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>23</th>
      <td>-4.52397e+14</td>
      <td>1.81042e+15</td>
      <td>6.79011e+14</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>24</th>
      <td>-4.52397e+14</td>
      <td>6.79011e+14</td>
      <td>1.13308e+14</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
  </tbody>
</table style="display:inline"><table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>25</th>
      <td>-4.52397e+14</td>
      <td>1.13308e+14</td>
      <td>-1.69544e+14</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>26</th>
      <td>-1.69544e+14</td>
      <td>1.13308e+14</td>
      <td>-2.81168e+13</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>27</th>
      <td>-2.81168e+13</td>
      <td>1.13308e+14</td>
      <td>4.25956e+13</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>28</th>
      <td>-2.81168e+13</td>
      <td>4.25956e+13</td>
      <td>7.23914e+12</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>29</th>
      <td>-2.81168e+13</td>
      <td>7.23914e+12</td>
      <td>-1.04401e+13</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>30</th>
      <td>-1.04401e+13</td>
      <td>7.23914e+12</td>
      <td>-1.60083e+12</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>31</th>
      <td>-1.60083e+12</td>
      <td>7.23914e+12</td>
      <td>2.81914e+12</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>32</th>
      <td>-1.60083e+12</td>
      <td>2.81914e+12</td>
      <td>6.08192e+11</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>33</th>
      <td>-1.60083e+12</td>
      <td>6.08192e+11</td>
      <td>-4.95989e+11</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>34</th>
      <td>-4.95989e+11</td>
      <td>6.08192e+11</td>
      <td>5.53889e+10</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>35</th>
      <td>-4.95989e+11</td>
      <td>5.53889e+10</td>
      <td>-2.19661e+11</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>36</th>
      <td>-2.19661e+11</td>
      <td>5.53889e+10</td>
      <td>-8.08824e+10</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>37</th>
      <td>-8.08824e+10</td>
      <td>5.53889e+10</td>
      <td>-1.18613e+10</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>38</th>
      <td>-1.18613e+10</td>
      <td>5.53889e+10</td>
      <td>2.27059e+10</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>39</th>
      <td>-1.18613e+10</td>
      <td>2.27059e+10</td>
      <td>4.90908e+09</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>40</th>
      <td>-1.18613e+10</td>
      <td>4.90908e+09</td>
      <td>-3.17055e+09</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>41</th>
      <td>-3.17055e+09</td>
      <td>4.90908e+09</td>
      <td>8.30787e+08</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>42</th>
      <td>-3.17055e+09</td>
      <td>8.30787e+08</td>
      <td>-2.54283e+09</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>43</th>
      <td>-2.54283e+09</td>
      <td>8.30787e+08</td>
      <td>-3.64425e+08</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>44</th>
      <td>-3.64425e+08</td>
      <td>8.30787e+08</td>
      <td>-5.25134e+08</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>45</th>
      <td>-5.25134e+08</td>
      <td>8.30787e+08</td>
      <td>1.13961e+09</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>46</th>
      <td>-5.25134e+08</td>
      <td>1.13961e+09</td>
      <td>7.3855e+08</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>47</th>
      <td>-5.25134e+08</td>
      <td>7.3855e+08</td>
      <td>1.15497e+09</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>48</th>
      <td>-5.25134e+08</td>
      <td>1.15497e+09</td>
      <td>-9.77219e+08</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
    <tr>
      <th>49</th>
      <td>-9.77219e+08</td>
      <td>1.15497e+09</td>
      <td>6.49231e+08</td>
      <td>0.212132</td>
      <td>0.212132</td>
      <td>0.212132</td>
    </tr>
  </tbody>
</table style="display:inline">



```python
energy_guess = 0.21213203429823696  # this is the second eigenvalue
plot_wavefunctions2(energy_guess)
```

Again our code has found the solution that we expect. We can see that it is quite a bit wider than the fundamental solution. We have scaled the potential by a factor of 4 so that it fits nicely on the graph. We can carry on and find the next solution.


```python
splitdf(find_harmonic(0.25, 0.6, 10), n = 2)
```


<table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>5.17976e+20</td>
      <td>6.83957e+16</td>
      <td>-6.15917e+18</td>
      <td>0.25</td>
      <td>0.6</td>
      <td>0.425</td>
    </tr>
    <tr>
      <th>1</th>
      <td>5.17976e+20</td>
      <td>-6.15917e+18</td>
      <td>2.10088e+19</td>
      <td>0.25</td>
      <td>0.425</td>
      <td>0.3375</td>
    </tr>
    <tr>
      <th>2</th>
      <td>2.10088e+19</td>
      <td>-6.15917e+18</td>
      <td>-1.09089e+19</td>
      <td>0.3375</td>
      <td>0.425</td>
      <td>0.38125</td>
    </tr>
    <tr>
      <th>3</th>
      <td>2.10088e+19</td>
      <td>-1.09089e+19</td>
      <td>-4.3282e+18</td>
      <td>0.3375</td>
      <td>0.38125</td>
      <td>0.359375</td>
    </tr>
    <tr>
      <th>4</th>
      <td>2.10088e+19</td>
      <td>-4.3282e+18</td>
      <td>5.09e+18</td>
      <td>0.3375</td>
      <td>0.359375</td>
      <td>0.348438</td>
    </tr>
    <tr>
      <th>5</th>
      <td>5.09e+18</td>
      <td>-4.3282e+18</td>
      <td>-3.04135e+17</td>
      <td>0.348438</td>
      <td>0.359375</td>
      <td>0.353906</td>
    </tr>
    <tr>
      <th>6</th>
      <td>5.09e+18</td>
      <td>-3.04135e+17</td>
      <td>2.20657e+18</td>
      <td>0.348438</td>
      <td>0.353906</td>
      <td>0.351172</td>
    </tr>
    <tr>
      <th>7</th>
      <td>2.20657e+18</td>
      <td>-3.04135e+17</td>
      <td>9.06571e+17</td>
      <td>0.351172</td>
      <td>0.353906</td>
      <td>0.352539</td>
    </tr>
    <tr>
      <th>8</th>
      <td>9.06571e+17</td>
      <td>-3.04135e+17</td>
      <td>2.90294e+17</td>
      <td>0.352539</td>
      <td>0.353906</td>
      <td>0.353223</td>
    </tr>
    <tr>
      <th>9</th>
      <td>2.90294e+17</td>
      <td>-3.04135e+17</td>
      <td>-9.62245e+15</td>
      <td>0.353223</td>
      <td>0.353906</td>
      <td>0.353564</td>
    </tr>
    <tr>
      <th>10</th>
      <td>2.90294e+17</td>
      <td>-9.62245e+15</td>
      <td>1.39656e+17</td>
      <td>0.353223</td>
      <td>0.353564</td>
      <td>0.353394</td>
    </tr>
    <tr>
      <th>11</th>
      <td>1.39656e+17</td>
      <td>-9.62245e+15</td>
      <td>6.48484e+16</td>
      <td>0.353394</td>
      <td>0.353564</td>
      <td>0.353479</td>
    </tr>
    <tr>
      <th>12</th>
      <td>6.48484e+16</td>
      <td>-9.62245e+15</td>
      <td>2.75704e+16</td>
      <td>0.353479</td>
      <td>0.353564</td>
      <td>0.353522</td>
    </tr>
    <tr>
      <th>13</th>
      <td>2.75704e+16</td>
      <td>-9.62245e+15</td>
      <td>8.96379e+15</td>
      <td>0.353522</td>
      <td>0.353564</td>
      <td>0.353543</td>
    </tr>
    <tr>
      <th>14</th>
      <td>8.96379e+15</td>
      <td>-9.62245e+15</td>
      <td>-3.32243e+14</td>
      <td>0.353543</td>
      <td>0.353564</td>
      <td>0.353554</td>
    </tr>
    <tr>
      <th>15</th>
      <td>8.96379e+15</td>
      <td>-3.32243e+14</td>
      <td>4.31532e+15</td>
      <td>0.353543</td>
      <td>0.353554</td>
      <td>0.353548</td>
    </tr>
    <tr>
      <th>16</th>
      <td>4.31532e+15</td>
      <td>-3.32243e+14</td>
      <td>1.99161e+15</td>
      <td>0.353548</td>
      <td>0.353554</td>
      <td>0.353551</td>
    </tr>
    <tr>
      <th>17</th>
      <td>1.99161e+15</td>
      <td>-3.32243e+14</td>
      <td>8.2944e+14</td>
      <td>0.353551</td>
      <td>0.353554</td>
      <td>0.353552</td>
    </tr>
    <tr>
      <th>18</th>
      <td>8.2944e+14</td>
      <td>-3.32243e+14</td>
      <td>2.48581e+14</td>
      <td>0.353552</td>
      <td>0.353554</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>19</th>
      <td>2.48581e+14</td>
      <td>-3.32243e+14</td>
      <td>-4.18333e+13</td>
      <td>0.353553</td>
      <td>0.353554</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>20</th>
      <td>2.48581e+14</td>
      <td>-4.18333e+13</td>
      <td>1.03413e+14</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>21</th>
      <td>1.03413e+14</td>
      <td>-4.18333e+13</td>
      <td>3.07758e+13</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>22</th>
      <td>3.07758e+13</td>
      <td>-4.18333e+13</td>
      <td>-5.54686e+12</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>23</th>
      <td>3.07758e+13</td>
      <td>-5.54686e+12</td>
      <td>1.30673e+13</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>24</th>
      <td>1.30673e+13</td>
      <td>-5.54686e+12</td>
      <td>3.99446e+12</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
  </tbody>
</table style="display:inline"><table style="display:inline" border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>out1</th>
      <th>out2</th>
      <th>out3</th>
      <th>start</th>
      <th>stop</th>
      <th>guess</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>25</th>
      <td>3.99446e+12</td>
      <td>-5.54686e+12</td>
      <td>-9.97978e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>26</th>
      <td>3.99446e+12</td>
      <td>-9.97978e+11</td>
      <td>1.26339e+12</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>27</th>
      <td>1.26339e+12</td>
      <td>-9.97978e+11</td>
      <td>1.62552e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>28</th>
      <td>1.62552e+11</td>
      <td>-9.97978e+11</td>
      <td>-4.38427e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>29</th>
      <td>1.62552e+11</td>
      <td>-4.38427e+11</td>
      <td>-1.42616e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>30</th>
      <td>1.62552e+11</td>
      <td>-1.42616e+11</td>
      <td>3.40973e+09</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>31</th>
      <td>3.40973e+09</td>
      <td>-1.42616e+11</td>
      <td>-6.50238e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>32</th>
      <td>3.40973e+09</td>
      <td>-6.50238e+10</td>
      <td>2.84252e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>33</th>
      <td>2.84252e+11</td>
      <td>-6.50238e+10</td>
      <td>-4.70616e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>34</th>
      <td>2.84252e+11</td>
      <td>-4.70616e+10</td>
      <td>-2.40256e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>35</th>
      <td>2.84252e+11</td>
      <td>-2.40256e+10</td>
      <td>-3.80363e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>36</th>
      <td>2.84252e+11</td>
      <td>-3.80363e+10</td>
      <td>4.11181e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>37</th>
      <td>4.11181e+11</td>
      <td>-3.80363e+10</td>
      <td>4.11557e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>38</th>
      <td>4.11557e+11</td>
      <td>-3.80363e+10</td>
      <td>-1.90051e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>39</th>
      <td>4.11557e+11</td>
      <td>-1.90051e+10</td>
      <td>4.07655e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>40</th>
      <td>4.07655e+11</td>
      <td>-1.90051e+10</td>
      <td>-5.00739e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>41</th>
      <td>4.07655e+11</td>
      <td>-5.00739e+10</td>
      <td>-4.13917e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>42</th>
      <td>4.07655e+11</td>
      <td>-4.13917e+10</td>
      <td>4.0781e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>43</th>
      <td>4.0781e+11</td>
      <td>-4.13917e+10</td>
      <td>-3.89362e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>44</th>
      <td>4.0781e+11</td>
      <td>-3.89362e+10</td>
      <td>-4.40134e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>45</th>
      <td>4.0781e+11</td>
      <td>-4.40134e+10</td>
      <td>-1.90452e+10</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>46</th>
      <td>4.0781e+11</td>
      <td>-1.90452e+10</td>
      <td>2.95727e+09</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>47</th>
      <td>2.95727e+09</td>
      <td>-1.90452e+10</td>
      <td>4.07951e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>48</th>
      <td>4.07951e+11</td>
      <td>-1.90452e+10</td>
      <td>2.76342e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
    <tr>
      <th>49</th>
      <td>2.76342e+11</td>
      <td>-1.90452e+10</td>
      <td>2.62854e+11</td>
      <td>0.353553</td>
      <td>0.353553</td>
      <td>0.353553</td>
    </tr>
  </tbody>
</table style="display:inline">



```python
energy_guess = 0.35355339015204545  # this is a higher order state
plot_wavefunctions2(energy_guess, ylims = [-0.4,0.4])
```

We know for the harmonic potential the eigenvalues are evenly spaced. In our case the spacing is about $\sqrt{2}/10$ so we expect the next solution to be at 0.49497474683058326708.


```python
energy_guess = 0.49497474683058326708  #no need to use find now since we know the energy spacing.
plot_wavefunctions2(energy_guess, ylims = [-0.3,0.3])
```


```python

```

ba0cfa2b258eabda63e1b957f10bd9ebf18a39bd
ipynb
Jupyter Notebook
schrodinger2.ipynb
hjelleyman/lorentz
9b21d9c2ece26604a29157191d6d32aa5d6b8823
MIT
schrodinger2.ipynb
hjelleyman/lorentz
9b21d9c2ece26604a29157191d6d32aa5d6b8823
MIT
2020-03-24T17:52:38.000Z
2021-08-23T20:31:03.000Z
schrodinger2.ipynb
hjelleyman/lorentz
9b21d9c2ece26604a29157191d6d32aa5d6b8823
MIT
Qwen/Qwen-72B
1. YES
2. YES