Maxima Function
solve_rec (eqn, var, [init])
Solves for hypergeometrical solutions to linear recurrence eqn with polynomials coefficient in variable var. Optional arguments init are initial conditions.
solve_rec
can solve linear recurrences with constant coefficients,
finds hypergeometrical solutions to homogeneous linear recurrences with
polynomial coefficients, rational solutions to linear recurrences with
polynomial coefficients and can solve Ricatti type recurrences.
Note that the running time of the algorithm used to find hypergeometrical solutions is exponential in the degree of the leading and trailing coefficient.
To use this function first load the solve_rec
package with
load(solve_rec);
.
Example of linear recurrence with constant coefficients:
(%i2) solve_rec(a[n]=a[n-1]+a[n-2]+n/2^n, a[n]); n n (sqrt(5) - 1) %k (- 1) 1 n (%o2) a = ------------------------- - ---- n n n 2 5 2 n (sqrt(5) + 1) %k 2 2 + ------------------ - ---- n n 2 5 2
Example of linear recurrence with polynomial coefficients:
(%i7) 2*x*(x+1)*y[x] - (x^2+3*x-2)*y[x+1] + (x-1)*y[x+2]; 2 (%o7) (x - 1) y - (x + 3 x - 2) y + 2 x (x + 1) y x + 2 x + 1 x (%i8) solve_rec(%, y[x], y[1]=1, y[3]=3); x 3 2 x! (%o9) y = ---- - -- x 4 2
Example of Ricatti type recurrence:
(%i2) x*y[x+1]*y[x] - y[x+1]/(x+2) + y[x]/(x-1) = 0; y y x + 1 x (%o2) x y y - ------ + ----- = 0 x x + 1 x + 2 x - 1 (%i3) solve_rec(%, y[x], y[3]=5)$ (%i4) ratsimp(minfactorial(factcomb(%))); 3 30 x - 30 x (%o4) y = - ------------------------------------------------- x 6 5 4 3 2 5 x - 3 x - 25 x + 15 x + 20 x - 12 x - 1584