```python
%matplotlib inline
```


```python
import numpy as np
import matplotlib.pyplot as plt
from sympy.physics.hydrogen import R_nl
from numerov import radial_wf
```


```python
n, l = 15, 1
```


```python
offset = 0.002

#plot
fig, ax = plt.subplots(1, 2, figsize=(10, 4))

# numerov
for i, step in enumerate([0.001, 0.01, 0.05]):
    r, y = radial_wf(n, l, step=step)
    ax[0].plot(r, offset * (i + 1) + y, label=step)
    ax[1].plot(r, offset * (i + 1) + (r * y)**2.0, label=step)

# textbook
num_points = 500
r0 = np.linspace(0, r.max(), num_points)
y0 = np.array([R_nl(n, l, x) for x in r0])
ax[0].plot(r0, y0, label='sympy')
ax[1].plot(r0, (r0 * y0)**2.0, label='sympy')

ax[0].set_xlabel(r'$r$')
ax[0].set_ylabel(r'$R_{n, l}$')
ax[1].set_xlabel(r'$r$')
ax[1].set_ylabel(r'$r^2 |R_{n, l} |^2$')
ax[1].legend()
plt.tight_layout()
plt.show()
```


```python
n = 15; l = 2
offset = 0.002

#plot
fig, ax = plt.subplots()

# numerov
r, y = radial_wf(n, l, step=0.001)
ax.plot(r, (r * y)**2.0, label="numerov")

# textbook
y0 = np.array([R_nl(n, l, x) for x in r])
ax.plot(r, (r * y0)**2.0, label='sympy')

ax.set_xlabel(r'$r$')
ax.set_ylabel(r'$r^2 |R_{n, l} |^2$')
ax.legend()
plt.show()
```


```python
# sympy
%timeit np.array([R_nl(n, l, x) for x in r])
```

    19.7 s ± 1.19 s per loop (mean ± std. dev. of 7 runs, 1 loop each)



```python
# numerov
%timeit radial_wf(n, l, step=0.001)
```

    1.56 ms ± 113 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)



```python
%timeit radial_wf(n, l, step=0.0001)
```

    15.9 ms ± 63.1 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)



```python

```

f6e7b93767813597add8cb2e8e41bc57706be50b
ipynb
Jupyter Notebook
notebooks/wavefunction.ipynb
ad3ller/numerov
78453cf66d0f300225e507daf9e4aeed5b9af5b9
BSD-3-Clause
2020-12-01T21:01:58.000Z
2020-12-01T21:01:58.000Z
notebooks/wavefunction.ipynb
ad3ller/numerov
78453cf66d0f300225e507daf9e4aeed5b9af5b9
BSD-3-Clause
notebooks/wavefunction.ipynb
ad3ller/numerov
78453cf66d0f300225e507daf9e4aeed5b9af5b9
BSD-3-Clause
Qwen/Qwen-72B
1. YES
2. YES