Average Error: 5.6 → 2.2
Time: 29.9s
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 -3.22480334132064979721719751753168462291 \cdot 10^{67}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot t\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{elif}\;z \le 3.708681601048053467557901564726162283421 \cdot 10^{124}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot y\right) \cdot t\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \sqrt[3]{k} \cdot \left(\left(\sqrt[3]{k} \cdot \sqrt[3]{k}\right) \cdot \left(27 \cdot j\right)\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 -3.22480334132064979721719751753168462291 \cdot 10^{67}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot t\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot y\right) \cdot t\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \sqrt[3]{k} \cdot \left(\left(\sqrt[3]{k} \cdot \sqrt[3]{k}\right) \cdot \left(27 \cdot j\right)\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 r34241528 = x;
        double r34241529 = 18.0;
        double r34241530 = r34241528 * r34241529;
        double r34241531 = y;
        double r34241532 = r34241530 * r34241531;
        double r34241533 = z;
        double r34241534 = r34241532 * r34241533;
        double r34241535 = t;
        double r34241536 = r34241534 * r34241535;
        double r34241537 = a;
        double r34241538 = 4.0;
        double r34241539 = r34241537 * r34241538;
        double r34241540 = r34241539 * r34241535;
        double r34241541 = r34241536 - r34241540;
        double r34241542 = b;
        double r34241543 = c;
        double r34241544 = r34241542 * r34241543;
        double r34241545 = r34241541 + r34241544;
        double r34241546 = r34241528 * r34241538;
        double r34241547 = i;
        double r34241548 = r34241546 * r34241547;
        double r34241549 = r34241545 - r34241548;
        double r34241550 = j;
        double r34241551 = 27.0;
        double r34241552 = r34241550 * r34241551;
        double r34241553 = k;
        double r34241554 = r34241552 * r34241553;
        double r34241555 = r34241549 - r34241554;
        return r34241555;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r34241556 = z;
        double r34241557 = -3.22480334132065e+67;
        bool r34241558 = r34241556 <= r34241557;
        double r34241559 = b;
        double r34241560 = c;
        double r34241561 = 18.0;
        double r34241562 = x;
        double r34241563 = r34241561 * r34241562;
        double r34241564 = t;
        double r34241565 = r34241563 * r34241564;
        double r34241566 = y;
        double r34241567 = r34241565 * r34241566;
        double r34241568 = r34241567 * r34241556;
        double r34241569 = 4.0;
        double r34241570 = a;
        double r34241571 = i;
        double r34241572 = r34241571 * r34241562;
        double r34241573 = fma(r34241564, r34241570, r34241572);
        double r34241574 = 27.0;
        double r34241575 = j;
        double r34241576 = r34241574 * r34241575;
        double r34241577 = k;
        double r34241578 = r34241576 * r34241577;
        double r34241579 = fma(r34241569, r34241573, r34241578);
        double r34241580 = r34241568 - r34241579;
        double r34241581 = fma(r34241559, r34241560, r34241580);
        double r34241582 = 3.7086816010480535e+124;
        bool r34241583 = r34241556 <= r34241582;
        double r34241584 = r34241556 * r34241566;
        double r34241585 = r34241584 * r34241562;
        double r34241586 = r34241564 * r34241585;
        double r34241587 = r34241586 * r34241561;
        double r34241588 = r34241587 - r34241579;
        double r34241589 = fma(r34241559, r34241560, r34241588);
        double r34241590 = r34241563 * r34241566;
        double r34241591 = r34241590 * r34241564;
        double r34241592 = r34241591 * r34241556;
        double r34241593 = cbrt(r34241577);
        double r34241594 = r34241593 * r34241593;
        double r34241595 = r34241594 * r34241576;
        double r34241596 = r34241593 * r34241595;
        double r34241597 = fma(r34241569, r34241573, r34241596);
        double r34241598 = r34241592 - r34241597;
        double r34241599 = fma(r34241559, r34241560, r34241598);
        double r34241600 = r34241583 ? r34241589 : r34241599;
        double r34241601 = r34241558 ? r34241581 : r34241600;
        return r34241601;
}

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.7
Herbie2.2
\[\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 3 regimes
  2. if z < -3.22480334132065e+67

    1. Initial program 7.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. Simplified7.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-*r*1.5

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

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

    if -3.22480334132065e+67 < z < 3.7086816010480535e+124

    1. Initial program 4.6

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

      \[\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)\]

    if 3.7086816010480535e+124 < z

    1. Initial program 8.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. Simplified8.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-*r*1.2

      \[\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), \left(27 \cdot j\right) \cdot k\right)\right)\]
    5. Using strategy rm
    6. Applied add-cube-cbrt1.5

      \[\leadsto \mathsf{fma}\left(b, c, \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), \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)\]
    7. Applied associate-*r*1.5

      \[\leadsto \mathsf{fma}\left(b, c, \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), \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 3 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.22480334132064979721719751753168462291 \cdot 10^{67}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot t\right) \cdot y\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{elif}\;z \le 3.708681601048053467557901564726162283421 \cdot 10^{124}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(t \cdot \left(\left(z \cdot y\right) \cdot x\right)\right) \cdot 18 - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(18 \cdot x\right) \cdot y\right) \cdot t\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \sqrt[3]{k} \cdot \left(\left(\sqrt[3]{k} \cdot \sqrt[3]{k}\right) \cdot \left(27 \cdot j\right)\right)\right)\right)\\ \end{array}\]

Reproduce

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