Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: hypergeom() gives Inf
Replies: 1   Last Post: Jun 30, 2012 3:06 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,737
Registered: 7/26/08
Re: hypergeom() gives Inf
Posted: Jun 30, 2012 3:06 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"kumar vishwajeet" wrote in message <jskipj$kqd$1@newscl01ah.mathworks.com>...
> Hi,
> I am using hypergeom function in Matlab to find 1F1. The arguments of hypergeom are:
> hypergeom(1.5,4,973). I get "Inf" for it. So, I tried to write the code for hypergeom function. Here is the code:
> total = 0;
> a = 1.5;b = 4;z = 973.2763;
> for k = 1:103 %theoretically k goes upto infinity
> num = 1;
> den = 1;
> for i = 1:k
> num = num*(a+i-1);
> den = den*(b+i-1);
> end
> total = total + ((num/den)*(z^k)/factorial(k));
> end
>
> I get Inf when I increase limit of k to 104. Unfortunately, the series in this case is non-converging. i.e as I increase the limit of k, the value "total" increases. How should I go about it??


Doesn't that Inf logical? Why insisting on computing a diverging series?

> Meanwhile, I tried a simple converging series with hypergeom(1,1,2). MATLAB gave me 7.3891.
> I used the code written above to calculate it myself. I got 6.3891 when the last limit of k = 172 i.e.k = 1:172.


It looks like the series starts at 0, not 1 as in your code

> As soon as I increased k to 173, I got NaN. So, I want to know How does the function hypergeom in MATLAB work?? Does it also work for diverging series, as in my case.

What a nonsense question, why do you expect something that would work on an impossible definition (diverging series)?

Bruno



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.