Average Error: 3.5 → 0.8
Time: 9.9s
Precision: 64
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;y \cdot 9 \le -1.65054985372108468 \cdot 10^{58} \lor \neg \left(y \cdot 9 \le 1.8765322534784896 \cdot 10^{-60}\right):\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, -\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\right)\right)\\ \end{array}\]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
\mathbf{if}\;y \cdot 9 \le -1.65054985372108468 \cdot 10^{58} \lor \neg \left(y \cdot 9 \le 1.8765322534784896 \cdot 10^{-60}\right):\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, -\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r772357 = x;
        double r772358 = 2.0;
        double r772359 = r772357 * r772358;
        double r772360 = y;
        double r772361 = 9.0;
        double r772362 = r772360 * r772361;
        double r772363 = z;
        double r772364 = r772362 * r772363;
        double r772365 = t;
        double r772366 = r772364 * r772365;
        double r772367 = r772359 - r772366;
        double r772368 = a;
        double r772369 = 27.0;
        double r772370 = r772368 * r772369;
        double r772371 = b;
        double r772372 = r772370 * r772371;
        double r772373 = r772367 + r772372;
        return r772373;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r772374 = y;
        double r772375 = 9.0;
        double r772376 = r772374 * r772375;
        double r772377 = -1.6505498537210847e+58;
        bool r772378 = r772376 <= r772377;
        double r772379 = 1.8765322534784896e-60;
        bool r772380 = r772376 <= r772379;
        double r772381 = !r772380;
        bool r772382 = r772378 || r772381;
        double r772383 = a;
        double r772384 = 27.0;
        double r772385 = r772383 * r772384;
        double r772386 = b;
        double r772387 = x;
        double r772388 = 2.0;
        double r772389 = r772387 * r772388;
        double r772390 = z;
        double r772391 = t;
        double r772392 = r772390 * r772391;
        double r772393 = r772376 * r772392;
        double r772394 = r772389 - r772393;
        double r772395 = fma(r772385, r772386, r772394);
        double r772396 = cbrt(r772375);
        double r772397 = r772396 * r772396;
        double r772398 = r772390 * r772374;
        double r772399 = r772391 * r772398;
        double r772400 = r772396 * r772399;
        double r772401 = r772397 * r772400;
        double r772402 = -r772401;
        double r772403 = fma(r772387, r772388, r772402);
        double r772404 = fma(r772385, r772386, r772403);
        double r772405 = r772382 ? r772395 : r772404;
        return r772405;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original3.5
Target2.6
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (* y 9.0) < -1.6505498537210847e+58 or 1.8765322534784896e-60 < (* y 9.0)

    1. Initial program 7.3

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified7.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    3. Using strategy rm
    4. Applied associate-*l*0.9

      \[\leadsto \mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right)\]

    if -1.6505498537210847e+58 < (* y 9.0) < 1.8765322534784896e-60

    1. Initial program 0.7

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified0.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    3. Using strategy rm
    4. Applied fma-neg0.7

      \[\leadsto \mathsf{fma}\left(a \cdot 27, b, \color{blue}{\mathsf{fma}\left(x, 2, -\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\right)\]
    5. Simplified0.7

      \[\leadsto \mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, \color{blue}{-9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\right)\right)\]
    6. Using strategy rm
    7. Applied add-cube-cbrt0.7

      \[\leadsto \mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}\right)} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\right)\]
    8. Applied associate-*l*0.7

      \[\leadsto \mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, -\color{blue}{\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)}\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 9 \le -1.65054985372108468 \cdot 10^{58} \lor \neg \left(y \cdot 9 \le 1.8765322534784896 \cdot 10^{-60}\right):\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, -\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2) (* (* (* y 9) z) t)) (* a (* 27 b))) (+ (- (* x 2) (* 9 (* y (* t z)))) (* (* a 27) b)))

  (+ (- (* x 2) (* (* (* y 9) z) t)) (* (* a 27) b)))