Average Error: 3.5 → 0.6
Time: 19.9s
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}\;z \le -1.893786164031411283844403967516072339818 \cdot 10^{65}:\\ \;\;\;\;x \cdot 2 + \left(27 \cdot \left(b \cdot a\right) - \left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right)\\ \mathbf{elif}\;z \le 1.204732720841708791880170738356908765686 \cdot 10^{-22}:\\ \;\;\;\;x \cdot 2 + \left(27 \cdot \left(b \cdot a\right) - \left(\left(z \cdot 9\right) \cdot t\right) \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2 + \left(27 \cdot \left(b \cdot a\right) - \left(9 \cdot \left(t \cdot y\right)\right) \cdot z\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}\;z \le -1.893786164031411283844403967516072339818 \cdot 10^{65}:\\
\;\;\;\;x \cdot 2 + \left(27 \cdot \left(b \cdot a\right) - \left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r50016735 = x;
        double r50016736 = 2.0;
        double r50016737 = r50016735 * r50016736;
        double r50016738 = y;
        double r50016739 = 9.0;
        double r50016740 = r50016738 * r50016739;
        double r50016741 = z;
        double r50016742 = r50016740 * r50016741;
        double r50016743 = t;
        double r50016744 = r50016742 * r50016743;
        double r50016745 = r50016737 - r50016744;
        double r50016746 = a;
        double r50016747 = 27.0;
        double r50016748 = r50016746 * r50016747;
        double r50016749 = b;
        double r50016750 = r50016748 * r50016749;
        double r50016751 = r50016745 + r50016750;
        return r50016751;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r50016752 = z;
        double r50016753 = -1.8937861640314113e+65;
        bool r50016754 = r50016752 <= r50016753;
        double r50016755 = x;
        double r50016756 = 2.0;
        double r50016757 = r50016755 * r50016756;
        double r50016758 = 27.0;
        double r50016759 = b;
        double r50016760 = a;
        double r50016761 = r50016759 * r50016760;
        double r50016762 = r50016758 * r50016761;
        double r50016763 = 9.0;
        double r50016764 = t;
        double r50016765 = y;
        double r50016766 = r50016764 * r50016765;
        double r50016767 = r50016763 * r50016766;
        double r50016768 = r50016767 * r50016752;
        double r50016769 = r50016762 - r50016768;
        double r50016770 = r50016757 + r50016769;
        double r50016771 = 1.2047327208417088e-22;
        bool r50016772 = r50016752 <= r50016771;
        double r50016773 = r50016752 * r50016763;
        double r50016774 = r50016773 * r50016764;
        double r50016775 = r50016774 * r50016765;
        double r50016776 = r50016762 - r50016775;
        double r50016777 = r50016757 + r50016776;
        double r50016778 = r50016772 ? r50016777 : r50016770;
        double r50016779 = r50016754 ? r50016770 : r50016778;
        return r50016779;
}

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.5
Target2.6
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 z < -1.8937861640314113e+65 or 1.2047327208417088e-22 < z

    1. Initial program 8.1

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

      \[\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 sub-neg8.1

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

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

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

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

    if -1.8937861640314113e+65 < z < 1.2047327208417088e-22

    1. Initial program 0.7

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

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

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

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

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

Reproduce

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