필터 지우기
필터 지우기

Wrong result from calculation

조회 수: 1 (최근 30일)
Veselin Manev
Veselin Manev 2020년 6월 9일
댓글: Veselin Manev 2020년 6월 9일
Dear all,
I have a question about high precision calculation of the fraction 1/998001 in Matlab. I use
vpa(1/998001,200)
which produces the following result
0.000001002003004005005955287066314596255978131011943332850933074951171875
On the Numberphile channel on youtube, they prove that the result should be
0.000001002003004005006007 .. 996997999
which has higher precision than the obtain result in MATLAB and it appears that there is some numerical error. Do you have any idea why is that?
Thank you
Regards,
Veselin

답변 (1개)

Steven Lord
Steven Lord 2020년 6월 9일
By the time you call vpa, MATLAB has already performed the division in double precision. So you're displaying the double precision value that results from that division to 200 decimal places.
Perform the division symbolically.
x1 = vpa(1/998001, 200)
x2 = vpa(sym(1)/998001, 200)
  댓글 수: 2
madhan ravi
madhan ravi 2020년 6월 9일
“Power of symbolic toolbox” never lets down ;)
Veselin Manev
Veselin Manev 2020년 6월 9일
Thank you very much!

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

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by