3

Summary: I have a k-th order recurrence relation, and I need to find the terms a[n] in terms of a[0], a[1], ..., a[k-1]


Consider this recurrence relation:

2*(n+2)*(n+1)*a[n+2] + 3*(n+1)*a[n+1] + (n+3)*a[n] = 0

Since this is a second order homogeneous linear recurrence relation, each a[n] can be expressed as a linear combination of a[0] and a[1]:

a[n] = c0[n] * a[0] + c1[n] * a[1]

Where c0[n] and c1[n] are some constants. I am trying to find a[n] in the form above (having only a[0] and a[1] from the sequence).


This is how I defined the recurrence in Maxima:

rec: 2*(n+2)*(n+1)*a[n+2] + 3*(n+1)*a[n+1] + (n+3)*a[n] = 0;

eqns: makelist(''rec, n, 0, 6);

output of commands above

My current approach is setting a[0] to 0 and a[1] to 1 to find the coefficients of a[1] and vice versa:

c0 = solve(append(eqns, [a[0] = 1, a[1] = 0]));

c1 = solve(append(eqns, [a[0] = 0, a[1] = 1]));

output of commands above

This works fine, and I get the coefficients. But I wonder how I can tell Maxima that a[0] and a[1] are the unknowns, and it should find, e.g. a[2], in terms of a[0] and a[1].

Cem
  • 1,276
  • 4
  • 17
  • I found the solution after I finished writing the question, I am posting it anyways. – Cem Aug 16 '21 at 15:40

1 Answers1

3

Tell Maxima that you want to solve for a[2], a[3], ..., a[n]:

eqns: makelist(''rec, n, 0, 6);

unknowns: makelist(a[i], i, 2, 8);

solve(eqns, unknowns);

result of the commands above

Cem
  • 1,276
  • 4
  • 17