Average Error: 4.0 → 0.8
Time: 25.7s
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 -1.49638175236613107 \cdot 10^{272} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 1.61472772918958622 \cdot 10^{81}\right):\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - \left(\left(9 \cdot t\right) \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - \left(9 \cdot t\right) \cdot \left(z \cdot y\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 -1.49638175236613107 \cdot 10^{272} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 1.61472772918958622 \cdot 10^{81}\right):\\
\;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - \left(\left(9 \cdot t\right) \cdot z\right) \cdot y\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r554103 = x;
        double r554104 = 2.0;
        double r554105 = r554103 * r554104;
        double r554106 = y;
        double r554107 = 9.0;
        double r554108 = r554106 * r554107;
        double r554109 = z;
        double r554110 = r554108 * r554109;
        double r554111 = t;
        double r554112 = r554110 * r554111;
        double r554113 = r554105 - r554112;
        double r554114 = a;
        double r554115 = 27.0;
        double r554116 = r554114 * r554115;
        double r554117 = b;
        double r554118 = r554116 * r554117;
        double r554119 = r554113 + r554118;
        return r554119;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r554120 = y;
        double r554121 = 9.0;
        double r554122 = r554120 * r554121;
        double r554123 = z;
        double r554124 = r554122 * r554123;
        double r554125 = -1.496381752366131e+272;
        bool r554126 = r554124 <= r554125;
        double r554127 = 1.6147277291895862e+81;
        bool r554128 = r554124 <= r554127;
        double r554129 = !r554128;
        bool r554130 = r554126 || r554129;
        double r554131 = 2.0;
        double r554132 = x;
        double r554133 = r554131 * r554132;
        double r554134 = 27.0;
        double r554135 = a;
        double r554136 = b;
        double r554137 = r554135 * r554136;
        double r554138 = r554134 * r554137;
        double r554139 = r554133 + r554138;
        double r554140 = t;
        double r554141 = r554121 * r554140;
        double r554142 = r554141 * r554123;
        double r554143 = r554142 * r554120;
        double r554144 = r554139 - r554143;
        double r554145 = r554123 * r554120;
        double r554146 = r554141 * r554145;
        double r554147 = r554139 - r554146;
        double r554148 = r554130 ? r554144 : r554147;
        return r554148;
}

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

Original4.0
Target2.9
Herbie0.8
\[\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) z) < -1.496381752366131e+272 or 1.6147277291895862e+81 < (* (* y 9.0) z)

    1. Initial program 21.2

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

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

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

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

    if -1.496381752366131e+272 < (* (* y 9.0) z) < 1.6147277291895862e+81

    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.4

      \[\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) - \color{blue}{\left(9 \cdot t\right) \cdot \left(z \cdot y\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -1.49638175236613107 \cdot 10^{272} \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 1.61472772918958622 \cdot 10^{81}\right):\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - \left(\left(9 \cdot t\right) \cdot z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - \left(9 \cdot t\right) \cdot \left(z \cdot y\right)\\ \end{array}\]

Reproduce

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