Average Error: 3.8 → 2.1
Time: 18.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 -5620875659079845081513984:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(b \cdot a\right) - \left(y \cdot \left(z \cdot t\right)\right) \cdot 9\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(b \cdot a\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\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 -5620875659079845081513984:\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(b \cdot a\right) - \left(y \cdot \left(z \cdot t\right)\right) \cdot 9\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r34394137 = x;
        double r34394138 = 2.0;
        double r34394139 = r34394137 * r34394138;
        double r34394140 = y;
        double r34394141 = 9.0;
        double r34394142 = r34394140 * r34394141;
        double r34394143 = z;
        double r34394144 = r34394142 * r34394143;
        double r34394145 = t;
        double r34394146 = r34394144 * r34394145;
        double r34394147 = r34394139 - r34394146;
        double r34394148 = a;
        double r34394149 = 27.0;
        double r34394150 = r34394148 * r34394149;
        double r34394151 = b;
        double r34394152 = r34394150 * r34394151;
        double r34394153 = r34394147 + r34394152;
        return r34394153;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r34394154 = y;
        double r34394155 = 9.0;
        double r34394156 = r34394154 * r34394155;
        double r34394157 = -5.620875659079845e+24;
        bool r34394158 = r34394156 <= r34394157;
        double r34394159 = 2.0;
        double r34394160 = x;
        double r34394161 = 27.0;
        double r34394162 = b;
        double r34394163 = a;
        double r34394164 = r34394162 * r34394163;
        double r34394165 = r34394161 * r34394164;
        double r34394166 = z;
        double r34394167 = t;
        double r34394168 = r34394166 * r34394167;
        double r34394169 = r34394154 * r34394168;
        double r34394170 = r34394169 * r34394155;
        double r34394171 = r34394165 - r34394170;
        double r34394172 = fma(r34394159, r34394160, r34394171);
        double r34394173 = r34394166 * r34394154;
        double r34394174 = r34394167 * r34394173;
        double r34394175 = r34394155 * r34394174;
        double r34394176 = r34394165 - r34394175;
        double r34394177 = fma(r34394159, r34394160, r34394176);
        double r34394178 = r34394158 ? r34394172 : r34394177;
        return r34394178;
}

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.8
Herbie2.1
\[\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 (* y 9.0) < -5.620875659079845e+24

    1. Initial program 8.9

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

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

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

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

    if -5.620875659079845e+24 < (* y 9.0)

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

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

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

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

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(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)))