The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]
kumar vishwajeet

Posts: 96
Registered: 4/6/10
hypergeom() gives Inf
Posted: Jun 29, 2012 11:49 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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);
total = total + ((num/den)*(z^k)/factorial(k));

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??
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. 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.


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.