I took a trip through sequences and recurrence relations and I got tangled up since the documentation didn't help much. I'm sure you can.
Given a sequence
s = {0, 1, 2, 5, 12, 27, 58, 121, 248, 503, 1014, 2037, 4084, 8179,
16370, 32753};
I'd like to find a recurrence relation for s
and try
fr = FindLinearRecurrence[s]
(* Out[150]= {4, -5, 2, 0} *)
Now the question: what does this list of four elements mean? How does the recurrence relation look like? I couldn't find an Explanation in the documentation.
Of course I tried what I would naturally consider the inverse, LinearRecurrence. But I even did not understand which arguments I had to put into the function.
Ok, I found a recurrence relation, but with another approach, which was a little adventurous. My question here is: how is this track to be passed correctly?
Here we go
fs = FindSequenceFunction[s]
(* Out[160]= DifferenceRoot[
Function[{\[FormalY], \[FormalN]}, {2 - \[FormalN] -
2 \[FormalY][\[FormalN]] + \[FormalY][1 + \[FormalN]] ==
0, \[FormalY][1] == 0, \[FormalY][2] == 1}]] *)
Here we can spot a recurrence relation together with initial conditions (we also replace [FormalX] by X)
eq = {2 - \[FormalN] -
2 \[FormalY][\[FormalN]] + \[FormalY][1 + \[FormalN]] ==
0, \[FormalY][1] == 0, \[FormalY][2] == 1} /. {\[FormalY] ->
y, \[FormalN] -> n}
(* Out[163]= {2 - n - 2 y[n] + y[1 + n] == 0, y[1] == 0, y[2] == 1} *)
Trying to solve it in the usual way
RSolve[eq, y[n], n]
During evaluation of In[164]:= RSolve::bvnul: For some branches of the general solution, the given boundary conditions lead to an empty solution. >>
(* Out[164]= {} *)
Again a failure! I'm not very lucky this time ...
Ok, let's RSolve the equation with only one initial condition (as it should be for a difference equation of order 1, I don`t understand the two Initial conditions under DifferenceRoot[] above):
yy[n_] = y[n] /.
RSolve[2 - n - 2 y[n] + y[1 + n] == 0 && y[1] == 1, y[n], n][[1]] //
Simplify
(* Out[206]= 1 + 2^(-1 + n) - n *)
This seems to be ok.
Table[yy[n], {n, 1, 16}]
(* Out[210]= {1, 1, 2, 5, 12, 27, 58, 121, 248, 503, 1014, 2037, 4084, 8179, 16370, 32753} *)
Except for the first term it is the case.
I'm sure all this can be done much better and shorter, and I hope you can help.
Regards, Wolfgang