Wrong result from calculation
1 view (last 30 days)
I have a question about high precision calculation of the fraction 1/998001 in Matlab. I use
which produces the following result
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?
Steven Lord on 9 Jun 2020
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)