# Why doesn’t Julia fma automatically?

**URL:** <https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982>\
**Category:** General Usage\
**Created:** [October 13, 2023, 3:31am UTC](https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982 "2023-10-13T03:31:53Z")\
**Posts on this page:** 1\
**Showing post:** 41

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [October 17, 2023, 12:41am UTC](https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982/41 "2023-10-17T00:41:26Z")

</div>

> [@ParadaCarleton](#):
>
> I think your post is the first one to bring up an actual case of these kinds of bugs causing problems in real life.

There were lots of concrete bogus examples in the other thread, I think this was one of the nicest ones:

> [@X \* y + z does not automatically use FMA instruction](https://discourse.julialang.org/t/x-y-z-does-not-automatically-use-fma-instruction/100640/19):
>
> Using FMA automatically can cause surprises. Consider the following: function f(a,b,c) @assert a\*b ≥ c return sqrt(a\*b-c) end a = 1.0 + 0.5^27 b = 1.0 - 0.5^27 c = 1.0 f(a,b,c) It works as expected. Now suppose the compiler automatically uses FMA inside f, like this: function f(a,b,c) @assert a\*b ≥ c return sqrt(fma(a,b,-c)) end Now f(a,b,c) throws and exception, because fma(a,b,-c) is negative, despite the assertion a\*b ≥ c.

And this was your “basic/case easy win `a*x + b`”

---

_[View the full topic](https://discourse.julialang.org/t/why-doesn-t-julia-fma-automatically/104982)._
