Average Error: 3.6 → 1.1
Time: 22.1s
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}\;y \cdot 9.0 \le -5.56286784221647 \cdot 10^{+126}:\\ \;\;\;\;\left(\left(27.0 \cdot b\right) \cdot a - y \cdot \left(z \cdot \left(9.0 \cdot t\right)\right)\right) + x \cdot 2.0\\ \mathbf{elif}\;y \cdot 9.0 \le 2.1986188378929088 \cdot 10^{-131}:\\ \;\;\;\;\mathsf{fma}\left(27.0, a \cdot b, \left(-9.0\right) \cdot \left(t \cdot \left(z \cdot y\right)\right)\right) + x \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - \left(t \cdot z\right) \cdot \left(y \cdot 9.0\right)\right) + b \cdot \left(27.0 \cdot a\right)\\ \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}\;y \cdot 9.0 \le -5.56286784221647 \cdot 10^{+126}:\\
\;\;\;\;\left(\left(27.0 \cdot b\right) \cdot a - y \cdot \left(z \cdot \left(9.0 \cdot t\right)\right)\right) + x \cdot 2.0\\

\mathbf{elif}\;y \cdot 9.0 \le 2.1986188378929088 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{fma}\left(27.0, a \cdot b, \left(-9.0\right) \cdot \left(t \cdot \left(z \cdot y\right)\right)\right) + x \cdot 2.0\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r36517655 = x;
        double r36517656 = 2.0;
        double r36517657 = r36517655 * r36517656;
        double r36517658 = y;
        double r36517659 = 9.0;
        double r36517660 = r36517658 * r36517659;
        double r36517661 = z;
        double r36517662 = r36517660 * r36517661;
        double r36517663 = t;
        double r36517664 = r36517662 * r36517663;
        double r36517665 = r36517657 - r36517664;
        double r36517666 = a;
        double r36517667 = 27.0;
        double r36517668 = r36517666 * r36517667;
        double r36517669 = b;
        double r36517670 = r36517668 * r36517669;
        double r36517671 = r36517665 + r36517670;
        return r36517671;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r36517672 = y;
        double r36517673 = 9.0;
        double r36517674 = r36517672 * r36517673;
        double r36517675 = -5.56286784221647e+126;
        bool r36517676 = r36517674 <= r36517675;
        double r36517677 = 27.0;
        double r36517678 = b;
        double r36517679 = r36517677 * r36517678;
        double r36517680 = a;
        double r36517681 = r36517679 * r36517680;
        double r36517682 = z;
        double r36517683 = t;
        double r36517684 = r36517673 * r36517683;
        double r36517685 = r36517682 * r36517684;
        double r36517686 = r36517672 * r36517685;
        double r36517687 = r36517681 - r36517686;
        double r36517688 = x;
        double r36517689 = 2.0;
        double r36517690 = r36517688 * r36517689;
        double r36517691 = r36517687 + r36517690;
        double r36517692 = 2.1986188378929088e-131;
        bool r36517693 = r36517674 <= r36517692;
        double r36517694 = r36517680 * r36517678;
        double r36517695 = -r36517673;
        double r36517696 = r36517682 * r36517672;
        double r36517697 = r36517683 * r36517696;
        double r36517698 = r36517695 * r36517697;
        double r36517699 = fma(r36517677, r36517694, r36517698);
        double r36517700 = r36517699 + r36517690;
        double r36517701 = r36517683 * r36517682;
        double r36517702 = r36517701 * r36517674;
        double r36517703 = r36517690 - r36517702;
        double r36517704 = r36517677 * r36517680;
        double r36517705 = r36517678 * r36517704;
        double r36517706 = r36517703 + r36517705;
        double r36517707 = r36517693 ? r36517700 : r36517706;
        double r36517708 = r36517676 ? r36517691 : r36517707;
        return r36517708;
}

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.4
Herbie1.1
\[\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 3 regimes
  2. if (* y 9.0) < -5.56286784221647e+126

    1. Initial program 11.1

      \[\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. Using strategy rm
    3. Applied associate-*l*1.3

      \[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
    4. Using strategy rm
    5. Applied sub-neg1.3

      \[\leadsto \color{blue}{\left(x \cdot 2.0 + \left(-\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)\right)\right)} + \left(a \cdot 27.0\right) \cdot b\]
    6. Applied associate-+l+1.3

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

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

    if -5.56286784221647e+126 < (* y 9.0) < 2.1986188378929088e-131

    1. Initial program 1.1

      \[\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. Using strategy rm
    3. Applied associate-*l*4.8

      \[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
    4. Using strategy rm
    5. Applied sub-neg4.8

      \[\leadsto \color{blue}{\left(x \cdot 2.0 + \left(-\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)\right)\right)} + \left(a \cdot 27.0\right) \cdot b\]
    6. Applied associate-+l+4.8

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

      \[\leadsto x \cdot 2.0 + \color{blue}{\left(a \cdot \left(27.0 \cdot b\right) - y \cdot \left(z \cdot \left(9.0 \cdot t\right)\right)\right)}\]
    8. Taylor expanded around inf 1.0

      \[\leadsto x \cdot 2.0 + \color{blue}{\left(27.0 \cdot \left(a \cdot b\right) - 9.0 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)}\]
    9. Using strategy rm
    10. Applied fma-neg1.0

      \[\leadsto x \cdot 2.0 + \color{blue}{\mathsf{fma}\left(27.0, a \cdot b, -9.0 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)}\]

    if 2.1986188378929088e-131 < (* y 9.0)

    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. Using strategy rm
    3. Applied associate-*l*1.4

      \[\leadsto \left(x \cdot 2.0 - \color{blue}{\left(y \cdot 9.0\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27.0\right) \cdot b\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 9.0 \le -5.56286784221647 \cdot 10^{+126}:\\ \;\;\;\;\left(\left(27.0 \cdot b\right) \cdot a - y \cdot \left(z \cdot \left(9.0 \cdot t\right)\right)\right) + x \cdot 2.0\\ \mathbf{elif}\;y \cdot 9.0 \le 2.1986188378929088 \cdot 10^{-131}:\\ \;\;\;\;\mathsf{fma}\left(27.0, a \cdot b, \left(-9.0\right) \cdot \left(t \cdot \left(z \cdot y\right)\right)\right) + x \cdot 2.0\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2.0 - \left(t \cdot z\right) \cdot \left(y \cdot 9.0\right)\right) + b \cdot \left(27.0 \cdot a\right)\\ \end{array}\]

Reproduce

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