Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As part of another problem, I am working to evaluate hypergeometric functions such as

Hypergeometric2F1[1, 1, n, -1]

for large $n$. I am hoping to obtain at least double-precision accuracy all the way through n = 1600. However, starting as low as n = 200, I obtain precision errors:

N[Hypergeometric2F1[1, 1, 200, -1], 17]
N::meprec: Internal precision limit

Are there ways to tell Mathematica it can use as much time as it wants to compute this quantity? Or are there any other workarounds?

share|improve this question
Try this Block[{$MaxExtraPrecision = 100}, N[Hypergeometric2F1[1, 1, 200, -1], 17]] – Spawn1701D Jun 7 '13 at 18:54
Better: Hypergeometric2F1[1, 1, 200, N[-1, 17]]. The problem is that N[] is by default unable to cope with the exact result being returned by Hypergeometric2F1[]. – J. M. Jun 7 '13 at 19:02
up vote 6 down vote accepted

Before people get any ideas: although we have the identity:

$${}_2 F_1\left({{1,1}\atop{m}}\mid -1\right)=\frac{m-1}{2}\Phi\left(\frac12,1,m-1\right)$$

where $\Phi(z,s,a)$ is the Lerch transcendent; or, in Mathematica notation:

Hypergeometric2F1[1, 1, m, -1] == (m - 1) HurwitzLerchPhi[1/2, 1, m - 1]/2

the computation becomes even more unstable with that replacement (I'm not really sure why); don't use it.

In any event, we have the relations

$$\begin{align*} {}_2 F_1\left({{1,1}\atop{m}}\mid -1\right)&=2^{m-2}(m-1)\sum_{k=m-1}^\infty \frac1{k 2^k}\\ &=2^{m-2}(m-1)\left(\log\,2-\sum_{k=1}^{m-2}\frac1{k 2^k}\right) \end{align*}$$

where we see why N[] might have a spot of trouble with evaluating the exact expression produced by Hypergeometric2F1[]: $\sum\limits_{k=1}^{m-2}\frac1{k 2^k}\approx \log\,2$, with the difference getting smaller as $m\to\infty$, and we thus see a fair amount of catastrophic cancellation during numerical evaluation. In particular, for $m=200$, $\sum\limits_{k=1}^{m-2}\frac1{k 2^k}$ and $\log\,2$ agree to $61$ (!) decimal places.

Fortunately for us, Hypergeometric2F1[] can cope nicely with inexact arguments:

Hypergeometric2F1[1, 1, N[200, 20], -1]

In short: just supply inexact numbers to Hypergeometric2F1[] at the outset.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.