<jupyter_start><jupyter_text>Introduction Consider the following 2nd order system (Mass-Damper-Spring):$\ddot{x} + \dot{x} = 3x + x^2 = 0 \Longleftrightarrow \ddot{x} + c \dot{x} + f(x) = 0$$c$ is the dampening force and $f(x)$ is the non-linear spring.   The system can be placed into the $\dot{\underline{x}} = \underline{f}(\underline{x})$ form:$\begin{cases}    \dot{x}_1 = x_2 \\    \dot{x}_2 = -3x_1 - x_1^2 - x_2\end{cases}$  Analysis of the system: ManualAnalysis of the system $\Rightarrow$ Phase Plane $(x_1, x_2)$:  Step 1: Find the Equillibrium Points:$\begin{cases}    f_1(x_1, x_2) = 0 \\    f_2(x_2, x_2) = 0\end{cases} \Rightarrow\begin{cases}    x_2 && = 0 \\    -3x_1 - x_1^2 - x_2 && = 0 \, \Rightarrow \, -3x_1 - x_1^2 = 0\end{cases}$$\begin{cases}    x_2 = 0 \\    x_1(-3 - x_1) = 0\end{cases} \Rightarrow$ 2 equillibrium points $\Rightarrow\begin{cases}    \underline{x}_1 = [0, 0]^T \\    \underline{x}_2 = [-3, 0]^T\end{cases}$  Step 2: Linearize the System Around the Equillibrium Points:$\displaystyle\dot{\underline{x}} = \underline{f}(\underline{x}) \Rightarrow \approx \underline{f}(\underline{x}^*) + \left . \frac{\partial \underline{f}}{\partial \underline{x}} \right |_{\underline{x}^*} (\underline{x} - \underline{x}^*)$$\displaystyle A = \left . \frac{\partial\underline{f}}{\partial\underline{x}} \right |_{\underline{x}_{1, \, 2}^*} = \begin{bmatrix}    0 && 1 \\    -3 - 2x_1 && -1\end{bmatrix}_{\underline{x}_1^*, \, \underline{x}_2^*}$  For $\underline{x} = \underline{x}_1$ We have the following system:$\dot{\underline{x}} = A_1 \underline{x} \Rightarrow A_1 = \begin{bmatrix}    0 && 1 \\    -3 && -1\end{bmatrix}$Look for the behavior of the system near $\underline{x}_1 = \underline{0}$.  e-value analysis:$\det (A_1 - \lambda I) = \begin{vmatrix}    -\lambda && 1 \\    -3 && -1 - \lambda\end{vmatrix}= \lambda \big(\lambda + 1\big) + 3 = 0$$\Rightarrow \lambda^2 + \lambda + 3 = 0 \Rightarrow \lambda_{12} = -\frac{1}{2} \left( 1 \pm \sqrt{1 - 12}\right) = -\frac{1}{2} \left( 1 \pm \sqrt{11} j\right)$  For $\underline{x} = \underline{x}_2$We have the following system:$\dot{\underline{x}} = A_2 \underline{x} \Rightarrow A_2 = \begin{bmatrix}    0 && 1 \\    3 && -1\end{bmatrix}$Look for the behavior of the system near $\underline{x}_2 = \underline{0}$.  e-value analysis:$\left|(A - \lambda I ) \right| = \begin{vmatrix}    -\lambda && 1 \\    3 && -1 - \lambda\end{vmatrix} = 0$$\Rightarrow \lambda \left(\lambda + 1 \right) - 3 = 0 \Rightarrow \, \lambda^2 + \lambda - 3 = 0$$\lambda = -\frac{1}{2} \left ( 1 \pm \sqrt{1 + 12} \right) = - \frac{1}{2} \pm \frac{1}{2} \sqrt{13}$Note that both solutions of $\lambda$ are REAL!  Therefore:$\begin{matrix}    \lambda_1 = -\frac{1}{2} \left( 1 - \sqrt{13} \right ) > 0 \\    \lambda_2 = -\frac{1}{2} \left( 1 + \sqrt{13} \right ) < 0\end{matrix} \Rightarrow \text{ Unstable } \Rightarrow \underline{\text{Saddle Point}}$Compute the e-vectors $\underline{v}_1,\, \underline{v}_2$ to determine the direction of convergence  Step 3: Put Everything Together:  !!!!! TODO: Insert Graphic !!!!!  Analysis of the System: Python Given that:$\begin{cases}    \dot{x}_1 = f_1(x_1, x_2) = x_2 \\    \dot{x}_2 = f_2(x_2, x_2) = -3x_1 - x_1^2 - x_2\end{cases}$We can define two variables to these functions:<jupyter_code>f_1 = x_2
f_2 = -3 * x_1 - x_1 ** 2 - x_2<jupyter_output><empty_output><jupyter_text>We can solve the system of equations using the `solve` function.<jupyter_code>slns = sp.solve([f_1, f_2])
slns<jupyter_output><empty_output><jupyter_text>We get the same solutions that we found previously.   To linearize the system, we need to take the derivatives of each function with respect to $x_1$ and $x_2$.  We'll compile this into a matrix A_1 like so:<jupyter_code>A = sp.Matrix([[sp.diff(f_1, x_1), sp.diff(f_1, x_2)], [sp.diff(f_2, x_1), sp.diff(f_2, x_2)]])
A<jupyter_output><empty_output><jupyter_text>Now we let $\dot{\underline{x}} = A_1 \, \underline{x}$.  Therefore `A_1` would be:<jupyter_code>A_1 = sp.Matrix([[0, 1], [-3, -1]])
A_1<jupyter_output><empty_output><jupyter_text>Next we find the determinate of $A_1 - \lambda I$<jupyter_code>λ_fun = sp.det(A_1 - λ * sp.eye(2))
λ_fun
sp.solve(λ_fun)<jupyter_output><empty_output><jupyter_text>Analysis of the System: Numpy Meshgrid<jupyter_code>import numpy as np
from matplotlib import pyplot as plt
x1, x2 = np.meshgrid(np.linspace(-.5, .5, 10), np.linspace(-.5, .5, 10))
x1dot = x2
x2dot = -3 * x1 - x1 ** 2 - x2
plt.figure()
plt.quiver(x1, x2, x1dot, x2dot)
plt.show()
@widgets.interact (
    x_start=(-10.0, 10.0, 0.1), 
    x_stop=(-10.0, 10.0, 0.1), 
    y_start=(-10.0, 10.0, 0.1), 
    y_stop=(-10.0, 10.0, 0.1), 
    space=(10, 50)
)
def inter_plot(x_start, x_stop, y_start, y_stop, space):
    x1, x2 = np.meshgrid(np.linspace(x_start, x_stop, space), np.linspace(y_start, y_stop, space))
    x1dot = x2
    x2dot = -3 * x1 - x1 ** 2 - x2
    plt.figure()
    plt.quiver(x1, x2, x1dot, x2dot)
    plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19652486518873577, 'fraction_numerical': 0.05172758138605952, 'mean_word_length': 3.6586046511627908, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '180243', 'license': 'MIT', 'n_tokens_mistral': 2101, 'n_tokens_neox': 1977, 'n_words': 490, 'path': '01a - Example of Phase-Plane Analysis.ipynb', 'repo_name': 'mertzjames/Linear-Systems-Theory', 'size': '5007'}