# Hypergeometric function representation in other forms for faster computation

I am using two hypergeomtric functions with MATLAB:

$_2F_1(a, b, a+1, d)$ and $_2F_1(a+1, b, a+2, d)$, where $d$ is from the open interval $(0,1)$ and $a > 0$, $b < 0$, all real numbers

However, evaluation in Matlab is extremely slow. Are there ways I can formulate this into another function that is much faster. Or, if there is any relationship between the 1st and 2nd hypergeometric functions? I would like to be able to reduce computation time by half possibly.

• See my answer here. Depending on the nature of your problem you may be able to use my hypergeom2F1 function or my optimized version of Matlab's hypergeom. Be sure to confirm that your results are consistent to the degree of accuracy you require. – horchler Mar 10 '17 at 18:08
• You can find a large number of alternate forms for the Gauss hypergeometric function $_2F_1$ at Wolfram's functions site. – horchler Mar 10 '17 at 18:11
• Thank you very much. I came across this response yesterday and implemented the hypergeomq function. The improvement in computation time is drastic! An order of magnitude difference. Solves my issue. – user424072 Mar 11 '17 at 13:09

I suggest to compare the times of computation for the hypergeometric function and the incomplete Beta function : $$_2F_1(a,b,a+1,x)=a\:x^{-a}B_x(a,1-b)$$ $$_2F_1(a+1,b,a+2,x)=a\:x^{-(a+1)}B_x(a+1,1-b)$$ Also, compare with the direct numerical integration method. See equation (1) in : http://mathworld.wolfram.com/IncompleteBetaFunction.html $$_2F_1(a,b,a+1,x)=a\:x^{-a}\int_0^x \frac{t^{a-1}}{(1-t)^b}dt$$ $$_2F_1(a+1,b,a+2,x)=(a+1)\:x^{-(a+1)}\int_0^x \frac{t^{a}}{(1-t)^b}dt$$
Note : For $x=\epsilon$ close to $0$ the integral reduces to $\int_0^\epsilon \frac{t^{a-1}}{(1-t)^b}dt\simeq a^{-1}\epsilon^a$.
• $1-x$ should be $1-t$ in the integrand. – WimC Mar 10 '17 at 18:33