Average Error: 34.0 → 14.6
Time: 21.4s
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 -7.373936881264135 \cdot 10^{+143}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{3}{2} \cdot \frac{c}{\frac{b}{a}}\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.7618819300646253 \cdot 10^{-60}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{b} \cdot \left(-\sqrt[3]{b}\right), \sqrt[3]{b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot a}{b} \cdot \frac{-3}{2}}{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 -7.373936881264135 \cdot 10^{+143}:\\
\;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{3}{2} \cdot \frac{c}{\frac{b}{a}}\right)}{3 \cdot a}\\

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

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3089454 = b;
        double r3089455 = -r3089454;
        double r3089456 = r3089454 * r3089454;
        double r3089457 = 3.0;
        double r3089458 = a;
        double r3089459 = r3089457 * r3089458;
        double r3089460 = c;
        double r3089461 = r3089459 * r3089460;
        double r3089462 = r3089456 - r3089461;
        double r3089463 = sqrt(r3089462);
        double r3089464 = r3089455 + r3089463;
        double r3089465 = r3089464 / r3089459;
        return r3089465;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3089466 = b;
        double r3089467 = -7.373936881264135e+143;
        bool r3089468 = r3089466 <= r3089467;
        double r3089469 = -2.0;
        double r3089470 = 1.5;
        double r3089471 = c;
        double r3089472 = a;
        double r3089473 = r3089466 / r3089472;
        double r3089474 = r3089471 / r3089473;
        double r3089475 = r3089470 * r3089474;
        double r3089476 = fma(r3089466, r3089469, r3089475);
        double r3089477 = 3.0;
        double r3089478 = r3089477 * r3089472;
        double r3089479 = r3089476 / r3089478;
        double r3089480 = 1.7618819300646253e-60;
        bool r3089481 = r3089466 <= r3089480;
        double r3089482 = cbrt(r3089466);
        double r3089483 = -r3089482;
        double r3089484 = r3089482 * r3089483;
        double r3089485 = r3089466 * r3089466;
        double r3089486 = r3089478 * r3089471;
        double r3089487 = r3089485 - r3089486;
        double r3089488 = sqrt(r3089487);
        double r3089489 = fma(r3089484, r3089482, r3089488);
        double r3089490 = r3089489 / r3089478;
        double r3089491 = r3089471 * r3089472;
        double r3089492 = r3089491 / r3089466;
        double r3089493 = -1.5;
        double r3089494 = r3089492 * r3089493;
        double r3089495 = r3089494 / r3089478;
        double r3089496 = r3089481 ? r3089490 : r3089495;
        double r3089497 = r3089468 ? r3089479 : r3089496;
        return r3089497;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Derivation

  1. Split input into 3 regimes
  2. if b < -7.373936881264135e+143

    1. Initial program 57.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-sqrt57.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}\]
    4. Applied sqrt-prod57.2

      \[\leadsto \frac{\left(-b\right) + \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}}}}{3 \cdot a}\]
    5. Taylor expanded around -inf 10.7

      \[\leadsto \frac{\color{blue}{\frac{3}{2} \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3 \cdot a}\]
    6. Simplified3.1

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

    if -7.373936881264135e+143 < b < 1.7618819300646253e-60

    1. Initial program 13.5

      \[\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-cbrt13.8

      \[\leadsto \frac{\left(-\color{blue}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}}\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    4. Applied distribute-lft-neg-in13.8

      \[\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}\]
    5. Applied fma-def13.8

      \[\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 1.7618819300646253e-60 < b

    1. Initial program 53.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 add-sqr-sqrt53.7

      \[\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}\]
    4. Applied sqrt-prod55.1

      \[\leadsto \frac{\left(-b\right) + \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}}}}{3 \cdot a}\]
    5. Taylor expanded around inf 19.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -7.373936881264135 \cdot 10^{+143}:\\ \;\;\;\;\frac{\mathsf{fma}\left(b, -2, \frac{3}{2} \cdot \frac{c}{\frac{b}{a}}\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.7618819300646253 \cdot 10^{-60}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\sqrt[3]{b} \cdot \left(-\sqrt[3]{b}\right), \sqrt[3]{b}, \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{c \cdot a}{b} \cdot \frac{-3}{2}}{3 \cdot a}\\ \end{array}\]

Reproduce

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