Average Error: 3.9 → 0.9
Time: 5.6s
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}\;t \le -1.69076388961076951 \cdot 10^{99} \lor \neg \left(t \le 8.3286735456102908 \cdot 10^{-20}\right):\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\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}\;t \le -1.69076388961076951 \cdot 10^{99} \lor \neg \left(t \le 8.3286735456102908 \cdot 10^{-20}\right):\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r1492139 = x;
        double r1492140 = 2.0;
        double r1492141 = r1492139 * r1492140;
        double r1492142 = y;
        double r1492143 = 9.0;
        double r1492144 = r1492142 * r1492143;
        double r1492145 = z;
        double r1492146 = r1492144 * r1492145;
        double r1492147 = t;
        double r1492148 = r1492146 * r1492147;
        double r1492149 = r1492141 - r1492148;
        double r1492150 = a;
        double r1492151 = 27.0;
        double r1492152 = r1492150 * r1492151;
        double r1492153 = b;
        double r1492154 = r1492152 * r1492153;
        double r1492155 = r1492149 + r1492154;
        return r1492155;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r1492156 = t;
        double r1492157 = -1.6907638896107695e+99;
        bool r1492158 = r1492156 <= r1492157;
        double r1492159 = 8.328673545610291e-20;
        bool r1492160 = r1492156 <= r1492159;
        double r1492161 = !r1492160;
        bool r1492162 = r1492158 || r1492161;
        double r1492163 = 2.0;
        double r1492164 = x;
        double r1492165 = 27.0;
        double r1492166 = a;
        double r1492167 = b;
        double r1492168 = r1492166 * r1492167;
        double r1492169 = r1492165 * r1492168;
        double r1492170 = 9.0;
        double r1492171 = z;
        double r1492172 = y;
        double r1492173 = r1492171 * r1492172;
        double r1492174 = r1492156 * r1492173;
        double r1492175 = r1492170 * r1492174;
        double r1492176 = r1492169 - r1492175;
        double r1492177 = fma(r1492163, r1492164, r1492176);
        double r1492178 = r1492165 * r1492167;
        double r1492179 = r1492164 * r1492163;
        double r1492180 = r1492171 * r1492156;
        double r1492181 = r1492170 * r1492180;
        double r1492182 = r1492172 * r1492181;
        double r1492183 = r1492179 - r1492182;
        double r1492184 = fma(r1492166, r1492178, r1492183);
        double r1492185 = r1492162 ? r1492177 : r1492184;
        return r1492185;
}

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.9
\[\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 t < -1.6907638896107695e+99 or 8.328673545610291e-20 < t

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

      \[\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. Taylor expanded around inf 1.0

      \[\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)}\]
    4. Simplified1.0

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

    if -1.6907638896107695e+99 < t < 8.328673545610291e-20

    1. Initial program 5.6

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

      \[\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. Using strategy rm
    4. Applied associate-*l*0.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.69076388961076951 \cdot 10^{99} \lor \neg \left(t \le 8.3286735456102908 \cdot 10^{-20}\right):\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right)\\ \end{array}\]

Reproduce

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