Average Error: 34.0 → 15.1
Time: 4.9s
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.427668844436332 \cdot 10^{79}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.62273985298184147 \cdot 10^{-79}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \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.427668844436332 \cdot 10^{79}:\\
\;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 3.62273985298184147 \cdot 10^{-79}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r90082 = b;
        double r90083 = -r90082;
        double r90084 = r90082 * r90082;
        double r90085 = 3.0;
        double r90086 = a;
        double r90087 = r90085 * r90086;
        double r90088 = c;
        double r90089 = r90087 * r90088;
        double r90090 = r90084 - r90089;
        double r90091 = sqrt(r90090);
        double r90092 = r90083 + r90091;
        double r90093 = r90092 / r90087;
        return r90093;
}

double f(double a, double b, double c) {
        double r90094 = b;
        double r90095 = -2.4276688444363324e+79;
        bool r90096 = r90094 <= r90095;
        double r90097 = -r90094;
        double r90098 = 1.5;
        double r90099 = a;
        double r90100 = c;
        double r90101 = r90099 * r90100;
        double r90102 = r90101 / r90094;
        double r90103 = r90098 * r90102;
        double r90104 = r90103 - r90094;
        double r90105 = r90097 + r90104;
        double r90106 = 3.0;
        double r90107 = r90106 * r90099;
        double r90108 = r90105 / r90107;
        double r90109 = 3.6227398529818415e-79;
        bool r90110 = r90094 <= r90109;
        double r90111 = cbrt(r90097);
        double r90112 = r90111 * r90111;
        double r90113 = r90094 * r90094;
        double r90114 = r90107 * r90100;
        double r90115 = r90113 - r90114;
        double r90116 = sqrt(r90115);
        double r90117 = fma(r90112, r90111, r90116);
        double r90118 = r90117 / r90107;
        double r90119 = -1.5;
        double r90120 = r90119 * r90102;
        double r90121 = r90120 / r90107;
        double r90122 = r90110 ? r90118 : r90121;
        double r90123 = r90096 ? r90108 : r90122;
        return r90123;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -2.4276688444363324e+79

    1. Initial program 43.9

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

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

    if -2.4276688444363324e+79 < b < 3.6227398529818415e-79

    1. Initial program 12.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-cube-cbrt12.4

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

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

    if 3.6227398529818415e-79 < b

    1. Initial program 53.1

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.427668844436332 \cdot 10^{79}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.62273985298184147 \cdot 10^{-79}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{-b} \cdot \sqrt[3]{-b}, \sqrt[3]{-b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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