Average Error: 3.9 → 0.6
Time: 5.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 -8.4160355144962912 \cdot 10^{233}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 1.79783517118745171 \cdot 10^{166}:\\ \;\;\;\;x \cdot 2 + \mathsf{fma}\left(a, 27 \cdot b, -\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \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 -8.4160355144962912 \cdot 10^{233}:\\
\;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\

\mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 1.79783517118745171 \cdot 10^{166}:\\
\;\;\;\;x \cdot 2 + \mathsf{fma}\left(a, 27 \cdot b, -\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;\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}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r682754 = x;
        double r682755 = 2.0;
        double r682756 = r682754 * r682755;
        double r682757 = y;
        double r682758 = 9.0;
        double r682759 = r682757 * r682758;
        double r682760 = z;
        double r682761 = r682759 * r682760;
        double r682762 = t;
        double r682763 = r682761 * r682762;
        double r682764 = r682756 - r682763;
        double r682765 = a;
        double r682766 = 27.0;
        double r682767 = r682765 * r682766;
        double r682768 = b;
        double r682769 = r682767 * r682768;
        double r682770 = r682764 + r682769;
        return r682770;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r682771 = y;
        double r682772 = 9.0;
        double r682773 = r682771 * r682772;
        double r682774 = z;
        double r682775 = r682773 * r682774;
        double r682776 = -8.416035514496291e+233;
        bool r682777 = r682775 <= r682776;
        double r682778 = x;
        double r682779 = 2.0;
        double r682780 = r682778 * r682779;
        double r682781 = t;
        double r682782 = r682774 * r682781;
        double r682783 = r682773 * r682782;
        double r682784 = r682780 - r682783;
        double r682785 = a;
        double r682786 = 27.0;
        double r682787 = r682785 * r682786;
        double r682788 = b;
        double r682789 = r682787 * r682788;
        double r682790 = r682784 + r682789;
        double r682791 = 1.7978351711874517e+166;
        bool r682792 = r682775 <= r682791;
        double r682793 = r682786 * r682788;
        double r682794 = r682775 * r682781;
        double r682795 = -r682794;
        double r682796 = fma(r682785, r682793, r682795);
        double r682797 = r682780 + r682796;
        double r682798 = r682772 * r682774;
        double r682799 = r682798 * r682781;
        double r682800 = r682771 * r682799;
        double r682801 = r682780 - r682800;
        double r682802 = r682785 * r682788;
        double r682803 = r682786 * r682802;
        double r682804 = 1.0;
        double r682805 = pow(r682803, r682804);
        double r682806 = r682801 + r682805;
        double r682807 = r682792 ? r682797 : r682806;
        double r682808 = r682777 ? r682790 : r682807;
        return r682808;
}

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.9
Target2.7
Herbie0.6
\[\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) < -8.416035514496291e+233

    1. Initial program 34.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 associate-*l*1.2

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

    if -8.416035514496291e+233 < (* (* y 9.0) z) < 1.7978351711874517e+166

    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. Using strategy rm
    3. Applied sub-neg0.5

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

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

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

    if 1.7978351711874517e+166 < (* (* y 9.0) z)

    1. Initial program 22.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*21.7

      \[\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 pow121.7

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -8.4160355144962912 \cdot 10^{233}:\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 1.79783517118745171 \cdot 10^{166}:\\ \;\;\;\;x \cdot 2 + \mathsf{fma}\left(a, 27 \cdot b, -\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\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}\\ \end{array}\]

Reproduce

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