Tabulating Numeric Approximation

I was wondering how to approximate or tabulate values for this numeric approximation: It is the following: The confusing part is how to implement the subscripts in mathematica.

$y_{i+1} = (t_i - y_i)h + y_i$

I want to do something of the following for this numeric solution.

x[t_] = t/(1 + t^4);
data = N[Table[{t, x[t]}, {t, -5, 5}], 2];
tableofcontents = Prepend[data, {"t", "x(t)"}];
Text@Grid[tableofcontents, Alignment -> Right, Dividers -> {Center, {False, True}},
Spacings -> 1]


-
Look at RecurrenceTable[]. What are you actually trying to do, and what results are you expecting? – J. M. Apr 27 '12 at 17:32
– tkott Apr 27 '12 at 18:04
what is the definition of $h$ and $t_i$? – Sjoerd C. de Vries Apr 27 '12 at 21:05
@SjoerdC.deVries: $h=1/n$, is the step size. $t_i$, is the time steps. – night owl Apr 29 '12 at 11:29
@J.M.: Approximate a solution to the equation in order to compare with the tabulated true solution values for the same time steps. – night owl Apr 29 '12 at 11:31

I recommend you look at RecurrenceTable as J. M. suggested. However to give you an idea of how you would implement subscripts (by which I think you mean recursion) in a "normal" way, here's a simple example using the Fibonacci sequence:

f[0] = 1;
f[1] = 1;
f[n_] := f[n - 1] + f[n - 2];


For performance you would also "memoize", which just means that you store every result so that you don't have to recalculate it later:

f[0] = 1;
f[1] = 1;
f[n_] := (
f[n] = f[n - 1] + f[n - 2]
);


Notice that the f[n] = within the function is not f[n_] :=, because we aren't matching to a generic pattern and we don't need to recalculate the expression every time it's used. We're telling Mathematica that f applied to the specific value that n has at that time is whatever it calculates on the right-hand side at that time, so the usage there is like array indexing. It's the same as was done in the first two lines specifying f[0] and f[1].

And for the sake of completeness, here's the RecurrenceTable version of the Fibonacci sequence that I pulled straight out of the documentation:

RecurrenceTable[{a[n] == a[n - 1] + a[n - 2], a[1] == 1, a[2] == 1}, a, {n, 10}]

-