Is there a function in MATLAB which reports the amount of error in the double-precision representation of a number?
For example, if I do the following in MATLAB:
>> a = double(2.2e-11);
Then a will come back when displayed using "format long" as:
a = 2.200000000000000e-11
so it appears there is perfect representation of a. But this is misleading I believe.
For example, I can prove this using another simple example:
d = 0.1;
d1 = d + eps(d)
Both d and d1 will display using format long as:
0.100000000000000
But when displayed using format hex they are different by 1 bit place as expected:
d = 3fb999999999999a
d1 = 3fb999999999999b
Now back to the original question, is there a way to quantify the difference, i.e. error, between the double precision representation of a double precision number like 2.2e-11 (which is 0x3db83073119f21d8) and the pure mathematical number 2.2e-11?
The function eps only tells me the step size for a given floating point value. It doesn't tell me error however. The error will be somewhere between 0 and eps, i.e. it's bounded by eps, but one cannot tell more than that.
Best Answer