Skip to content

DifferenceDelta ​

f(n+1) - f(n), simplified -- the forward difference of a sequence.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageDifferenceDelta!
DifferenceDelta(f, n)f(n+1) - f(n), simplified
SymPydifference_delta(f, n)
Typed signatures
TypePackageApplies
(any, symbol) -> anycombinatoricsalways

Domain: Collections

Details
  • Substitutes n -> n+1 into f and simplifies the difference; stays symbolic when it does not collapse further.

Examples

Basic #

(n+1)2−n2=2n+1(n+1)^2 - n^2 = 2n + 1

live ↗
InDifferenceDelta(n2,n)\mathrm{DifferenceDelta}(n^2, n)Out2n+12n+1

The forward difference of a linear function is its slope, everywhere

live ↗
InDifferenceDelta(3n+5,n)\mathrm{DifferenceDelta}(3n+5, n)Out33

Forward difference of a symbolic falling factorial

live ↗
InDifferenceDelta(FallingFactorial(k,n),k)\mathrm{DifferenceDelta}(\mathrm{FallingFactorial}(k, n), k)OutFallingFactorial(k+1,n)−FallingFactorial(k,n)\mathrm{FallingFactorial}(k+1, n)-\mathrm{FallingFactorial}(k, n)
Scope #

Naming the index ii should keep it a bound variable, not the imaginary unit; compute-engine lifts a variable i to the imaginary unit when it boxes, so the difference comes back over ii and 1+i1 + i

live ↗

Δk3=(k+1)3−k3\Delta k^3=(k+1)^3-k^3, left unexpanded

live ↗
InDifferenceDelta(k3,k)\mathrm{DifferenceDelta}(k^3, k)Out(k+1)3−k3(k+1)^3-k^3

Δk3‾=3k2‾\Delta k^{\underline3}=3k^{\underline2}, here as 3k2−3k3k^2-3k

live ↗
InDifferenceDelta(FallingFactorial(k,3),k)\mathrm{DifferenceDelta}(\mathrm{FallingFactorial}(k, 3), k)Out3k2−3k3k^2-3k

A rational term gives a difference of two fractions

live ↗
InDifferenceDelta(k+1k+3,k)\mathrm{DifferenceDelta}(\frac{k+1}{k+3}, k)Outk+2k+4+−k−1k+3\frac{k+2}{k+4}+\frac{-k-1}{k+3}

A negative falling factorial index gives a rational difference

live ↗
InDifferenceDelta(FallingFactorial(k,−3),k)\mathrm{DifferenceDelta}(\mathrm{FallingFactorial}(k, -3), k)Out1(−k−3)(−k−2)(−k−1)−1(−k−4)(−k−3)(−k−2)\frac{1}{(-k-3)(-k-2)(-k-1)}-\frac{1}{(-k-4)(-k-3)(-k-2)}

Works with the Hurwitz zeta in its second argument

live ↗
InDifferenceDelta(ζ(2,k),k)\mathrm{DifferenceDelta}(ζ(2, k), k)Outζ(2,k+1)−ζ(2,k)ζ(2, k+1)-ζ(2, k)

Exponentials: Δak=ak+1−ak\Delta a^k=a^{k+1}-a^k

live ↗
InDifferenceDelta(ak,k)\mathrm{DifferenceDelta}(a^{k}, k)Outak+1−aka^{k+1}-a^{k}

Δ2k=2k+1−2k=2k\Delta 2^k=2^{k+1}-2^k=2^k, shown unsimplified

live ↗
InDifferenceDelta(2k,k)\mathrm{DifferenceDelta}(2^{k}, k)Out2k+1−2k2^{k+1}-2^{k}

Polynomial times exponential uses the product shift

live ↗
InDifferenceDelta((k2+k+1)×2k,k)\mathrm{DifferenceDelta}((k^2+k+1)×2^{k}, k)Out((k+1)2+k+2)×2k+1−(k2+k+1)×2k((k+1)^2+k+2)×2^{k+1}-(k^2+k+1)×2^{k}

Rational times exponential, stays as a difference of terms

live ↗
InDifferenceDelta((k+1)×2kk+3,k)\mathrm{DifferenceDelta}(\frac{(k+1)×2^{k}}{k+3}, k)Out(k+2)×2k+1k+4−(k+1)×2kk+3\frac{(k+2)×2^{k+1}}{k+4}-\frac{(k+1)×2^{k}}{k+3}
live ↗
InDifferenceDelta(sin⁡(ak+b),k)\mathrm{DifferenceDelta}(\sin(ak+b), k)Outsin⁡(ak+a+b)−sin⁡(ak+b)\sin(ak+a+b)-\sin(ak+b)
live ↗
InDifferenceDelta(sinh⁡(ak+b),k)\mathrm{DifferenceDelta}(\sinh(ak+b), k)Outsinh⁡(a×(k+1)+b)−sinh⁡(ak+b)\sinh(a×(k+1)+b)-\sinh(ak+b)
live ↗
InDifferenceDelta(Pochhammer(k,n),k)\mathrm{DifferenceDelta}(\mathrm{Pochhammer}(k, n), k)OutPochhammer(k+1,n)−Pochhammer(k,n)\mathrm{Pochhammer}(k+1, n)-\mathrm{Pochhammer}(k, n)
live ↗
InDifferenceDelta(k!,k)\mathrm{DifferenceDelta}(k!, k)Outkk!kk!
live ↗
InDifferenceDelta((k+nn),k)\mathrm{DifferenceDelta}(\binom{k+n}{n}, k)Out(k+n+1n)−(k+nn)\binom{k+n+1}{n}-\binom{k+n}{n}
live ↗
InDifferenceDelta(Γ(k),k)\mathrm{DifferenceDelta}(Γ(k), k)OutΓ(k+1)−Γ(k)Γ(k+1)-Γ(k)
live ↗
InDifferenceDelta(B(k,n),k)\mathrm{DifferenceDelta}(\mathrm{B}(k, n), k)OutB(k+1,n)−B(k,n)\mathrm{B}(k+1, n)-\mathrm{B}(k, n)
live ↗
InDifferenceDelta(FallingFactorial(a,k)FallingFactorial(b,k),k)\mathrm{DifferenceDelta}(\frac{\mathrm{FallingFactorial}(a, k)}{\mathrm{FallingFactorial}(b, k)}, k)OutFallingFactorial(a,k+1)FallingFactorial(b,k+1)−FallingFactorial(a,k)FallingFactorial(b,k)\frac{\mathrm{FallingFactorial}(a, k+1)}{\mathrm{FallingFactorial}(b, k+1)}-\frac{\mathrm{FallingFactorial}(a, k)}{\mathrm{FallingFactorial}(b, k)}
live ↗
InDifferenceDelta(GammaRegularized⁡(k,z),k)\mathrm{DifferenceDelta}(\operatorname{GammaRegularized}(k, z), k)OutGammaRegularized⁡(k+1,z)−GammaRegularized⁡(k,z)\operatorname{GammaRegularized}(k+1, z)-\operatorname{GammaRegularized}(k, z)
live ↗
InDifferenceDelta(BetaRegularized⁡(z,k,j),k)\mathrm{DifferenceDelta}(\operatorname{BetaRegularized}(z, k, j), k)OutBetaRegularized⁡(z,k+1,j)−BetaRegularized⁡(z,k,j)\operatorname{BetaRegularized}(z, k+1, j)-\operatorname{BetaRegularized}(z, k, j)
live ↗
InDifferenceDelta(BetaRegularized⁡(z,k,j),j)\mathrm{DifferenceDelta}(\operatorname{BetaRegularized}(z, k, j), j)OutBetaRegularized⁡(z,k,j+1)−BetaRegularized⁡(z,k,j)\operatorname{BetaRegularized}(z, k, j+1)-\operatorname{BetaRegularized}(z, k, j)
live ↗
InDifferenceDelta(QFactorial(k,q),k)\mathrm{DifferenceDelta}(\mathrm{QFactorial}(k, q), k)OutQFactorial(k+1,q)−QFactorial(k,q)\mathrm{QFactorial}(k+1, q)-\mathrm{QFactorial}(k, q)
live ↗
InDifferenceDelta(QPochhammer(5,q,k),k)\mathrm{DifferenceDelta}(\mathrm{QPochhammer}(5, q, k), k)OutQPochhammer(5,q,k+1)−QPochhammer(5,q,k)\mathrm{QPochhammer}(5, q, k+1)-\mathrm{QPochhammer}(5, q, k)
live ↗
InDifferenceDelta(QBinomial(k,m,q),k)\mathrm{DifferenceDelta}(\mathrm{QBinomial}(k, m, q), k)OutQBinomial(k+1,m,q)−QBinomial(k,m,q)\mathrm{QBinomial}(k+1, m, q)-\mathrm{QBinomial}(k, m, q)
live ↗
InDifferenceDelta(QBinomial(n,k,q),k)\mathrm{DifferenceDelta}(\mathrm{QBinomial}(n, k, q), k)OutQBinomial(n,k+1,q)−QBinomial(n,k,q)\mathrm{QBinomial}(n, k+1, q)-\mathrm{QBinomial}(n, k, q)
About
Examples28
Checked againstWolfram Language 26 agree1 differSymPy 23 agree
CrosswalkWolfram LanguageSymPy

Implementation

mappedsympypackages/oracle/src/mappings.ts

See also: DiscreteRatio