Average Error: 5.9 → 1.8
Time: 30.5s
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}\;z \le -4.872473314684069170084131104847792702954 \cdot 10^{103}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(y \cdot \left(18 \cdot x\right)\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \mathbf{elif}\;z \le 5233734057954217984:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(y \cdot z\right) \cdot x\right)\right) \cdot 18 - \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(t \cdot \left(y \cdot \left(18 \cdot x\right)\right)\right) \cdot z - \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}\;z \le -4.872473314684069170084131104847792702954 \cdot 10^{103}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(y \cdot \left(18 \cdot x\right)\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\

\mathbf{elif}\;z \le 5233734057954217984:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(y \cdot z\right) \cdot x\right)\right) \cdot 18 - \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(t \cdot \left(y \cdot \left(18 \cdot x\right)\right)\right) \cdot z - \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 r31530568 = x;
        double r31530569 = 18.0;
        double r31530570 = r31530568 * r31530569;
        double r31530571 = y;
        double r31530572 = r31530570 * r31530571;
        double r31530573 = z;
        double r31530574 = r31530572 * r31530573;
        double r31530575 = t;
        double r31530576 = r31530574 * r31530575;
        double r31530577 = a;
        double r31530578 = 4.0;
        double r31530579 = r31530577 * r31530578;
        double r31530580 = r31530579 * r31530575;
        double r31530581 = r31530576 - r31530580;
        double r31530582 = b;
        double r31530583 = c;
        double r31530584 = r31530582 * r31530583;
        double r31530585 = r31530581 + r31530584;
        double r31530586 = r31530568 * r31530578;
        double r31530587 = i;
        double r31530588 = r31530586 * r31530587;
        double r31530589 = r31530585 - r31530588;
        double r31530590 = j;
        double r31530591 = 27.0;
        double r31530592 = r31530590 * r31530591;
        double r31530593 = k;
        double r31530594 = r31530592 * r31530593;
        double r31530595 = r31530589 - r31530594;
        return r31530595;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r31530596 = z;
        double r31530597 = -4.872473314684069e+103;
        bool r31530598 = r31530596 <= r31530597;
        double r31530599 = b;
        double r31530600 = c;
        double r31530601 = t;
        double r31530602 = y;
        double r31530603 = 18.0;
        double r31530604 = x;
        double r31530605 = r31530603 * r31530604;
        double r31530606 = r31530602 * r31530605;
        double r31530607 = r31530601 * r31530606;
        double r31530608 = r31530607 * r31530596;
        double r31530609 = 4.0;
        double r31530610 = a;
        double r31530611 = i;
        double r31530612 = r31530611 * r31530604;
        double r31530613 = fma(r31530601, r31530610, r31530612);
        double r31530614 = 27.0;
        double r31530615 = j;
        double r31530616 = k;
        double r31530617 = r31530615 * r31530616;
        double r31530618 = r31530614 * r31530617;
        double r31530619 = fma(r31530609, r31530613, r31530618);
        double r31530620 = r31530608 - r31530619;
        double r31530621 = fma(r31530599, r31530600, r31530620);
        double r31530622 = 5.233734057954218e+18;
        bool r31530623 = r31530596 <= r31530622;
        double r31530624 = r31530602 * r31530596;
        double r31530625 = r31530624 * r31530604;
        double r31530626 = r31530601 * r31530625;
        double r31530627 = r31530626 * r31530603;
        double r31530628 = r31530627 - r31530619;
        double r31530629 = fma(r31530599, r31530600, r31530628);
        double r31530630 = r31530623 ? r31530629 : r31530621;
        double r31530631 = r31530598 ? r31530621 : r31530630;
        return r31530631;
}

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.9
Target1.6
Herbie1.8
\[\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 z < -4.872473314684069e+103 or 5.233734057954218e+18 < z

    1. Initial program 8.2

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

      \[\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-*l*8.0

      \[\leadsto \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), \color{blue}{27 \cdot \left(j \cdot k\right)}\right)\right)\]
    5. Using strategy rm
    6. Applied associate-*r*1.7

      \[\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), 27 \cdot \left(j \cdot k\right)\right)\right)\]

    if -4.872473314684069e+103 < z < 5.233734057954218e+18

    1. Initial program 4.7

      \[\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. Simplified4.6

      \[\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-*l*4.6

      \[\leadsto \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), \color{blue}{27 \cdot \left(j \cdot k\right)}\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), 27 \cdot \left(j \cdot k\right)\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.872473314684069170084131104847792702954 \cdot 10^{103}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(y \cdot \left(18 \cdot x\right)\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \mathbf{elif}\;z \le 5233734057954217984:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(y \cdot z\right) \cdot x\right)\right) \cdot 18 - \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(t \cdot \left(y \cdot \left(18 \cdot x\right)\right)\right) \cdot z - \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 2019174 +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)))