Average Error: 33.8 → 8.8
Time: 22.2s
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 -3.56950087216670373 \cdot 10^{75}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -2.3007108173901322 \cdot 10^{-262}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 1.958082194924451 \cdot 10^{133}:\\ \;\;\;\;\frac{\frac{\frac{3 \cdot a}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}}{3}}{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 -3.56950087216670373 \cdot 10^{75}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r113570 = b;
        double r113571 = -r113570;
        double r113572 = r113570 * r113570;
        double r113573 = 3.0;
        double r113574 = a;
        double r113575 = r113573 * r113574;
        double r113576 = c;
        double r113577 = r113575 * r113576;
        double r113578 = r113572 - r113577;
        double r113579 = sqrt(r113578);
        double r113580 = r113571 + r113579;
        double r113581 = r113580 / r113575;
        return r113581;
}

double f(double a, double b, double c) {
        double r113582 = b;
        double r113583 = -3.5695008721667037e+75;
        bool r113584 = r113582 <= r113583;
        double r113585 = 0.5;
        double r113586 = c;
        double r113587 = r113586 / r113582;
        double r113588 = r113585 * r113587;
        double r113589 = 0.6666666666666666;
        double r113590 = a;
        double r113591 = r113582 / r113590;
        double r113592 = r113589 * r113591;
        double r113593 = r113588 - r113592;
        double r113594 = -2.3007108173901322e-262;
        bool r113595 = r113582 <= r113594;
        double r113596 = r113582 * r113582;
        double r113597 = 3.0;
        double r113598 = r113597 * r113590;
        double r113599 = r113598 * r113586;
        double r113600 = r113596 - r113599;
        double r113601 = sqrt(r113600);
        double r113602 = r113601 - r113582;
        double r113603 = r113602 / r113597;
        double r113604 = r113603 / r113590;
        double r113605 = 1.958082194924451e+133;
        bool r113606 = r113582 <= r113605;
        double r113607 = -r113582;
        double r113608 = r113607 - r113601;
        double r113609 = r113608 / r113586;
        double r113610 = r113598 / r113609;
        double r113611 = r113610 / r113597;
        double r113612 = r113611 / r113590;
        double r113613 = -0.5;
        double r113614 = r113613 * r113587;
        double r113615 = r113606 ? r113612 : r113614;
        double r113616 = r113595 ? r113604 : r113615;
        double r113617 = r113584 ? r113593 : r113616;
        return r113617;
}

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 < -3.5695008721667037e+75

    1. Initial program 42.2

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

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

    if -3.5695008721667037e+75 < b < -2.3007108173901322e-262

    1. Initial program 8.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*8.7

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

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

    if -2.3007108173901322e-262 < b < 1.958082194924451e+133

    1. Initial program 32.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 flip-+32.1

      \[\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. Simplified16.6

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

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{\left(3 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3}}}{a}\]
    8. Using strategy rm
    9. Applied associate-/l*14.7

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

    if 1.958082194924451e+133 < b

    1. Initial program 61.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.56950087216670373 \cdot 10^{75}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -2.3007108173901322 \cdot 10^{-262}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 1.958082194924451 \cdot 10^{133}:\\ \;\;\;\;\frac{\frac{\frac{3 \cdot a}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{c}}}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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