- #1

svletana

- 21

- 1

Here's the code I have:

Python:

```
from numpy import *
from numpy.linalg import eigh
import matplotlib.pyplot as plt
from __future__ import division
def Laplacian(x):
h = x[1]-x[0] # assume uniformly spaced points
n = len(x)
M = -2*identity(n,'d')
for i in range(1,n):
M[i,i-1] = M[i-1,i] = 1
return M/h**2
L = 6
x = linspace(0, L, 100)
T = -0.5*Laplacian(x)
H = T
E,U = eigh(H)
n = 1 # change to see another state
plt.plot(x,U[:,n-1],'o')
plt.plot(x, sqrt(2/L)*sin(n*pi*x/L),'o')
plt.show()
```

First of all, the eigenfunctions U[:,i] appear to be normalized if I check, but they don't match the analytic solution. Also, the eigenvalues don't match the values of energy for the infinite well 0.5(πn/L)

^{2}.

What could I be missing? The math seems to be fine.

Would it make it better to use scipy.linalg instead of numpy's?

Thanks!