Average Error: 3.5 → 1.3
Time: 17.3s
Precision: 64
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;t \le -5.676106603176618479833130858551602850216 \cdot 10^{-187} \lor \neg \left(t \le 1.156508872709047150996877341481149061061 \cdot 10^{-29}\right):\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
\mathbf{if}\;t \le -5.676106603176618479833130858551602850216 \cdot 10^{-187} \lor \neg \left(t \le 1.156508872709047150996877341481149061061 \cdot 10^{-29}\right):\\
\;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r585053 = x;
        double r585054 = 2.0;
        double r585055 = r585053 * r585054;
        double r585056 = y;
        double r585057 = 9.0;
        double r585058 = r585056 * r585057;
        double r585059 = z;
        double r585060 = r585058 * r585059;
        double r585061 = t;
        double r585062 = r585060 * r585061;
        double r585063 = r585055 - r585062;
        double r585064 = a;
        double r585065 = 27.0;
        double r585066 = r585064 * r585065;
        double r585067 = b;
        double r585068 = r585066 * r585067;
        double r585069 = r585063 + r585068;
        return r585069;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r585070 = t;
        double r585071 = -5.676106603176618e-187;
        bool r585072 = r585070 <= r585071;
        double r585073 = 1.1565088727090472e-29;
        bool r585074 = r585070 <= r585073;
        double r585075 = !r585074;
        bool r585076 = r585072 || r585075;
        double r585077 = x;
        double r585078 = 2.0;
        double r585079 = r585077 * r585078;
        double r585080 = y;
        double r585081 = 9.0;
        double r585082 = z;
        double r585083 = r585081 * r585082;
        double r585084 = r585080 * r585083;
        double r585085 = r585084 * r585070;
        double r585086 = r585079 - r585085;
        double r585087 = a;
        double r585088 = 27.0;
        double r585089 = b;
        double r585090 = r585088 * r585089;
        double r585091 = r585087 * r585090;
        double r585092 = r585086 + r585091;
        double r585093 = r585083 * r585070;
        double r585094 = r585080 * r585093;
        double r585095 = r585079 - r585094;
        double r585096 = r585087 * r585088;
        double r585097 = r585096 * r585089;
        double r585098 = r585095 + r585097;
        double r585099 = r585076 ? r585092 : r585098;
        return r585099;
}

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.5
Target2.6
Herbie1.3
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811188954625810696587370427881 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -5.676106603176618e-187 or 1.1565088727090472e-29 < t

    1. Initial program 1.6

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*1.6

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot \left(9 \cdot z\right)\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    4. Using strategy rm
    5. Applied associate-*l*1.6

      \[\leadsto \left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \color{blue}{a \cdot \left(27 \cdot b\right)}\]

    if -5.676106603176618e-187 < t < 1.1565088727090472e-29

    1. Initial program 6.6

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*6.6

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot \left(9 \cdot z\right)\right)} \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    4. Using strategy rm
    5. Applied associate-*l*0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.676106603176618479833130858551602850216 \cdot 10^{-187} \lor \neg \left(t \le 1.156508872709047150996877341481149061061 \cdot 10^{-29}\right):\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2) (* (* (* y 9) z) t)) (* a (* 27 b))) (+ (- (* x 2) (* 9 (* y (* t z)))) (* (* a 27) b)))

  (+ (- (* x 2) (* (* (* y 9) z) t)) (* (* a 27) b)))