# Solving recurrent function with 2 variables

My understanding of Mathematica is very limited since I just started using it, I would appreciate any feed back or help.

I am trying to find the closed form of a recurrent function with 2 variables:

A[n_,k_] := 1/n*Sum[A[n-i, k-1], {i,1,n}];
A[0,1] :=0;
A[0,k_]:=0;
A[n_, 1] :=1/n;


I tried doing it using RSolve:

RSolve[{
a[n,k] == (1/n)*Sum[a[n-i, k-1], {i,1,n}],
a[0,1]==0,
a[0,k] ==0,
a[n,1]==1/n},
a[n,k], {n, k}]


But i just get as a response the RSolve input: http://imgur.com/a/T1TMH

Am I doing the RSolve equation correctly or am I missing something out here?

• Try this again in a fresh kernel; it seems you had old definitions hanging around. – J. M. is away Dec 22 '16 at 1:33
• Thanks for you reply! I tried that and now I don't get the recurrsion error. Although when i enter the RSolve, the output I get is the same RSolve formula again. Not the closed form. – t0m9er Dec 22 '16 at 9:39
• It means RSolve[] has no idea what to do; sadly, for partial difference equations, this seems to be par for the course. – J. M. is away Dec 22 '16 at 12:38
• There goes my hope! Thanks for the help though :) – t0m9er Dec 22 '16 at 13:33

Here is the recursion with seems to work

A[n_][k_] :=
A[n][k] = If[k > 1, 1/n*Sum[A[n - i][k - 1], {i, 1, n}], 1/n];
A[0][1] := 0;
A[0][k_ /; k > 1] := 0;


I have tried with

A[5][1]
A[100][2]


which gives

1/5

and

360968703235711654233892612988250163157207/\ 6972037522971247716453380893531230355680000

with

A[1000][5]

it's also working --- it gives 0.110791.

You can test or play with your recursion like this :

p = Table[N[A[500][i]], {i, 1, 20}]
q = Table[N[A[i][3]], {i, 1, 20}]


• Thanks for the help! I tried using the if clause inside the RSolve: imgur.com/a/T1TMH But got the same result. Is that were you were referring to? or am I doing it wrong? – t0m9er Dec 22 '16 at 17:03
• Sorry I have seen an error but to be able to correct It I must close my kernel and I cannot do it right now I will come back to this point later. – cyrille.piatecki Dec 22 '16 at 17:54
• Thanks a lot! I would really appreciate it! – t0m9er Dec 22 '16 at 19:50
• I have corrected the code. It seems to work properly. But it will be advised to test manually for small values. – cyrille.piatecki Dec 22 '16 at 21:09
• Hey! Thanks for the corrected code. I can now play with the recursion, but I am looking for a closed form of the equation. You have any idea how to get to the closed from using the formula? I think usually RSolve does it in Mathematica, but it doesn't seem to work for me. – t0m9er Dec 22 '16 at 21:25

It turns out this recurrent function have been researched before. It can be solved by: $$\frac{S(n,k)}{n!}$$ Where $S(n,k)$ is Sterling number of the first kind: https://en.wikipedia.org/wiki/Stirling_numbers_of_the_first_kind The Stirling numbers of the first kind have known generating functions and are much more researched.

@Sil deserves the credit for finding it.