Average Error: 3.8 → 0.6
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}\;\left(y \cdot 9\right) \cdot z = -\infty \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 2.73534201683668052 \cdot 10^{138}\right):\\ \;\;\;\;1 \cdot \mathsf{fma}\left(27, a \cdot b, 2 \cdot x - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\ \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}\;\left(y \cdot 9\right) \cdot z = -\infty \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 2.73534201683668052 \cdot 10^{138}\right):\\
\;\;\;\;1 \cdot \mathsf{fma}\left(27, a \cdot b, 2 \cdot x - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\

\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 r755035 = x;
        double r755036 = 2.0;
        double r755037 = r755035 * r755036;
        double r755038 = y;
        double r755039 = 9.0;
        double r755040 = r755038 * r755039;
        double r755041 = z;
        double r755042 = r755040 * r755041;
        double r755043 = t;
        double r755044 = r755042 * r755043;
        double r755045 = r755037 - r755044;
        double r755046 = a;
        double r755047 = 27.0;
        double r755048 = r755046 * r755047;
        double r755049 = b;
        double r755050 = r755048 * r755049;
        double r755051 = r755045 + r755050;
        return r755051;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r755052 = y;
        double r755053 = 9.0;
        double r755054 = r755052 * r755053;
        double r755055 = z;
        double r755056 = r755054 * r755055;
        double r755057 = -inf.0;
        bool r755058 = r755056 <= r755057;
        double r755059 = 2.7353420168366805e+138;
        bool r755060 = r755056 <= r755059;
        double r755061 = !r755060;
        bool r755062 = r755058 || r755061;
        double r755063 = 1.0;
        double r755064 = 27.0;
        double r755065 = a;
        double r755066 = b;
        double r755067 = r755065 * r755066;
        double r755068 = 2.0;
        double r755069 = x;
        double r755070 = r755068 * r755069;
        double r755071 = t;
        double r755072 = r755071 * r755055;
        double r755073 = r755072 * r755052;
        double r755074 = r755053 * r755073;
        double r755075 = r755070 - r755074;
        double r755076 = fma(r755064, r755067, r755075);
        double r755077 = r755063 * r755076;
        double r755078 = r755064 * r755066;
        double r755079 = r755069 * r755068;
        double r755080 = r755056 * r755071;
        double r755081 = r755079 - r755080;
        double r755082 = fma(r755065, r755078, r755081);
        double r755083 = r755062 ? r755077 : r755082;
        return r755083;
}

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
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 2 regimes
  2. if (* (* y 9.0) z) < -inf.0 or 2.7353420168366805e+138 < (* (* y 9.0) z)

    1. Initial program 27.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 pow127.7

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

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

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

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

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

      \[\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 *-un-lft-identity27.6

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\mathsf{fma}\left(27, a \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    14. Taylor expanded around inf 26.9

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

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

    if -inf.0 < (* (* y 9.0) z) < 2.7353420168366805e+138

    1. Initial program 0.4

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified0.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z = -\infty \lor \neg \left(\left(y \cdot 9\right) \cdot z \le 2.73534201683668052 \cdot 10^{138}\right):\\ \;\;\;\;1 \cdot \mathsf{fma}\left(27, a \cdot b, 2 \cdot x - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\ \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 2020024 +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)))