MathGroup Archive 2009

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

Search the Archive

Re: Re: Bug with Hypergeometric2F1?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99563] Re: [mg99544] Re: Bug with Hypergeometric2F1?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 8 May 2009 00:14:30 -0400 (EDT)
  • References: <200905071038.GAA19604@smc.vnet.net>

On 7 May 2009, at 19:38, Bill Rowe wrote:

> On 5/6/09 at 5:21 AM, akoz at mimuw.edu.pl (Andrzej Kozlowski) wrote:
>
>> On 5 May 2009, at 18:40, Bill Rowe wrote:
>>
>>> If you want to use machine precision numbers you should be using
>>> NSum rather than Sum. That is:
>
>>> In[4]:= f[n_, k_] := NSum[Binomial[n, i], {i, 0, k}]
>
>>> In[5]:= f[1000, 1.]
>
>>> Out[5]= 1001.
>
>> The supposed advantage of NSUm over Sum in this particular case is a
>> mere illusion.
>
>> g[n_, k_] := Sum[Binomial[n, i], {i, 0, k}]
>> g[1000, 1.]
>> 1001
>
>> Note that you are using SetDelayed while the original post has Set;
>> hence the difference.
>
> I don't believe your interpretation of what occurs is correct. I
> am reasonably certain when you use Sum with machine precision
> numbers a numerical estimate is made using the same code used by
> NSum. That is, I believe the effect of using machine precision
> numbers is to call NSum.
>
> I used SetDelayed since Set cannot be used with NSum in this
> example. With Set, Mathematica tries to evaluate the right hand
> side which cannot be done since n and k are not defined at this point.
>
>


Sorry, but I think it is you who is confused. The point is this: when  
you evaluate Sum[Binomial[100., i], {i, 0, 1.}], which is what you are  
doing when you use SetDelayed, Mathematica automatically replaces  
approximate numbers by exact ones when evaluating the sum, so it gets  
the right answer anyway. The original problem had nothing to do with  
Sum or NSum at all, that's what I meant by "illusion". It was all  
concenred with evaluating the formula:

2^n - Binomial[n, k + 1]*Hypergeometric2F1[1,  k - n + 1, k + 2, -1]

with n and k approximate numbers. It is this formula and not Sum that  
is the cause of the problem. The problem would still be present if f  
was defined simply as

f[n_,k_]=2^n - Binomial[n, k + 1]*Hypergeometric2F1[1,  k - n + 1, k +  
2, -1]


If you use SetDelayed in the original definition of f,  the  above  
formula is never used so the issue does not arise. NSum was completely  
irrelevant to this problem.

Andrzej Kozlowski

  


  • Prev by Date: Re: copy and paste to other programs
  • Next by Date: Re: copy and paste to other programs
  • Previous by thread: Re: Bug with Hypergeometric2F1?
  • Next by thread: Re: Bug with Hypergeometric2F1?