Average Error: 3.7 → 3.4
Time: 4.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}\;x \cdot 2 \le -1.11549142136836587 \cdot 10^{-260}:\\ \;\;\;\;x \cdot 2 - \mathsf{fma}\left(\left(t \cdot y\right) \cdot 9, z, \left(-27\right) \cdot \left(a \cdot b\right)\right)\\ \mathbf{elif}\;x \cdot 2 \le 2.89772908520654599 \cdot 10^{73}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\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}\;x \cdot 2 \le -1.11549142136836587 \cdot 10^{-260}:\\
\;\;\;\;x \cdot 2 - \mathsf{fma}\left(\left(t \cdot y\right) \cdot 9, z, \left(-27\right) \cdot \left(a \cdot b\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\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 r772333 = x;
        double r772334 = 2.0;
        double r772335 = r772333 * r772334;
        double r772336 = y;
        double r772337 = 9.0;
        double r772338 = r772336 * r772337;
        double r772339 = z;
        double r772340 = r772338 * r772339;
        double r772341 = t;
        double r772342 = r772340 * r772341;
        double r772343 = r772335 - r772342;
        double r772344 = a;
        double r772345 = 27.0;
        double r772346 = r772344 * r772345;
        double r772347 = b;
        double r772348 = r772346 * r772347;
        double r772349 = r772343 + r772348;
        return r772349;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r772350 = x;
        double r772351 = 2.0;
        double r772352 = r772350 * r772351;
        double r772353 = -1.1154914213683659e-260;
        bool r772354 = r772352 <= r772353;
        double r772355 = t;
        double r772356 = y;
        double r772357 = r772355 * r772356;
        double r772358 = 9.0;
        double r772359 = r772357 * r772358;
        double r772360 = z;
        double r772361 = 27.0;
        double r772362 = -r772361;
        double r772363 = a;
        double r772364 = b;
        double r772365 = r772363 * r772364;
        double r772366 = r772362 * r772365;
        double r772367 = fma(r772359, r772360, r772366);
        double r772368 = r772352 - r772367;
        double r772369 = 2.897729085206546e+73;
        bool r772370 = r772352 <= r772369;
        double r772371 = r772358 * r772360;
        double r772372 = r772371 * r772355;
        double r772373 = r772356 * r772372;
        double r772374 = r772352 - r772373;
        double r772375 = r772363 * r772361;
        double r772376 = r772375 * r772364;
        double r772377 = r772374 + r772376;
        double r772378 = r772356 * r772371;
        double r772379 = r772378 * r772355;
        double r772380 = r772352 - r772379;
        double r772381 = r772361 * r772364;
        double r772382 = r772363 * r772381;
        double r772383 = r772380 + r772382;
        double r772384 = r772370 ? r772377 : r772383;
        double r772385 = r772354 ? r772368 : r772384;
        return r772385;
}

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

Target

Original3.7
Target2.4
Herbie3.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 (* x 2.0) < -1.1154914213683659e-260

    1. Initial program 4.0

      \[\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 pow14.0

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

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

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

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

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

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

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

      \[\leadsto x \cdot 2 - \color{blue}{\mathsf{fma}\left(t \cdot \left(y \cdot 9\right), z, \left(-27\right) \cdot \left(a \cdot b\right)\right)}\]
    12. Using strategy rm
    13. Applied associate-*r*3.1

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

    if -1.1154914213683659e-260 < (* x 2.0) < 2.897729085206546e+73

    1. Initial program 3.3

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

      \[\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*3.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\]

    if 2.897729085206546e+73 < (* x 2.0)

    1. Initial program 3.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*3.8

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

      \[\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)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \le -1.11549142136836587 \cdot 10^{-260}:\\ \;\;\;\;x \cdot 2 - \mathsf{fma}\left(\left(t \cdot y\right) \cdot 9, z, \left(-27\right) \cdot \left(a \cdot b\right)\right)\\ \mathbf{elif}\;x \cdot 2 \le 2.89772908520654599 \cdot 10^{73}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020020 +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)))