<jupyter_start><jupyter_text>Infinite Square Well<jupyter_code>N = 1000
H = np.zeros((N,N))
x = np.linspace(0.0,1.0,N)
xn = np.linspace(0.0,N-1,N)
a = 1.0
V = np.zeros(N)
##SETUP THE MATRIX H ALONG DIAGONALS AND NEAR DIAGONALS
for i in range(0,N):
    if (i<N-1):
        H[i,i+1] = -a
    if (i>0):
        H[i,i-1] = -a
    H[i,i] = 2*a+V[i]
print(H)
w,v = eigh(H)
L = 1
n = 1
analyticWellFuncs = []
number = 1
for n in range(1,number+1):
    analyticWell = -np.sqrt(2/L)*np.sin(n*np.pi*x / L)
    
    analyticWellFuncs.append(analyticWell)

print(len(analyticWellFuncs))
plt.figure()

for i in range(0,len(analyticWellFuncs)):
    plt.plot(x,analyticWellFuncs[i])
plt.plot(x,v[:,0]/np.sqrt(1/N))<jupyter_output>1<jupyter_text>Wow! They're identical!<jupyter_code>dx = 1/N
En = (dx**2)*(np.pi**2)*(xn**2)
plt.loglog(xn,w)
plt.loglog(xn,En)<jupyter_output><empty_output><jupyter_text>The agreement is decent, except for deviations at the beginning and end. The beginning is off I think because of a lack of samples. Once enough samples get processed, it agrees amazingly! Eventually, though, it deviates again. This deviation is possibly due to rounding errors in the analytic solution. 3a E = n*hbar*omega   Harmonic Oscillator<jupyter_code>m = 1
omega = 1
hbar = np.sqrt(2*a*m*dx**2)
hbar
Evals = xn*hbar*omega
plt.loglog(xn,Evals)
N = 1000
H = np.zeros((N,N))
x = np.linspace(-0.5,0.5,N)
xn = np.linspace(0.0,N-1,N)
a = 1.0
V = 0.5*(np.linspace(-0.5,0.5,N))**2
##SETUP THE MATRIX H ALONG DIAGONALS AND NEAR DIAGONALS
for i in range(0,N):
    if (i<N-1):
        H[i,i+1] = -a
    if (i>0):
        H[i,i-1] = -a
    H[i,i] = 2*a+V[i]
print(H)
w,v = eigh(H)
Evals = xn*hbar*omega
plt.figure(figsize=[10,10])
plt.loglog(xn,Evals)
plt.loglog(xn,w)<jupyter_output><empty_output><jupyter_text>WoW! It lines up again, except for the later values.<jupyter_code>phinot = (1/(np.pi*hbar))**(1/4)*np.exp((-1/(2*hbar))*(x**2))
plt.plot(xn, v[:,0]/np.sqrt(dx))
plt.plot(xn, -phinot)<jupyter_output><empty_output><jupyter_text>Linear Potential<jupyter_code>N = 1000
H = np.zeros((N,N))
xmax = N
x = np.linspace(0,1,N)
xn = np.linspace(0.0,N-1,N)
a = 1.0
V = x
dx = 1/N
hbar = np.sqrt(2)*dx

##SETUP THE MATRIX H ALONG DIAGONALS AND NEAR DIAGONALS
for i in range(0,N):
    if (i<N-1):
        H[i,i+1] = -a
    if (i>0):
        H[i,i-1] = -a
    H[i,i] = 2*a+V[i]
print(H)
w,v = eigh(H)
#Evals = ((3/2)*(x*dx**2 * np.pi))**(2/3)
Evals = ((3.0*pi*np.sqrt(2)*dx*xn)**(2/3))/(2.0)
plt.figure(figsize=[10,10])
plt.loglog(xn,Evals)
plt.loglog(xn,w)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19922027290448344, 'fraction_numerical': 0.042884990253411304, 'mean_word_length': 4.226069246435845, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '386173', 'license': 'MIT', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1233, 'n_words': 241, 'path': 'physics/quant/BoundStates.ipynb', 'repo_name': 'soundofives/hpu-classes', 'size': '2565'}