Average Error: 5.8 → 3.9
Time: 28.5s
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 -1.678881092436276430221066447463770847059 \cdot 10^{-108} \lor \neg \left(z \le 1.231185713899018210228913934991313267285 \cdot 10^{-25}\right):\\ \;\;\;\;\mathsf{fma}\left(c, b, \left(z \cdot \left(x \cdot \left(y \cdot 18\right)\right)\right) \cdot t\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), j \cdot \left(27 \cdot k\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c, b, 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, x \cdot i\right), \left(j \cdot 27\right) \cdot k\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 -1.678881092436276430221066447463770847059 \cdot 10^{-108} \lor \neg \left(z \le 1.231185713899018210228913934991313267285 \cdot 10^{-25}\right):\\
\;\;\;\;\mathsf{fma}\left(c, b, \left(z \cdot \left(x \cdot \left(y \cdot 18\right)\right)\right) \cdot t\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), j \cdot \left(27 \cdot k\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, b, 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, x \cdot i\right), \left(j \cdot 27\right) \cdot k\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 r490359 = x;
        double r490360 = 18.0;
        double r490361 = r490359 * r490360;
        double r490362 = y;
        double r490363 = r490361 * r490362;
        double r490364 = z;
        double r490365 = r490363 * r490364;
        double r490366 = t;
        double r490367 = r490365 * r490366;
        double r490368 = a;
        double r490369 = 4.0;
        double r490370 = r490368 * r490369;
        double r490371 = r490370 * r490366;
        double r490372 = r490367 - r490371;
        double r490373 = b;
        double r490374 = c;
        double r490375 = r490373 * r490374;
        double r490376 = r490372 + r490375;
        double r490377 = r490359 * r490369;
        double r490378 = i;
        double r490379 = r490377 * r490378;
        double r490380 = r490376 - r490379;
        double r490381 = j;
        double r490382 = 27.0;
        double r490383 = r490381 * r490382;
        double r490384 = k;
        double r490385 = r490383 * r490384;
        double r490386 = r490380 - r490385;
        return r490386;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r490387 = z;
        double r490388 = -1.6788810924362764e-108;
        bool r490389 = r490387 <= r490388;
        double r490390 = 1.2311857138990182e-25;
        bool r490391 = r490387 <= r490390;
        double r490392 = !r490391;
        bool r490393 = r490389 || r490392;
        double r490394 = c;
        double r490395 = b;
        double r490396 = x;
        double r490397 = y;
        double r490398 = 18.0;
        double r490399 = r490397 * r490398;
        double r490400 = r490396 * r490399;
        double r490401 = r490387 * r490400;
        double r490402 = t;
        double r490403 = r490401 * r490402;
        double r490404 = fma(r490394, r490395, r490403);
        double r490405 = 4.0;
        double r490406 = a;
        double r490407 = i;
        double r490408 = r490396 * r490407;
        double r490409 = fma(r490402, r490406, r490408);
        double r490410 = j;
        double r490411 = 27.0;
        double r490412 = k;
        double r490413 = r490411 * r490412;
        double r490414 = r490410 * r490413;
        double r490415 = fma(r490405, r490409, r490414);
        double r490416 = r490404 - r490415;
        double r490417 = r490387 * r490397;
        double r490418 = r490396 * r490417;
        double r490419 = r490402 * r490418;
        double r490420 = r490398 * r490419;
        double r490421 = fma(r490394, r490395, r490420);
        double r490422 = r490410 * r490411;
        double r490423 = r490422 * r490412;
        double r490424 = fma(r490405, r490409, r490423);
        double r490425 = r490421 - r490424;
        double r490426 = r490393 ? r490416 : r490425;
        return r490426;
}

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.6
Herbie3.9
\[\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 z < -1.6788810924362764e-108 or 1.2311857138990182e-25 < z

    1. Initial program 6.3

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(c, b, \left(\color{blue}{\left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(18 \cdot \left(x \cdot y\right)\right)\right)} \cdot \sqrt[3]{z}\right) \cdot t\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), j \cdot \left(27 \cdot k\right)\right)\]
    9. Using strategy rm
    10. Applied *-un-lft-identity6.5

      \[\leadsto \mathsf{fma}\left(c, b, \left(\left(\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(18 \cdot \left(x \cdot y\right)\right)\right) \cdot \sqrt[3]{z}\right) \cdot \color{blue}{\left(1 \cdot t\right)}\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), j \cdot \left(27 \cdot k\right)\right)\]
    11. Applied associate-*r*6.5

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

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

    if -1.6788810924362764e-108 < z < 1.2311857138990182e-25

    1. Initial program 5.3

      \[\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. Simplified5.3

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

      \[\leadsto \mathsf{fma}\left(c, b, \color{blue}{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, x \cdot i\right), \left(j \cdot 27\right) \cdot k\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.9

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

Reproduce

herbie shell --seed 2019235 +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.680279438052224) (+ (- (* (* 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)))