```python
%matplotlib inline
```


```python
import matplotlib.pyplot as plt
from numba import jit
from sympy import integrate, oo, var
from sympy.physics.hydrogen import R_nl
from numerov.cy.core import radial_wf as radial_wf_cy
from numerov.core import radial_wf as radial_wf_py
```

numba.jit can provide significant speed improvements (faster than cython for `radial_wf` and comparable for `radial_integral`).


```python
radial_wf_jit = jit(radial_wf_py)
```


```python
step = 0.0001
n = 10
l = 5
```


```python
offset = 0.002

fig, ax = plt.subplots()

# python
r_py, y_py = radial_wf_py(n, l, step=step)
ax.plot(r_py, y_py + 3*offset, label="py")

# jit
r_jit, y_jit = radial_wf_jit(n, l, step=step)
ax.plot(r_jit, y_jit + 2*offset, label="jit")

# cython
r_cy, y_cy = radial_wf_cy(n, l, step=step)
ax.plot(r_cy, y_cy + offset, label="cy")

# sympy
y_sympy = [R_nl(n, l, r).evalf() for r in r_cy]
ax.plot(r_cy, y_sympy, label="sympy")

ax.legend(loc=0)
plt.show()
```


```python
%timeit radial_wf_py(n, l, step=step)
```

    66.4 ms ± 359 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)



```python
%timeit radial_wf_jit(n, l, step=step)
```

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



```python
%timeit radial_wf_cy(n, l, step=step)
```

    15.3 ms ± 1.93 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)



```python
from numerov.cy.core import radial_integral as radial_integral_cy
from numerov.core import radial_integral as radial_integral_py
radial_integral_jit = jit(radial_integral_py)
```


```python
n1, l1 = 14, 1
n2, l2 = 13, 2
```


```python
# python
radial_integral_py(n1, l1, n2 ,l2, step=step)
```




    47.82964249999974




```python
%timeit radial_integral_py(n1, l1, n2 ,l2, step=step)
```

    115 ms ± 7.1 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)



```python
# numba.jit
radial_integral_jit(n1, l1, n2 ,l2, step=step)
```




    47.829642499999736




```python
%timeit radial_integral_jit(n1, l1, n2 ,l2, step=step)
```

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



```python
# cython
radial_integral_cy(n1, l1, n2 ,l2, step=step)
```




    47.82964250000002




```python
%timeit radial_integral_cy(n1, l1, n2 ,l2, step=step)
```

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



```python
# sympy
var("r")
integrate(R_nl(n1, l1, r) * r**3 * R_nl(n2, l2, r), (r, 0, oo)).evalf()
```




$\displaystyle 47.8295909083453$




```python
%timeit integrate(R_nl(n1, l1, r) * r**3 * R_nl(n2, l2, r), (r, 0, oo)).evalf()
```

    158 ms ± 3.22 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)



```python

```

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