Average Error: 33.4 → 9.8
Time: 20.6s
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.227559942910082 \cdot 10^{+74}:\\ \;\;\;\;\frac{\frac{(\frac{3}{2} \cdot \left(\frac{a}{\frac{b}{c}}\right) + \left(b \cdot -2\right))_*}{3}}{a}\\ \mathbf{elif}\;b \le 1.1130390635885432 \cdot 10^{-84}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} + \left(-b\right)}{3}}{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.227559942910082e+74

    1. Initial program 39.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*39.7

      \[\leadsto \color{blue}{\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}}\]
    4. Taylor expanded around -inf 9.4

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

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

    if -2.227559942910082e+74 < b < 1.1130390635885432e-84

    1. Initial program 12.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*12.7

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

    if 1.1130390635885432e-84 < b

    1. Initial program 52.3

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

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

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

Reproduce

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