```python
import sympy as sp
from sympy import init_printing
import numpy as np
import matplotlib.pyplot as plt

init_printing()
```


```python
# Define the system
x = (sp.Matrix([sp.symbols('q p', real = True)])).T
m, l , g = sp.symbols('m l g', real = True)
H = 1/2 * x[1]**2 / (l**2 * m) + m*g*l*sp.sin(x[0])
dH = H.diff(x)
dx = sp.Matrix([[0, 1],[-1, 0]]) * dH
dx
```


```python
# Taylor series
dx.taylor_term(1, x)
```


```python
dq = np.arange(0, 2*np.pi, np.pi/20)
dp = np.arange(-10, 10, 0.1)
DQ, DP = np.meshgrid(dq, dp)
# Make a func
dx_f = sp.lambdify((x[0], x[1]),dx.subs([(m, 1), (g, -9.81), (l, 1)]) )
```


```python
dt = sp.symbols('t')
J = (sp.eye(2) + dt*dx.jacobian(x))
J_E = J.subs(([(m, 1), (g, -9.81), (l, 1), (dt, 0.1)]) )
e1, e2 = J_E.eigenvals().items()
eigenvals_n = sp.lambdify(x[0], np.array([e1[0], e2[0]]))
```


```python
e1, e2 = eigenvals_n(dq)
plt.plot(dq, e1)
plt.plot(dq, e2)
```


```python

```

15be6f831ac1b435112bb098a2339235a8fd1ef8
ipynb
Jupyter Notebook
code/Untitled.ipynb
AlCap23/crrn_2018
17f593d35182104e1705255ac81765dc42e674f0
Unlicense
code/Untitled.ipynb
AlCap23/crrn_2018
17f593d35182104e1705255ac81765dc42e674f0
Unlicense
code/Untitled.ipynb
AlCap23/crrn_2018
17f593d35182104e1705255ac81765dc42e674f0
Unlicense
Qwen/Qwen-72B
1. YES
2. YES