# How can I express this recurrence function in Mathematica?

\begin{equation} r_{i+1}=r_{i}+V_{i}{\Delta}t \end{equation}

Where \begin{equation} V_{i}=(0.01, 0.40) \end{equation} and ${\Delta}t$ is the difference in time.

My implementation (this is for ${\Delta}t$ = 1):

V = {0.01, 0.4};
list = List[Do[Print[V*t], {t, 1, 10}]];

* $RecursionLimit::reclim: Recursion depth of 1024 exceeded. *  This generates the correct values but I can't change${\Delta}t\$ and the values aren't stored as a list (for use with ListPlot[...]).

I have tried other implementations such as r[t_]=r[t]+V*t and r[t_+1]=r[t]+V*t but this didn't work.

• I would suggest using RecurrenceTable - it's designed for this purpose, but sadly it doesn't support vector-valued recurrence equations as gracefully as it should... – kirma Mar 8 '15 at 6:51

With

v = {0.01, 0.4};


you can define

r[n_, dt_] := r[n, dt] = r[n - 1, dt] + v dt
r[0, dt_] = {0, 0}


Now

Table[r[n, 1], {n, 1, 10}]

{{0.01, 0.4}, {0.02, 0.8}, {0.03, 1.2}, {0.04, 1.6}, {0.05, 2.}, {0.06, 2.4}, {0.07, 2.8},
{0.08, 3.2}, {0.09, 3.6}, {0.1, 4.}}


and

Manipulate[
ListPlot[Table[r[n, deltat], {n, 1, 10}], PlotRange -> 20],
{{deltat, 1, "Δt"}, 0, 5}] You can also use NestList:

tbl[v_, delta_, n_, init_: {0, 0}] := NestList[# + v delta &, init, n]

tbl[v, 1, 10]
(* {{0, 0}, {0.01, 0.4}, {0.02, 0.8}, {0.03, 1.2}, {0.04, 1.6},
{0.05, 2.}, {0.06, 2.4}, {0.07, 2.8}, {0.08, 3.2}, {0.09, 3.6}, {0.1, 4.}} *)