Average Error: 34.3 → 15.5
Time: 12.0s
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 -1.8858229491725349 \cdot 10^{86}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1.5, \frac{a \cdot c}{b}, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.127343185313157 \cdot 10^{-68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}, \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}, -b\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 -1.8858229491725349 \cdot 10^{86}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1.5, \frac{a \cdot c}{b}, -2 \cdot b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 3.127343185313157 \cdot 10^{-68}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}, \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}, -b\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 r137478 = b;
        double r137479 = -r137478;
        double r137480 = r137478 * r137478;
        double r137481 = 3.0;
        double r137482 = a;
        double r137483 = r137481 * r137482;
        double r137484 = c;
        double r137485 = r137483 * r137484;
        double r137486 = r137480 - r137485;
        double r137487 = sqrt(r137486);
        double r137488 = r137479 + r137487;
        double r137489 = r137488 / r137483;
        return r137489;
}

double f(double a, double b, double c) {
        double r137490 = b;
        double r137491 = -1.885822949172535e+86;
        bool r137492 = r137490 <= r137491;
        double r137493 = 1.5;
        double r137494 = a;
        double r137495 = c;
        double r137496 = r137494 * r137495;
        double r137497 = r137496 / r137490;
        double r137498 = -2.0;
        double r137499 = r137498 * r137490;
        double r137500 = fma(r137493, r137497, r137499);
        double r137501 = 3.0;
        double r137502 = r137501 * r137494;
        double r137503 = r137500 / r137502;
        double r137504 = 3.127343185313157e-68;
        bool r137505 = r137490 <= r137504;
        double r137506 = r137490 * r137490;
        double r137507 = r137502 * r137495;
        double r137508 = r137506 - r137507;
        double r137509 = sqrt(r137508);
        double r137510 = sqrt(r137509);
        double r137511 = -r137490;
        double r137512 = fma(r137510, r137510, r137511);
        double r137513 = r137512 / r137502;
        double r137514 = -1.5;
        double r137515 = r137514 * r137497;
        double r137516 = r137515 / r137502;
        double r137517 = r137505 ? r137513 : r137516;
        double r137518 = r137492 ? r137503 : r137517;
        return r137518;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -1.885822949172535e+86

    1. Initial program 45.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified45.5

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt45.5

      \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot \color{blue}{\left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}\right)}} - b}{3 \cdot a}\]
    5. Applied associate-*r*45.5

      \[\leadsto \frac{\sqrt{b \cdot b - \color{blue}{\left(\left(3 \cdot a\right) \cdot \left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)\right) \cdot \sqrt[3]{c}}} - b}{3 \cdot a}\]
    6. Taylor expanded around -inf 10.8

      \[\leadsto \frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    7. Simplified10.8

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

    if -1.885822949172535e+86 < b < 3.127343185313157e-68

    1. Initial program 13.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified13.7

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt13.7

      \[\leadsto \frac{\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}}} - b}{3 \cdot a}\]
    5. Applied sqrt-prod13.9

      \[\leadsto \frac{\color{blue}{\sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}} - b}{3 \cdot a}\]
    6. Applied fma-neg13.9

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

    if 3.127343185313157e-68 < b

    1. Initial program 52.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified52.9

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. 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.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.8858229491725349 \cdot 10^{86}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1.5, \frac{a \cdot c}{b}, -2 \cdot b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 3.127343185313157 \cdot 10^{-68}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}, \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}, -b\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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