Date: Jun 29, 2012 11:49 AM
Author: kumar vishwajeet
Subject: hypergeom() gives Inf
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.