# RSolve and incomplete gamma function

I am interested in how Mathematica uses the incomplete gamma function to solve difference equations. For example, if we have this inhomogeneous, 2nd order equation and use RSolve:

RSolve[{(n - 2)*a[n - 2] + (n - 1)*a[n - 1] == a[n], a == 1,
a == 1} , a , n]


The solution given is:

(2 n Gamma[n] Gamma[3, -1] + 2 n Gamma[1 + n] Gamma[3, -1] -
n Gamma[n] Gamma[4, -1] - n Gamma[1 + n] Gamma[4, -1] +
2 Gamma[2 + n, -1])/(2 n (3 Gamma[3, -1] - Gamma[4, -1]))


I am wondering if there is some very general algorithm that solves recurrence relations in terms of the incomplete gamma functions, and if so, what are the conditions on the difference equation that lets us apply the theorem. Any reference would be greatly appreciated.

• The usual references are Bender-Orszag and Milne-Thomson. – J. M. will be back soon May 5 '13 at 11:41
• is a first course in difference equations and some complex analysis enough prerequisite for this material? – chartman May 6 '13 at 1:52
• I suppose. Then again, I'm self-taught with these... – J. M. will be back soon May 6 '13 at 1:58