There are two similar matlab programs, one iterates 10 times while another iterates 11 times.
One:
i = 0;
x = 0.0;
h = 0.1;
while x < 1.0
i = i + 1;
x = i * h;
disp([i,x]);
end
Another:
i = 0;
x = 0.0;
h = 0.1;
while x < 1.0
i = i + 1;
x = x + h;
disp([i,x]);
end
I don’t understand why there is difference between the floating point add operation and the multiple.
Compare the output of the following:
Also compare against using MATLAB’s COLON operator:
If you want to see the 64-bit binary representation, use:
Some suggested readings (MATLAB related):
Accuracy
my answer is the result of round-off
error or a bug?
work?