MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bug with Hypergeometric2F1?

  • To: mathgroup at
  • Subject: [mg99400] Re: [mg99384] Bug with Hypergeometric2F1?
  • From: Andrzej Kozlowski <akoz at>
  • Date: Tue, 5 May 2009 05:39:32 -0400 (EDT)
  • References: <>

This is just the usual machine precision problem. What happens is that  
your vol1 first evaluates to

  vol1[n_, k_] = Sum[Binomial[n, i], {i, 0, k}]
  2^n - Binomial[n, k + 1]*Hypergeometric2F1[1, k - n + 1, k + 2, -1]

Now, this is defined for arbitrary k, not just integers, but the  
expression is numerically sensitive and you can check that you need   
precision of about 303 (or more) in the second argument to get the  
"right answer":

vol1[1000, 1`303]


In[21]:= vol1[1000, 1`302]
Out[21]= 1.00*10^3

and with only hundred digits of precision

vol1[1000, 1`100]

which should make it pretty clear why you can't get a sensible answer  
with MachinePrecision, which only uses about 16 digits.
On the other hand:

Sum[Binomial[1000, i], {i, 0, 1.}]

because this time Mathematica does not compute the numerically  
sensitive general formula but replaces your inexact (and hence  
nonsensical) limit in Sum by an exact one and gets the "right" answer.

(I put "right" in quotation marks because actually your input clearly  
does not make sense and so Sum would be justified in returning any  
answer on the GIGO principle).

Andrzej Kozlowski

On 4 May 2009, at 19:02, irchans wrote:

> When I run this code:
> vol1[n_, k_] = Sum[ Binomial[n, i], {i, 0, k}]
> vol1[1000, 1]
> vol1[1000, 1.]
> I get
> Out[1] = 1001
> Out[2] = 7.12935*10^288
> I am running Mathematica 7.0.0 on windows 2000.  Does anyone else have
> this problem?

  • Prev by Date: Some function like Position[] but uses criteria, not pattern?
  • Next by Date: Re: Control[], Manipulate, Why labels not showing?
  • Previous by thread: Re: Bug with Hypergeometric2F1?
  • Next by thread: Re: Bug with Hypergeometric2F1?