```python
from sympy import *
init_printing()
```


```python
# Example 1
```


```python
hbar, m, L, g = symbols("hbar, m, L, g", positive=True)
```


```python
n, ell = symbols('n, ell', integer=True)
```


```python
x = symbols('x', real=True)
```


```python
def phi0(x,n):
    return sqrt(2/L)*sin(n*pi*x/L)
```


```python
phi0(x,n)
```


```python
def E0(n):
    return hbar**2*n**2*pi**2/(2*m*L**2)
```


```python
E0(n)
```


```python
#first order energy corrections
def E1(n):
    return integrate(phi0(x,n)*(m*g*x)*phi0(x,n),(x,0,L))
```


```python
E1(n) # the top line is the one that counts: n neq 0
```


```python
# first order state corrections
```


```python
# first, the integrals are
integrate(phi0(x,ell)*m*g*x*phi0(x,n),(x,0,L))
# The last line is the only good one: ell neq n and both are > 0
```


```python
_15.subs(n,1)
```


```python
summation(_16,(ell,2,oo))
```


```python
str(_15)
```




    'Piecewise((0, (Eq(ell, 0) & Eq(n, 0)) | (Eq(ell, 0) & Eq(ell, n) & Eq(n, 0)) | (Eq(ell, 0) & Eq(n, 0) & Eq(ell, -n)) | (Eq(ell, 0) & Eq(ell, n) & Eq(n, 0) & Eq(ell, -n))), (-L*g*m/2, Eq(ell, -n) | (Eq(ell, 0) & Eq(ell, -n)) | (Eq(ell, n) & Eq(ell, -n)) | (Eq(n, 0) & Eq(ell, -n)) | (Eq(ell, 0) & Eq(ell, n) & Eq(ell, -n)) | (Eq(ell, n) & Eq(n, 0) & Eq(ell, -n))), (L*g*m/2, Eq(ell, n) | (Eq(ell, 0) & Eq(ell, n)) | (Eq(ell, n) & Eq(n, 0))), (4*(-1)**ell*(-1)**n*L*ell*g*m*n/(pi**2*ell**4 - 2*pi**2*ell**2*n**2 + pi**2*n**4) - 4*L*ell*g*m*n/(pi**2*ell**4 - 2*pi**2*ell**2*n**2 + pi**2*n**4), True))'




```python
Hprimeelln = 4*(-1)**ell*(-1)**n*L*ell*g*m*n/(pi**2*ell**4 - 2*pi**2*ell**2*n**2 + pi**2*n**4) - 4*L*ell*g*m*n/(pi**2*ell**4 - 2*pi**2*ell**2*n**2 + pi**2*n**4)
```


```python
sumterm = Hprimeelln/(E0(n)-E0(ell))*phi0(ell,x)
```


```python
sumterm
```


```python
with assuming((Q.nonzero(n-ell)),Q.positive(n),Q.positive(ell)):
    summation(sumterm,(ell,1,n-1))+summation(sumterm,(ell,n+1,oo))
```


```python
theta = symbols('theta', real=True)
```


```python
Hmatrix = Matrix([[cos(theta),sin(theta)/sqrt(2),0],[sin(theta)/sqrt(2),0,sin(theta)/sqrt(2)],[0,sin(theta)/sqrt(2),-cos(theta)]])
```


```python
Hmatrix
```


```python
Hmatrix.eigenvects(simplify=True)
```


```python

```


```python

```

fab078d80176c469e54833fd27923d4c7c4110c9
ipynb
Jupyter Notebook
Lecture4-ex.ipynb
corcoted/Phys475
8fc0ee6bccda19e5afff14f0e8fda6aef7ee6d66
MIT
2021-03-10T04:30:46.000Z
2021-07-12T09:20:43.000Z
Lecture4-ex.ipynb
corcoted/Phys475
8fc0ee6bccda19e5afff14f0e8fda6aef7ee6d66
MIT
Lecture4-ex.ipynb
corcoted/Phys475
8fc0ee6bccda19e5afff14f0e8fda6aef7ee6d66
MIT
Qwen/Qwen-72B
1. YES
2. YES