# Fast math in NASA benchmark

**URL:** https://discourse.julialang.org/t/fast-math-in-nasa-benchmark/43580
**Category:** General Usage
**Created:** [July 23, 2020, 7:28pm UTC](https://discourse.julialang.org/t/fast-math-in-nasa-benchmark/43580 "2020-07-23T19:28:45Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [July 23, 2020, 8:55pm UTC](https://discourse.julialang.org/t/fast-math-in-nasa-benchmark/43580/8 "2020-07-23T20:55:55Z")

</div>

There was once a very long (non-readers-digest) discussion about this, but this post is fairly self-contained:

> [@Accurate summation algorithm](https://discourse.julialang.org/t/accurate-summation-algorithm/7163/9):
>
> A point I’ve made several times previously is the following: Mathematically, since + is associative and commutative, all correct summation algorithms are algebraically equivalent to each other, in particular they are all equivalent to left-to-right summation. The -ffast-math option gives the compiler license to transform any algorithm into any algebraically equivalent one in the mathematical sense. Therefore -ffast-math gives the compiler license to transform any summation algorithm int…

Especially if you combine it with the fact that you can pick a collection of 2046 numbers that can sum to just about _any_ number depending upon their ordering:

> [@Array ordering and naive summation](https://discourse.julialang.org/t/array-ordering-and-naive-summation/1929):
>
> One of the first things you learn in numerical analysis is that floating-point operations are not associative. A classic example is this: julia\> (0.1 + 0.2) + 0.3 0.6000000000000001 julia\> 0.1 + (0.2 + 0.3) 0.6 I was thinking of ways to make floating-point summation independent of the order of the summands without making the performance much worse (this is a hobby of mine). Julia currently uses a pairwise summation algorithm, which is much better than naive left-to-right reduction while havin…

Base’s code actually depends upon smartly re-ordering summations to improve precision that fast math might break.

---

_[View the full topic](https://discourse.julialang.org/t/fast-math-in-nasa-benchmark/43580)._
