Skip to content

Commit

Permalink
add another algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Mar 29, 2024
1 parent ef61b90 commit 2d1ac79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Instead of specifying any particular algorithm, this proposal requires the maxim
Python's [`math.fsum`](https://docs.python.org/3/library/math.html#math.fsum) is currently implemented using the same algorithm (though without handling intermediate overflow).

A more recent algorithm is given in [Fast exact summation using small and large superaccumulators](https://arxiv.org/abs/1505.05571) by Radford M. Neal, MIT-licensed code for which is available [here](https://gitlab.com/radfordneal/xsum).

### Iterable-taking or variadic?

`Math.max` precedent suggests variadic, but that's really not what you want - once your lists get larger than a few tens of thousands of elements, you'll probably overflow the stack and get a RangeError.
Expand Down
3 changes: 2 additions & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ <h1>Math.sumExact ( _items_ )</h1>
1. If _state_ is ~minus-infinity~, return *-∞*<sub>𝔽</sub>.
1. If _state_ is ~minus-zero~, return *-0*<sub>𝔽</sub>.
1. Return 𝔽(_sum_).
1. NOTE: The value of _sum_ can be computed without arbitrary-precision arithmetic by a variety of algorithms. One such is the "Grow-Expansion" algorithm given in <i>Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates</i> by Jonathan Richard Shewchuk.
1. NOTE: The value of _sum_ can be computed without arbitrary-precision arithmetic by a variety of algorithms. One such is the "Grow-Expansion" algorithm given in <i>Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates</i> by Jonathan Richard Shewchuk. A more recent algorithm is given in "<a href="https://arxiv.org/abs/1505.05571">Fast exact summation using small and large superaccumulators
</a>", code for which is available <a href="https://gitlab.com/radfordneal/xsum">here</a>.
</emu-alg>
</emu-clause>

0 comments on commit 2d1ac79

Please sign in to comment.