Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: hypergeom() gives Inf
Posted:
Jun 30, 2012 3:06 AM
|
|
"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
|
|
|
|