# Lorenz System

The Lorenz system is a series of ordinary differential equations studied by MIT Professor Edward Lorenz:


\begin{align}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{align}

It is an idealized model of atmospheric convection.  \\( x \\) is proportional to the rate of convection, \\( y \\) to the horizontal temperature variation, and \\( z \\) to the vertical temperature variation. \\( \sigma \\), \\( \rho \\), \\( \beta \\) are fluid dynamic parameters. Let's plot the Lorenz attractor using these equations.

Define our imports


```python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
```

Define our `lorenz` function to model equations defined earlier.


```python
def lorenz (x, y, z, s=10, r=28, b=2.667):
    x_dot = s*(y - x)
    y_dot = r*x - y - x*z
    z_dot = x*y - b*z
    return x_dot, y_dot, z_dot
```

Finally, let's use this function to plot the Lorenz Attractor:


```python
dt = 0.01; stepCnt = 10000
xs = np.empty((stepCnt + 1,))
ys = np.empty((stepCnt + 1,))
zs = np.empty((stepCnt + 1,))
xs[0], ys[0], zs[0] = (0., 1., 1.05)

for i in range(stepCnt):
    x_dot, y_dot, z_dot = lorenz(xs[i], ys[i], zs[i])
    xs[i + 1] = xs[i] + (x_dot * dt)
    ys[i + 1] = ys[i] + (y_dot * dt)
    zs[i + 1] = zs[i] + (z_dot * dt)
    
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(xs, ys, zs, lw=0.5)
plt.title('Lorenz Attractor')
plt.show()
```


```python

```

e6976e97ad2802197e96e03a83088f77531d003b
ipynb
Jupyter Notebook
notebooks/lorenz.ipynb
Unidata/uncc-workshop-2020
472376b67632caa095483db5cb52a58505520f4d
MIT
2020-03-15T19:34:06.000Z
2020-09-07T03:48:57.000Z
notebooks/lorenz.ipynb
Unidata/uncc-workshop-2020
472376b67632caa095483db5cb52a58505520f4d
MIT
notebooks/lorenz.ipynb
Unidata/uncc-workshop-2020
472376b67632caa095483db5cb52a58505520f4d
MIT
2020-02-14T19:56:21.000Z
2020-02-14T19:56:21.000Z
Qwen/Qwen-72B
1. YES
2. YES