Are you not satisfied with difference root objects? I think that @belisarius has given the most general solution. If you want to give your sequence values and see how it behaves there's no reason to use RSolve
. You can define the n-th term recursively and build the sequence from the bottom up (in what follows, I changed l
to q
):
ClearAll[a, g, data, data2, plot, an6];
a[n_] := If[n >= q,
((1 + n - q) (q + (-1 + n) (n - q) a[-1 + n] + 2 (n - q) a[n - q]))/
n,
0]
Now you can generate a few terms and watch a
grow:
data = Table[Table[{q, k, Log[a[k]]}, {q, 1, k}], {k, 1, 16}];
where I take the logarithm because it grows too fast and I want to plot it. Here's how (the logarithm of) your sequence looks for the first few n
, q
:
plot = ListPointPlot3D[Flatten[data, 1]]
If you are after solutions for large n
and small q
s the following might be a bit quicker than @belisaruis's:
g[q_] := b[n] /.
RSolve[{b[n] == ((1 + n - q) (q + (-1 + n) (n - q) b[-1 + n] + 2 (n - q) b[n - q]))/n,
b[q] == 1},
b[n], n]
but for every g[n]
it needs n-1
additional values to determine an equal number of constants. So
g[1]
evaluates to
(*out*){(1/(n! (2 + n)!))
2 (BesselI[2, 2] n! (2 + n)! -
HypergeometricPFQ[{1}, {1 + n, 3 + n}, 1]) Pochhammer[
1, -1 + n] Pochhammer[3, -1 + n]}
but
g[2]
evaluates to a difference root object with one constant. The point here is that you have another constant to determine for every increment of q
. So I can use my a[n]
above to determine the constants at every step:
data2 = Table[Table[a[k], {q, 1, k}], {k, 1, 17}];
which gives a table like the ones described in other answers. Now, say
an6 = First@With[{q = 6},
g[q] /. Thread[
C /@ Range[q - 1] -> data2[[q + 1 ;; 2 q - 1, q - 1]]]]
gives you a difference root object for q=6
and any n
$\geq$q
. The last bit is a set of rules that replaces the constants based on the table of values data2
above. This is exactly where the problem lies: the higher the q
the more constants you need and my function a[n]
gets quite slow for larger n
, q
so this essentially transposes the problem with speed to generating values to replace the constants. As I said, I don't think you can do anything more general than what @belisarius did. But if you care for the first few q
s this might be more viable as you have a difference root object for any n
given a q
so in my example for q=6
above, you can go to any n
:
Show[ListPointPlot3D[Table[{6, n, Log[an6]}, {n, 1, 35}],
PlotStyle -> Red], plot,
PlotRange -> All]
Using data2
you can do the same thing for q
between 1 and 9 and this will definitely be fast the more n
grows.
RSolve[]
$\endgroup$a[n]
for anyl
? $\endgroup$a[n]
forl=2
? I don't know how to link the second equation to the first. $\endgroup$