Download or view Pochhammer.frink in plain text format
/** This program calculates the "rising factorial" and the "falling factorial."
and the "double factorial."
Sometimes one of these is called the "Pochhammer function" but that naming
convention is almost certainly going to be ambiguous. (See Knuth, below)
Beware the (terrible) notation as (v)_k or v^(n) which may represent either
the rising or falling factorial! (Just because a quantity is in parentheses
you're supposed to infer that it means some totally different thing than
that number in parentheses?! Get out of here with that, you, and your
binomial theorem notation and your Legendre symbol notation and your Jacobi
symbol notation and every other mathematician who thought "hey I'm just
gonna make parentheses mean something TOTALLY NEW and AMBIGUOUS and name it
after myself.")
Pochhammer himself used that notation to mean something else! So stop it!
See
Knuth, Donald E. "Two Notes on Notation",
https://arxiv.org/abs/math/9205211
beginning around equation (2.11) for many more details and better (but still
ambiguous and awful) notation.
*/
/** Calculate the rising factorial.
The rising factorial calculates:
v (v+1) (v+2) ... (v + k - 1)
This function is closely related to the gamma function, which is closely
related to the factorial.
This implementation includes an extension to negative numbers, where:
risingFactorial[v, -k] := (-1)^-k / risingFactorial[1-v, -k]
Since this function only utilizes basic arithmetic, it automatically
works to arbitrary precision and works for complex numbers.
This function also works with symbolic values of v:
risingFactorial[x,3]
produces:
x (1 + x) (2 + x)
See:
https://en.wikipedia.org/wiki/Falling_and_rising_factorials
Gonzalez, Ivan & Jiu, Lin & Moll, Victor. (2015). Pochhammer Symbol with
Negative Indices. A New Rule for the Method of Brackets. Open
Mathematics. 14. 10.1515/math-2016-0063.
Which can be found at:
https://www.researchgate.net/publication/280695601_Pochhammer_Symbol_with_Negative_Indices_A_New_Rule_for_the_Method_of_Brackets/fulltext/55c4077508aeb97567402184/280695601_Pochhammer_Symbol_with_Negative_Indices_A_New_Rule_for_the_Method_of_Brackets.pdf?origin=publication_detail
or in arxiv:
https://arxiv.org/abs/1508.00056
*/
risingFactorial[v, k] :=
{
if ! isInteger[k]
{
println["risingFactorial not defined for non-integer value k = $k"]
return undef
}
// Extension to negative numbers
if k < 0
return (-1)^-k / risingFactorial[1-v, -k]
product = 1
for s = 0 to k-1
product = product * (v+s)
return product
}
/** An alternate name for the rising factorial. As noted above, the
name "Pochhammer" can indicate a rising or falling factorial depending
on the conventions in your field and this usage should be deprecated.
*/
Pochhammer[v, k] := risingFactorial[v, k]
/** Calculate the falling factorial.
This calculates
x (x-1) (x-2) ... (x-n+1)
See
https://en.wikipedia.org/wiki/Falling_and_rising_factorials
*/
fallingFactorial[x, n] :=
{
product = 1
for k = 0 to n-1
product = product * (x-k)
return product
}
/** This is a generalization of the binomial theorem to rational r using
Newton's generalization. r can even be symbolic.
This utilizes the fact that the binomial theorem for (r, k)
can be generalized for r and integer k by:
fallingFactorial[r, k] / k!
See:
https://en.wikipedia.org/wiki/Binomial_theorem#Newton's_generalized_binomial_theorem
*/
generalizedBinomial[r, k] := fallingFactorial[r, k] / k!
/** The so-called "double factorial" which is sometimes represented as n!!
which is terrible ambiguous wrong notation.
See:
https://en.wikipedia.org/wiki/Double_factorial
*/
doubleFactorial[n] :=
{
product = 1
for k = 0 to ceil[n/2] - 1
product = product * (n - 2 k)
return product
}
Download or view Pochhammer.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20194 days, 8 hours, 49 minutes ago.