My salutation to Edward Lorenz, the founder of Chaos Theory. These graphs are generated through Python and SciPy. Try dumping the following codes into the IPython and have fun changing the view of the Lorenz attactor.

The following is my Python source code.

import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import odeint
import scipy
fig = plt.figure()
ax = Axes3D(fig)
#
def lorenz_int(initial, t):
x = initial[0]
y = initial[1]
z = initial[2]
#
sigma = 10
rho = 28
beta = 8.0/3
x_dot = sigma * (y - x)
y_dot = x * (rho -z) - y
z_dot = x * y - beta* z
return [x_dot, y_dot, z_dot]
#
initial = [0, 1, 1.05]
t = scipy.arange(0, 100, 0.01)
lorenz_sol = odeint(lorenz_int, initial, t)
x = [i[0] for i in lorenz_sol]
y = [i[1] for i in lorenz_sol]
z = [i[2] for i in lorenz_sol]
#
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
ax.plot(x, y, z, label="lorenz" )
ax.legend()
plt.show()

Hi! Thanks a lot for posting this. Seeing an example of scipy’s DE solver in action was very useful for me in understanding the syntax of that (rather important) function. It is good to have such a clear demonstration 3D plotting as well. And a very excellent topic, of course 🙂

My adaptations were primarily modularization; I separated defining the DE, solving it, and plotting it – this modularization allowed me to do things like generate a number of very similar initial conditions to get an ensemble of simulations and iterate over a number of values of rho values.
Take care!
Charlie

Hi! Thanks a lot for posting this. Seeing an example of scipy’s DE solver in action was very useful for me in understanding the syntax of that (rather important) function. It is good to have such a clear demonstration 3D plotting as well. And a very excellent topic, of course 🙂

I used code that I adapted from this in a recent article, in which I explain why Lorenz’s discovery of extreme sensitivity to initial conditions doesn’t mean doom for climate modelling. The article is available: http://topologicoceans.wordpress.com/2011/08/30/did-chaos-theory-kill-the-climatology-star/

My adaptations were primarily modularization; I separated defining the DE, solving it, and plotting it – this modularization allowed me to do things like generate a number of very similar initial conditions to get an ensemble of simulations and iterate over a number of values of rho values.

Take care!

Charlie

Hello Kitty.