d3/d3-array

Implement exact summation (fsum)?

Fil opened this issue · 1 comments

Fil commented

Discussed with Kahan summation (#33, #149), fsum is a bit slower but provably "exact" and would be the preferred "exact summation" algorithm for d3-array.

I've implemented it in https://observablehq.com/d/723090bd2ef54f5f ; it does not return a sum but an object that can be used to continue the sum by adding more terms.

  • speed test (about 2x slower than d3.sum which is not that bad)
  • a valueof accessor
  • check if this implementation is useful in d3-geo.
  • document
Fil commented

Good news: replacing d3-geo/adder with fsum can help solve https://observablehq.com/@fil/small-circle-test by enhancing the precision of the sums.