Skip to content

Inconsistency in hypergeometric_1F1(n, n, x) with negative n #829

@WarrenWeckesser

Description

@WarrenWeckesser

According the documentation of hypergeometric_1F1, "This function has the same definition as Mathematica's Hypergeometric1F1[a, b, z]." There appears to be a difference in the case a == b and a is a negative integer. I used the Wolfram Alpha website to check the Mathematica values, and I also checked mpmath. The following shows the actual results that I get when computing ₁F₁(n, n, x) for the three libraries. Tn(x) is the degree n Taylor polynomial of exp(x) (i.e. T0(x) = 1, T1(x) = 1 + x, T2(x) = 1 + x + x**2/2, etc).

             Boost               Wolfram Alpha            mpmath
   n   hypergeometric_1F1      Hypergeometric1F1       mpmath.hyp1f1
   0          T0(x)                 T0(x)                  T0(x)
  -1          T1(x)                 T1(x)                  T1(x)
  -2          exp(x)                T2(x)                  T2(x)
  -3          exp(x)                T3(x)                  T3(x)

Note that when a = b = n where n is a negative integer, two independent solutions to Kummer's equation are Tn(x) and exp(x). The question then is, in this edge case, which one is considered the confluent hypergeometric function? That is, which solution is the "first kind"? Wolfram Alpha and mpmath consistently use the polynomial. If the documentation is correct, then I would expect Boost to do the same. If there is a compelling reason to use exp(x), I would expect that to apply in the cases n=0 and n=-1 also.

I ran into this while converting SciPy's implementation of hyp1f1 to use Boost as the backend. Currently SciPy uses a mix of some custom code and the Fortran library SPECFUN. The current SciPy code also follows the convention of using the Taylor polynomial consistently.

I also checked GSL (GNU Scientific Library). It appears to use exp(x) in all the above cases except n = 0, where it generates a domain error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions