Average Error: 5.7 → 2.7
Time: 28.3s
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}\;t \le -129629017863690450409738691674112:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\ \mathbf{elif}\;t \le 4.876643435439087564674222281670203784324 \cdot 10^{-122}:\\ \;\;\;\;\mathsf{fma}\left(b, c, \left(y \cdot \left(x \cdot \left(t \cdot z\right)\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(x \cdot \left(t \cdot 18\right)\right) \cdot \left(y \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\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}\;t \le -129629017863690450409738691674112:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), 27 \cdot \left(j \cdot k\right)\right)\right)\\

\mathbf{elif}\;t \le 4.876643435439087564674222281670203784324 \cdot 10^{-122}:\\
\;\;\;\;\mathsf{fma}\left(b, c, \left(y \cdot \left(x \cdot \left(t \cdot z\right)\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(x \cdot \left(t \cdot 18\right)\right) \cdot \left(y \cdot z\right) - \mathsf{fma}\left(4, \mathsf{fma}\left(t, a, i \cdot x\right), \left(27 \cdot j\right) \cdot k\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 r655855 = x;
        double r655856 = 18.0;
        double r655857 = r655855 * r655856;
        double r655858 = y;
        double r655859 = r655857 * r655858;
        double r655860 = z;
        double r655861 = r655859 * r655860;
        double r655862 = t;
        double r655863 = r655861 * r655862;
        double r655864 = a;
        double r655865 = 4.0;
        double r655866 = r655864 * r655865;
        double r655867 = r655866 * r655862;
        double r655868 = r655863 - r655867;
        double r655869 = b;
        double r655870 = c;
        double r655871 = r655869 * r655870;
        double r655872 = r655868 + r655871;
        double r655873 = r655855 * r655865;
        double r655874 = i;
        double r655875 = r655873 * r655874;
        double r655876 = r655872 - r655875;
        double r655877 = j;
        double r655878 = 27.0;
        double r655879 = r655877 * r655878;
        double r655880 = k;
        double r655881 = r655879 * r655880;
        double r655882 = r655876 - r655881;
        return r655882;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
        double r655883 = t;
        double r655884 = -1.2962901786369045e+32;
        bool r655885 = r655883 <= r655884;
        double r655886 = b;
        double r655887 = c;
        double r655888 = x;
        double r655889 = 18.0;
        double r655890 = r655888 * r655889;
        double r655891 = y;
        double r655892 = r655890 * r655891;
        double r655893 = z;
        double r655894 = r655892 * r655893;
        double r655895 = r655894 * r655883;
        double r655896 = 4.0;
        double r655897 = a;
        double r655898 = i;
        double r655899 = r655898 * r655888;
        double r655900 = fma(r655883, r655897, r655899);
        double r655901 = 27.0;
        double r655902 = j;
        double r655903 = k;
        double r655904 = r655902 * r655903;
        double r655905 = r655901 * r655904;
        double r655906 = fma(r655896, r655900, r655905);
        double r655907 = r655895 - r655906;
        double r655908 = fma(r655886, r655887, r655907);
        double r655909 = 4.876643435439088e-122;
        bool r655910 = r655883 <= r655909;
        double r655911 = r655883 * r655893;
        double r655912 = r655888 * r655911;
        double r655913 = r655891 * r655912;
        double r655914 = r655913 * r655889;
        double r655915 = r655901 * r655902;
        double r655916 = r655915 * r655903;
        double r655917 = fma(r655896, r655900, r655916);
        double r655918 = r655914 - r655917;
        double r655919 = fma(r655886, r655887, r655918);
        double r655920 = r655883 * r655889;
        double r655921 = r655888 * r655920;
        double r655922 = r655891 * r655893;
        double r655923 = r655921 * r655922;
        double r655924 = r655923 - r655917;
        double r655925 = fma(r655886, r655887, r655924);
        double r655926 = r655910 ? r655919 : r655925;
        double r655927 = r655885 ? r655908 : r655926;
        return r655927;
}

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.7
Target1.8
Herbie2.7
\[\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 t < -1.2962901786369045e+32

    1. Initial program 1.8

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

      \[\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-*l*1.8

      \[\leadsto \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), \color{blue}{27 \cdot \left(j \cdot k\right)}\right)\right)\]

    if -1.2962901786369045e+32 < t < 4.876643435439088e-122

    1. Initial program 7.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.876643435439088e-122 < t

    1. Initial program 3.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. Simplified3.7

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(b, c, \color{blue}{\left(\left(18 \cdot t\right) \cdot x\right)} \cdot \left(y \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. Recombined 3 regimes into one program.
  4. Final simplification2.7

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

Reproduce

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