Answer the question
In order to leave comments, you need to log in
Why does the number of iterations decrease sharply when finding the machine epsilon for sufficiently small values of the real number?
In general, there is such a piece of code:
cout << "Wtite a num:"; cin>> fNum;
fNum=pow(fNum,-5);
fMachineEps=fNum2=fNum;
do
{
fMachineEps/=2;
fNum=fNum2+fMachineEps;
++itersAmount;
}while(fNum>fNum2);
At the input, we get the number 10(float) and raise it to some negative power, and then find the machine epsilon for it, i.e., if I understand correctly, the minimum number that will be perceived by the machine as not zero, well, the number is considered -in iterations, which remains stable(25) up to 10^(-38). Then there is a decrease in 3-4 iterations with each degree. Why is this happening? I'm guessing the point is that when reaching such values, I get closer to the lowest possible value of the float data type, so less computation is required.
Answer the question
In order to leave comments, you need to log in
float max holds up to +/-38 degree number.
Here is a table of type dimensions.
A machine epsilon is the minimum number such that 1 + ε ≠ 1. So, basically, you calculated it correctly, even though the code is student. But there is one caveat.
The fact is that float and double are normalized and denormalized. What it is?
Any number in the binary system starts with one. Therefore, the head unit is implied and not stored - the so-called. "normalized number". BUT: when the order is 00 ... 00, it is considered that the head is ZERO, and the relative error is replaced by an absolute one - this is a denormalized number.
0 1010…00 00000001 = +0.1101 2 ×2 −127 — normalized number
0 1010…00 00000000 = +0.0101 2 ×2 −127 — denormalized
0 0000…00 00000000 = +0.00002 ×2 −127 . Zero is also a denormalized number.
10 −38 is the minimum normalized number. 10 −45 — minimum denormalized, with mantissa 0.00…001. Remember, I said that in denormalized numbers, the relative error is replaced by the absolute error in these same 10 −45 - because the smaller the number, the more "type-epsilon".
10-byte extended, aka long double, as far as I know, is not normalized, i.e. the head unit is stored explicitly there. But such accuracy is rarely needed, memory overrun appears (2 or 6 bytes, depending on the processor and its settings), and coprocessors are not too optimized for such numbers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question