Learn R Programming

Davies (version 1.1-5)

hypergeo: The hypergeometric function

Description

The Hypergeometric and generalized hypergeometric functions as defined by Abramowitz and Stegun. These functions are defunct and will be removed altogether soon. To evaluate hypergeometric functions, use the hypergeo package

Usage

hypergeo (A, B, C, z, tol = 1e-06, maxiter = 2000, strict=TRUE)
hypergeo2(A, B, C, z, tol = 1e-06, maxiter = 2000, strict=TRUE)
genhypergeo(U, L, z, tol = 1e-06, maxiter = 2000, strict=TRUE)

Arguments

A,B,C
Parameters for hypergeo()
U,L
Upper and lower vector parameters for genhypergeo()
z
argument
tol
absolute tolerance
maxiter
Maximum number of iterations
strict
Boolean, with default TRUE meaning to return NA if the series appears not to converge, and FALSE meaning to return the partial sum

Details

The hypergeometric function as defined by Abramowitz and Stegun, equation 15.1.1, page 556 is $${}_1F_2(a,b;c;z) = \sum_{n=0}^\infty\frac{(a)_n(b)_n}{(c)_n}\cdot\frac{z^n}{n!}$$

where $(a)_n=a(a+1)\ldots(a+n-1)=\Gamma(a+n)/\Gamma(a)$ is the Pochammer symbol (6.1.22, page 256).

The generalized hypergeometric function appears from time to time in the literature (eg Mathematica) as

$$F(U,L;z) = \sum_{n=0}^\infty\frac{(u_1)_n(u_2)_n\ldots (u_i)_n}{(l_1)_n(l_2)_n\ldots (l_j)_n}\cdot\frac{z^n}{n!}$$

where $U=\left(u_1,\ldots,u_i\right)$ and $L=\left(l_1,\ldots,l_i\right)$ are the upper and lower vectors respectively.

For the Confluent Hypergeometric function, use genhypergeo() with length-1 vectors for arguments U and V.

For the ${}_0\!F_1$ function (ie no upper arguments), use genhypergeo(NULL,L,x).

References

Abramowitz and Stegun 1955. Handbook of mathematical functions with formulas, graphs and mathematical tables (AMS-55). National Bureau of Standards

Examples

Run this code
#  equation 15.1.3, page 556:
f1 <- function(x){-log(1-x)/x}
f2 <- function(x){hypergeo(1,1,2,x)}
f3 <- function(x){hypergeo(1,1,2,x,tol=1e-10)}
x <- seq(from = -0.6,to=0.6,len=14)
f1(x)-f2(x)
f1(x)-f3(x)  # Note tighter tolerance


# equation 15.1.7, p556:
g1 <- function(x){log(x + sqrt(1+x^2))/x}
g2 <- function(x){hypergeo(1/2,1/2,3/2,-x^2)}
g1(x)-g2(x)  # should be small 
abs(g1(x+0.1i) - g2(x+0.1i))  # should have small modulus.

# Just a random call, verified by Maple [ Hypergeom([],[1.22],0.9087) ]:
genhypergeo(NULL,1.22,0.9087)

Run the code above in your browser using DataLab