Average Error: 5.7 → 3.5
Time: 31.6s
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 -3.308576004970711423906714916915033699205 \cdot 10^{-41}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \mathbf{elif}\;t \le 925478270354778253145669632:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(x \cdot 18\right) \cdot y\right) \cdot \left(z \cdot t\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\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 -3.308576004970711423906714916915033699205 \cdot 10^{-41}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right)\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\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 r129162443 = x;
        double r129162444 = 18.0;
        double r129162445 = r129162443 * r129162444;
        double r129162446 = y;
        double r129162447 = r129162445 * r129162446;
        double r129162448 = z;
        double r129162449 = r129162447 * r129162448;
        double r129162450 = t;
        double r129162451 = r129162449 * r129162450;
        double r129162452 = a;
        double r129162453 = 4.0;
        double r129162454 = r129162452 * r129162453;
        double r129162455 = r129162454 * r129162450;
        double r129162456 = r129162451 - r129162455;
        double r129162457 = b;
        double r129162458 = c;
        double r129162459 = r129162457 * r129162458;
        double r129162460 = r129162456 + r129162459;
        double r129162461 = r129162443 * r129162453;
        double r129162462 = i;
        double r129162463 = r129162461 * r129162462;
        double r129162464 = r129162460 - r129162463;
        double r129162465 = j;
        double r129162466 = 27.0;
        double r129162467 = r129162465 * r129162466;
        double r129162468 = k;
        double r129162469 = r129162467 * r129162468;
        double r129162470 = r129162464 - r129162469;
        return r129162470;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r129162471 = t;
        double r129162472 = -3.3085760049707114e-41;
        bool r129162473 = r129162471 <= r129162472;
        double r129162474 = b;
        double r129162475 = c;
        double r129162476 = x;
        double r129162477 = 18.0;
        double r129162478 = r129162476 * r129162477;
        double r129162479 = y;
        double r129162480 = z;
        double r129162481 = r129162479 * r129162480;
        double r129162482 = r129162478 * r129162481;
        double r129162483 = r129162482 * r129162471;
        double r129162484 = 4.0;
        double r129162485 = a;
        double r129162486 = i;
        double r129162487 = r129162486 * r129162476;
        double r129162488 = fma(r129162471, r129162485, r129162487);
        double r129162489 = 27.0;
        double r129162490 = j;
        double r129162491 = k;
        double r129162492 = r129162490 * r129162491;
        double r129162493 = r129162489 * r129162492;
        double r129162494 = fma(r129162484, r129162488, r129162493);
        double r129162495 = r129162483 - r129162494;
        double r129162496 = fma(r129162474, r129162475, r129162495);
        double r129162497 = 9.254782703547783e+26;
        bool r129162498 = r129162471 <= r129162497;
        double r129162499 = r129162478 * r129162479;
        double r129162500 = r129162480 * r129162471;
        double r129162501 = r129162499 * r129162500;
        double r129162502 = r129162501 - r129162494;
        double r129162503 = fma(r129162474, r129162475, r129162502);
        double r129162504 = r129162498 ? r129162503 : r129162496;
        double r129162505 = r129162473 ? r129162496 : r129162504;
        return r129162505;
}

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.7
Target1.5
Herbie3.5
\[\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 < -3.3085760049707114e-41 or 9.254782703547783e+26 < t

    1. Initial program 1.9

      \[\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.8

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

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

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

    if -3.3085760049707114e-41 < t < 9.254782703547783e+26

    1. Initial program 8.1

      \[\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. Simplified8.1

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

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

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

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

Reproduce

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