I would like to have a series of functions that depend one another, indexed by a number, and that are defined via a Do loop. However, Mathematica seems unable to replace the index in the loop. My trial code:
Do[
If[i == 1,
ff[i, x_, y_] := x + y;,
ff[i, x_, y_] := (x - y)*ff[i - 1, x, y];
];
, {i, 1, 2}];
ff[2, x, y]
Output: (x - y) ff[-1 + i, x, y]
Desired output is however: (x - y)(x + y)
This thing surprises me since if I manually define
ff[2, x_, y_] := (x - y)*ff[1, x, y];
then I get the desired output. It seems that the Do loop is not replacing inside the function.
Is this normal? :-o