Skip to content

DifferenceRootReduce ​

Reduces a hypergeometric-type sequence f(n)f(n) to its holonomic (P-recursive) representation — DifferenceRoot\mathrm{DifferenceRoot}, a linear recurrence with polynomial(n) coefficients plus enough initial values to pin the sequence down, applied straight back to nn. Covers Factorial, ana^n, CatalanNumber, Binomial(n, k) for concrete k, polynomials in n, Fibonacci, LucasL, HarmonicNumber, and a sum of two hypergeometric terms; declines everything else, leaving the call symbolic. Provided by @enumeratio/analytic.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageDifferenceRootReduce✓
DifferenceRootReduce(f(n), n)the P-recursive reduction of f(n)f(n), as DifferenceRoot(…)(n)\mathrm{DifferenceRoot}(\ldots)(n).
Typed signatures
TypePackageApplies
(expression, symbol) -> expressionanalyticalways

Domain: Special functions

Details
  • Order 1 (a single recurrence step, one or two initial conditions): Factorial(n), ana^n, CatalanNumber(n), polynomials in n, and Binomial(n, k) for k a concrete non-negative integer — plus products and quotients of these. Binomial's recurrence has a genuine pole at n=k−1n = k - 1 (its own ratio C(n+1,k)/C(n,k)C(n{+}1,k)/C(n,k) divides by n+1−kn{+}1{-}k), so it carries two anchors, at n=−1n=-1 and n=kn=k, straddling it — confirmed against a local wolframscript, which makes the identical choice.
  • Order 2, constant coefficients: Fibonacci(n) and LucasL(n), y(n+2)=y(n+1)+y(n)y(n{+}2) = y(n{+}1) + y(n) with (y(0),y(1))=(0,1)(y(0),y(1)) = (0,1) or (2,1)(2,1).
  • HarmonicNumber(n) reduces to order 1 with a constant inhomogeneous term, (n+1)(y(n+1)−y(n))=1(n{+}1)(y(n{+}1) - y(n)) = 1 — Wolfram's own reduction, not the order-2 homogeneous form the standard difference identity for HnH_n would otherwise suggest; probed rather than guessed.
  • Sum of two hypergeometric terms (order 1 each) reduces to order ≤ 2 via the classical cross-product elimination (Petkovšek's sum rule): 2n+3n2^n + 3^n below.
  • Every reduction is checked by running its own recurrence forward (exact rational arithmetic, DifferenceRoot) against the original expression at ~20 integer points before being trusted; see difference-root.ts.
  • Declines (returns the call unevaluated) a polynomial or product/quotient the internal ratio decomposition doesn't recognize, a symbolic or negative Binomial order, three or more summands, and anything outside the heads listed above.

Examples

4 more kept as data, checked against the oracles
Basic #

Fibonacci: y(n+2)−y(n+1)−y(n)=0y(n{+}2) - y(n{+}1) - y(n) = 0, y(0)=0,y(1)=1y(0){=}0, y(1){=}1

live ↗
InDifferenceRootReduce(Fibonacci(n),n)\mathrm{DifferenceRootReduce}(\mathrm{Fibonacci}(n), n)OutDifferenceRoot((y,k)↦{−y(k)−y(k+1)+y(k+2)=0y(0)=0y(1)=1)⊲n\mathrm{DifferenceRoot}((y, k)↦\begin{cases}-y(k)-y(k+1)+y(k+2)=0\\y(0)=0\\y(1)=1\end{cases})\lhd n

Factorial: (n+1)y(n)=y(n+1)(n{+}1) y(n) = y(n{+}1), y(0)=1y(0){=}1

live ↗
InDifferenceRootReduce(n!,n)\mathrm{DifferenceRootReduce}(n!, n)OutDifferenceRoot((y,k)↦{(−k−1)y(k)+y(k+1)=0y(0)=1)⊲n\mathrm{DifferenceRoot}((y, k)↦\begin{cases}(-k-1)y(k)+y(k+1)=0\\y(0)=1\end{cases})\lhd n

(n3)\binom{n}{3}: anchors at n=−1n=-1 and n=3n=3, either side of the recurrence's pole at n=2n=2

live ↗
InDifferenceRootReduce((n3),n)\mathrm{DifferenceRootReduce}(\binom{n}{3}, n)OutDifferenceRoot((y,k)↦{(k−2)y(k+1)+(−k−1)y(k)=0y(−1)=−1y(3)=1)⊲n\mathrm{DifferenceRoot}((y, k)↦\begin{cases}(k-2)y(k+1)+(-k-1)y(k)=0\\y(-1)=-1\\y(3)=1\end{cases})\lhd n
live ↗
InDifferenceRootReduce(Fibonacci(k),k)\mathrm{DifferenceRootReduce}(\mathrm{Fibonacci}(k), k)OutDifferenceRoot((y,n)↦{−y(n)−y(n+1)+y(n+2)=0y(0)=0y(1)=1)⊲k\mathrm{DifferenceRoot}((y, n)↦\begin{cases}-y(n)-y(n+1)+y(n+2)=0\\y(0)=0\\y(1)=1\end{cases})\lhd k
Scope #

HnH_n: (n+1)(y(n+1)−y(n))=1(n{+}1)(y(n{+}1) - y(n)) = 1 — order 1, not the order-2 homogeneous form

live ↗
InDifferenceRootReduce(HarmonicNumber(n),n)\mathrm{DifferenceRootReduce}(\mathrm{HarmonicNumber}(n), n)OutDifferenceRoot((y,k)↦{(k+1)y(k+1)+(−k−1)y(k)−1=0y(0)=0)⊲n\mathrm{DifferenceRoot}((y, k)↦\begin{cases}(k+1)y(k+1)+(-k-1)y(k)-1=0\\y(0)=0\end{cases})\lhd n

2n+3n2^n + 3^n: sum-of-two-hypergeometric closure, order 2

live ↗
InDifferenceRootReduce(2n+3n,n)\mathrm{DifferenceRootReduce}(2^{n}+3^{n}, n)OutDifferenceRoot((y,k)↦{−5y(k+1)+6y(k)+y(k+2)=0y(0)=2y(1)=5)⊲n\mathrm{DifferenceRoot}((y, k)↦\begin{cases}-5y(k+1)+6y(k)+y(k+2)=0\\y(0)=2\\y(1)=5\end{cases})\lhd n
live ↗
InDifferenceRootReduce(n2+1,n)\mathrm{DifferenceRootReduce}(n^2+1, n)OutDifferenceRoot((y,k)↦{(−(k+1)2−1)y(k)+(k2+1)y(k+1)=0y(0)=1)⊲n\mathrm{DifferenceRoot}((y, k)↦\begin{cases}(-(k+1)^2-1)y(k)+(k^2+1)y(k+1)=0\\y(0)=1\end{cases})\lhd n

3⋅2n3\cdot2^n: y(k+1)=2y(k)y(k+1)=2y(k) with y(0)=3y(0)=3 (the factor 3 is in the anchor)

live ↗
InDifferenceRootReduce(3×2n,n)\mathrm{DifferenceRootReduce}(3×2^{n}, n)OutDifferenceRoot((y,k)↦{y(k+1)−2y(k)=0y(0)=3)⊲n\mathrm{DifferenceRoot}((y, k)↦\begin{cases}y(k+1)-2y(k)=0\\y(0)=3\end{cases})\lhd n

Constant in mm: y(m+1)=y(m)y(m+1)=y(m) with y(0)=Fny(0)=F_n

live ↗
InDifferenceRootReduce(Fibonacci(n),m)\mathrm{DifferenceRootReduce}(\mathrm{Fibonacci}(n), m)OutDifferenceRoot((y,k)↦{y(k+1)−y(k)=0y(0)=Fibonacci(n))⊲m\mathrm{DifferenceRoot}((y, k)↦\begin{cases}y(k+1)-y(k)=0\\y(0)=\mathrm{Fibonacci}(n)\end{cases})\lhd m
About
Examples13
Checked againstWolfram Language 11 agree1 unevaluated
CrosswalkWolfram Language

See also: DifferenceRoot, DifferentialRootReduce, Fibonacci, LucasL, HarmonicNumber, Binomial