A comparison of float calculation and exact expression for
NumberForm[0.3^2 - (3/10)^2, 18]
gives an exact zero for $0.3$. However,
R[n_Integer] = n 1./10.;
Rex[n_Integer] = n/10;
Table[R[n]^2 - Rex[n]^2, {n, 1, 5}]
gives
{1.73472*10^-18, 6.93889*10^-18, 2.77556*10^-17, 2.77556*10^-17, 0.}
Thus, here we get
0.3^2 - (3/10)^2 = 2.77556*10^-17
instead of zero. Why is the ouput different in the Table[] calculation?
0.3^2 - (3/10)^2return0.whileR[3]^2 - Rex[3]^2returns2.77556*10^-17? – anderstood Jul 20 '17 at 18:06R[3]: `In[17]:= {.3, (3*1./10)} // InputFormOut[17]//InputForm= {0.3, 0.30000000000000004}`
– Daniel Lichtblau Jul 20 '17 at 18:45