|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2025 The Stdlib Authors. |
| 6 | +
|
| 7 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +you may not use this file except in compliance with the License. |
| 9 | +You may obtain a copy of the License at |
| 10 | +
|
| 11 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +
|
| 13 | +Unless required by applicable law or agreed to in writing, software |
| 14 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +See the License for the specific language governing permissions and |
| 17 | +limitations under the License. |
| 18 | +
|
| 19 | +--> |
| 20 | + |
| 21 | +# Gaussian hypergeometric function |
| 22 | + |
| 23 | +> Evaluates the [Gaussian hypergeometric function][hypergeometric-function]. |
| 24 | +
|
| 25 | +<section class="intro"> |
| 26 | + |
| 27 | +The [Gaussian hypergeometric function][hypergeometric-function] is defined for `|x| < 1` by the power series: |
| 28 | + |
| 29 | +<!-- <equation class="equation" label="eq:hypergeometric_function" align="center" raw="{}_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" alt="Gaussian hypergeometric function."> --> |
| 30 | + |
| 31 | +```math |
| 32 | +{}_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 |
| 33 | +``` |
| 34 | + |
| 35 | +<!-- <div class="equation" align="center" data-raw-text="{}_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" data-equation="eq:hypergeometric_function"> |
| 36 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/hyp2f1/docs/img/equation_hypergeometric_function.svg" alt="Gaussian hypergeometric function."> |
| 37 | + <br> |
| 38 | +</div> --> |
| 39 | + |
| 40 | +<!-- </equation> --> |
| 41 | + |
| 42 | +and is undefined (or infinite) if `c` equals a non-positive integer. |
| 43 | + |
| 44 | +Here `(q)ₙ` is the (rising) [Pochhammer symbol][pochhammer-symbol], which is defined by: |
| 45 | + |
| 46 | +<!-- <equation class="equation" label="eq:pochhammer_symbol" align="center" raw="(q)_n = \begin{cases} 1 & n = 0 \\ q(q+1) \cdots (q+n-1) & n > 0 \end{cases}" alt="Pochhammer symbol."> --> |
| 47 | + |
| 48 | +```math |
| 49 | +(q)_n = \begin{cases} 1 & n = 0 \\ q(q+1) \cdots (q+n-1) & n > 0 \end{cases} |
| 50 | +``` |
| 51 | + |
| 52 | +<!-- <div class="equation" align="center" data-raw-text="(q)_n = \begin{cases} 1 & n = 0 \\ q(q+1) \cdots (q+n-1) & n > 0 \end{cases}" data-equation="eq:pochhammer_symbol"> |
| 53 | + <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/hyp2f1/docs/img/equation_pochhammer_symbol.svg" alt="Pochhammer symbol."> |
| 54 | + <br> |
| 55 | +</div> --> |
| 56 | + |
| 57 | +<!-- </equation> --> |
| 58 | + |
| 59 | +For `|x| >= 1`, the function can be [analytically continued][analytic-continuation] using functional identities and transformation formulas. |
| 60 | + |
| 61 | +</section> |
| 62 | + |
| 63 | +<!-- /.intro --> |
| 64 | + |
| 65 | +<section class="usage"> |
| 66 | + |
| 67 | +## Usage |
| 68 | + |
| 69 | +```javascript |
| 70 | +var hyp2f1 = require( '@stdlib/math/base/special/hyp2f1' ); |
| 71 | +``` |
| 72 | + |
| 73 | +#### hyp2f1( a, b, c, x ) |
| 74 | + |
| 75 | +Evaluates the [Gaussian hypergeometric function][hypergeometric-function]. |
| 76 | + |
| 77 | +```javascript |
| 78 | +var v = hyp2f1( 1.0, 1.0, 1.0, 0.0 ); |
| 79 | +// returns 1.0 |
| 80 | + |
| 81 | +v = hyp2f1( 10.0, 7.4, -1.8, -0.99 ); |
| 82 | +// returns ~0.423 |
| 83 | + |
| 84 | +v = hyp2f1( 3.0, 4.0, 7.0, 1.0 ); |
| 85 | +// returns +Infinity |
| 86 | + |
| 87 | +v = hyp2f1( NaN, 3.0, 2.0, 0.5 ); |
| 88 | +// returns NaN |
| 89 | +``` |
| 90 | + |
| 91 | +</section> |
| 92 | + |
| 93 | +<!-- /.usage --> |
| 94 | + |
| 95 | +<section class="examples"> |
| 96 | + |
| 97 | +## Examples |
| 98 | + |
| 99 | +<!-- eslint no-undef: "error" --> |
| 100 | + |
| 101 | +```javascript |
| 102 | +var linspace = require( '@stdlib/array/base/linspace' ); |
| 103 | +var hyp2f1 = require( '@stdlib/math/base/special/hyp2f1' ); |
| 104 | + |
| 105 | +var a = linspace( -50.0, 50.0, 100 ); |
| 106 | +var b = linspace( -50.0, 50.0, 100 ); |
| 107 | +var c = linspace( -50.0, 50.0, 100 ); |
| 108 | +var x = linspace( -50.0, 50.0, 100 ); |
| 109 | + |
| 110 | +var i; |
| 111 | +for ( i = 0; i < x.length; i++ ) { |
| 112 | + 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 ] ) ); |
| 113 | +} |
| 114 | +``` |
| 115 | + |
| 116 | +</section> |
| 117 | + |
| 118 | +<!-- /.examples --> |
| 119 | + |
| 120 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> |
| 121 | + |
| 122 | +<section class="related"> |
| 123 | + |
| 124 | +</section> |
| 125 | + |
| 126 | +<!-- /.related --> |
| 127 | + |
| 128 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 129 | + |
| 130 | +<section class="links"> |
| 131 | + |
| 132 | +[hypergeometric-function]: https://en.wikipedia.org/wiki/Hypergeometric_function |
| 133 | + |
| 134 | +[pochhammer-symbol]: https://en.wikipedia.org/wiki/Falling_and_rising_factorials |
| 135 | + |
| 136 | +[analytic-continuation]: https://en.wikipedia.org/wiki/Analytic_continuation |
| 137 | + |
| 138 | +</section> |
| 139 | + |
| 140 | +<!-- /.links --> |
0 commit comments