Average Error: 3.8 → 2.2
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}\;y \cdot 9 \le -1.13292851015590868 \cdot 10^{-59}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + {\left(27 \cdot \left(a \cdot b\right)\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\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}\;y \cdot 9 \le -1.13292851015590868 \cdot 10^{-59}:\\
\;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + {\left(27 \cdot \left(a \cdot b\right)\right)}^{1}\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r702600 = x;
        double r702601 = 2.0;
        double r702602 = r702600 * r702601;
        double r702603 = y;
        double r702604 = 9.0;
        double r702605 = r702603 * r702604;
        double r702606 = z;
        double r702607 = r702605 * r702606;
        double r702608 = t;
        double r702609 = r702607 * r702608;
        double r702610 = r702602 - r702609;
        double r702611 = a;
        double r702612 = 27.0;
        double r702613 = r702611 * r702612;
        double r702614 = b;
        double r702615 = r702613 * r702614;
        double r702616 = r702610 + r702615;
        return r702616;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r702617 = y;
        double r702618 = 9.0;
        double r702619 = r702617 * r702618;
        double r702620 = -1.1329285101559087e-59;
        bool r702621 = r702619 <= r702620;
        double r702622 = x;
        double r702623 = 2.0;
        double r702624 = r702622 * r702623;
        double r702625 = z;
        double r702626 = r702618 * r702625;
        double r702627 = t;
        double r702628 = r702626 * r702627;
        double r702629 = r702617 * r702628;
        double r702630 = r702624 - r702629;
        double r702631 = 27.0;
        double r702632 = a;
        double r702633 = b;
        double r702634 = r702632 * r702633;
        double r702635 = r702631 * r702634;
        double r702636 = 1.0;
        double r702637 = pow(r702635, r702636);
        double r702638 = r702630 + r702637;
        double r702639 = r702631 * r702633;
        double r702640 = r702619 * r702625;
        double r702641 = r702640 * r702627;
        double r702642 = r702624 - r702641;
        double r702643 = fma(r702632, r702639, r702642);
        double r702644 = r702621 ? r702638 : r702643;
        return r702644;
}

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.8
Target2.7
Herbie2.2
\[\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 2 regimes
  2. if (* y 9.0) < -1.1329285101559087e-59

    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 pow16.6

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

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

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

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

      \[\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. Simplified6.5

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

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

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

    if -1.1329285101559087e-59 < (* y 9.0)

    1. Initial program 2.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. Simplified2.8

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

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

Reproduce

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