import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import pandas as pd
def lorenz(x, y , z, s=10, r=28, b=8/3):
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]
def chaos():
dt = 0.01
xyz_ini = [0.0, 10.0, 50.0]
num = 10000
xs = np.empty(num)
ys = np.empty(num)
zs = np.empty(num)
xs[0], ys[0], zs[0] = xyz_ini
for i in range(1, num):
x_dot, y_dot, z_dot = lorenz(xs[i-1], ys[i-1], zs[i-1])
xs[i] = xs[i-1] + (x_dot * dt)
ys[i] = ys[i-1] + (y_dot * dt)
zs[i] = zs[i-1] + (z_dot * dt)
fig_chaos = plt.figure()
ax = fig_chaos.add_subplot(projection='3d')
ax.plot(xs, ys, zs, lw=0.5)
plt.show()