Average Error: 33.3 → 6.6
Time: 1.6m
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}\;b \le -2.4303065077827792 \cdot 10^{+145}:\\ \;\;\;\;\frac{-2}{3} \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.5014879013292337 \cdot 10^{-291}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}{3}}{a}\\ \mathbf{elif}\;b \le 5.008686661579128 \cdot 10^{+94}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \sqrt{(-3 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\left(-b\right) - 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 4 regimes
  2. if b < -2.4303065077827792e+145

    1. Initial program 56.9

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

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

    if -2.4303065077827792e+145 < b < -1.5014879013292337e-291

    1. Initial program 9.0

      \[\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*9.0

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

    if -1.5014879013292337e-291 < b < 5.008686661579128e+94

    1. Initial program 30.6

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Applied associate-/l/36.1

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

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

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

      \[\leadsto \frac{\frac{3 \cdot \left(c \cdot a\right)}{3 \cdot a}}{\color{blue}{\left(-b\right) - \sqrt{(\left(a \cdot -3\right) \cdot c + \left(b \cdot b\right))_*}}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity15.6

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

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

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

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

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

    if 5.008686661579128e+94 < b

    1. Initial program 58.4

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    4. Applied associate-/l/58.7

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \frac{c}{\left(-b\right) - \color{blue}{b}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.4303065077827792 \cdot 10^{+145}:\\ \;\;\;\;\frac{-2}{3} \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.5014879013292337 \cdot 10^{-291}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}{3}}{a}\\ \mathbf{elif}\;b \le 5.008686661579128 \cdot 10^{+94}:\\ \;\;\;\;\frac{c}{\left(-b\right) - \sqrt{(-3 \cdot \left(a \cdot c\right) + \left(b \cdot b\right))_*}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{\left(-b\right) - b}\\ \end{array}\]

Runtime

Time bar (total: 1.6m)Debug logProfile

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