I'm angry with the Lyapunov stability criteria. Consider this system:
Here, $u$ is the input and $x_1$, $x_2$ are my state variables. Now, solve for the transference of the system, defining my output as $y = x_1$:
$$Y(s) = X_1(s) = U(s) \frac{\frac{1}{s-1}}{1 + \frac{2}{s-1}} \frac{\frac{1}{s}}{1 + \frac{1}{s}} = U(s) \frac{1}{s+1} \frac{1}{s+1}$$
I got two negative poles on $s = -1$, nothing weird, a completely stable system.
Now, let's build the state equation:
$$\begin{cases}X_1 (s+1) = X_2\\ X_2 (s+1) = U\end{cases}$$ $$\begin{cases}x_1'(t) + x_1(t) = x_2(t)\\ x_2'(t) + x_2(t) = u(t)\end{cases}$$
Rearranging we got that:
$$\begin{bmatrix}x_1'(t)\\x_2'(t)\end{bmatrix} = \begin{bmatrix}-1&1\\0&-1\end{bmatrix}\begin{bmatrix}x_1(t)\\x_2(t)\end{bmatrix} + \begin{bmatrix}0\\1\end{bmatrix} u(t)$$
Now, determine stability using Lyapunov criteria. I have to find a matrix that is the solution to Lyapunov. Having $A = \begin{bmatrix}-1&1\\0&-1\end{bmatrix}$ and proposing $Q = \begin{bmatrix}1&0\\0&1\end{bmatrix}$, I run on Python the function of Scipy:
import numpy as np
from scipy import linalg
a = np.array([[-1, 1], [0, -1]])
q = np.eye(2)
m = linalg.solve_continuous_lyapunov(a, q)
e = np.linalg.eig(m)
From where I got $M = \begin{bmatrix}-0.75&-0.25\\-0.25&-0.5\end{bmatrix}$, and computing its eigenvalues I got $\lambda_1 = -0.9045085$, $\lambda_2 = -0.3454915$. Therefore, the Lyapunov matrix for this system is not definite positive, hence the system is unstable, but previously my conclusion was that the system was stable!!! What am I doing wrong?