Average Error: 3.7 → 0.8
Time: 3.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}\;\left(y \cdot 9\right) \cdot z \le -8.1397860995161549 \cdot 10^{279}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - y \cdot \left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(z \cdot t\right)\right)\right)\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 5.441915156838296 \cdot 10^{58}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\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}\;\left(y \cdot 9\right) \cdot z \le -8.1397860995161549 \cdot 10^{279}:\\
\;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - y \cdot \left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(z \cdot t\right)\right)\right)\right)\\

\mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 5.441915156838296 \cdot 10^{58}:\\
\;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r735559 = x;
        double r735560 = 2.0;
        double r735561 = r735559 * r735560;
        double r735562 = y;
        double r735563 = 9.0;
        double r735564 = r735562 * r735563;
        double r735565 = z;
        double r735566 = r735564 * r735565;
        double r735567 = t;
        double r735568 = r735566 * r735567;
        double r735569 = r735561 - r735568;
        double r735570 = a;
        double r735571 = 27.0;
        double r735572 = r735570 * r735571;
        double r735573 = b;
        double r735574 = r735572 * r735573;
        double r735575 = r735569 + r735574;
        return r735575;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r735576 = y;
        double r735577 = 9.0;
        double r735578 = r735576 * r735577;
        double r735579 = z;
        double r735580 = r735578 * r735579;
        double r735581 = -8.139786099516155e+279;
        bool r735582 = r735580 <= r735581;
        double r735583 = a;
        double r735584 = 27.0;
        double r735585 = b;
        double r735586 = r735584 * r735585;
        double r735587 = x;
        double r735588 = 2.0;
        double r735589 = r735587 * r735588;
        double r735590 = cbrt(r735577);
        double r735591 = r735590 * r735590;
        double r735592 = t;
        double r735593 = r735579 * r735592;
        double r735594 = r735590 * r735593;
        double r735595 = r735591 * r735594;
        double r735596 = r735576 * r735595;
        double r735597 = r735589 - r735596;
        double r735598 = fma(r735583, r735586, r735597);
        double r735599 = 5.441915156838296e+58;
        bool r735600 = r735580 <= r735599;
        double r735601 = r735580 * r735592;
        double r735602 = r735589 - r735601;
        double r735603 = r735583 * r735584;
        double r735604 = r735603 * r735585;
        double r735605 = r735602 + r735604;
        double r735606 = r735577 * r735579;
        double r735607 = r735606 * r735592;
        double r735608 = r735576 * r735607;
        double r735609 = r735589 - r735608;
        double r735610 = fma(r735583, r735586, r735609);
        double r735611 = r735600 ? r735605 : r735610;
        double r735612 = r735582 ? r735598 : r735611;
        return r735612;
}

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.7
Target3.0
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 3 regimes
  2. if (* (* y 9.0) z) < -8.139786099516155e+279

    1. Initial program 50.4

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

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

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

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

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

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

    if -8.139786099516155e+279 < (* (* y 9.0) z) < 5.441915156838296e+58

    1. Initial program 0.4

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

    if 5.441915156838296e+58 < (* (* y 9.0) z)

    1. Initial program 11.2

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -8.1397860995161549 \cdot 10^{279}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - y \cdot \left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(z \cdot t\right)\right)\right)\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 5.441915156838296 \cdot 10^{58}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020089 +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)))