Incorrect results from hypergeom function in MATLAB R2018a.
Mostrar comentarios más antiguos
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 comentarios
Dyuman Joshi
el 24 de Mzo. de 2024
Editada: Dyuman Joshi
el 24 de Mzo. de 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
el 24 de Mzo. de 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
el 24 de Mzo. de 2024
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Just for fun en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!