rsolve
recurrence equation solver
Calling Sequence
Parameters
Description
Examples
rsolve(eqns, fcns)
rsolve(eqns, fcns, 'genfunc'(z))
rsolve(eqns, fcns, 'makeproc')
rsolve(eqns, fcns, 'series')
eqns
-
single equation or a set of equations
fcns
function name or set of function names
z
name, the generating function variable
The rsolve command attempts to solve the recurrence relation(s) specified in eqns for the functions in fcns, returning an expression for the general term of the function.
The first argument must be a single recurrence relation or a set of recurrence relations and boundary conditions. Any expressions in eqns, which are not equations are understood to be equal to zero. Boundary conditions should be given in consecutive values of the indices, and for the case of multiple functions, all conditions should start at the same index.
The second argument fcns indicates the functions that rsolve must solve for. A function may be represented by a name or an unevaluated function call whose argument is a name. If the function is represented by a name, the index variable for the solution is deduced from the recurrence equations. If the function is represented by an unevaluated function call, the argument name is used as the solution index. If the solution index differs from the index name in a recurrence equation, then the equation must be independent of the solution index.
If fcns is a set, the solution is returned as a set of equations. The left-hand side of each equation is the function name. Otherwise, an expression for the solution is returned.
The rsolve command can solve linear recurrences with constant coefficients, systems of linear recurrences with constant coefficients, divide and conquer recurrences with constant coefficients, many first order linear recurrences, and some nonlinear first order recurrences.
If insufficient boundary conditions are given, rsolve uses symbolic function names as default values.
For linear recurrences with constant coefficients and systems of linear recurrences with constant coefficients, if no boundary conditions are given, symbolic function calls starting with index 0 are used.
Note: A solution of a recurrence can be completely different based on the starting point of the recurrence. If output is desired in terms of symbolic function calls starting at an index different from 0, use conditions of the form u⁡i=u⁡i,u⁡i+1=u⁡i+1,... for a recurrence starting at i.
For divide and conquer recurrences, a symbolic function call at index 1 is used.
The ratio of the indices in divide and conquer recurrences must be an integer greater than 1 or a name. If the ratio is a name, it is understood to represent an integer greater than 1. It is assumed that the index variable is a non-negative power of the ratio.
Boundary conditions for linear recurrences with constant coefficients and systems of linear recurrences with constant coefficients may be specified in one of three ways:
t⁡a=c,
t⁡a..b=c,
or t⁡k=a..b=f⁡k,
- a and b are integers
- c is a constant with respect to the index variable for the sequence
- k is a name
- f⁡k is an expression of k.
The boundary condition t⁡a..b=c is equivalent to t⁡a=t⁡a+1=...=t⁡b=c and the condition t⁡k=a..b=f⁡k is equivalent to t⁡a=f⁡a,t⁡a+1=f⁡a+1,...,t⁡b=f⁡b.
The genfunc⁡z option is valid for linear recurrences with constant coefficients and systems of linear recurrences with constant coefficients. In this case, rsolve returns the generating functions of the sequences defined by eqns. The name z is used as the generating function variable.
The makeproc option is valid for any single recurrence that can be uniquely isolated (solved) for the highest indexed function. In this case, rsolve returns a procedure body for evaluating the function defined by eqns.
The series option leads to finding formal series solution using LinearFunctionalSystems[SeriesSolution]. The truncation order of the series is determined by the global variable Order.
Setting infolevel['rsolve'] := 2 provides information about the choices rsolve makes to evaluate a recurrence.
If rsolve is unable to compute a solution, it returns the unevaluated function invocation. This unevaluated rsolve invocation may be understood by other functions; for example, the asympt function is able to compute an asymptotic series expansion for the solution in some cases.
rsolve⁡f⁡n=−3⁢f⁡n−1−2⁢f⁡n−2,f⁡k
f⁡1+2⁢f⁡0⁢−1k+−f⁡1−f⁡0⁢−2k
rsolve⁡f⁡n=−3⁢f⁡n−1−2⁢f⁡n−2,f⁡1..2=1,f
f⁡n=−2n−3⁢−1n
rsolve⁡f⁡n=3⁢f⁡n2+5⁢n,f⁡n
f⁡1⁢nln⁡3ln⁡2−10⁢n+10⁢nln⁡3ln⁡2
rsolve⁡t⁡b⁢n=a⁢t⁡n+n,t⁡m
mln⁡aln⁡b⁢t⁡1+1−baln⁡mln⁡b−b+a
rsolve⁡y⁡0=1,y⁡n=n⁢y⁡n−1,y
Γ⁡n+1
rsolve⁡y⁡n⁢y⁡n−1+y⁡n−y⁡n−1=0,y⁡0=a,y
an⁢a+1
rsolve⁡y⁡n+1+f⁡n=2⁢2n+n,f⁡n+1−y⁡n=n−2n+3,f⁡5=6,y⁡k=1..5=2k−1,f,y
f⁡n=n+1,y⁡n=2n−1
rsolve⁡F⁡n=F⁡n−1+F⁡n−2,F⁡1..2=1,F,genfunc⁡x
−xx2+x−1
rsolve⁡s⁡0=0,s⁡n=s⁡n−1+t⁡n−1,t⁡0=1,t⁡n=s⁡n+t⁡n−1,s,t,genfunc⁡z
s⁡z=zz2−3⁢z+1,t⁡z=−z−1z2−3⁢z+1
rsolve⁡s⁡0=1,s⁡n=2⁢s⁡n−1,s,makeproc
procnif1<nargsthen'procname'⁡argselseexpand⁡2^nend ifend proc
An example of a recurrence having different solutions based on the starting point
rsolve⁡n⁢u⁡n+1+u⁡n,u⁡n
u⁡0n=0undefinedotherwise
rsolve⁡n⁢u⁡n+1+u⁡n,u⁡1=u⁡1,u⁡n
−−1n⁢u⁡1Γ⁡n
An example of a series solution
sys≔y2⁡x⁢x2+3⁢y2⁡x⁢x+2⁢y2⁡x−2⁢y1⁡x⁢x2−4⁢y1⁡x⁢x+y1⁡x+1⁢x2+y1⁡x+1⁢x,y2⁡x+2−y1⁡x:
vars≔y1⁡x,y2⁡x:
rsolve⁡sys,vars,series
y1⁡x=12916⁢_c13−736400⁢_c4−182480⁢_c3+13440⁢_c2+x⁢98000⁢_c4+25040⁢_c3−1732⁢_c13−1560⁢_c2+x⁢x−1⁢−7000⁢_c4−1480⁢_c3+170⁢_c13+240⁢_c2+x⁢x−1⁢x−2⁢1400⁢_c4+440⁢_c3−10⁢_c13+20⁢_c2+x⁢x−1⁢x−2⁢x−3⁢30⁢_c3+_c1+10⁢_c2+x⁢x−1⁢x−2⁢x−3⁢x−4⁢12⁢_c3+_c2+42⁢_c4+O⁡x6,y2⁡x=3600⁢_c1−604800⁢_c4−151200⁢_c3+10800⁢_c2+x⁢−2520⁢_c2+151200⁢_c4+38880⁢_c3−960⁢_c1+x⁢x−1⁢−4120⁢_c3−15400⁢_c4+338⁢_c13+240⁢_c2+x⁢x−1⁢x−2⁢1400⁢_c4+440⁢_c3−34⁢_c13+x⁢x−1⁢x−2⁢x−3⁢_c1+x⁢x−1⁢x−2⁢x−3⁢x−4⁢_c2+O⁡x6
See Also
asympt
dsolve
genfunc
LinearFunctionalSystems[SeriesSolution]
msolve
Order
solve
Download Help Document