# How to create a sequence of functions defined recursively?

I'm trying to create a Table of functions where each new element is defined recursively via indefinite integration of the previous one. I've tried doing:

RecurrenceTable[{f[n + 1] == Integrate[f[n], x], f[0] == x}, f, {n,10}]


However I get the following output:

{x, x^2, x^3, x^4, x^5, x^6, x^7, x^8, x^9, x^10, x^11}


I've also tried doing several variations of this like:

RecurrenceTable[{f[n + 1, x] == Integrate[f[n, x], x], f[0, x] := x}, f, {n, 10}]


But it throws up an error message. I'm new to Mathematica, so any help would be appreciated.

• What's wrong with the first output you get? What were you expecting instead? And what would you like to obtain? Jun 29 at 16:00
• @MarcoB I was expecting x, x^2/2, x^3/6, etc. Jun 29 at 16:06
• Use NestList instead: NestList[Integrate[#, x] &, x, 10]. Jun 29 at 16:08
• "each new element is defined recursively via indefinite integration of the previous one" - have you already seen this? Jun 29 at 18:17

Clear["Global*"]


As suggested by Domen, use NestList

seq = NestList[Integrate[#, x] &, x, 6]

(* {x, x^2/2, x^3/6, x^4/24, x^5/120, x^6/720, x^7/5040} *)


EDIT: Alternatively, using RecurrenceTable, delay the integration

seq = RecurrenceTable[{f[n + 1] == g[f[n], x], f[0] == x}, f, {n, 6}] /.
g -> Integrate

(* {x, x^2/2, x^3/6, x^4/24, x^5/120, x^6/720, x^7/5040} *)


Then use FindSequenceFunction to generalize the result

f[n_, x_] = FindSequenceFunction[seq, n] // FunctionExpand

(* x^n/Gamma[1 + n] *)

• The formula in the MathWorld link I gave above quickly generates the required expression: Assuming[x > 0 && n > 0, Integrate[t (x - t)^(n - 1)/(n - 1)!, {t, 0, x}]]. Jun 30 at 15:00

If you use Trace, you can see what's happening. We evaluate the Integrate before solving the recurrence. So, the recurrence that actually gets used is this:

f[1 + n] == x f[n]


Another way:

f[n_, x_]:= f[n, x]= If[n==0, 1, Integrate[f[n-1, t], {t, 0, x}]];
Table[f[n, x], {n, 10}]


which gives the result:

{x, x^2/2, x^3/6, x^4/24, x^5/120, x^6/720, x^7/5040, x^8/40320, x^9/362880, x^10/3628800}
`