Average Error: 5.4 → 4.0
Time: 38.6s
Precision: 64
\[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.654247913107458 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left(18.0 \cdot \left(x \cdot \left(z \cdot y\right)\right), t, b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27.0 \cdot j\right) \cdot k\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \left(k \cdot j\right) \cdot 27.0\right)\right) + y \cdot \left(\left(18.0 \cdot \left(z \cdot x\right)\right) \cdot t\right)\\ \end{array}\]
\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k
\begin{array}{l}
\mathbf{if}\;x \le -7.654247913107458 \cdot 10^{+153}:\\
\;\;\;\;\mathsf{fma}\left(18.0 \cdot \left(x \cdot \left(z \cdot y\right)\right), t, b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27.0 \cdot j\right) \cdot k\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \left(k \cdot j\right) \cdot 27.0\right)\right) + y \cdot \left(\left(18.0 \cdot \left(z \cdot x\right)\right) \cdot t\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 r34412730 = x;
        double r34412731 = 18.0;
        double r34412732 = r34412730 * r34412731;
        double r34412733 = y;
        double r34412734 = r34412732 * r34412733;
        double r34412735 = z;
        double r34412736 = r34412734 * r34412735;
        double r34412737 = t;
        double r34412738 = r34412736 * r34412737;
        double r34412739 = a;
        double r34412740 = 4.0;
        double r34412741 = r34412739 * r34412740;
        double r34412742 = r34412741 * r34412737;
        double r34412743 = r34412738 - r34412742;
        double r34412744 = b;
        double r34412745 = c;
        double r34412746 = r34412744 * r34412745;
        double r34412747 = r34412743 + r34412746;
        double r34412748 = r34412730 * r34412740;
        double r34412749 = i;
        double r34412750 = r34412748 * r34412749;
        double r34412751 = r34412747 - r34412750;
        double r34412752 = j;
        double r34412753 = 27.0;
        double r34412754 = r34412752 * r34412753;
        double r34412755 = k;
        double r34412756 = r34412754 * r34412755;
        double r34412757 = r34412751 - r34412756;
        return r34412757;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r34412758 = x;
        double r34412759 = -7.654247913107458e+153;
        bool r34412760 = r34412758 <= r34412759;
        double r34412761 = 18.0;
        double r34412762 = z;
        double r34412763 = y;
        double r34412764 = r34412762 * r34412763;
        double r34412765 = r34412758 * r34412764;
        double r34412766 = r34412761 * r34412765;
        double r34412767 = t;
        double r34412768 = b;
        double r34412769 = c;
        double r34412770 = r34412768 * r34412769;
        double r34412771 = 4.0;
        double r34412772 = a;
        double r34412773 = i;
        double r34412774 = r34412773 * r34412758;
        double r34412775 = fma(r34412767, r34412772, r34412774);
        double r34412776 = 27.0;
        double r34412777 = j;
        double r34412778 = r34412776 * r34412777;
        double r34412779 = k;
        double r34412780 = r34412778 * r34412779;
        double r34412781 = fma(r34412771, r34412775, r34412780);
        double r34412782 = r34412770 - r34412781;
        double r34412783 = fma(r34412766, r34412767, r34412782);
        double r34412784 = r34412779 * r34412777;
        double r34412785 = r34412784 * r34412776;
        double r34412786 = fma(r34412771, r34412775, r34412785);
        double r34412787 = r34412770 - r34412786;
        double r34412788 = r34412762 * r34412758;
        double r34412789 = r34412761 * r34412788;
        double r34412790 = r34412789 * r34412767;
        double r34412791 = r34412763 * r34412790;
        double r34412792 = r34412787 + r34412791;
        double r34412793 = r34412760 ? r34412783 : r34412792;
        return r34412793;
}

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.4
Target1.4
Herbie4.0
\[\begin{array}{l} \mathbf{if}\;t \lt -1.6210815397541398 \cdot 10^{-69}:\\ \;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\ \mathbf{elif}\;t \lt 165.68027943805222:\\ \;\;\;\;\left(\left(18.0 \cdot y\right) \cdot \left(x \cdot \left(z \cdot t\right)\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) + \left(c \cdot b - 27.0 \cdot \left(k \cdot j\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(18.0 \cdot t\right) \cdot \left(\left(x \cdot y\right) \cdot z\right) - \left(a \cdot t + i \cdot x\right) \cdot 4.0\right) - \left(\left(k \cdot j\right) \cdot 27.0 - c \cdot b\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -7.654247913107458e+153

    1. Initial program 17.2

      \[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
    2. Simplified17.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(x \cdot \left(z \cdot 18.0\right)\right), t, b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27.0 \cdot j\right) \cdot k\right)\right)}\]
    3. Taylor expanded around inf 8.7

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

    if -7.654247913107458e+153 < x

    1. Initial program 4.6

      \[\left(\left(\left(\left(\left(\left(x \cdot 18.0\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4.0\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4.0\right) \cdot i\right) - \left(j \cdot 27.0\right) \cdot k\]
    2. Simplified4.4

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

      \[\leadsto \mathsf{fma}\left(y \cdot \left(x \cdot \left(z \cdot 18.0\right)\right), t, b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \color{blue}{27.0 \cdot \left(j \cdot k\right)}\right)\right)\]
    5. Using strategy rm
    6. Applied fma-udef4.4

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

      \[\leadsto \color{blue}{y \cdot \left(\left(x \cdot \left(z \cdot 18.0\right)\right) \cdot t\right)} + \left(b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), 27.0 \cdot \left(j \cdot k\right)\right)\right)\]
    9. Using strategy rm
    10. Applied associate-*r*3.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.654247913107458 \cdot 10^{+153}:\\ \;\;\;\;\mathsf{fma}\left(18.0 \cdot \left(x \cdot \left(z \cdot y\right)\right), t, b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27.0 \cdot j\right) \cdot k\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot c - \mathsf{fma}\left(4.0, \mathsf{fma}\left(t, a, i \cdot x\right), \left(k \cdot j\right) \cdot 27.0\right)\right) + y \cdot \left(\left(18.0 \cdot \left(z \cdot x\right)\right) \cdot t\right)\\ \end{array}\]

Reproduce

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