Average Error: 5.8 → 2.0
Time: 30.7s
Precision: 64
\[\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\]
\[\begin{array}{l} \mathbf{if}\;t \le -6.442181096393705101750420734141792839571 \cdot 10^{95}:\\ \;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{elif}\;t \le 1208.546700118903572729323059320449829102:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(y \cdot 18\right) \cdot \left(t \cdot x\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(k \cdot j\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \end{array}\]
\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k
\begin{array}{l}
\mathbf{if}\;t \le -6.442181096393705101750420734141792839571 \cdot 10^{95}:\\
\;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\

\mathbf{elif}\;t \le 1208.546700118903572729323059320449829102:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(y \cdot 18\right) \cdot \left(t \cdot x\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(k \cdot j\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r27991409 = x;
        double r27991410 = 18.0;
        double r27991411 = r27991409 * r27991410;
        double r27991412 = y;
        double r27991413 = r27991411 * r27991412;
        double r27991414 = z;
        double r27991415 = r27991413 * r27991414;
        double r27991416 = t;
        double r27991417 = r27991415 * r27991416;
        double r27991418 = a;
        double r27991419 = 4.0;
        double r27991420 = r27991418 * r27991419;
        double r27991421 = r27991420 * r27991416;
        double r27991422 = r27991417 - r27991421;
        double r27991423 = b;
        double r27991424 = c;
        double r27991425 = r27991423 * r27991424;
        double r27991426 = r27991422 + r27991425;
        double r27991427 = r27991409 * r27991419;
        double r27991428 = i;
        double r27991429 = r27991427 * r27991428;
        double r27991430 = r27991426 - r27991429;
        double r27991431 = j;
        double r27991432 = 27.0;
        double r27991433 = r27991431 * r27991432;
        double r27991434 = k;
        double r27991435 = r27991433 * r27991434;
        double r27991436 = r27991430 - r27991435;
        return r27991436;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r27991437 = t;
        double r27991438 = -6.442181096393705e+95;
        bool r27991439 = r27991437 <= r27991438;
        double r27991440 = b;
        double r27991441 = c;
        double r27991442 = 18.0;
        double r27991443 = z;
        double r27991444 = y;
        double r27991445 = r27991443 * r27991444;
        double r27991446 = x;
        double r27991447 = r27991445 * r27991446;
        double r27991448 = r27991437 * r27991447;
        double r27991449 = r27991442 * r27991448;
        double r27991450 = 4.0;
        double r27991451 = a;
        double r27991452 = i;
        double r27991453 = r27991452 * r27991446;
        double r27991454 = fma(r27991437, r27991451, r27991453);
        double r27991455 = 27.0;
        double r27991456 = j;
        double r27991457 = r27991455 * r27991456;
        double r27991458 = k;
        double r27991459 = r27991457 * r27991458;
        double r27991460 = fma(r27991450, r27991454, r27991459);
        double r27991461 = r27991449 - r27991460;
        double r27991462 = fma(r27991440, r27991441, r27991461);
        double r27991463 = 1208.5467001189036;
        bool r27991464 = r27991437 <= r27991463;
        double r27991465 = r27991444 * r27991442;
        double r27991466 = r27991437 * r27991446;
        double r27991467 = r27991465 * r27991466;
        double r27991468 = r27991467 * r27991443;
        double r27991469 = r27991458 * r27991456;
        double r27991470 = r27991455 * r27991469;
        double r27991471 = fma(r27991450, r27991454, r27991470);
        double r27991472 = r27991468 - r27991471;
        double r27991473 = fma(r27991440, r27991441, r27991472);
        double r27991474 = r27991464 ? r27991473 : r27991462;
        double r27991475 = r27991439 ? r27991462 : r27991474;
        return r27991475;
}

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

Bits error versus c

Bits error versus i

Bits error versus j

Bits error versus k

Target

Original5.8
Target1.7
Herbie2.0
\[\begin{array}{l} \mathbf{if}\;t \lt -1.62108153975413982700795070153457058168 \cdot 10^{-69}:\\ \;\;\;\;\left(\left(18 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4\right) - \left(\left(k \cdot j\right) \cdot 27 - c \cdot b\right)\\ \mathbf{elif}\;t \lt 165.6802794380522243500308832153677940369:\\ \;\;\;\;\left(\left(18 \cdot y\right) \cdot \left(x \cdot \left(z \cdot t\right)\right) - \left(a \cdot t + i \cdot x\right) \cdot 4\right) + \left(c \cdot b - 27 \cdot \left(k \cdot j\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(18 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4\right) - \left(\left(k \cdot j\right) \cdot 27 - c \cdot b\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if t < -6.442181096393705e+95 or 1208.5467001189036 < t

    1. Initial program 1.5

      \[\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\]
    2. Simplified1.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, c, t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)}\]
    3. Using strategy rm
    4. Applied associate-*r*6.9

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(t \cdot \left(\left(x \cdot 18\right) \cdot y\right)\right) \cdot z} - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)\]
    5. Taylor expanded around inf 1.9

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{18 \cdot \left(t \cdot \left(x \cdot \left(z \cdot y\right)\right)\right)} - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)\]

    if -6.442181096393705e+95 < t < 1208.5467001189036

    1. Initial program 7.6

      \[\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\]
    2. Simplified7.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, c, t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)}\]
    3. Using strategy rm
    4. Applied associate-*r*4.5

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(t \cdot \left(\left(x \cdot 18\right) \cdot y\right)\right) \cdot z} - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)\]
    5. Using strategy rm
    6. Applied associate-*r*2.1

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(\left(t \cdot \left(x \cdot 18\right)\right) \cdot y\right)} \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(27 \cdot j\right) \cdot k\right)\right)\]
    7. Using strategy rm
    8. Applied associate-*l*2.0

      \[\leadsto \mathsf{fma}\left(b, c, \left(\left(t \cdot \left(x \cdot 18\right)\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \color{blue}{27 \cdot \left(j \cdot k\right)}\right)\right)\]
    9. Using strategy rm
    10. Applied *-un-lft-identity2.0

      \[\leadsto \mathsf{fma}\left(b, c, \left(\left(t \cdot \left(x \cdot 18\right)\right) \cdot y\right) \cdot \color{blue}{\left(1 \cdot z\right)} - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), 27 \cdot \left(j \cdot k\right)\right)\right)\]
    11. Applied associate-*r*2.0

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(\left(\left(t \cdot \left(x \cdot 18\right)\right) \cdot y\right) \cdot 1\right) \cdot z} - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), 27 \cdot \left(j \cdot k\right)\right)\right)\]
    12. Simplified2.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -6.442181096393705101750420734141792839571 \cdot 10^{95}:\\ \;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{elif}\;t \le 1208.546700118903572729323059320449829102:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(y \cdot 18\right) \cdot \left(t \cdot x\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(k \cdot j\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (x y z t a b c i j k)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, E"

  :herbie-target
  (if (< t -1.6210815397541398e-69) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b))) (if (< t 165.68027943805222) (+ (- (* (* 18.0 y) (* x (* z t))) (* (+ (* a t) (* i x)) 4.0)) (- (* c b) (* 27.0 (* k j)))) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b)))))

  (- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))