Skip to content

Latest commit

 

History

History
162 lines (99 loc) · 6 KB

File metadata and controls

162 lines (99 loc) · 6 KB

Hypergeometric function

Evaluates the Hypergeometric function.

The Hypergeometric function is defined for |x| < 1 by the power series:

$${}_2F_1(a, b; c; x) = \sum_{n=0}^{\infty} \frac{(a)_n (b)_n}{(c)_n} \frac{x^n}{n!} = 1 + \frac{a b}{c} x + \frac{a(a+1) b(b+1)}{c(c+1)} \frac{x^2}{2!} + \frac{a(a+1)(a+2) b(b+1)(b+2)}{c(c+1)(c+2)} \frac{x^3}{3!} + \cdots$$

and is undefined (or infinite) if c equals a non-positive integer.

Here (q)ₙ is the (rising) Pochhammer symbol, which is defined by:

$$(q)_n = \begin{cases} 1 & n = 0 \\ q(q+1) \cdots (q+n-1) & n > 0 \end{cases}$$

For |x| >= 1, the function can be analytically continued using functional identities and transformation formulas.

Usage

var hyp2f1 = require( '@stdlib/math/base/special/hyp2f1' );

hyp2f1( a, b, c, x )

Evaluates the Hypergeometric function.

var v = hyp2f1( 1.0, 1.0, 1.0, 0.0 );
// returns 1.0

v = hyp2f1( 10.0, 7.4, -1.8, -0.99 );
// returns ~0.423

v = hyp2f1( 3.0, 4.0, 7.0, 1.0 );
// returns +Infinity

v = hyp2f1( NaN, 3.0, 2.0, 0.5 );
// returns NaN

Examples

var linspace = require( '@stdlib/array/base/linspace' );
var hyp2f1 = require( '@stdlib/math/base/special/hyp2f1' );

var a = linspace( -50.0, 50.0, 100 );
var b = linspace( -50.0, 50.0, 100 );
var c = linspace( -50.0, 50.0, 100 );
var x = linspace( -50.0, 50.0, 100 );

var i;
for ( i = 0; i < x.length; i++ ) {
    console.log( 'a: %d, b: %d, c: %d, x: %d, 2F1(a,b;c;x): %d', a[ i ], b[ i ], c[ i ], x[ i ], hyp2f1( a[ i ], b[ i ], c[ i ], x[ i ] ) );
}

See Also