Average Error: 5.5 → 1.7
Time: 27.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}\;y \le -2.680403119349005211527207326591847105806 \cdot 10^{-60}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot y - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{elif}\;y \le 1.36398631041649601295810271534666308836 \cdot 10^{-14}:\\ \;\;\;\;\mathsf{fma}\left(b, c, t \cdot \left(\left(y \cdot \left(x \cdot 18\right)\right) \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(\left(27 \cdot j\right) \cdot \left(\sqrt[3]{k} \cdot \sqrt[3]{k}\right)\right) \cdot \sqrt[3]{k}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot y - \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}\;y \le -2.680403119349005211527207326591847105806 \cdot 10^{-60}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot y - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\

\mathbf{elif}\;y \le 1.36398631041649601295810271534666308836 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(b, c, t \cdot \left(\left(y \cdot \left(x \cdot 18\right)\right) \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(\left(27 \cdot j\right) \cdot \left(\sqrt[3]{k} \cdot \sqrt[3]{k}\right)\right) \cdot \sqrt[3]{k}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot y - \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 r31786627 = x;
        double r31786628 = 18.0;
        double r31786629 = r31786627 * r31786628;
        double r31786630 = y;
        double r31786631 = r31786629 * r31786630;
        double r31786632 = z;
        double r31786633 = r31786631 * r31786632;
        double r31786634 = t;
        double r31786635 = r31786633 * r31786634;
        double r31786636 = a;
        double r31786637 = 4.0;
        double r31786638 = r31786636 * r31786637;
        double r31786639 = r31786638 * r31786634;
        double r31786640 = r31786635 - r31786639;
        double r31786641 = b;
        double r31786642 = c;
        double r31786643 = r31786641 * r31786642;
        double r31786644 = r31786640 + r31786643;
        double r31786645 = r31786627 * r31786637;
        double r31786646 = i;
        double r31786647 = r31786645 * r31786646;
        double r31786648 = r31786644 - r31786647;
        double r31786649 = j;
        double r31786650 = 27.0;
        double r31786651 = r31786649 * r31786650;
        double r31786652 = k;
        double r31786653 = r31786651 * r31786652;
        double r31786654 = r31786648 - r31786653;
        return r31786654;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r31786655 = y;
        double r31786656 = -2.680403119349005e-60;
        bool r31786657 = r31786655 <= r31786656;
        double r31786658 = b;
        double r31786659 = c;
        double r31786660 = 18.0;
        double r31786661 = z;
        double r31786662 = x;
        double r31786663 = t;
        double r31786664 = r31786662 * r31786663;
        double r31786665 = r31786661 * r31786664;
        double r31786666 = r31786660 * r31786665;
        double r31786667 = r31786666 * r31786655;
        double r31786668 = 4.0;
        double r31786669 = a;
        double r31786670 = i;
        double r31786671 = r31786670 * r31786662;
        double r31786672 = fma(r31786663, r31786669, r31786671);
        double r31786673 = 27.0;
        double r31786674 = j;
        double r31786675 = r31786673 * r31786674;
        double r31786676 = k;
        double r31786677 = r31786675 * r31786676;
        double r31786678 = fma(r31786668, r31786672, r31786677);
        double r31786679 = r31786667 - r31786678;
        double r31786680 = fma(r31786658, r31786659, r31786679);
        double r31786681 = 1.363986310416496e-14;
        bool r31786682 = r31786655 <= r31786681;
        double r31786683 = r31786662 * r31786660;
        double r31786684 = r31786655 * r31786683;
        double r31786685 = r31786684 * r31786661;
        double r31786686 = r31786663 * r31786685;
        double r31786687 = cbrt(r31786676);
        double r31786688 = r31786687 * r31786687;
        double r31786689 = r31786675 * r31786688;
        double r31786690 = r31786689 * r31786687;
        double r31786691 = fma(r31786668, r31786672, r31786690);
        double r31786692 = r31786686 - r31786691;
        double r31786693 = fma(r31786658, r31786659, r31786692);
        double r31786694 = r31786682 ? r31786693 : r31786680;
        double r31786695 = r31786657 ? r31786680 : r31786694;
        return r31786695;
}

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.5
Target1.4
Herbie1.7
\[\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 y < -2.680403119349005e-60 or 1.363986310416496e-14 < y

    1. Initial program 9.8

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

      \[\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. Taylor expanded around inf 12.0

      \[\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)\]
    4. Using strategy rm
    5. Applied associate-*r*9.8

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

      \[\leadsto \mathsf{fma}\left(b, c, 18 \cdot \color{blue}{\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), \left(27 \cdot j\right) \cdot k\right)\right)\]
    8. Using strategy rm
    9. Applied associate-*r*2.1

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

    if -2.680403119349005e-60 < y < 1.363986310416496e-14

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

      \[\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 add-cube-cbrt1.3

      \[\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), \left(27 \cdot j\right) \cdot \color{blue}{\left(\left(\sqrt[3]{k} \cdot \sqrt[3]{k}\right) \cdot \sqrt[3]{k}\right)}\right)\right)\]
    5. Applied associate-*r*1.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.680403119349005211527207326591847105806 \cdot 10^{-60}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot y - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{elif}\;y \le 1.36398631041649601295810271534666308836 \cdot 10^{-14}:\\ \;\;\;\;\mathsf{fma}\left(b, c, t \cdot \left(\left(y \cdot \left(x \cdot 18\right)\right) \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(\left(27 \cdot j\right) \cdot \left(\sqrt[3]{k} \cdot \sqrt[3]{k}\right)\right) \cdot \sqrt[3]{k}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(18 \cdot \left(z \cdot \left(x \cdot t\right)\right)\right) \cdot y - \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 2019172 +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)))