Average Error: 3.7 → 0.8
Time: 4.8s
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.40697699593857467 \cdot 10^{-86} \lor \neg \left(t \le 30288488466054408\right):\\ \;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, 2, -\left(9 \cdot \left(z \cdot t\right)\right) \cdot y\right) + \mathsf{fma}\left(a, 27 \cdot b, \mathsf{fma}\left(-9 \cdot \left(z \cdot t\right), y, \left(9 \cdot \left(z \cdot t\right)\right) \cdot y\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.40697699593857467 \cdot 10^{-86} \lor \neg \left(t \le 30288488466054408\right):\\
\;\;\;\;\left(x \cdot 2 - \left(y \cdot \left(9 \cdot z\right)\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r748213 = x;
        double r748214 = 2.0;
        double r748215 = r748213 * r748214;
        double r748216 = y;
        double r748217 = 9.0;
        double r748218 = r748216 * r748217;
        double r748219 = z;
        double r748220 = r748218 * r748219;
        double r748221 = t;
        double r748222 = r748220 * r748221;
        double r748223 = r748215 - r748222;
        double r748224 = a;
        double r748225 = 27.0;
        double r748226 = r748224 * r748225;
        double r748227 = b;
        double r748228 = r748226 * r748227;
        double r748229 = r748223 + r748228;
        return r748229;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r748230 = t;
        double r748231 = -1.4069769959385747e-86;
        bool r748232 = r748230 <= r748231;
        double r748233 = 3.028848846605441e+16;
        bool r748234 = r748230 <= r748233;
        double r748235 = !r748234;
        bool r748236 = r748232 || r748235;
        double r748237 = x;
        double r748238 = 2.0;
        double r748239 = r748237 * r748238;
        double r748240 = y;
        double r748241 = 9.0;
        double r748242 = z;
        double r748243 = r748241 * r748242;
        double r748244 = r748240 * r748243;
        double r748245 = r748244 * r748230;
        double r748246 = r748239 - r748245;
        double r748247 = a;
        double r748248 = 27.0;
        double r748249 = r748247 * r748248;
        double r748250 = b;
        double r748251 = r748249 * r748250;
        double r748252 = r748246 + r748251;
        double r748253 = r748242 * r748230;
        double r748254 = r748241 * r748253;
        double r748255 = r748254 * r748240;
        double r748256 = -r748255;
        double r748257 = fma(r748237, r748238, r748256);
        double r748258 = r748248 * r748250;
        double r748259 = -r748254;
        double r748260 = fma(r748259, r748240, r748255);
        double r748261 = fma(r748247, r748258, r748260);
        double r748262 = r748257 + r748261;
        double r748263 = r748236 ? r748252 : r748262;
        return r748263;
}

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.7
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 t < -1.4069769959385747e-86 or 3.028848846605441e+16 < t

    1. Initial program 1.0

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

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

    if -1.4069769959385747e-86 < t < 3.028848846605441e+16

    1. Initial program 6.3

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

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

      \[\leadsto \left(x \cdot 2 - \color{blue}{y \cdot \left(9 \cdot \left(z \cdot t\right)\right)}\right) + \left(a \cdot 27\right) \cdot b\]
    6. Using strategy rm
    7. Applied prod-diff0.6

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

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

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

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

Reproduce

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