Average Error: 3.8 → 0.6
Time: 16.1s
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}\;\left(y \cdot 9\right) \cdot z \le -2.547759248047978209133550690022447008716 \cdot 10^{265} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 9.335746773442967732613960751609446066357 \cdot 10^{90}\right):\\ \;\;\;\;\left(2 \cdot x - z \cdot \left(\left(t \cdot y\right) \cdot 9\right)\right) + a \cdot \left(b \cdot 27\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(b \cdot a\right)\right) - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\ \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}\;\left(y \cdot 9\right) \cdot z \le -2.547759248047978209133550690022447008716 \cdot 10^{265} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 9.335746773442967732613960751609446066357 \cdot 10^{90}\right):\\
\;\;\;\;\left(2 \cdot x - z \cdot \left(\left(t \cdot y\right) \cdot 9\right)\right) + a \cdot \left(b \cdot 27\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r626258 = x;
        double r626259 = 2.0;
        double r626260 = r626258 * r626259;
        double r626261 = y;
        double r626262 = 9.0;
        double r626263 = r626261 * r626262;
        double r626264 = z;
        double r626265 = r626263 * r626264;
        double r626266 = t;
        double r626267 = r626265 * r626266;
        double r626268 = r626260 - r626267;
        double r626269 = a;
        double r626270 = 27.0;
        double r626271 = r626269 * r626270;
        double r626272 = b;
        double r626273 = r626271 * r626272;
        double r626274 = r626268 + r626273;
        return r626274;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r626275 = y;
        double r626276 = 9.0;
        double r626277 = r626275 * r626276;
        double r626278 = z;
        double r626279 = r626277 * r626278;
        double r626280 = -2.5477592480479782e+265;
        bool r626281 = r626279 <= r626280;
        double r626282 = 9.335746773442968e+90;
        bool r626283 = r626279 <= r626282;
        double r626284 = !r626283;
        bool r626285 = r626281 || r626284;
        double r626286 = 2.0;
        double r626287 = x;
        double r626288 = r626286 * r626287;
        double r626289 = t;
        double r626290 = r626289 * r626275;
        double r626291 = r626290 * r626276;
        double r626292 = r626278 * r626291;
        double r626293 = r626288 - r626292;
        double r626294 = a;
        double r626295 = b;
        double r626296 = 27.0;
        double r626297 = r626295 * r626296;
        double r626298 = r626294 * r626297;
        double r626299 = r626293 + r626298;
        double r626300 = r626295 * r626294;
        double r626301 = r626296 * r626300;
        double r626302 = r626288 + r626301;
        double r626303 = r626279 * r626289;
        double r626304 = r626302 - r626303;
        double r626305 = r626285 ? r626299 : r626304;
        return r626305;
}

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.8
Target2.8
Herbie0.6
\[\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 (* (* y 9.0) z) < -2.5477592480479782e+265 or 9.335746773442968e+90 < (* (* y 9.0) z)

    1. Initial program 20.8

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified20.7

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

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

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

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

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

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

    if -2.5477592480479782e+265 < (* (* y 9.0) z) < 9.335746773442968e+90

    1. Initial program 0.4

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified0.4

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

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

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

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

Reproduce

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