Incorrect results from hypergeom function in MATLAB R2018a.
Afficher commentaires plus anciens
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 commentaires
Dyuman Joshi
le 24 Mar 2024
Modifié(e) : Dyuman Joshi
le 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
le 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
le 24 Mar 2024
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Just for fun dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!