DifferenceRoot[lde][k]
gives the holonomic sequence
, specified by the linear difference equation lde[h,k].
DifferenceRoot[lde]
represents a pure holonomic sequence
.
DifferenceRoot
DifferenceRoot[lde][k]
gives the holonomic sequence
, specified by the linear difference equation lde[h,k].
DifferenceRoot[lde]
represents a pure holonomic sequence
.
Details
- Mathematical sequence, suitable for both symbolic and numerical manipulation; also known as holonomic sequence and P-recursive sequence.
- The holonomic sequence
defined by a DifferenceRoot function satisfies a holonomic difference equation
with polynomial coefficients
and initial values
. - DifferenceRoot can be used like any other mathematical function.
- FunctionExpand will attempt to convert DifferenceRoot functions in terms of special functions.
- The sequences representable by DifferenceRoot include a large number of special sequences.
- DifferenceRootReduce can convert many special sequences to DifferenceRoot sequences.
- Holonomic sequences are closed under many operations, including:
-
, 
constant multiple, integer power
, 
sums and products 
discrete convolution
,
, 
discrete shift, difference and sum - DifferenceRoot is automatically generated by functions such as Sum, RSolve and SeriesCoefficient.
- Functions such as Sum, DifferenceDelta and GeneratingFunction work with DifferenceRoot inputs.
- DifferenceRoot automatically threads over lists.
Examples
open all close allBasic Examples (2)
Define f to be the Fibonacci sequence:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] + y[n], y[0] == 0, y[1] == 1}]]Calculate the 20th Fibonacci number:
f[20]Compare the result with the built-in Fibonacci function:
Fibonacci[20]Plot the first 10 Fibonacci numbers:
DiscretePlot[f[n], {n, 0, 10}]Several functions can produce closed-form answers by using DifferenceRoot functions:
Sum[(n + 4)!2 ^ n, n]RSolve[y[n + 3] + n y[n + 2] + y[n] == n! && y[0] == y[1] == y[2] == 1, y[n], n]SeriesCoefficient[Exp[(1/x^2 + 1)], {x, 0, n}]Scope (21)
Numerical Evaluation (6)
Define a DifferenceRoot sequence:
f = DifferenceRoot[Function[{y, n}, {y[n + 1] == (n + 1)y[n], y[1] == 1}]]Evaluate at an arbitrary point:
f[20]Evaluate sequences with inexact coefficients:
f = DifferenceRoot[Function[{y, n}, {3.5 y[n + 1] == (n + 1)y[n], y[1] == 1}]][{3, 5, 10}]Evaluate sequences with complex coefficients:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] - (n + 1)y[n], y[0] == 1 + 2I, y[1] == -3 + 2I}]][4]Evaluate sequences with parameters:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == x y[n + 1] - (n + 1)y[n], y[0] == 1, y[1] == -3}]][4]Evaluate sequences for negative terms:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] - y[n], y[0] == 1, y[1] == 1 / 3}]][-5]DifferenceRoot threads elementwise over lists and matrices:
DifferenceRoot[Function[{y, n}, {y[n + 1] / (n + 1) - y[n] == 0, y[0] == 0, y[1] == 1}]][{1, 2, 3, 4, 5}]DifferenceRoot[Function[{y, n}, {y[n + 1] / (n + 1) - y[n] == 0, y[-1] == 1, y[1] == 1}]][(| | |
| :- | :- |
| 3 | -1 |
| -2 | 6 |)]Visualization (2)
Define a DifferenceRoot object called f:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] - 1 / 2y[n], y[0] == 0, y[1] == 1}]]DiscretePlot[f[n], {n, 0, 15}]Plot the first 25 terms of f using ListLinePlot:
ListLinePlot[Table[f[n], {n, 1, 25}], PlotRange -> All]Define a DifferenceRoot object f where the parameter a may be arbitrary:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == a y[n + 1] - 1 / 2y[n], y[0] == 0, y[1] == 1}]]Plot the sequence f for different values of the parameter a:
DiscretePlot3D[f[n], {n, 3, 10}, {a, -1, 1, 1 / 10}, AxesLabel -> Automatic]Function Properties (9)
DifferenceRoot works with linear recurrences:
DifferenceRoot[Function[{y, n}, {y[n + 1] - n y[n] == 0, y[0] == 0, y[1] == 1}]]DifferenceRoot transforms recurrences with rational coefficients to ones with polynomial coefficients:
DifferenceRoot[Function[{y, n}, {y[n + 1] / (n + 1) - y[n] == 0, y[0] == 0, y[1] == 1}]]Inhomogeneous recurrences are transformed to higher-order homogeneous recurrences:
DifferenceRoot[Function[{y, n}, {y[n + 1] - n y[n] == n!, y[1] == 1}]]DifferenceRoot works on inhomogeneous equations with polynomial forcing functions:
f = DifferenceRoot[Function[{y, n}, {y[n + 1] - y[n] == n ^ 2, y[0] == 0, y[1] == 1}]]Calculate the first 10 terms of this sequence:
Table[f[n], {n, 1, 10}]DifferenceRoot works with multiple initial values:
DifferenceRoot[Function[{y, n}, {-n y[n] + (1 + n)y[1 + n] == 0, y[-1] == 0, y[1] == 1}]]Difference function for a series with symbolic components:
DifferenceRootReduce[Fibonacci[n, x], n]Table[%, {n, 10}]Find the leading asymptotic term of a DifferenceRoot object as
approaches Infinity:
f = DifferenceRoot[Function[{y, n}, {y[n + 1] - n ^ 2 y[n] == 0, y[1] == 1}]][n]DiscreteAsymptotic[f, n -> ∞]Obtain the same result using AsymptoticRSolveValue:
AsymptoticRSolveValue[{y[n + 1] - n ^ 2 * y[n] == 0, y[1] == 1}, y[n], n -> ∞]DifferenceRoot can take parameters:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == a y[n + 1] - 1 / 2y[n], y[0] == 0, y[1] == 1}]]Calculate the first 5 terms of this sequence for symbolic a:
Table[f[n], {n, 1, 5}]% /. a -> -1 / 10Plot the sequence f for different values of the parameter a:
DiscretePlot3D[f[n], {n, 2, 10}, {a, -1, 1, 1 / 10}, AxesLabel -> Automatic]If possible, DifferenceRoot reduces to built-in functions:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] + y[n], y[0] == 0, y[1] == 1}]]FullSimplify[f[n]]Special Sequences (3)
Difference equation form of Fibonacci:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] + y[n], y[0] == 0, y[1] == 1}]]FullSimplify[f[n]]Difference equation form of LucasL:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] + y[n], y[0] == 2, y[1] == 1}]]FullSimplify[f[n]]Difference equation form of HarmonicNumber:
f = DifferenceRoot[Function[{y, n}, {(n + 1)y[n + 1] == (n + 1) y[n] + 1, y[0] == 0}]]FullSimplify[f[n]]Differentiation (1)
Generate a parametric sequence corresponding to ChebyshevT polynomials:
ChebTSequence = DifferenceRootReduce[ChebyshevT[n, x], n]Calculate the derivative of this sequence wrt to parameter:
dChebTSequence = D[ChebTSequence, x]Extract the difference equation that the derivatives of ChebyshevT obey:
%[[0, 1]][y, n]Check the equality of the first 10 terms of this sequence with the direct derivatives of ChebyshevT:
Table[Expand[dChebTSequence == D[ChebyshevT[n, x], x]], {n, 0, 10}]Generalizations & Extensions (2)
Equations with holonomic constant terms are automatically lifted to polynomial coefficients:
DifferenceRoot[Function[{y, n}, {y[n + 1] - y[n] == n!, y[0] == 1}]]The following function is not defined for n>0:
f = DifferenceRoot[Function[{y, n}, {n y[1 + n] + (-1 + n) y[n] == 0, y[-1] == -1}]];Table[f[n], {n, -2, 2}]Add the initial value y[1]=2 so that it is defined for all n:
g = DifferenceRoot[Function[{y, n}, {n y[1 + n] + (-1 + n) y[n] == 0, y[1] == 2, y[-1] == -1}]];Table[g[n], {n, -2, 2}]Applications (7)
Use DifferenceRoot to get the difference equation form of HarmonicNumber:
DifferenceRootReduce[HarmonicNumber[k], k]Reduce combinations of special sequences to their DifferenceRoot forms:
f = DifferenceRootReduce[Fibonacci[n] + 2LucasL[n] + n ^ 2, n]Table[f, {n, 0, 5}]Table[Fibonacci[n] + 2LucasL[n] + n ^ 2, {n, 0, 5}]Define the Pell number sequence using DifferenceRoot:
PellNumber = DifferenceRoot[Function[{y, n}, {-y[n] - 2y[1 + n] + y[2 + n] == 0, y[0] == 0, y[1] == 1}]]Table[PellNumber[n], {n, 0, 5}]Prove properties of Pell numbers:
FullSimplify[PellNumber[n + 1]PellNumber[n - 1] - PellNumber[n] ^ 2 == (-1) ^ n]DifferenceRootReduce[PellNumber[n] == (-(1 - Sqrt[2]) ^ n + (1 + Sqrt[2]) ^ n) / (2Sqrt[2]), n]DifferenceRootReduce[Sum[PellNumber[i], {i, 0, 4n + 1}] == (PellNumber[2n] + PellNumber[2n + 1]) ^ 2, n]Reduce combinations of special sequences to a DifferenceRoot function:
f = DifferenceRootReduce[Fibonacci[n] ^ 2, n]DiscretePlot[f, {n, -5, 5}]Generate a function for which the Taylor expansion is the given DifferenceRoot object:
GeneratingFunction[DifferenceRoot[Function[{y, n}, {y[n] + y[n + 1] + (1 + n) (2 + n) y[n + 2] == 0, y[0] == 0, y[1] == 1}]][n], n, x]SeriesCoefficient[%, {x, 0, n}]Generate the DifferenceRoot object that generates the BesselJ functions:
f = BesselJ[k, z];DifferenceRootReduce[f, k]Define f to be the Fibonacci sequence:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] + y[n], y[0] == 0, y[1] == 1}]]Calculate the sum of the first 30 Fibonacci numbers:
Sum[f[n], {n, 30}]Find the generating function
for the Fibonacci sequence:
F[x_] = GeneratingFunction[f[n], n, x]Find the first 10 coefficients of the series expansion of
:
Table[SeriesCoefficient[F[x], {x, 0, n}], {n, 0, 10}]Compare the result with the first 10 Fibonacci numbers:
Fibonacci[Table[n, {n, 0, 10}]]Properties & Relations (14)
Use DifferenceRootReduce to generate DifferenceRoot objects:
f = DifferenceRootReduce[Fibonacci[n], n]Get the corresponding ordinary difference equation:
oΔe = First[Head[f]][y, n]Use the equation to verify solutions:
oΔe /. y -> Fibonacci//FullSimplifySum of a DifferenceRoot object:
Sum[DifferenceRoot[Function[{y, n}, {-y[n] - y[n + 1] + y[n + 2] == 0, y[0] == 0, y[1] == 1}]][n], n]Table[%, {n, 1, 10}]Accumulate[Table[Fibonacci[n], {n, 0, 9}]]GeneratingFunction may generate a DifferentialRoot object from a holonomic sequence:
GeneratingFunction[DifferenceRoot[Function[{y, n}, {y[n] + (1 + n) (2 + n) y[n + 2] == 0, y[0] == 0, y[1] == 1}]][n], n, x]For specific cases, GeneratingFunction may give an explicit function:
GeneratingFunction[DifferenceRoot[Function[{y, n}, {-y[n] - y[n + 1] + y[n + 2] == 0, y[0] == 0, y[1] == 1}]][n], n, z]Find the exponential generating function of a DifferenceRoot object:
ExponentialGeneratingFunction[DifferenceRoot[Function[{y, n}, {-y[n] - y[n + 1] + y[n + 2] == 0, y[0] == 0, y[1] == 1}]][n], n, z]The solution of a difference equation may be a DifferenceRoot object:
RSolve[a[1 + n] == a[n] + n a[n - 1] + n! && a[0] == 1 && a[1] == 2, a, n]A result from Sum may be a DifferenceRoot object:
Sum[(n + 4)! 2^n, n]Coefficients in the expansion of a function may be given as a DifferenceRoot object:
SeriesCoefficient[Exp[Sqrt[x + 1]], {x, 0, n}]The FindSequenceFunction result may be a DifferenceRoot object:
FindSequenceFunction[{2, 3 / 2, 7 / 3, 13 / 4, 26 / 5, 49 / 6, 92 / 7, 169 / 8, 307 / 9, 551 / 10, 980 / 11, 1729 / 12, 3030 / 13, 5279 / 14, 9151 / 15, 15793 / 16, 27150 / 17, 46513 / 18, 79440 / 19, 135301 / 20}, n]FunctionExpand attempts to generate simpler expressions for DifferenceRoot:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == y[n + 1] + y[n], y[0] == 0, y[1] == 1}]]FunctionExpand[f[n]]FunctionExpand attempts to generate simpler expressions for parametric sequences:
f = DifferenceRoot[Function[{y, n}, {y[n + 2] == a y[n + 1] + y[n], y[0] == 0, y[1] == 1}]]FunctionExpand[f[n]]Define f to be some holonomic sequence:
f = DifferenceRoot[Function[{y, n}, {y[n + 1] == 3y[n], y[1] == 7}]][{1, 2, 3, 4, 5}]Compare the result with the output of the RecurrenceTable:
RecurrenceTable[{y[n + 1] == 3y[n], y[1] == 7}, y, {n, 1, 5}]DiscreteShift takes a DifferenceRoot function and generates a shifted sequence:
f = DifferenceRoot[Function[{y, n}, {y[n + 1] == (n + 2) y[n], y[1] == 1}]]f[{1, 2, 3, 4, 5}]ds = DiscreteShift[f[n], n]ds /. n -> {1, 2, 3, 4, 5}DifferenceDelta takes a DifferenceRoot function as an input:
f = DifferenceRoot[Function[{y, n}, {y[n + 1] == n ^ 2 y[n], y[1] == 1}]]dd = DifferenceDelta[f[n], n]dd//FunctionExpandPossible Issues (2)
DifferenceRoot evaluates only linear difference sequences with polynomial coefficients:
DifferenceRoot[Function[{y, n}, {(Sqrt[n] + 1)y[n + 1] - y^2[n] == 0, y[0] == 0, y[1] == 1}]]
DifferenceRoot evaluates only integer terms:
f = DifferenceRoot[Function[{y, n}, {y[n + 1] == (n + 1)y[n], y[1] == 1}]]f[3 / 2]Neat Examples (1)
Define a DifferenceRoot function:
PadovanNumber = DifferenceRoot[Function[{y, n}, {y[n + 3] - y[n + 1] - y[n] == 0, y[0] == 1, y[1] == 1, y[2] == 1}]]DiscretePlot[PadovanNumber[n], {n, 0, 20}]DifferenceRootReduce[PadovanNumber[k] == PadovanNumber[k - 2] + PadovanNumber[k - 4] + PadovanNumber[k - 8], k]DifferenceRootReduce[Sum[PadovanNumber[2k + 1], {k, 0, n}] == PadovanNumber[2n + 4] - 1, n]Attempt to expand into less general functions:
g = FunctionExpand[PadovanNumber[n]]DiscretePlot[g, {n, 0, 20}]See Also
DifferenceRootReduce DifferentialRoot RSolve RecurrenceTable LinearRecurrence FunctionExpand
Function Repository: FindLinearRecurrenceEquations
Tech Notes
Related Guides
Text
Wolfram Research (2008), DifferenceRoot, Wolfram Language function, https://reference.wolfram.com/language/ref/DifferenceRoot.html (updated 2020).
CMS
Wolfram Language. 2008. "DifferenceRoot." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/DifferenceRoot.html.
APA
Wolfram Language. (2008). DifferenceRoot. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DifferenceRoot.html
BibTeX
@misc{reference.wolfram_2026_differenceroot, author="Wolfram Research", title="{DifferenceRoot}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/DifferenceRoot.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_differenceroot, organization={Wolfram Research}, title={DifferenceRoot}, year={2020}, url={https://reference.wolfram.com/language/ref/DifferenceRoot.html}, note=[Accessed: 12-June-2026]}