Average Error: 3.7 → 0.4
Time: 18.4s
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.15852263230124105 \cdot 10^{235}:\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 1.55309100679065705 \cdot 10^{278}:\\ \;\;\;\;2 \cdot x + \left(27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot x - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + a \cdot \left(27 \cdot b\right)\\ \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.15852263230124105 \cdot 10^{235}:\\
\;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\\

\mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 1.55309100679065705 \cdot 10^{278}:\\
\;\;\;\;2 \cdot x + \left(27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r562322 = x;
        double r562323 = 2.0;
        double r562324 = r562322 * r562323;
        double r562325 = y;
        double r562326 = 9.0;
        double r562327 = r562325 * r562326;
        double r562328 = z;
        double r562329 = r562327 * r562328;
        double r562330 = t;
        double r562331 = r562329 * r562330;
        double r562332 = r562324 - r562331;
        double r562333 = a;
        double r562334 = 27.0;
        double r562335 = r562333 * r562334;
        double r562336 = b;
        double r562337 = r562335 * r562336;
        double r562338 = r562332 + r562337;
        return r562338;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r562339 = y;
        double r562340 = 9.0;
        double r562341 = r562339 * r562340;
        double r562342 = z;
        double r562343 = r562341 * r562342;
        double r562344 = -2.158522632301241e+235;
        bool r562345 = r562343 <= r562344;
        double r562346 = 2.0;
        double r562347 = x;
        double r562348 = r562346 * r562347;
        double r562349 = 27.0;
        double r562350 = a;
        double r562351 = b;
        double r562352 = r562350 * r562351;
        double r562353 = r562349 * r562352;
        double r562354 = r562348 + r562353;
        double r562355 = t;
        double r562356 = r562355 * r562342;
        double r562357 = r562356 * r562339;
        double r562358 = r562340 * r562357;
        double r562359 = r562354 - r562358;
        double r562360 = 1.553091006790657e+278;
        bool r562361 = r562343 <= r562360;
        double r562362 = r562342 * r562339;
        double r562363 = r562355 * r562362;
        double r562364 = r562340 * r562363;
        double r562365 = r562353 - r562364;
        double r562366 = r562348 + r562365;
        double r562367 = r562340 * r562342;
        double r562368 = r562367 * r562355;
        double r562369 = r562339 * r562368;
        double r562370 = r562348 - r562369;
        double r562371 = r562349 * r562351;
        double r562372 = r562350 * r562371;
        double r562373 = r562370 + r562372;
        double r562374 = r562361 ? r562366 : r562373;
        double r562375 = r562345 ? r562359 : r562374;
        return r562375;
}

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.7
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \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 3 regimes
  2. if (* (* y 9.0) z) < -2.158522632301241e+235

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

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

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

    if -2.158522632301241e+235 < (* (* y 9.0) z) < 1.553091006790657e+278

    1. Initial program 0.5

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Taylor expanded around inf 0.3

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

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

    if 1.553091006790657e+278 < (* (* y 9.0) z)

    1. Initial program 48.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. Using strategy rm
    3. Applied associate-*l*48.8

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

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot \color{blue}{{t}^{1}}\right) + a \cdot \left(27 \cdot b\right)\]
    6. Applied pow148.8

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

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

      \[\leadsto \left(x \cdot 2 - \left(\left(\color{blue}{{y}^{1}} \cdot {9}^{1}\right) \cdot {z}^{1}\right) \cdot {t}^{1}\right) + a \cdot \left(27 \cdot b\right)\]
    9. Applied pow-prod-down48.8

      \[\leadsto \left(x \cdot 2 - \left(\color{blue}{{\left(y \cdot 9\right)}^{1}} \cdot {z}^{1}\right) \cdot {t}^{1}\right) + a \cdot \left(27 \cdot b\right)\]
    10. Applied pow-prod-down48.8

      \[\leadsto \left(x \cdot 2 - \color{blue}{{\left(\left(y \cdot 9\right) \cdot z\right)}^{1}} \cdot {t}^{1}\right) + a \cdot \left(27 \cdot b\right)\]
    11. Applied pow-prod-down48.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -2.15852263230124105 \cdot 10^{235}:\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 1.55309100679065705 \cdot 10^{278}:\\ \;\;\;\;2 \cdot x + \left(27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot x - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + a \cdot \left(27 \cdot b\right)\\ \end{array}\]

Reproduce

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