Average Error: 5.6 → 4.0
Time: 22.0s
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 -8.438842758934493 \cdot 10^{49} \lor \neg \left(z \le 1.554625306792136 \cdot 10^{-183}\right):\\ \;\;\;\;\mathsf{fma}\left(t, \left(\left(x \cdot 18\right) \cdot y\right) \cdot z, b \cdot c\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(k \cdot j\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(x \cdot \left(z \cdot y\right)\right)\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(k \cdot j\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 -8.438842758934493 \cdot 10^{49} \lor \neg \left(z \le 1.554625306792136 \cdot 10^{-183}\right):\\
\;\;\;\;\mathsf{fma}\left(t, \left(\left(x \cdot 18\right) \cdot y\right) \cdot z, b \cdot c\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(k \cdot j\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, 18 \cdot \left(t \cdot \left(x \cdot \left(z \cdot y\right)\right)\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(k \cdot j\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 r834569 = x;
        double r834570 = 18.0;
        double r834571 = r834569 * r834570;
        double r834572 = y;
        double r834573 = r834571 * r834572;
        double r834574 = z;
        double r834575 = r834573 * r834574;
        double r834576 = t;
        double r834577 = r834575 * r834576;
        double r834578 = a;
        double r834579 = 4.0;
        double r834580 = r834578 * r834579;
        double r834581 = r834580 * r834576;
        double r834582 = r834577 - r834581;
        double r834583 = b;
        double r834584 = c;
        double r834585 = r834583 * r834584;
        double r834586 = r834582 + r834585;
        double r834587 = r834569 * r834579;
        double r834588 = i;
        double r834589 = r834587 * r834588;
        double r834590 = r834586 - r834589;
        double r834591 = j;
        double r834592 = 27.0;
        double r834593 = r834591 * r834592;
        double r834594 = k;
        double r834595 = r834593 * r834594;
        double r834596 = r834590 - r834595;
        return r834596;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r834597 = z;
        double r834598 = -8.438842758934493e+49;
        bool r834599 = r834597 <= r834598;
        double r834600 = 1.554625306792136e-183;
        bool r834601 = r834597 <= r834600;
        double r834602 = !r834601;
        bool r834603 = r834599 || r834602;
        double r834604 = t;
        double r834605 = x;
        double r834606 = 18.0;
        double r834607 = r834605 * r834606;
        double r834608 = y;
        double r834609 = r834607 * r834608;
        double r834610 = r834609 * r834597;
        double r834611 = b;
        double r834612 = c;
        double r834613 = r834611 * r834612;
        double r834614 = fma(r834604, r834610, r834613);
        double r834615 = 4.0;
        double r834616 = a;
        double r834617 = i;
        double r834618 = r834617 * r834605;
        double r834619 = fma(r834604, r834616, r834618);
        double r834620 = 27.0;
        double r834621 = k;
        double r834622 = j;
        double r834623 = r834621 * r834622;
        double r834624 = r834620 * r834623;
        double r834625 = fma(r834615, r834619, r834624);
        double r834626 = r834614 - r834625;
        double r834627 = r834597 * r834608;
        double r834628 = r834605 * r834627;
        double r834629 = r834604 * r834628;
        double r834630 = r834606 * r834629;
        double r834631 = fma(r834611, r834612, r834630);
        double r834632 = r834631 - r834625;
        double r834633 = r834603 ? r834626 : r834632;
        return r834633;
}

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.6
Target1.6
Herbie4.0
\[\begin{array}{l} \mathbf{if}\;t \lt -1.6210815397541398 \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.680279438052224:\\ \;\;\;\;\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 < -8.438842758934493e+49 or 1.554625306792136e-183 < z

    1. Initial program 6.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. Simplified6.2

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

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

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

      \[\leadsto \mathsf{fma}\left(t, \left(\left(x \cdot 18\right) \cdot y\right) \cdot z, b \cdot c\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(\color{blue}{{j}^{1}} \cdot {27}^{1}\right) \cdot {k}^{1}\right)\]
    7. Applied pow-prod-down6.2

      \[\leadsto \mathsf{fma}\left(t, \left(\left(x \cdot 18\right) \cdot y\right) \cdot z, b \cdot c\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \color{blue}{{\left(j \cdot 27\right)}^{1}} \cdot {k}^{1}\right)\]
    8. Applied pow-prod-down6.2

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

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

    if -8.438842758934493e+49 < z < 1.554625306792136e-183

    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.7

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

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

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

      \[\leadsto \mathsf{fma}\left(t, \left(\left(x \cdot 18\right) \cdot y\right) \cdot z, b \cdot c\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(\color{blue}{{j}^{1}} \cdot {27}^{1}\right) \cdot {k}^{1}\right)\]
    7. Applied pow-prod-down4.7

      \[\leadsto \mathsf{fma}\left(t, \left(\left(x \cdot 18\right) \cdot y\right) \cdot z, b \cdot c\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \color{blue}{{\left(j \cdot 27\right)}^{1}} \cdot {k}^{1}\right)\]
    8. Applied pow-prod-down4.7

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

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

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

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

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

Reproduce

herbie shell --seed 2020042 +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"
  :precision binary64

  :herbie-target
  (if (< t -1.6210815397541398e-69) (- (- (* (* 18 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4)) (- (* (* k j) 27) (* c b))) (if (< t 165.68027943805222) (+ (- (* (* 18 y) (* x (* z t))) (* (+ (* a t) (* i x)) 4)) (- (* c b) (* 27 (* k j)))) (- (- (* (* 18 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4)) (- (* (* k j) 27) (* c b)))))

  (- (- (+ (- (* (* (* (* x 18) y) z) t) (* (* a 4) t)) (* b c)) (* (* x 4) i)) (* (* j 27) k)))