# Should Julia guarantee semi-monotonic where appropriate (or even monotonic) math?

**URL:** <https://discourse.julialang.org/t/should-julia-guarantee-semi-monotonic-where-appropriate-or-even-monotonic-math/140346>\
**Category:** Internals & Design\
**Created:** [October 29, 2026, 5:20pm UTC](https://discourse.julialang.org/t/should-julia-guarantee-semi-monotonic-where-appropriate-or-even-monotonic-math/140346 "2026-10-29T17:20:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [October 29, 2026, 5:20pm UTC](https://discourse.julialang.org/t/should-julia-guarantee-semi-monotonic-where-appropriate-or-even-monotonic-math/140346/1 "2026-10-29T17:20:23Z")

</div>

Continuing the discussion from [Formalizing Julia in Lean (and finding 400+ bugs in Base)](https://discourse.julialang.org/t/formalizing-julia-in-lean-and-finding-400-bugs-in-base/140243/15):

> [@Formalizing Julia in Lean (and finding 400+ bugs in Base)](https://discourse.julialang.org/t/formalizing-julia-in-lean-and-finding-400-bugs-in-base/140243/15):
>
> Also, `tanh(::Float32)` appears to be [locally non-monotonic](https://github.com/JuliaLang/julia/issues/64225) at an ordinary Float32 value

I see at the Java docs [see linked from the issue] even the sine function is guaranteed semi-monotonic… Semi-monotonic doesn’t imply correctly rounded I think i.e. it’s a stricter goal. I just discovered the non-monotonic bug and existence of semi- definition. Correctly rounding is a trade-off might be slower, not sure about semi-.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [October 29, 2026, 6:21pm UTC](https://discourse.julialang.org/t/should-julia-guarantee-semi-monotonic-where-appropriate-or-even-monotonic-math/140346/2 "2026-10-29T18:21:56Z")

</div>

I think monotonic/semi-monotonic should be cheaper than correctly rounded (although it’s of course much harder for Float64 especially on multiple argument functions)
