Average Error: 5.8 → 1.4
Time: 28.8s
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 -5.771702439406874937861711724651597749554 \cdot 10^{51} \lor \neg \left(t \le 0.0965905518888733327642626136366743594408\right):\\ \;\;\;\;\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(\sqrt{27} \cdot j\right) \cdot \left(\sqrt{27} \cdot k\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(y \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(j \cdot k\right) \cdot 27\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 -5.771702439406874937861711724651597749554 \cdot 10^{51} \lor \neg \left(t \le 0.0965905518888733327642626136366743594408\right):\\
\;\;\;\;\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(\sqrt{27} \cdot j\right) \cdot \left(\sqrt{27} \cdot k\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(y \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(j \cdot k\right) \cdot 27\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 r706574 = x;
        double r706575 = 18.0;
        double r706576 = r706574 * r706575;
        double r706577 = y;
        double r706578 = r706576 * r706577;
        double r706579 = z;
        double r706580 = r706578 * r706579;
        double r706581 = t;
        double r706582 = r706580 * r706581;
        double r706583 = a;
        double r706584 = 4.0;
        double r706585 = r706583 * r706584;
        double r706586 = r706585 * r706581;
        double r706587 = r706582 - r706586;
        double r706588 = b;
        double r706589 = c;
        double r706590 = r706588 * r706589;
        double r706591 = r706587 + r706590;
        double r706592 = r706574 * r706584;
        double r706593 = i;
        double r706594 = r706592 * r706593;
        double r706595 = r706591 - r706594;
        double r706596 = j;
        double r706597 = 27.0;
        double r706598 = r706596 * r706597;
        double r706599 = k;
        double r706600 = r706598 * r706599;
        double r706601 = r706595 - r706600;
        return r706601;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r706602 = t;
        double r706603 = -5.771702439406875e+51;
        bool r706604 = r706602 <= r706603;
        double r706605 = 0.09659055188887333;
        bool r706606 = r706602 <= r706605;
        double r706607 = !r706606;
        bool r706608 = r706604 || r706607;
        double r706609 = b;
        double r706610 = c;
        double r706611 = x;
        double r706612 = 18.0;
        double r706613 = r706611 * r706612;
        double r706614 = y;
        double r706615 = r706613 * r706614;
        double r706616 = z;
        double r706617 = r706615 * r706616;
        double r706618 = r706617 * r706602;
        double r706619 = 4.0;
        double r706620 = a;
        double r706621 = i;
        double r706622 = r706621 * r706611;
        double r706623 = fma(r706602, r706620, r706622);
        double r706624 = 27.0;
        double r706625 = sqrt(r706624);
        double r706626 = j;
        double r706627 = r706625 * r706626;
        double r706628 = k;
        double r706629 = r706625 * r706628;
        double r706630 = r706627 * r706629;
        double r706631 = fma(r706619, r706623, r706630);
        double r706632 = r706618 - r706631;
        double r706633 = fma(r706609, r706610, r706632);
        double r706634 = r706611 * r706602;
        double r706635 = r706616 * r706634;
        double r706636 = r706614 * r706635;
        double r706637 = r706636 * r706612;
        double r706638 = r706626 * r706628;
        double r706639 = r706638 * r706624;
        double r706640 = fma(r706619, r706623, r706639);
        double r706641 = r706637 - r706640;
        double r706642 = fma(r706609, r706610, r706641);
        double r706643 = r706608 ? r706633 : r706642;
        return r706643;
}

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.4
Herbie1.4
\[\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 < -5.771702439406875e+51 or 0.09659055188887333 < t

    1. Initial program 1.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. Simplified1.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*1.2

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

      \[\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}{\left(\sqrt{27} \cdot \sqrt{27}\right)} \cdot \left(j \cdot k\right)\right)\right)\]
    7. Applied associate-*l*1.2

      \[\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}{\sqrt{27} \cdot \left(\sqrt{27} \cdot \left(j \cdot k\right)\right)}\right)\right)\]
    8. Simplified1.2

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

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

    if -5.771702439406875e+51 < t < 0.09659055188887333

    1. Initial program 8.0

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

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

      \[\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 8.2

      \[\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)\]
    6. Simplified1.5

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{18 \cdot \left(\left(\left(t \cdot x\right) \cdot z\right) \cdot y\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.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -5.771702439406874937861711724651597749554 \cdot 10^{51} \lor \neg \left(t \le 0.0965905518888733327642626136366743594408\right):\\ \;\;\;\;\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(\sqrt{27} \cdot j\right) \cdot \left(\sqrt{27} \cdot k\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(y \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(j \cdot k\right) \cdot 27\right)\right)\\ \end{array}\]

Reproduce

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