Popular articles

How to write the Kahan summation algorithm in pseudocode?

How to write the Kahan summation algorithm in pseudocode?

In pseudocode, the algorithm is: function KahanSum(input) var sum = 0.0 var c = 0.0 // A running compensation for lost low-order bits. for i = 1 to input.length do var y = input[i] – c // So far, so good: c is zero. var t = sum + y // Alas, sum is big, y small, so low-order digits of y are lost.

How is Kahan summation used in numerical analysis?

In numerical analysis, the Kahan summation algorithm, also known as compensated summation, significantly reduces the numerical error in the total obtained by adding a sequence of finite- precision floating-point numbers, compared to the obvious approach.

Are there any libraries that support Kahan summation?

Support by libraries. In general, built-in “sum” functions in computer languages typically provide no guarantees that a particular summation algorithm will be employed, much less Kahan summation.

How is the error bound of a summation algorithm related?

The relative error bound of every ( backwards stable) summation method by a fixed algorithm in fixed precision (i.e. not those that use arbitrary precision arithmetic, nor algorithms whose memory and time requirements change based on the data), is proportional to this condition number.

Which is an example of a summation algorithm?

For example, we found in Section 1.2 that the jth iteration of insertion sort took time proportional to jin the worst case. By adding up the time spent on each iteration, we obtained the summation (or series)

Which is more accurate Kahan summation or naive summation?

A careful analysis of the errors in compensated summation is needed to appreciate its accuracy characteristics. While it is more accurate than naive summation, it can still give large relative errors for ill-conditioned sums. Suppose that one is summing n values xi, for i = 1,