Skip to content

RecurrenceTable ​

A table of the values of a sequence defined by a recurrence equation and initial conditions.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageRecurrenceTable✓
RecurrenceTable(eqns, a, {n, nmin, nmax})a(nmin),…,a(nmax)a(nmin), \dots, a(nmax), given eqnseqns: one general recurrence equation over aa plus its initial conditions.
Typed signatures
TypePackageApplies
(eqns: list<any>, a: any, spec: list<any>) -> list<any>combinatoricsalways

Domain: Collections

Details
  • eqnseqns mixes literal-index equations (initial conditions, a(1)=7a(1) = 7) with exactly one general equation whose index mentions nn (a(n+1)=3 a(n)a(n+1) = 3\,a(n), or plainly a(n)=a(n−1)+a(n−2)a(n) = a(n-1) + a(n-2)) — only a single recurrence order is supported, not a piecewise definition.
  • aa never needs to be declared as a head: it is read directly out of eqnseqns and resolved by walking the recurrence, not by evaluating a(n)a(n) as an ordinary compute-engine call.
  • See LinearRecurrence for the constant-coefficient case without writing out the equations.

Examples

Basic #

a geometric sequence

live ↗
InRecurrenceTable({a(n+1)=3a(n)a(1)=7,a,[n,1,5])\mathrm{RecurrenceTable}(\begin{cases}a(n+1)=3a(n)\\a(1)=7\end{cases}, a, \bigl\lbrack n, 1, 5\bigr\rbrack)Out[7,21,63,189,567]\bigl\lbrack7, 21, 63, 189, 567\bigr\rbrack
Scope #

the Fibonacci recurrence

live ↗
InRecurrenceTable({a(n)=a(n−1)+a(n−2)a(1)=1a(2)=1,a,[n,1,10])\mathrm{RecurrenceTable}(\begin{cases}a(n)=a(n-1)+a(n-2)\\a(1)=1\\a(2)=1\end{cases}, a, \bigl\lbrack n, 1, 10\bigr\rbrack)Out[1,1,2,3,5,8,13,21,34,55]\bigl\lbrack1, 1, 2, 3, 5, 8, 13, 21, 34, 55\bigr\rbrack
About
Examples2
Checked againstWolfram Language 2 agree
CrosswalkWolfram Language

See also: LinearRecurrence, Fibonacci