# Animating the Lorenz Equations

I am trying to use the Animate command to vary a parameter of the Lorenz Equations in 3-D phase space and I'm not having much luck.

The equations are:

\begin{align*} \dot{x} &= \sigma(y-x)\\ \dot{y} &= rx-y-xz\\ \dot{z} &= xy-bz \end{align*}

Where $\sigma, r, b > 0$ are parameters to be varied.

Insofar, I am using the NDSolve command to numerically integrate these equations, then ParametricPlot3D and the Evaluate command to plot them.

Just for starters, I am trying to create an animate command to vary $\sigma$ for example from 0 to 10. Can anyone guide me in the right direction? My code looks like this so far:

σ = 10;

NDSolve[{x'[t] == σ (y[t] - x[t]),
y'[t] == 28 x[t] - y[t] - x[t] z[t], z'[t] == x[t] y[t] - 8/3 z[t],
x[0] == z[0] == 0, y[0] == 2}, {x, y, z}, {t, 0, 25}]

Animate[ParametricPlot3D[
Evaluate[{x[t], y[t], z[t]} /. solution], {t, 0, 25}], {σ, 0, 25},
AnimationRunning -> False]


This will generate an animated plot but obviously as σ varies, nothing is changing since I am not implementing new NDSolve commands. Can anyone guide me as to how I can implement successive NDSolve's inside the animate command? Thank you

EDIT: I am using $r=28$ and $b=\frac83$ in place of r and b in my code.

• Have a look at ParametricNDSolveValue. – b.gates.you.know.what Apr 24 '13 at 8:38
• Can I apply ParametricNDSolveValue or ParametricNDSolve to animations in 3D? – Abudin Apr 24 '13 at 9:19
• Yes, please give it a try. – b.gates.you.know.what Apr 24 '13 at 10:08
• I don't think my version of mathematica actually has those functions in them Lol.. I have mathematica 8.0, are these 9.0 commands? – Abudin Apr 24 '13 at 10:21
• Indeed, they are new in 9.0. – b.gates.you.know.what Apr 24 '13 at 10:23

You can define a solution function depending on your parameter and then use it for the animation :

sol[sigma_] := {x, y, z} /.
NDSolve[{x'[t] == sigma (y[t] - x[t]), y'[t] == 28 x[t] - y[t] - x[t] z[t],
z'[t] == x[t]*y[t] - 8/3 z[t], x[0] == z[0] == 0, y[0] == 2},
{x, y, z}, {t, 0, 25}][[1]]

Animate[
With[{f = sol[sigma]},
ParametricPlot3D[{f[[1]][t], f[[2]][t], f[[3]][t]}, {t, 0, 25}]
], {sigma, 0, 25}, AnimationRunning -> False
]

• For an animation, you probably want to set a fixed PlotRange for the ParametricPlot (unless you actually want a zoom effect) as well as include option PerformanceGoal->"Quality". – murray Apr 24 '13 at 15:11
• @murray Thanks, very good suggestions. – b.gates.you.know.what Apr 24 '13 at 15:26

If you just want to do a simple cartoon (as opposed to evaluating the solution components of the Lorenz equations at particular values), you can just directly extract the points generated by NDSolve[]. Here's one way to go about it:

sol[σ_] :=
Transpose[Through[{x, y, z}["ValuesOnGrid"] /.
First @ NDSolve[{x'[t] == σ (y[t] - x[t]),
y'[t] == 28 x[t] - y[t] - x[t] z[t],
z'[t] == x[t] y[t] - 8 z[t]/3,
x[0] == z[0] == 0, y[0] == 2}, {x, y, z}, {t, 0, 25}]]]

Animate[Graphics3D[{Red, Tube[sol[σ]]}, Axes -> True,
PlotRange -> {{-30, 30}, {-30, 30}, {0, 50}}],
{σ, 0, 25}, AnimationRunning -> False]