Average Error: 5.9 → 1.8
Time: 25.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 -817524477245330816:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(t \cdot x\right) \cdot \left(18 \cdot y\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot k\right) \cdot j\right)\right)\\ \mathbf{elif}\;z \le 9.069839166806894665192579007227268998295 \cdot 10^{-30}:\\ \;\;\;\;\mathsf{fma}\left(b, c, t \cdot \left(\left(18 \cdot y\right) \cdot \left(z \cdot x\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), k \cdot \left(27 \cdot j\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(y \cdot t\right) \cdot x\right) \cdot \left(18 \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(j \cdot k\right) \cdot 27\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 -817524477245330816:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(t \cdot x\right) \cdot \left(18 \cdot y\right)\right) \cdot z - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot k\right) \cdot j\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(y \cdot t\right) \cdot x\right) \cdot \left(18 \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(j \cdot k\right) \cdot 27\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 r560202 = x;
        double r560203 = 18.0;
        double r560204 = r560202 * r560203;
        double r560205 = y;
        double r560206 = r560204 * r560205;
        double r560207 = z;
        double r560208 = r560206 * r560207;
        double r560209 = t;
        double r560210 = r560208 * r560209;
        double r560211 = a;
        double r560212 = 4.0;
        double r560213 = r560211 * r560212;
        double r560214 = r560213 * r560209;
        double r560215 = r560210 - r560214;
        double r560216 = b;
        double r560217 = c;
        double r560218 = r560216 * r560217;
        double r560219 = r560215 + r560218;
        double r560220 = r560202 * r560212;
        double r560221 = i;
        double r560222 = r560220 * r560221;
        double r560223 = r560219 - r560222;
        double r560224 = j;
        double r560225 = 27.0;
        double r560226 = r560224 * r560225;
        double r560227 = k;
        double r560228 = r560226 * r560227;
        double r560229 = r560223 - r560228;
        return r560229;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r560230 = z;
        double r560231 = -8.175244772453308e+17;
        bool r560232 = r560230 <= r560231;
        double r560233 = b;
        double r560234 = c;
        double r560235 = t;
        double r560236 = x;
        double r560237 = r560235 * r560236;
        double r560238 = 18.0;
        double r560239 = y;
        double r560240 = r560238 * r560239;
        double r560241 = r560237 * r560240;
        double r560242 = r560241 * r560230;
        double r560243 = 4.0;
        double r560244 = a;
        double r560245 = i;
        double r560246 = r560245 * r560236;
        double r560247 = fma(r560235, r560244, r560246);
        double r560248 = 27.0;
        double r560249 = k;
        double r560250 = r560248 * r560249;
        double r560251 = j;
        double r560252 = r560250 * r560251;
        double r560253 = fma(r560243, r560247, r560252);
        double r560254 = r560242 - r560253;
        double r560255 = fma(r560233, r560234, r560254);
        double r560256 = 9.069839166806895e-30;
        bool r560257 = r560230 <= r560256;
        double r560258 = r560230 * r560236;
        double r560259 = r560240 * r560258;
        double r560260 = r560235 * r560259;
        double r560261 = r560248 * r560251;
        double r560262 = r560249 * r560261;
        double r560263 = fma(r560243, r560247, r560262);
        double r560264 = r560260 - r560263;
        double r560265 = fma(r560233, r560234, r560264);
        double r560266 = r560239 * r560235;
        double r560267 = r560266 * r560236;
        double r560268 = r560238 * r560230;
        double r560269 = r560267 * r560268;
        double r560270 = r560251 * r560249;
        double r560271 = r560270 * r560248;
        double r560272 = fma(r560243, r560247, r560271);
        double r560273 = r560269 - r560272;
        double r560274 = fma(r560233, r560234, r560273);
        double r560275 = r560257 ? r560265 : r560274;
        double r560276 = r560232 ? r560255 : r560275;
        return r560276;
}

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.9
Target1.7
Herbie1.8
\[\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 < -8.175244772453308e+17

    1. Initial program 7.4

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

      \[\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. Simplified1.9

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(\left(t \cdot x\right) \cdot \left(y \cdot 18\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)\]
    6. Using strategy rm
    7. Applied associate-*l*1.8

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

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

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

    if -8.175244772453308e+17 < z < 9.069839166806895e-30

    1. Initial program 5.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. Simplified5.1

      \[\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 *-un-lft-identity5.1

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(1 \cdot t\right)} \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)\]
    5. Applied associate-*l*5.1

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{1 \cdot \left(t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\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. Simplified1.7

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

    if 9.069839166806895e-30 < 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(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. Simplified2.0

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(\left(t \cdot x\right) \cdot \left(y \cdot 18\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)\]
    6. Using strategy rm
    7. Applied associate-*l*1.9

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

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

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

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

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

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

Reproduce

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