Hi, folks, I'm now a proud owner of a full Mathematica licence and trying to understand the language. Actually I'll understand the following, small program:
Euler[a0_, b0_, steps0_, x0_, v0_] :=
Module[{a = a0, b = b0, steps = steps0, xinit = x0, vinit = v0},
dt = (b - a)/steps;
k = 5.0;
m = 2.0;
c = 0.5;
f[{t_, x_, v_}] := v;
g[{t_, x_, v_}] := -x (k/m) - c v;
euler[{t_, x_, v_}] := {t + dt, x + dt f[{t, x, v}],
v + dt g[{t, x, v}]};
NestList[euler, {a, xinit, vinit}, steps]]
result = Euler[0, 20, 100000, 1, 1];
ListPlot[{result[[All, 2]], result[[All, 3]]}, PlotRange -> All]
I've no idea, why obviously the function values of curve 1 are stored in
result[[All, 2]] and the values of curve 2 in result[[All, 3]]. Every hints, where I can find further information ( books?) are highly appreciated! Thank you very much!
Peter