```python
from sympy import *
init_printing()
import numpy as np
%matplotlib widget
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from scipy.integrate import solve_ivp
```


```python
Y, X = np.mgrid[-7:7:500j, -7:7:500j]

U = np.sin(X + Y)
V = X - Y
plt.streamplot(X, Y, U, V)
```


    Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …





    <matplotlib.streamplot.StreamplotSet at 0x7f8f6dd053d0>




```python
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')

def lorenz(t, X):
    # Unpack `X` into 3 coordinates
    x, y, z = X
    # Formulas for `\dot x`, `\dot y`, `\dot z`
    dx = 10 * (y - x)
    dy = x * (28 - z) - y
    dz = x * y - (8 / 3) * z
    return (dx, dy, dz)

for pt in [(0.01, 0, 0), (0, 0, 1)]:
    r = solve_ivp(lorenz, (0, 200), pt, dense_output=True)
    T = np.linspace(50, 80, 10000)
    Y = r.sol(T)
    ax.plot(Y[0], Y[1], Y[2])
```


    Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …



```python
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')

def pendulum2(t, X):
    # Unpack `X` into 4 coordinates
    x, y, z, u = X
    # Formulas for `\dot x`, `\dot y`, `\dot z`, `\dot u`
    dx = y
    dy = -x
    dz = u
    du = -z
    return (dx, dy, dz, du)

for pt in [(0.5, 0, 0, 0.5), (0, 0.5, 1, 0)]:
    r = solve_ivp(pendulum2, (0, 200), pt, dense_output=True)
    T = np.linspace(50, 80, 10000)
    Y = r.sol(T)
    ax.plot(Y[0], Y[1], Y[2])
```


    Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …



```python
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)

for pt in [(0.5, 0, 0, 0.5), (0, 0.5, 1, 0)]:
    r = solve_ivp(pendulum2, (0, 200), pt, dense_output=True)
    T = np.linspace(50, 80, 10000)
    Y = r.sol(T)
    ax.plot(Y[0], Y[2])
```


    Canvas(toolbar=Toolbar(toolitems=[('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous …


86855c7eb57ff9443cf9bf676c7c016dbe0f1206
ipynb
Jupyter Notebook
Plot_phase_portraits.ipynb
urkud/mat332-notebooks
c334255e246bdde22b6c905b38b714b92f74c8d6
MIT
Plot_phase_portraits.ipynb
urkud/mat332-notebooks
c334255e246bdde22b6c905b38b714b92f74c8d6
MIT
Plot_phase_portraits.ipynb
urkud/mat332-notebooks
c334255e246bdde22b6c905b38b714b92f74c8d6
MIT
2020-12-29T22:25:25.000Z
2020-12-29T22:25:25.000Z
Qwen/Qwen-72B
1. YES
2. YES