Average Error: 44.3 → 42.5
Time: 1.3m
Precision: 64
Internal Precision: 3200
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -2.2160293792658697 \cdot 10^{-307}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{3} \cdot \frac{b}{a}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -2.2160293792658697e-307

    1. Initial program 24.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]

    if -2.2160293792658697e-307 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 61.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied expm1-log1p-u61.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{(e^{\log_* (1 + \left(3 \cdot a\right) \cdot c)} - 1)^*}}}{3 \cdot a}\]
    4. Taylor expanded around inf 61.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(\left(\frac{1}{3} \cdot \frac{e^{\log 3 - \left(\log \left(\frac{1}{c}\right) + \log \left(\frac{1}{a}\right)\right)}}{c \cdot a} + e^{\log 3 - \left(\log \left(\frac{1}{c}\right) + \log \left(\frac{1}{a}\right)\right)}\right) - 1\right)}}}{3 \cdot a}\]
    5. Applied simplify61.8

      \[\leadsto \color{blue}{\frac{\sqrt{(b \cdot b + 1)_* - (\frac{1}{3} \cdot \left(\frac{a \cdot 3}{a}\right) + \left(\left(a \cdot c\right) \cdot 3\right))_*} - b}{a \cdot 3}}\]
    6. Taylor expanded around -inf 58.5

      \[\leadsto \color{blue}{\frac{-2}{3} \cdot \frac{b}{a}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.3m)Debug logProfile

herbie shell --seed '#(1070706311 3771791028 4128836681 4194990999 2341756049 504035650)' +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))