Average Error: 33.8 → 9.2
Time: 7.6s
Precision: 64
\[\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.24503988324174896 \cdot 10^{55}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 4.51532117608273917 \cdot 10^{-212}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{0.333333333333333315}{a}\\ \mathbf{elif}\;b \le 1.7721907466644651 \cdot 10^{-19}:\\ \;\;\;\;\frac{\frac{3 \cdot \left(a \cdot c\right) + b \cdot \left(b - b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]
\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.24503988324174896 \cdot 10^{55}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 4.51532117608273917 \cdot 10^{-212}:\\
\;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{0.333333333333333315}{a}\\

\mathbf{elif}\;b \le 1.7721907466644651 \cdot 10^{-19}:\\
\;\;\;\;\frac{\frac{3 \cdot \left(a \cdot c\right) + b \cdot \left(b - b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r151582 = b;
        double r151583 = -r151582;
        double r151584 = r151582 * r151582;
        double r151585 = 3.0;
        double r151586 = a;
        double r151587 = r151585 * r151586;
        double r151588 = c;
        double r151589 = r151587 * r151588;
        double r151590 = r151584 - r151589;
        double r151591 = sqrt(r151590);
        double r151592 = r151583 + r151591;
        double r151593 = r151592 / r151587;
        return r151593;
}

double f(double a, double b, double c) {
        double r151594 = b;
        double r151595 = -2.245039883241749e+55;
        bool r151596 = r151594 <= r151595;
        double r151597 = 0.5;
        double r151598 = c;
        double r151599 = r151598 / r151594;
        double r151600 = r151597 * r151599;
        double r151601 = 0.6666666666666666;
        double r151602 = a;
        double r151603 = r151594 / r151602;
        double r151604 = r151601 * r151603;
        double r151605 = r151600 - r151604;
        double r151606 = 4.515321176082739e-212;
        bool r151607 = r151594 <= r151606;
        double r151608 = -r151594;
        double r151609 = r151594 * r151594;
        double r151610 = 3.0;
        double r151611 = r151610 * r151602;
        double r151612 = r151611 * r151598;
        double r151613 = r151609 - r151612;
        double r151614 = sqrt(r151613);
        double r151615 = r151608 + r151614;
        double r151616 = 0.3333333333333333;
        double r151617 = r151616 / r151602;
        double r151618 = r151615 * r151617;
        double r151619 = 1.772190746664465e-19;
        bool r151620 = r151594 <= r151619;
        double r151621 = r151602 * r151598;
        double r151622 = r151610 * r151621;
        double r151623 = r151594 - r151594;
        double r151624 = r151594 * r151623;
        double r151625 = r151622 + r151624;
        double r151626 = r151608 - r151614;
        double r151627 = r151625 / r151626;
        double r151628 = r151627 / r151611;
        double r151629 = -0.5;
        double r151630 = r151629 * r151599;
        double r151631 = r151620 ? r151628 : r151630;
        double r151632 = r151607 ? r151618 : r151631;
        double r151633 = r151596 ? r151605 : r151632;
        return r151633;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -2.245039883241749e+55

    1. Initial program 39.0

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}}\]

    if -2.245039883241749e+55 < b < 4.515321176082739e-212

    1. Initial program 10.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 div-inv10.0

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

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

    if 4.515321176082739e-212 < b < 1.772190746664465e-19

    1. Initial program 27.8

      \[\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-+27.8

      \[\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. Simplified18.9

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

    if 1.772190746664465e-19 < b

    1. Initial program 55.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.24503988324174896 \cdot 10^{55}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 4.51532117608273917 \cdot 10^{-212}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{0.333333333333333315}{a}\\ \mathbf{elif}\;b \le 1.7721907466644651 \cdot 10^{-19}:\\ \;\;\;\;\frac{\frac{3 \cdot \left(a \cdot c\right) + b \cdot \left(b - b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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