Hypergeometric2F1¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
Hypergeometric2F1[a, b, c, z]
is the Gauss hypergeometric 2F1, equal to HypergeometricPFQ[{a, b}, {c}, z]; continued analytically to the whole
Notes
plane, with the cut z \> 1 taking the limit from below.Examples (15)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (4)¶
In[1]:= Hypergeometric2F1[1, 1, 2, z]
Out[1]= -Log[1 - z]/z
In[2]:= Hypergeometric2F1[1, 1, 3/2, z]
Out[2]= ArcSin[Sqrt[z]]/(Sqrt[z] Sqrt[1 - z])
In[3]:= Hypergeometric2F1[1, 2, 3, 2.5]
Out[3]= -0.929749 - 1.00531*I
In[4]:= N[Hypergeometric2F1[1/3, 1/2, 1/5, 99/100], 50]
Out[4]= 24.8565393133858972090022500136712230259988212774851
Applications (11)¶
The logarithm
Terminates to (1 - z)^3
The central-binomial ArcSin family
Since z 2F1(1/2,1/2;3/2;z^2) = ArcSin[z], here at z = 1/2
In[8]:= N[Hypergeometric2F1[1/2, 1/2, 3/2, 1/4]/2, 40]
Out[8]= 0.52359877559829887307710723054658381403285
The same value from ArcSin
Far outside the unit disc, by a connection formula
On the cut z > 1: the limit from below, ArcSin[Sqrt[3]]/Sqrt[3]
Complex argument beyond |z| = 1
Arbitrary precision near the unit circle, via arb
In[13]:= N[Hypergeometric2F1[1/3, 2/3, 5/6, 99/100], 50]
Out[13]= 2.95897980754556447425507657958878991881629488154278
Listable
Exact Gauss sum at z = 1 is not applied: stays unevaluated
Implementation notes¶
Algorithm. builtin_hypergeometric_2f1 (hypergeopfq.c) first tries the
machine gate hg_machine_head — every argument a machine-scalar leaf
(sf_machine_scalar_args), at least one a machine Real — and otherwise rewrites
to HypergeometricPFQ[{a, b}, {c}, z], inheriting its exact steps (cancellation,
z == 0, termination for non-positive integer a/b, the closed forms
-Log[1-z]/z, (1-z)^-a and the ArcSin[Sqrt[z]] family). The real machine
kernel sf_machine_hyper2f1 builds a Hy2Plan from the parameters (polynomial,
(1-z)^-b / (1-z)^-a, or generic) and evaluates: the direct series on
(0, 0.9], Pfaff's (1-z)^-a F(a, c-b; c; z/(z-1)) on [-9, 0), Gauss's sum
G(c)G(c-a-b)/(G(c-a)G(c-b)) at z = 1, and the shared complex core
hy2f1_core elsewhere. That core picks the cheapest of direct / Pfaff series
(|w| <= 0.75), the 1-z and 1/(1-z) connection formulas (|w| <= 0.6,
accepted only while the combination's condition number is at most 2, with the
degenerate logarithmic cases when c-a-b is an integer), and — around
z = e^(±i π/3) or for ill-conditioned parameters — continuation of the
hypergeometric ODE by Taylor steps from z0 = 1/2 ± 0.45 i (hy2f1_continue).
A machine-real z > 1 returns the complex value from below the cut (zi = -0).
Complex parameters use the series only, for |z| <= 0.9. At arbitrary precision
|z| < 1 goes to arb's acb_hypgeom_2f1 (flint_num_hyp2f1 in
src/flint_num_bridge.c), with the MPFR series as fallback.
Data structures. Plain C99 double, complex values as re/im pairs, with
double-double (hdd) re-sums for a series that loses more than one bit or peaks
late; Hy2Plan / Hy2Tab hold the coefficient recurrence
c_{k+1} = c_k (p0+k)(p1+k)/((q0+k)(k+1)), which a buffer tabulates once. When
the terms are one-signed and never grow ("lean", decided from the parameters)
sf_machine_pfq_vec sums four buffer elements in lock-step, bit-identical to the
scalar loop. ND: n-ary kernel NDKN_Hypergeometric2F1 (arity 4, REG_N); on
pack.c's AWARE list with the family; a buffer containing a cut element comes
back complex. Attributes: Listable, NumericFunction, Protected.
Complexity / limits. Scalar about 0.3 µs real and 1.7 µs complex; 10^6 packed
elements about 0.14 s. Term caps 20000 (double) and 6000 (double-double); a
case where nothing converges declines to the exact / MPFR route. The arbitrary
precision path still requires |z| < 1, so an exact or MPFR z outside the unit
disc stays unevaluated, as does the exact Gauss value at z = 1.
Compile[] lowers at real and complex scalar shapes (through
HypergeometricPFQ's OP_KERNN / OP_KERNN_C); the rank-1 array shape reports
Compiled -> False, while the packed / NDArray path still serves the REPL.
Attributes: Listable, NumericFunction, Protected.
References¶
- DLMF §15 — the Gauss hypergeometric function 2F1.
- M. Abramowitz and I. A. Stegun, Handbook of Mathematical Functions (1964), 15.3.3-15.3.12 — the linear transformations and the degenerate logarithmic cases.
- R. C. Forrey, Computing the hypergeometric function, J. Comput. Phys. 137 (1997) 79-100.
- N. Michel and M. V. Stoitsov, Fast computation of the Gauss hypergeometric function with all its parameters complex, Comput. Phys. Commun. 178 (2008) 535-551.
- W. Bühring, An analytic continuation of the hypergeometric series, SIAM J. Math. Anal. 18 (1987) 884-889.
- Source:
src/special_functions/hypergeopfq.c - Specification:
docs/spec/builtins/special-functions.md - Tests:
tests/test_compile.c - Tests:
tests/test_compile_coverage.c - Tests:
tests/test_compiledfunction.c - Tests:
tests/test_dsolve.c
Notes & additional examples¶
Notes¶
Hypergeometric2F1[a, b, c, z]is the Gauss hypergeometric function, equal toHypergeometricPFQ[{a, b}, {c}, z]; an unevaluated call comes back in theHypergeometricPFQform.- At machine precision it is evaluated on the whole complex plane (real
parameters): direct and Pfaff series, the
1-zand1/(1-z)connection formulas, and continuation of the hypergeometric ODE where all of these are slow. On the cutz > 1a real argument gives the value from below, the same convention as Mathematica. With complex parameters only|z| <= 0.9is evaluated. - Arbitrary precision is limited to
|z| < 1, where arb'sacb_hypgeom_2f1is used. An exact or high-precisionzoutside the disc stays unevaluated, and so does the exact value atz = 1. A machinez = 1.uses Gauss's sum. - Attributes
Listable,NumericFunction,Protected. Packed arrays andNDArrayarguments map the machine kernel over the buffer (the coefficient table is built once per buffer); a buffer with an element on the cut comes back complex.Compile[]lowers real and complex scalars; rank-1 array arguments are not lowered yet. - See also:
HypergeometricPFQ,Hypergeometric1F1,LegendreP,EllipticK.