# Plot Lorenz system

I solved the Lorenz system by using Euler forward method (without using NDSolve). But I am not getting the attractor. The Mathematica code is as follows

Clear[x, y, z]
x[0] = 0; y[0] = 1; z[0] = 0;
Do[x[n + 1] = x[n] + .01 ( -3 ( x[n] - y[n])), {n, 0, 100}]
Do[y[n + 1] = y[n] + .01 (-x[n] z[n] + 28 x[n] - y[n]), {n, 0, 100}]
Do[z[n + 1] = z[n] + .01 (x[n] y[n] - z[n]), {n, 0, 100}]
Plot[{z[n], y[n], z[n]}, {n, 0, 100}]


• Greetings! Make the most of Mma.SE and take the tour now.Choose a meaningful name. Help us to help you, write an excellent question. Edit if improvable, show due diligence, give brief context, include minimum working examples of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. Oct 1 '15 at 6:56
• Your Plot command does not contain x[n] but instead has z[n] twice. Oct 1 '15 at 7:06

Another version:

euler[{x_, y_, z_}] :=
{x + .01 (-3 (x - y)),y + .01 (-x z + 28 x - y),z + .01 (x y - z)}

steps = 1000;
init = {0, 1, 0};

sol = NestList[euler, init, steps];

(* ListLinePlot[Transpose@sol] *)
p = Interpolation /@ Transpose@sol;
Plot[Evaluate@Through@p@x, {x, 1, 1000}]


Edit (@belisarius comment)

ParametricPlot3D[
Through@p@x, {x, 1, 1000},
PlotPoints -> 1000,ColorFunction -> (Hue[#4] &)]


Edit 2

The OP works with Mathematica $5.0$. In this version the procedures ListLinePlot and ListPlot[..., Joined->true]are not introduced. With this edit it should work.

• For your second plot probably p = Interpolation /@ Transpose@sol; ParametricPlot3D[ Through@p@x, {x, 1, 1000}] is cleaner Oct 1 '15 at 9:03
• @belisarius Thank you, I edit this.
– user31001
Oct 1 '15 at 9:11
• Thank You. I have Mathematica 5. Is this run the above code. I am copy the code and run... they are shown some error... Oct 2 '15 at 9:13
• @G Velmurugan It works with Mathematica 10.2 perfectly. I don't have Mathematica 5 and cannot help further.
– user31001
Oct 2 '15 at 9:58
• @G Velmurugan I have made an edit, so it should work in Mathematica 5.0. Unfortunately I can not test it.
– user31001
Oct 2 '15 at 13:16

Try this

Clear[x, y, z]

x[n_] := x[n] = x[n - 1] + .01 (-3 (x[n - 1] - y[n - 1]))
y[n_] := y[n] = y[n - 1] + .01 (-x[n - 1] z[n - 1] + 28 x[n - 1] - y[n - 1])
z[n_] := z[n] = z[n - 1] + .01 (x[n - 1] y[n - 1] - z[n - 1])

x[0] = 0;
y[0] = 1;
z[0] = 0;

limitN = 1000;
resAll = Table[{x[n], y[n], z[n]}, {n, 0, limitN}];

ListLinePlot[{resAll[[;; , 1]], resAll[[;; , 2]], resAll[[;; , 3]]},
PlotLegends -> {"x[n]", "y[n]", "z[n]"},
PlotLabel -> "n=" <> ToString[limitN]]


• Thank You. I have Mathematica 5. Is this run the above code. I am copy the code and run... they are shown some error... Oct 2 '15 at 9:13
• @GVelmurugan Yes, it's the code for the shown plot. I don't get an error with version 10. What error do you get?
– Phab
Oct 2 '15 at 9:22
• Thank You Phab. I have download Mathematica 9 and install it. Now the code is works. Further, any query I will contact. Oct 3 '15 at 4:50