Incorrect results from hypergeom function in MATLAB R2018a.
Show older comments
In view of the following exact result:
2F1(1-n,1+n;3/2;1/2) =sin(nπ/2)/n
one would expect the result:
hypergeom([1−n,1+n],1.5,0.5)=0 if n is even.
However, for n=300, Matlab R2018a yields:
hypergeom([1−n,1+n],1.5,0.5)=Inf.
Why does this happen?
3 Comments
Dyuman Joshi
on 24 Mar 2024
Edited: Dyuman Joshi
on 24 Mar 2024
Can you share a picture of the result, along with the code?
FYI, the results in R2023b are as follows -
n=300;
%numeric function
hypergeom([1-n,1+n],1.5,0.5)
%symbolic function
hypergeom(sym([1-n,1+n]), sym(1.5), sym(0.5))
Manikanta Aditya
on 24 Mar 2024
Mostly the issue here is due to the limitations of numerical precision and the way 'hypergeom' function handles larger inputs.
In your case, when n=300, the parameters of the hypergeom function become very large ([1−300,1+300]), which can lead to numerical instability and might result in MATLAB returning Inf.
If you need to compute the hypergeometric function for large parameters, you might need to use more specialized numerical methods or software that can handle such cases.
Thanks!
yann
on 24 Mar 2024
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!