# Evaluate numerically derivatives of hypergeometric functions

I would like to evaluate numerically the coefficients of a series expansion. This is usually straightforward to do, however in this case I encounter terms of the following type:

$$^{\phantom{0}}_2F_1^{(0,1,0,1)} \left( \frac{1}{2} , 1 , \frac{3}{2} , 0 \right). \tag{1}$$

Using N on such an expression gives the following output:

Limit[Indeterminate, SystemHypergeometricPFQDumpeps$$148402513$$148402514 -> 0, Analytic -> False, Assumptions -> True, Direction -> Automatic, Method -> "InternalClassic"]


I am not sure how to interpret this message, but when I plot this function:

$$^{\phantom{0}}_2F_1^{(0,1,0,1)} \left( \frac{1}{2} , 1 , \frac{3}{2} , x \right), \tag{2}$$

for $$-1 it seems continuous (and non-zero) at $$x=0$$. So what gives? How can I get the numerical values for expressions such as (1)? I have other similar hypergeometric functions with the same problem. I tried increasing the working precision of N but that did not help.

The code that creates the unexpected message above:

\!$$\*SuperscriptBox[\(Hypergeometric2F1$$, TagBox[RowBox[{"(",RowBox[{"0", ",", "1", ",", "0", ",", "1"}], ")"}],Derivative],MultilineFunction->None]\)[1/2, 1, 3/2, 0] // N

• You should file a bug report. In the meantime With[{zero = 10.^-10}, Derivative[0, 1, 0, 1][Hypergeometric2F1][1/2, 1, 3/2, zero]] or similar. Sep 1 '20 at 10:36
• @Natas Okay I filed a bug report. Thanks for the suggestion.
– Pxx
Sep 1 '20 at 10:56

In my experience it is often easier to express the hypergeometric function in terms of its defining sum, and then work with the terms of this sum individually.

For the present case, starting from $$g(x,y)={_2}F_{1}\left(\frac12,y,\frac32,x\right)= \sum_{k=0}^{\infty}\frac{\left(\frac12\right)_k\left(y\right)_k}{\left(\frac32\right)_k}\frac{x^k}{k!}$$ we have $$\frac{\partial^2 g(x,y)}{\partial x\partial y}= \sum_{k=0}^{\infty}\frac{\left(\frac12\right)_k\left(y\right)_k\left[\psi(y+k)-\psi(y)\right]}{\left(\frac32\right)_k}\frac{k x^{k-1}}{k!}$$ in terms of the digamma function $$\psi(z)$$ that is PolyGamma in Mathematica.

Evaluating the terms in the sum for the specific values $$y=1$$ and $$x=0$$:

Table[Pochhammer[1/2,k]*Pochhammer[y,k]*(PolyGamma[y+k]-PolyGamma[y])/Pochhammer[3/2,k]*
k*x^(k-1)/k!, {k, 0, 20}] /. {y -> 1, x -> 0}

(*    {0, 1/3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}    *)


So you see that only one term remains, and the result is $$1/3$$.

Another way of proceeding is to take the derivatives one by one and studying intermediate results:

D[Hypergeometric2F1[1/2, y, 3/2, x], x]

(*    ((1 - x)^-y - Hypergeometric2F1[1/2, y, 3/2, x])/(2 x)    *)

Limit[%, x -> 0]

(*    y/3    *)


which implies that $$\left.\frac{\partial^2 g(x,y)}{\partial x \partial y}\right|_{x=0}=\frac13$$ $$\forall y$$.

• The hypergeometric functions just showed up in the expansion of a series, I "didn't order them". Your solution is nice but implies that I have to rewrite the (huge) content of the series expansion, right?
– Pxx
Sep 1 '20 at 14:50
• @Jxx In similar cases you should take an appropriately long Taylor series in a close point and calculate it in the point where you are lookin for the value. Alternatively you should use PadeApproximant. In the both cases you can get a good approximation of the actual value assuming you can expand your function in a power series, which is the case here since hypergeometric functions are holomorphic. Sep 2 '20 at 10:54