Skip to content

Instantly share code, notes, and snippets.

@MetroWind
Created December 4, 2015 05:11
Show Gist options
  • Save MetroWind/412df0f2ce66aedc580b to your computer and use it in GitHub Desktop.
Save MetroWind/412df0f2ce66aedc580b to your computer and use it in GitHub Desktop.
Mathematica code that calculate the Lorenz attractor.
Clear[Evaluate[Context[] <> "*"]];
SetDirectory[NotebookDirectory[]];
sigma = 10;
rho = 28;
beta = 8/3;
tMax = 50;
s = NDSolve[{x'[t] == sigma*(y[t] - x[t]),
y'[t] == x[t]*(rho - z[t]) - y[t], z'[t] == x[t]*y[t] - beta*z[t],
x[0] == 1, y[0] == 1, z[0] == 1}, {x, y, z}, {t, 0, tMax},
AccuracyGoal -> 20, PrecisionGoal -> 20, WorkingPrecision -> 40,
MaxSteps -> Infinity, MaxStepSize -> 0.001]
data = Evaluate[{x[t], y[t], z[t]} /. s];
ParametricPlot3D[data, {t, 0, tMax}, PlotRange -> All,
MaxRecursion -> 8]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment