Average Error: 5.4 → 2.0
Time: 1.0m
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}\;x \le -1.09062840131856804 \cdot 10^{48} \lor \neg \left(x \le 1.08808733666263652 \cdot 10^{39}\right):\\ \;\;\;\;\mathsf{fma}\left(c, b, x \cdot \left(\left(18 \cdot y\right) \cdot \left(t \cdot z\right)\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(j \cdot 27\right) \cdot k\right)\\ \mathbf{else}:\\ \;\;\;\;\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(k \cdot 27\right) \cdot j\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}\;x \le -1.09062840131856804 \cdot 10^{48} \lor \neg \left(x \le 1.08808733666263652 \cdot 10^{39}\right):\\
\;\;\;\;\mathsf{fma}\left(c, b, x \cdot \left(\left(18 \cdot y\right) \cdot \left(t \cdot z\right)\right)\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, x \cdot i\right), \left(j \cdot 27\right) \cdot k\right)\\

\mathbf{else}:\\
\;\;\;\;\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(k \cdot 27\right) \cdot j\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 r459193 = x;
        double r459194 = 18.0;
        double r459195 = r459193 * r459194;
        double r459196 = y;
        double r459197 = r459195 * r459196;
        double r459198 = z;
        double r459199 = r459197 * r459198;
        double r459200 = t;
        double r459201 = r459199 * r459200;
        double r459202 = a;
        double r459203 = 4.0;
        double r459204 = r459202 * r459203;
        double r459205 = r459204 * r459200;
        double r459206 = r459201 - r459205;
        double r459207 = b;
        double r459208 = c;
        double r459209 = r459207 * r459208;
        double r459210 = r459206 + r459209;
        double r459211 = r459193 * r459203;
        double r459212 = i;
        double r459213 = r459211 * r459212;
        double r459214 = r459210 - r459213;
        double r459215 = j;
        double r459216 = 27.0;
        double r459217 = r459215 * r459216;
        double r459218 = k;
        double r459219 = r459217 * r459218;
        double r459220 = r459214 - r459219;
        return r459220;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r459221 = x;
        double r459222 = -1.090628401318568e+48;
        bool r459223 = r459221 <= r459222;
        double r459224 = 1.0880873366626365e+39;
        bool r459225 = r459221 <= r459224;
        double r459226 = !r459225;
        bool r459227 = r459223 || r459226;
        double r459228 = c;
        double r459229 = b;
        double r459230 = 18.0;
        double r459231 = y;
        double r459232 = r459230 * r459231;
        double r459233 = t;
        double r459234 = z;
        double r459235 = r459233 * r459234;
        double r459236 = r459232 * r459235;
        double r459237 = r459221 * r459236;
        double r459238 = fma(r459228, r459229, r459237);
        double r459239 = 4.0;
        double r459240 = a;
        double r459241 = i;
        double r459242 = r459221 * r459241;
        double r459243 = fma(r459233, r459240, r459242);
        double r459244 = j;
        double r459245 = 27.0;
        double r459246 = r459244 * r459245;
        double r459247 = k;
        double r459248 = r459246 * r459247;
        double r459249 = fma(r459239, r459243, r459248);
        double r459250 = r459238 - r459249;
        double r459251 = r459221 * r459230;
        double r459252 = r459251 * r459231;
        double r459253 = r459252 * r459234;
        double r459254 = r459253 * r459233;
        double r459255 = fma(r459228, r459229, r459254);
        double r459256 = r459247 * r459245;
        double r459257 = r459256 * r459244;
        double r459258 = fma(r459239, r459243, r459257);
        double r459259 = r459255 - r459258;
        double r459260 = r459227 ? r459250 : r459259;
        return r459260;
}

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.6
Herbie2.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 x < -1.090628401318568e+48 or 1.0880873366626365e+39 < x

    1. Initial program 13.5

      \[\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. Simplified13.5

      \[\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*10.2

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

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

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

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

    if -1.090628401318568e+48 < x < 1.0880873366626365e+39

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

      \[\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 pow12.2

      \[\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), \left(j \cdot 27\right) \cdot \color{blue}{{k}^{1}}\right)\]
    5. Applied pow12.2

      \[\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), \left(j \cdot \color{blue}{{27}^{1}}\right) \cdot {k}^{1}\right)\]
    6. Applied pow12.2

      \[\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), \left(\color{blue}{{j}^{1}} \cdot {27}^{1}\right) \cdot {k}^{1}\right)\]
    7. Applied pow-prod-down2.2

      \[\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}{{\left(j \cdot 27\right)}^{1}} \cdot {k}^{1}\right)\]
    8. Applied pow-prod-down2.2

      \[\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}{{\left(\left(j \cdot 27\right) \cdot k\right)}^{1}}\right)\]
    9. Simplified2.2

      \[\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}{\left(j \cdot \left(k \cdot 27\right)\right)}}^{1}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.0

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

Reproduce

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