Pochhammer.frink

View or download Pochhammer.frink in plain text format


/** Calculate the Pochhammer function.

    The Pochhammer function or Pochhammer symbol (written terribly as (v)_k )
    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:

    Pochhammer[v, -k] := (-1)^-k / Pochhammer[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:

    Pochhammer[x,3]

  produces:
    x (1 + x) (2 + x)    

    See:

    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
*/

Pochhammer[v, k] :=
{
   if ! isInteger[k]
   {
      println["Pochhammer not defined for non-integer value k = $k"]
      return undef
   }

   // Extension to negative numbers
   if k < 0
      return (-1)^-k / Pochhammer[1-v, -k]
   
   product = 1
   for s = 0 to k-1
      product = product * (v+s)
   
   return product
}


View or download 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 17927 days, 8 hours, 27 minutes ago.