Average Error: 3.7 → 0.7
Time: 14.7s
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}:\\ \;\;\;\;a \cdot \left(27.0 \cdot b\right) + \left(x \cdot 2.0 - 9.0 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right)\\ \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}:\\
\;\;\;\;a \cdot \left(27.0 \cdot b\right) + \left(x \cdot 2.0 - 9.0 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right)\\

\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 r36089889 = x;
        double r36089890 = 2.0;
        double r36089891 = r36089889 * r36089890;
        double r36089892 = y;
        double r36089893 = 9.0;
        double r36089894 = r36089892 * r36089893;
        double r36089895 = z;
        double r36089896 = r36089894 * r36089895;
        double r36089897 = t;
        double r36089898 = r36089896 * r36089897;
        double r36089899 = r36089891 - r36089898;
        double r36089900 = a;
        double r36089901 = 27.0;
        double r36089902 = r36089900 * r36089901;
        double r36089903 = b;
        double r36089904 = r36089902 * r36089903;
        double r36089905 = r36089899 + r36089904;
        return r36089905;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r36089906 = y;
        double r36089907 = 9.0;
        double r36089908 = r36089906 * r36089907;
        double r36089909 = -6.0467200572044766e-30;
        bool r36089910 = r36089908 <= r36089909;
        double r36089911 = 27.0;
        double r36089912 = a;
        double r36089913 = r36089911 * r36089912;
        double r36089914 = b;
        double r36089915 = r36089913 * r36089914;
        double r36089916 = x;
        double r36089917 = 2.0;
        double r36089918 = r36089916 * r36089917;
        double r36089919 = z;
        double r36089920 = r36089919 * r36089907;
        double r36089921 = t;
        double r36089922 = r36089920 * r36089921;
        double r36089923 = r36089922 * r36089906;
        double r36089924 = r36089918 - r36089923;
        double r36089925 = r36089915 + r36089924;
        double r36089926 = 1.1656528674519957e+63;
        bool r36089927 = r36089908 <= r36089926;
        double r36089928 = r36089911 * r36089914;
        double r36089929 = r36089912 * r36089928;
        double r36089930 = r36089906 * r36089919;
        double r36089931 = r36089921 * r36089930;
        double r36089932 = r36089907 * r36089931;
        double r36089933 = r36089918 - r36089932;
        double r36089934 = r36089929 + r36089933;
        double r36089935 = r36089927 ? r36089934 : r36089925;
        double r36089936 = r36089910 ? r36089925 : r36089935;
        return r36089936;
}

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 \color{blue}{\left(2.0 \cdot x - 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(2.0 \cdot x - 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}:\\ \;\;\;\;a \cdot \left(27.0 \cdot b\right) + \left(x \cdot 2.0 - 9.0 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right)\\ \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)))