Average Error: 3.7 → 0.7
Time: 15.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 -6.0467200572044766 \cdot 10^{-30}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(\left(z \cdot 9.0\right) \cdot t\right) \cdot y\right)\\ \mathbf{elif}\;y \cdot 9.0 \le 1.1656528674519957 \cdot 10^{+63}:\\ \;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) + \left(27.0 \cdot b\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(\left(z \cdot 9.0\right) \cdot t\right) \cdot y\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 -6.0467200572044766 \cdot 10^{-30}:\\
\;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(\left(z \cdot 9.0\right) \cdot t\right) \cdot y\right)\\

\mathbf{elif}\;y \cdot 9.0 \le 1.1656528674519957 \cdot 10^{+63}:\\
\;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) + \left(27.0 \cdot b\right) \cdot a\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r37061685 = x;
        double r37061686 = 2.0;
        double r37061687 = r37061685 * r37061686;
        double r37061688 = y;
        double r37061689 = 9.0;
        double r37061690 = r37061688 * r37061689;
        double r37061691 = z;
        double r37061692 = r37061690 * r37061691;
        double r37061693 = t;
        double r37061694 = r37061692 * r37061693;
        double r37061695 = r37061687 - r37061694;
        double r37061696 = a;
        double r37061697 = 27.0;
        double r37061698 = r37061696 * r37061697;
        double r37061699 = b;
        double r37061700 = r37061698 * r37061699;
        double r37061701 = r37061695 + r37061700;
        return r37061701;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r37061702 = y;
        double r37061703 = 9.0;
        double r37061704 = r37061702 * r37061703;
        double r37061705 = -6.0467200572044766e-30;
        bool r37061706 = r37061704 <= r37061705;
        double r37061707 = 27.0;
        double r37061708 = a;
        double r37061709 = r37061707 * r37061708;
        double r37061710 = b;
        double r37061711 = r37061709 * r37061710;
        double r37061712 = x;
        double r37061713 = 2.0;
        double r37061714 = r37061712 * r37061713;
        double r37061715 = z;
        double r37061716 = r37061715 * r37061703;
        double r37061717 = t;
        double r37061718 = r37061716 * r37061717;
        double r37061719 = r37061718 * r37061702;
        double r37061720 = r37061714 - r37061719;
        double r37061721 = r37061711 + r37061720;
        double r37061722 = 1.1656528674519957e+63;
        bool r37061723 = r37061704 <= r37061722;
        double r37061724 = r37061702 * r37061715;
        double r37061725 = r37061717 * r37061724;
        double r37061726 = r37061703 * r37061725;
        double r37061727 = r37061714 - r37061726;
        double r37061728 = r37061707 * r37061710;
        double r37061729 = r37061728 * r37061708;
        double r37061730 = r37061727 + r37061729;
        double r37061731 = r37061723 ? r37061730 : r37061721;
        double r37061732 = r37061706 ? r37061721 : r37061731;
        return r37061732;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.7
Target2.6
Herbie0.7
\[\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 (* y 9.0) < -6.0467200572044766e-30 or 1.1656528674519957e+63 < (* y 9.0)

    1. Initial program 8.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\]
    2. Using strategy rm
    3. Applied associate-*l*7.9

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

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

    if -6.0467200572044766e-30 < (* y 9.0) < 1.1656528674519957e+63

    1. Initial program 0.6

      \[\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. Taylor expanded around inf 0.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 9.0 \le -6.0467200572044766 \cdot 10^{-30}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(\left(z \cdot 9.0\right) \cdot t\right) \cdot y\right)\\ \mathbf{elif}\;y \cdot 9.0 \le 1.1656528674519957 \cdot 10^{+63}:\\ \;\;\;\;\left(x \cdot 2.0 - 9.0 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right) + \left(27.0 \cdot b\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(x \cdot 2.0 - \left(\left(z \cdot 9.0\right) \cdot t\right) \cdot y\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 
(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)))