Average Error: 33.5 → 14.1
Time: 2.5m
Precision: 64
Internal Precision: 3392
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) = -\infty:\\ \;\;\;\;\frac{-c}{b + b}\\ \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \le -1.5982339424674708 \cdot 10^{-255}:\\ \;\;\;\;\frac{\frac{\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3}}{a}\\ \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \le 2.855099414002002 \cdot 10^{-254}:\\ \;\;\;\;\frac{-c}{b + b}\\ \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \le 3.4191119758542845 \cdot 10^{+293}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b + b}\\ \end{array}\]

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 3 regimes
  2. if (* (- (sqrt (fma (* 3 a) (- c) (* b b))) b) (/ 1 (* 3 a))) < -inf.0 or -1.5982339424674708e-255 < (* (- (sqrt (fma (* 3 a) (- c) (* b b))) b) (/ 1 (* 3 a))) < 2.855099414002002e-254 or 3.4191119758542845e+293 < (* (- (sqrt (fma (* 3 a) (- c) (* b b))) b) (/ 1 (* 3 a)))

    1. Initial program 58.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Applied simplify58.4

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--59.1

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} \cdot \sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b \cdot b}{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} + b}}}{3 \cdot a}\]
    5. Applied simplify38.1

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

      \[\leadsto \frac{\frac{\left(c \cdot a\right) \cdot \left(-3\right)}{\color{blue}{b} + b}}{3 \cdot a}\]
    7. Applied simplify22.6

      \[\leadsto \color{blue}{\frac{c}{b + b} \cdot \left(-1\right)}\]

    if -inf.0 < (* (- (sqrt (fma (* 3 a) (- c) (* b b))) b) (/ 1 (* 3 a))) < -1.5982339424674708e-255

    1. Initial program 4.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Applied simplify4.0

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied associate-/r*4.0

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3}}{a}}\]

    if 2.855099414002002e-254 < (* (- (sqrt (fma (* 3 a) (- c) (* b b))) b) (/ 1 (* 3 a))) < 3.4191119758542845e+293

    1. Initial program 4.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Applied simplify4.1

      \[\leadsto \color{blue}{\frac{\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-inv4.1

      \[\leadsto \color{blue}{\left(\sqrt{(\left(3 \cdot a\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \cdot \frac{1}{3 \cdot a}}\]
  3. Recombined 3 regimes into one program.
  4. Applied simplify14.1

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) = -\infty:\\ \;\;\;\;\frac{-c}{b + b}\\ \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \le -1.5982339424674708 \cdot 10^{-255}:\\ \;\;\;\;\frac{\frac{\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b}{3}}{a}\\ \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \le 2.855099414002002 \cdot 10^{-254}:\\ \;\;\;\;\frac{-c}{b + b}\\ \mathbf{if}\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right) \le 3.4191119758542845 \cdot 10^{+293}:\\ \;\;\;\;\frac{1}{a \cdot 3} \cdot \left(\sqrt{(\left(a \cdot 3\right) \cdot \left(-c\right) + \left(b \cdot b\right))_*} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{b + b}\\ \end{array}}\]

Runtime

Time bar (total: 2.5m)Debug logProfile

herbie shell --seed '#(1072936661 1621281212 3440817831 3219514234 460296804 1258167384)' +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))