Average Error: 34.0 → 10.4
Time: 6.1s
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.71711085460076329 \cdot 10^{118}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 8.87069060473612544 \cdot 10^{-35}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \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 -3.71711085460076329 \cdot 10^{118}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 8.87069060473612544 \cdot 10^{-35}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \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 r115706 = b;
        double r115707 = -r115706;
        double r115708 = r115706 * r115706;
        double r115709 = 3.0;
        double r115710 = a;
        double r115711 = r115709 * r115710;
        double r115712 = c;
        double r115713 = r115711 * r115712;
        double r115714 = r115708 - r115713;
        double r115715 = sqrt(r115714);
        double r115716 = r115707 + r115715;
        double r115717 = r115716 / r115711;
        return r115717;
}

double f(double a, double b, double c) {
        double r115718 = b;
        double r115719 = -3.7171108546007633e+118;
        bool r115720 = r115718 <= r115719;
        double r115721 = 0.5;
        double r115722 = c;
        double r115723 = r115722 / r115718;
        double r115724 = r115721 * r115723;
        double r115725 = 0.6666666666666666;
        double r115726 = a;
        double r115727 = r115718 / r115726;
        double r115728 = r115725 * r115727;
        double r115729 = r115724 - r115728;
        double r115730 = 8.870690604736125e-35;
        bool r115731 = r115718 <= r115730;
        double r115732 = -r115718;
        double r115733 = r115718 * r115718;
        double r115734 = 3.0;
        double r115735 = r115734 * r115726;
        double r115736 = r115735 * r115722;
        double r115737 = r115733 - r115736;
        double r115738 = sqrt(r115737);
        double r115739 = r115738 * r115738;
        double r115740 = sqrt(r115739);
        double r115741 = r115732 + r115740;
        double r115742 = r115741 / r115735;
        double r115743 = -0.5;
        double r115744 = r115743 * r115723;
        double r115745 = r115731 ? r115742 : r115744;
        double r115746 = r115720 ? r115729 : r115745;
        return r115746;
}

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 3 regimes
  2. if b < -3.7171108546007633e+118

    1. Initial program 52.1

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

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

    if -3.7171108546007633e+118 < b < 8.870690604736125e-35

    1. Initial program 14.2

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

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

    if 8.870690604736125e-35 < b

    1. Initial program 54.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.71711085460076329 \cdot 10^{118}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 8.87069060473612544 \cdot 10^{-35}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \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 2020027 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))