LinearRecurrence[ker,init,n]
gives the sequence of length n obtained by iterating the linear recurrence with kernel ker starting with initial values init.
LinearRecurrence[ker,init,{n}]
gives the n
term
.
LinearRecurrence[ker,init,{nmin,nmax}]
yields terms nmin through nmax.
LinearRecurrence
LinearRecurrence[ker,init,n]
gives the sequence of length n obtained by iterating the linear recurrence with kernel ker starting with initial values init.
LinearRecurrence[ker,init,{n}]
gives the n
term
.
LinearRecurrence[ker,init,{nmin,nmax}]
yields terms nmin through nmax.
Details
- The ker and init can involve arbitrary symbolic expressions, as well as arrays.
- The initial list init must be at least as long as the kernel list ker.
- If init is longer than ker, only the last Length[ker] elements are used.
- LinearRecurrence[{a1,…,ad},{y1,…,yd},n] iterates the recurrence equation
with initial conditions
, …,
. - When coefficients ai and initial values yj are arrays, then the iterated recurrence is interpreted as
with dot products of values and the reversed coefficients. - If the initial values yj have dimensions {m1,…,ms} then the coefficients ai must either be scalar or must have dimensions {m1,m1}.
Examples
open all close allBasic Examples (3)
LinearRecurrence[{a, b}, {1, 1}, 5]Solve an initial-value problem for a first-order difference equation with kernel {-3, 1}:
LinearRecurrence[{-3, 1}, {7, 2}, 10]Find the first few Fibonacci numbers:
LinearRecurrence[{1, 1}, {1, 1}, 10]Table[Fibonacci[n], {n, 10}]Scope (2)
LinearRecurrence works with symbolic kernels and initial values:
LinearRecurrence[{a, b}, {c, d}, 5]LinearRecurrence works with arrays:
LinearRecurrence[{1, 1}, {{1, 2}, {2, 1}}, 10]LinearRecurrence[{{{1, 1}, {0, 1}}, {{1, 0}, {-1, 1}}}, {{1, 2}, {2, 1}}, 6]Generalizations & Extensions (2)
Applications (2)
Generate recursive sequences, including a Padovan sequence:
LinearRecurrence[{0, 1, 1}, {1, 1, 1}, 10]LinearRecurrence[{2, 1}, {0, 1}, 10]LinearRecurrence[{2, 1}, {2, 2}, 10]LinearRecurrence[{0, 1, 1}, {3, 0, 2}, 10]Efficiently compute the n
term of a linear recurrence for large n:
LinearRecurrence[{3, 2, 1, 4}, {1, -36, 9, 80}, {500}]//AbsoluteTimingLinearRecurrence[{3, 2, 1, 4}, {1, -36, 9, 80}, {500000}];//AbsoluteTimingProperties & Relations (1)
RSolve finds a symbolic solution for difference equations:
RSolve[{a[n + 2] == a[n + 1] + a[n], a[0] == 1, a[1] == 1}, a, n]Table[a[n] /. %[[1]], {n, 0, 6}]LinearRecurrence generates a procedural solution:
LinearRecurrence[{1, 1}, {1, 1}, {7}]Obtain the same result using RSolveValue:
RSolveValue[{a[n + 2] == a[n + 1] + a[n], a[0] == 1, a[1] == 1}, a[6], n]Possible Issues (1)
Neat Examples (1)
ListLinePlot[{Re[#], Im[#]}& /@ LinearRecurrence[{Exp[I Pi / Sqrt[2]], I} / 1.1, {1, 1}, 100], PlotRange -> All, AspectRatio -> Automatic]Related Guides
Related Links
Text
Wolfram Research (2008), LinearRecurrence, Wolfram Language function, https://reference.wolfram.com/language/ref/LinearRecurrence.html (updated 2017).
CMS
Wolfram Language. 2008. "LinearRecurrence." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/LinearRecurrence.html.
APA
Wolfram Language. (2008). LinearRecurrence. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LinearRecurrence.html
BibTeX
@misc{reference.wolfram_2026_linearrecurrence, author="Wolfram Research", title="{LinearRecurrence}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/LinearRecurrence.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_linearrecurrence, organization={Wolfram Research}, title={LinearRecurrence}, year={2017}, url={https://reference.wolfram.com/language/ref/LinearRecurrence.html}, note=[Accessed: 13-June-2026]}