Average Error: 33.4 → 10.2
Time: 31.5s
Precision: 64
Internal Precision: 128
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.468778267430938 \cdot 10^{+135}:\\ \;\;\;\;\frac{(\frac{3}{2} \cdot \left(\frac{a}{\frac{b}{c}}\right) + \left(b \cdot -2\right))_*}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.7918240183827983 \cdot 10^{-125}:\\ \;\;\;\;\frac{1}{3} \cdot \frac{\sqrt{(-3 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{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 b < -2.468778267430938e+135

    1. Initial program 54.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 10.5

      \[\leadsto \frac{\color{blue}{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    3. Simplified2.3

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

    if -2.468778267430938e+135 < b < 1.7918240183827983e-125

    1. Initial program 10.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 *-un-lft-identity10.9

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    4. Applied *-un-lft-identity10.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    5. Applied distribute-lft-out10.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}\]
    6. Applied times-frac11.0

      \[\leadsto \color{blue}{\frac{1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}}\]
    7. Simplified11.0

      \[\leadsto \color{blue}{\frac{1}{3}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{a}\]
    8. Simplified11.0

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

    if 1.7918240183827983e-125 < b

    1. Initial program 50.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around inf 11.5

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.468778267430938 \cdot 10^{+135}:\\ \;\;\;\;\frac{(\frac{3}{2} \cdot \left(\frac{a}{\frac{b}{c}}\right) + \left(b \cdot -2\right))_*}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.7918240183827983 \cdot 10^{-125}:\\ \;\;\;\;\frac{1}{3} \cdot \frac{\sqrt{(-3 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*} - b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019091 +o rules:numerics
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))