Values of a recurrence relation or a system: seqsolve

### 5.14.2 Values of a recurrence relation or a system: seqsolve

See also section 5.14.3.

The seqsolve command takes three arguments; an expression or list of expressions that define a recurrence relation, the variables used, and the starting values. For example, if a recurrence relation is defined by un+1 = f(un,n) with u0 = a, the arguments to seqsolve will be f(x,n), [x,n] and a. If the recurrence relation is defined by un+2 = g(un,un+1,n) with u0 = a and u1 = b, the arguments to seqsolve will be g(x,y,n), [x,y,n] and [a,b]. The recurrence relation must have a homogeneous linear part, the nonhomogeneous part must be a linear combination of a polynomials in n times geometric terms in n.
seqsolve returns the sequence, as a function of n.

Examples:

- To find un, given that un+1 = 2un + n and u0=3: Input:
  seqsolve(2x+n,[x,n],3)
  Output:
  -n-1+4*2^n
- To find un, given that un+1 = 2un + n 3n and u0=3: Input:
  seqsolve(2x+n*3^n,[x,n],3)
  Output:
  (n-3)*3^n+6*2^n
- To find un, given that un+1 = un + un−1, u0 = 0 and u1=1: Input:
  seqsolve(x+y,[x,y,n],[0,1])
  Output:
  (5+sqrt(5))/10*((sqrt(5)+1)/2)^(n-1)+ (5-(sqrt(5)))/10*((-sqrt(5)+1)/2)^(n-1)
- To find un and vn, given that un+1=un + 2vn, vn+1 = un + n + 1 with u0 = 1, v0 = 1:
  Input:
  seqsolve([x+2*y,n+1+x],[x,y,n],[0,1])
  Output:
  [(-2*n-(-1)^n+4*2^n-3)/2,((-1)^n+2*2^n-1)/2]