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

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r37673967 = x;
        double r37673968 = 2.0;
        double r37673969 = r37673967 * r37673968;
        double r37673970 = y;
        double r37673971 = 9.0;
        double r37673972 = r37673970 * r37673971;
        double r37673973 = z;
        double r37673974 = r37673972 * r37673973;
        double r37673975 = t;
        double r37673976 = r37673974 * r37673975;
        double r37673977 = r37673969 - r37673976;
        double r37673978 = a;
        double r37673979 = 27.0;
        double r37673980 = r37673978 * r37673979;
        double r37673981 = b;
        double r37673982 = r37673980 * r37673981;
        double r37673983 = r37673977 + r37673982;
        return r37673983;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r37673984 = y;
        double r37673985 = 9.0;
        double r37673986 = r37673984 * r37673985;
        double r37673987 = -6.0467200572044766e-30;
        bool r37673988 = r37673986 <= r37673987;
        double r37673989 = 27.0;
        double r37673990 = a;
        double r37673991 = r37673989 * r37673990;
        double r37673992 = b;
        double r37673993 = r37673991 * r37673992;
        double r37673994 = 2.0;
        double r37673995 = x;
        double r37673996 = r37673994 * r37673995;
        double r37673997 = z;
        double r37673998 = t;
        double r37673999 = r37673997 * r37673998;
        double r37674000 = r37673984 * r37673999;
        double r37674001 = r37674000 * r37673985;
        double r37674002 = r37673996 - r37674001;
        double r37674003 = r37673993 + r37674002;
        double r37674004 = 1.1656528674519957e+63;
        bool r37674005 = r37673986 <= r37674004;
        double r37674006 = r37673997 * r37673984;
        double r37674007 = r37673998 * r37674006;
        double r37674008 = r37673985 * r37674007;
        double r37674009 = r37673996 - r37674008;
        double r37674010 = r37673989 * r37673992;
        double r37674011 = r37674010 * r37673990;
        double r37674012 = r37674009 + r37674011;
        double r37674013 = r37673985 * r37673997;
        double r37674014 = r37674013 * r37673998;
        double r37674015 = r37674014 * r37673984;
        double r37674016 = r37673996 - r37674015;
        double r37674017 = r37673993 + r37674016;
        double r37674018 = r37674005 ? r37674012 : r37674017;
        double r37674019 = r37673988 ? r37674003 : r37674018;
        return r37674019;
}

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 3 regimes
  2. if (* y 9.0) < -6.0467200572044766e-30

    1. Initial program 7.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. Taylor expanded around inf 7.0

      \[\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-*r*0.9

      \[\leadsto \left(2.0 \cdot x - 9.0 \cdot \color{blue}{\left(\left(t \cdot z\right) \cdot y\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)}\]

    if 1.1656528674519957e+63 < (* y 9.0)

    1. Initial program 9.5

      \[\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*9.2

      \[\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.6

      \[\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\]
  3. Recombined 3 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(2.0 \cdot x - \left(y \cdot \left(z \cdot t\right)\right) \cdot 9.0\right)\\ \mathbf{elif}\;y \cdot 9.0 \le 1.1656528674519957 \cdot 10^{+63}:\\ \;\;\;\;\left(2.0 \cdot x - 9.0 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right) + \left(27.0 \cdot b\right) \cdot a\\ \mathbf{else}:\\ \;\;\;\;\left(27.0 \cdot a\right) \cdot b + \left(2.0 \cdot x - \left(\left(9.0 \cdot z\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)))