(en.wikipedia.org) Kahan summation algorithm - Wikipedia

ROAM_REFS: https://en.wikipedia.org/wiki/Kahan_summation_algorithm

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 naive approach. This is done by keeping a separate running compensation (a variable to accumulate small errors), in effect extending the precision of the sum by the precision of the compensation variable.

In particular, simply summing \(n\) numbers in sequence has a worst-case error that grows proportional to \(n\), and a root mean square error that grows as \(\sqrt{n}\) for random inputs (the roundoff errors form a random walk). With compensated summation, using a compensation variable with sufficiently high precision the worst-case error bound is effectively independent of \(n\), so a large number of values can be summed with an error that only depends on the floating-point precision of the result.

The algorithm is attributed to William Kahan; Ivo Babuška seems to have come up with a similar algorithm independently (hence Kahan–Babuška summation). Similar, earlier techniques are, for example, Bresenham's line algorithm, keeping track of the accumulated error in integer operations (although first documented around the same time) and the delta-sigma modulation.

Local Graph

org-roam 72b48fe7-9cba-4953-8624-580b8fea2485 (en.wikipedia.org) Kahan summation al... //en.wikipedia.org/wiki/Numerical_analysis https://en.wikipedia.org/wiki/Numerical_analysis 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Numerical_analysis //en.wikipedia.org/wiki/Numerical_error https://en.wikipedia.org/wiki/Numerical_error 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Numerical_error //en.wikipedia.org/wiki/Sequence https://en.wikipedia.org/wiki/Sequence 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Sequence //en.wikipedia.org/wiki/Decimal_precision https://en.wikipedia.org/wiki/Decimal_precision 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Decimal_precision //en.wikipedia.org/wiki/Floating-point_number https://en.wikipedia.org/wiki/Floating-point_number 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Floating-point_number //en.wikipedia.org/wiki/Root_mean_square https://en.wikipedia.org/wiki/Root_mean_square 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Root_mean_square //en.wikipedia.org/wiki/Random_walk https://en.wikipedia.org/wiki/Random_walk 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Random_walk //en.wikipedia.org/wiki/Precision_(arithmetic) https://en.wikipedia.org/wiki/Precision_(arithmetic) 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Precision_(arithmetic) //en.wikipedia.org/wiki/Algorithm https://en.wikipedia.org/wiki/Algorithm 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Algorithm //en.wikipedia.org/wiki/William_Kahan https://en.wikipedia.org/wiki/William_Kahan 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/William_Kahan //en.wikipedia.org/wiki/Ivo_Babuška https://en.wikipedia.org/wiki/Ivo_Babuška 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Ivo_Babuška //en.wikipedia.org/wiki/Bresenham's_line_algorithm //en.wikipedia.org/wiki/Bresenham's_line_algorithm 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Bresenham's_line_algorithm //en.wikipedia.org/wiki/Delta-sigma_modulation https://en.wikipedia.org/wiki/Delta-sigma_modulation 72b48fe7-9cba-4953-8624-580b8fea2485->//en.wikipedia.org/wiki/Delta-sigma_modulation //en.wikipedia.org/wiki/Bresenham's_line_algorithm https://en.wikipedia.org/wiki/Bresenham's_line_algorithm