# Reduce vs. foldl: performance and precision

**URL:** https://discourse.julialang.org/t/reduce-vs-foldl-performance-and-precision/43231
**Category:** Performance
**Tags:** question, unrolling
**Created:** [July 17, 2020, 12:07pm UTC](https://discourse.julialang.org/t/reduce-vs-foldl-performance-and-precision/43231 "2020-07-17T12:07:45Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)
#### Post date: [July 17, 2020, 12:36pm UTC](https://discourse.julialang.org/t/reduce-vs-foldl-performance-and-precision/43231/2 "2020-07-17T12:36:31Z")

</div>

The `foldl` call sums the numbers strictly from left to right whereas `sum` uses [pairwise summation](https://en.wikipedia.org/wiki/Pairwise_summation), which is much more accurate and also faster. Doing a left-to-right SIMD summation would be even faster but not as accurate (although slightly more accurate than strict left-to-right). Floating-point summation is an unexpectedly deep and tricky problem.

---

_[View the full topic](https://discourse.julialang.org/t/reduce-vs-foldl-performance-and-precision/43231)._
