i am trying to implement a recursive difference equation step by step, by implementing rules, similar to Rojo's method in this thread: How can I evaluate only a single step of a recursive function?
But the rules are not applied to my function, I think because it contains more than one variable. This is important for the answer, since one of the variables is integrated over. The other variable is decremented, which is what I want to iterate step-wise:
Clear[f, frules];
frules = {f[n_, x_] -> (n - 1) x^n Cos[x] f[n - 1, x] + Integrate[Sin[x] f[n - 1, x], x]};
f[3] /. frules
f[3] /. frules /. frules
f[m] /. frules
This just gives $f[3]$, or $f[m]$, without implementing the recursion.
I'm specifically interested in the symbolic expressions after 1,2,...p steps. How to start from a given integer value $m$ and write the expression after $p$ decrements of 1?
The mathematical expression should be well posed because I can incrementally increment the function, with a given starting value:
f[n_, x_] := (n - 1) x^n Cos[x] f[n - 1, x] + Integrate[Sin[x] f[n - 1, x], x]
f[0, x] = 1;
Gives well defined functions for f[1], f[2], f[3], etc. E.g. $f[1] = -Cos[x]$ , $f[2] = \frac{1}{2} (1 - 2 x^2) Cos[x]^2 $ , etc.