Average Error: 3.4 → 0.6
Time: 32.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 \le -4.549863115849115575191730460193448270284 \cdot 10^{233}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 3.507106405654514527034514001504645185509 \cdot 10^{234}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\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}\;\left(y \cdot 9\right) \cdot z \le -4.549863115849115575191730460193448270284 \cdot 10^{233}:\\
\;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\

\mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 3.507106405654514527034514001504645185509 \cdot 10^{234}:\\
\;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r183973339 = x;
        double r183973340 = 2.0;
        double r183973341 = r183973339 * r183973340;
        double r183973342 = y;
        double r183973343 = 9.0;
        double r183973344 = r183973342 * r183973343;
        double r183973345 = z;
        double r183973346 = r183973344 * r183973345;
        double r183973347 = t;
        double r183973348 = r183973346 * r183973347;
        double r183973349 = r183973341 - r183973348;
        double r183973350 = a;
        double r183973351 = 27.0;
        double r183973352 = r183973350 * r183973351;
        double r183973353 = b;
        double r183973354 = r183973352 * r183973353;
        double r183973355 = r183973349 + r183973354;
        return r183973355;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r183973356 = y;
        double r183973357 = 9.0;
        double r183973358 = r183973356 * r183973357;
        double r183973359 = z;
        double r183973360 = r183973358 * r183973359;
        double r183973361 = -4.549863115849116e+233;
        bool r183973362 = r183973360 <= r183973361;
        double r183973363 = a;
        double r183973364 = 27.0;
        double r183973365 = b;
        double r183973366 = r183973364 * r183973365;
        double r183973367 = x;
        double r183973368 = 2.0;
        double r183973369 = r183973367 * r183973368;
        double r183973370 = t;
        double r183973371 = r183973359 * r183973370;
        double r183973372 = r183973358 * r183973371;
        double r183973373 = r183973369 - r183973372;
        double r183973374 = fma(r183973363, r183973366, r183973373);
        double r183973375 = 3.5071064056545145e+234;
        bool r183973376 = r183973360 <= r183973375;
        double r183973377 = r183973360 * r183973370;
        double r183973378 = r183973369 - r183973377;
        double r183973379 = r183973363 * r183973364;
        double r183973380 = r183973379 * r183973365;
        double r183973381 = r183973378 + r183973380;
        double r183973382 = r183973376 ? r183973381 : r183973374;
        double r183973383 = r183973362 ? r183973374 : r183973382;
        return r183973383;
}

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.4
Target2.4
Herbie0.6
\[\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) z) < -4.549863115849116e+233 or 3.5071064056545145e+234 < (* (* y 9.0) z)

    1. Initial program 31.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. Simplified31.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. Using strategy rm
    4. Applied associate-*l*1.6

      \[\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)\]

    if -4.549863115849116e+233 < (* (* y 9.0) z) < 3.5071064056545145e+234

    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\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \le -4.549863115849115575191730460193448270284 \cdot 10^{233}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{elif}\;\left(y \cdot 9\right) \cdot z \le 3.507106405654514527034514001504645185509 \cdot 10^{234}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \end{array}\]

Reproduce

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