Average Error: 3.6 → 0.8
Time: 22.9s
Precision: 64
\[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;t \le -6.962711199315669 \cdot 10^{-11}:\\ \;\;\;\;\left(x \cdot 2.0 - t \cdot \left(z \cdot \left(9.0 \cdot y\right)\right)\right) + \left(27.0 \cdot a\right) \cdot b\\ \mathbf{elif}\;t \le 2.0315483928606443 \cdot 10^{+68}:\\ \;\;\;\;\mathsf{fma}\left(x, 2.0, a \cdot \left(27.0 \cdot b\right)\right) - \left(\left(\left(t \cdot y\right) \cdot \left(\sqrt[3]{9.0} \cdot \sqrt[3]{9.0}\right)\right) \cdot \sqrt[3]{9.0}\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - t \cdot \left(z \cdot \left(9.0 \cdot y\right)\right)\right) + \left(27.0 \cdot a\right) \cdot b\\ \end{array}\]
\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b
\begin{array}{l}
\mathbf{if}\;t \le -6.962711199315669 \cdot 10^{-11}:\\
\;\;\;\;\left(x \cdot 2.0 - t \cdot \left(z \cdot \left(9.0 \cdot y\right)\right)\right) + \left(27.0 \cdot a\right) \cdot b\\

\mathbf{elif}\;t \le 2.0315483928606443 \cdot 10^{+68}:\\
\;\;\;\;\mathsf{fma}\left(x, 2.0, a \cdot \left(27.0 \cdot b\right)\right) - \left(\left(\left(t \cdot y\right) \cdot \left(\sqrt[3]{9.0} \cdot \sqrt[3]{9.0}\right)\right) \cdot \sqrt[3]{9.0}\right) \cdot z\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2.0 - t \cdot \left(z \cdot \left(9.0 \cdot y\right)\right)\right) + \left(27.0 \cdot a\right) \cdot b\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r34414595 = x;
        double r34414596 = 2.0;
        double r34414597 = r34414595 * r34414596;
        double r34414598 = y;
        double r34414599 = 9.0;
        double r34414600 = r34414598 * r34414599;
        double r34414601 = z;
        double r34414602 = r34414600 * r34414601;
        double r34414603 = t;
        double r34414604 = r34414602 * r34414603;
        double r34414605 = r34414597 - r34414604;
        double r34414606 = a;
        double r34414607 = 27.0;
        double r34414608 = r34414606 * r34414607;
        double r34414609 = b;
        double r34414610 = r34414608 * r34414609;
        double r34414611 = r34414605 + r34414610;
        return r34414611;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r34414612 = t;
        double r34414613 = -6.962711199315669e-11;
        bool r34414614 = r34414612 <= r34414613;
        double r34414615 = x;
        double r34414616 = 2.0;
        double r34414617 = r34414615 * r34414616;
        double r34414618 = z;
        double r34414619 = 9.0;
        double r34414620 = y;
        double r34414621 = r34414619 * r34414620;
        double r34414622 = r34414618 * r34414621;
        double r34414623 = r34414612 * r34414622;
        double r34414624 = r34414617 - r34414623;
        double r34414625 = 27.0;
        double r34414626 = a;
        double r34414627 = r34414625 * r34414626;
        double r34414628 = b;
        double r34414629 = r34414627 * r34414628;
        double r34414630 = r34414624 + r34414629;
        double r34414631 = 2.0315483928606443e+68;
        bool r34414632 = r34414612 <= r34414631;
        double r34414633 = r34414625 * r34414628;
        double r34414634 = r34414626 * r34414633;
        double r34414635 = fma(r34414615, r34414616, r34414634);
        double r34414636 = r34414612 * r34414620;
        double r34414637 = cbrt(r34414619);
        double r34414638 = r34414637 * r34414637;
        double r34414639 = r34414636 * r34414638;
        double r34414640 = r34414639 * r34414637;
        double r34414641 = r34414640 * r34414618;
        double r34414642 = r34414635 - r34414641;
        double r34414643 = r34414632 ? r34414642 : r34414630;
        double r34414644 = r34414614 ? r34414630 : r34414643;
        return r34414644;
}

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.6
Target2.6
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + a \cdot \left(27.0 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27.0\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -6.962711199315669e-11 or 2.0315483928606443e+68 < t

    1. Initial program 1.0

      \[\left(x \cdot 2.0 - \left(\left(y \cdot 9.0\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27.0\right) \cdot b\]

    if -6.962711199315669e-11 < t < 2.0315483928606443e+68

    1. Initial program 5.2

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

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

      \[\leadsto \mathsf{fma}\left(27.0 \cdot a, b, x \cdot 2.0\right) - z \cdot \left(\left(t \cdot y\right) \cdot \color{blue}{\left(\left(\sqrt[3]{9.0} \cdot \sqrt[3]{9.0}\right) \cdot \sqrt[3]{9.0}\right)}\right)\]
    5. Applied associate-*r*0.7

      \[\leadsto \mathsf{fma}\left(27.0 \cdot a, b, x \cdot 2.0\right) - z \cdot \color{blue}{\left(\left(\left(t \cdot y\right) \cdot \left(\sqrt[3]{9.0} \cdot \sqrt[3]{9.0}\right)\right) \cdot \sqrt[3]{9.0}\right)}\]
    6. Taylor expanded around 0 0.6

      \[\leadsto \color{blue}{\left(2.0 \cdot x + 27.0 \cdot \left(a \cdot b\right)\right)} - z \cdot \left(\left(\left(t \cdot y\right) \cdot \left(\sqrt[3]{9.0} \cdot \sqrt[3]{9.0}\right)\right) \cdot \sqrt[3]{9.0}\right)\]
    7. Simplified0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -6.962711199315669 \cdot 10^{-11}:\\ \;\;\;\;\left(x \cdot 2.0 - t \cdot \left(z \cdot \left(9.0 \cdot y\right)\right)\right) + \left(27.0 \cdot a\right) \cdot b\\ \mathbf{elif}\;t \le 2.0315483928606443 \cdot 10^{+68}:\\ \;\;\;\;\mathsf{fma}\left(x, 2.0, a \cdot \left(27.0 \cdot b\right)\right) - \left(\left(\left(t \cdot y\right) \cdot \left(\sqrt[3]{9.0} \cdot \sqrt[3]{9.0}\right)\right) \cdot \sqrt[3]{9.0}\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - t \cdot \left(z \cdot \left(9.0 \cdot y\right)\right)\right) + \left(27.0 \cdot a\right) \cdot b\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))