# What's going on with exp() and --math-mode=fast?

**URL:** https://discourse.julialang.org/t/whats-going-on-with-exp-and-math-mode-fast/64619
**Category:** General Usage
**Tags:** fast-math
**Created:** [July 14, 2021, 8:34am UTC](https://discourse.julialang.org/t/whats-going-on-with-exp-and-math-mode-fast/64619 "2021-07-14T08:34:03Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [July 14, 2021, 9:36am UTC](https://discourse.julialang.org/t/whats-going-on-with-exp-and-math-mode-fast/64619/4 "2021-07-14T09:36:12Z")

</div>

The beginning of the code for `exp` looks something like:

```julia
const a = 369.3299304675746
const b = 6.755399441055744e15

function f(x::Float64)
    z = muladd(x, a, b)
    z -= b
end

```

Without `--math-mode=fast` this gives the result `369.0`, with it it gives `369.3299304675746`. Looking at the generated code, in fast mode, it has simplified this code to `x*a`:

```julia
julia> @code_llvm f(1.0)
...
  %1 = fmul fast double %0, 0x40771547652B82FE
  ret double %1
}

```

while it otherwise computes things as given:

```julia
julia> @code_llvm f(1.0)
...
   %1 = fmul contract double %0, 0x40771547652B82FE
   %2 = fadd contract double %1, 0x4338000000000000
   %3 = fadd double %2, 0xC338000000000000
  ret double %3
}

```

There can be an arbitrary error in the final result from such a change.

---

_[View the full topic](https://discourse.julialang.org/t/whats-going-on-with-exp-and-math-mode-fast/64619)._
