필터 지우기
필터 지우기

Incorrect results from hypergeom function in MATLAB R2018a.

조회 수: 2 (최근 30일)
yann
yann 2024년 3월 24일
댓글: Dyuman Joshi 2024년 4월 19일
In view of the following exact result:
2F1(1-n,1+n;3/2;1/2) =sin(/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
Manikanta Aditya
Manikanta Aditya 2024년 3월 24일
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
yann 2024년 3월 24일
Thank all of you very much.
In MATLAB R2018b:
n = 300
>> hypergeom([1-n,1+n],1.5,0.5)
ans = -4.0076e-06
Nevertheless, In MATLAB R2016b, I obtain the correct answer:
n = 300
>> hypergeom([1-n,1+n],1.5,0.5)
ans = 0
How the disrepancy between MATLAB R2018b and MATLAB R2016a is explained?

댓글을 달려면 로그인하십시오.

채택된 답변

Amal Raj
Amal Raj 2024년 4월 16일
The difference is likely due to improvements or changes in MATLAB's numerical algorithms between versions R2016b and R2018b. While such discrepancies can be confusing, they often reflect efforts to improve the accuracy and reliability of numerical computations. For critical applications, it's always a good practice to check the release notes of MATLAB for any changes in numerical functions you rely on and to consider the implications of numerical precision and stability in your computations.
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2024년 4월 19일
FYI - Release Notes for R2016b and R2018b are not available on the online MATLAB Release Notes documentation page. (The earliest one available right now is of R2019a, same as function documentations - only the information for last 5 years is available online)
I suppose one would have to contact the support team for that. And they would provide a better answer and clarification regarding the same as well, with appropriate information/explaination.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by