I am trying to use indexed functions in a For loop; to illustrate, I give a trivial example.
f[1, x_] := x^2
Now, I can define:
f[2,x_] := f[1,x]+x f[3,x_] := f[2,x]+x
and the results are as expected, x^2 +x and x^2 + 2x, respectively. However, when I use the For loop
For[j = 1, j < 6, j++, f[j + 1, x] := f[j, x] + x]
I get the following error message:
$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of f[j,x].
What gives? (the real function I need to work with is a parametric integral, so the := definition is necessary).