Converge to zero through underflow

please ignore this post, I read the algorithm incorrectly, so the question does not matter. However, I can no longer close the post . Please vote to close

I use a specific algorithm from numerical recipes that converges to zero through underflow:

// all types are the same floating type
sum = 0
for (i in 0,N)
   sum += abs(V[i]);

my question is how does this happen? how does the sum of small positive floating point numbers converge to underflow / zero?

is there any condition where 0 + f = 0 , f > 0?

the algorithm in question is Jacobi, http://www.mpi-hd.mpg.de/astrophysik/HEA/internal/Numerical_Recipes/f11-1.pdf , p. 460. It is possible that I misunderstand how convergence is achieved if it is so please correct me.

Thank you

+3
3

V - doubles, sum - float ( single), > 0, 0, , float.

, sum , ? ?

: , , . , , . .

+2

? f - float, d1 d2 - , .

double d1 = std::numeric_limits<double>::min();
double d2 = std::numeric_limits<double>::min();
float f = d1 + d2;
if (f == 0.0) std::cout << "yes";
else std::cout << "no";

"".

+1

, IEEE 754. , IEEE 754 , , .

So, if you have sum + V[i], this value will always be greater than or equal sum. Rounding to the next representable number will either result in an expression sumor a larger number sum.

Of course, there is nothing in the original question that would prevent sumbeing negative in the first place. In this case, the answer will be trivial.

IEEE 754 arithmetic does not have a number fsuch as 0 + f = 0at the same time f > 0.

0
source

Source: https://habr.com/ru/post/1754871/


All Articles