Average Error: 3.6 → 1.4
Time: 4.8s
Precision: 64
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.093967716233190167127795978495846537109 \cdot 10^{80}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{\sqrt[3]{9} \cdot \sqrt[3]{9}} \cdot \left(\sqrt[3]{\sqrt[3]{9}} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\right)\right)\\ \mathbf{elif}\;y \le 6.392287508762893125747406036083933338353 \cdot 10^{178}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - {\left(\left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right)}^{1}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, x, \left(27 \cdot a\right) \cdot b - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\ \end{array}\]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
\mathbf{if}\;y \le -1.093967716233190167127795978495846537109 \cdot 10^{80}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{\sqrt[3]{9} \cdot \sqrt[3]{9}} \cdot \left(\sqrt[3]{\sqrt[3]{9}} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\right)\right)\\

\mathbf{elif}\;y \le 6.392287508762893125747406036083933338353 \cdot 10^{178}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - {\left(\left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right)}^{1}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, x, \left(27 \cdot a\right) \cdot b - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r754888 = x;
        double r754889 = 2.0;
        double r754890 = r754888 * r754889;
        double r754891 = y;
        double r754892 = 9.0;
        double r754893 = r754891 * r754892;
        double r754894 = z;
        double r754895 = r754893 * r754894;
        double r754896 = t;
        double r754897 = r754895 * r754896;
        double r754898 = r754890 - r754897;
        double r754899 = a;
        double r754900 = 27.0;
        double r754901 = r754899 * r754900;
        double r754902 = b;
        double r754903 = r754901 * r754902;
        double r754904 = r754898 + r754903;
        return r754904;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r754905 = y;
        double r754906 = -1.0939677162331902e+80;
        bool r754907 = r754905 <= r754906;
        double r754908 = 2.0;
        double r754909 = x;
        double r754910 = 27.0;
        double r754911 = a;
        double r754912 = b;
        double r754913 = r754911 * r754912;
        double r754914 = r754910 * r754913;
        double r754915 = 9.0;
        double r754916 = cbrt(r754915);
        double r754917 = r754916 * r754916;
        double r754918 = cbrt(r754917);
        double r754919 = cbrt(r754916);
        double r754920 = t;
        double r754921 = z;
        double r754922 = r754920 * r754921;
        double r754923 = r754922 * r754905;
        double r754924 = r754919 * r754923;
        double r754925 = r754918 * r754924;
        double r754926 = r754917 * r754925;
        double r754927 = r754914 - r754926;
        double r754928 = fma(r754908, r754909, r754927);
        double r754929 = 6.392287508762893e+178;
        bool r754930 = r754905 <= r754929;
        double r754931 = r754920 * r754905;
        double r754932 = r754915 * r754931;
        double r754933 = r754932 * r754921;
        double r754934 = 1.0;
        double r754935 = pow(r754933, r754934);
        double r754936 = r754914 - r754935;
        double r754937 = fma(r754908, r754909, r754936);
        double r754938 = r754910 * r754911;
        double r754939 = r754938 * r754912;
        double r754940 = r754915 * r754923;
        double r754941 = r754939 - r754940;
        double r754942 = fma(r754908, r754909, r754941);
        double r754943 = r754930 ? r754937 : r754942;
        double r754944 = r754907 ? r754928 : r754943;
        return r754944;
}

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

Target

Original3.6
Target2.7
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811188954625810696587370427881 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if y < -1.0939677162331902e+80

    1. Initial program 9.9

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified9.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    3. Taylor expanded around inf 9.5

      \[\leadsto \color{blue}{\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\]
    4. Simplified9.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)}\]
    5. Using strategy rm
    6. Applied associate-*r*0.6

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \color{blue}{\left(\left(t \cdot z\right) \cdot y\right)}\right)\]
    7. Using strategy rm
    8. Applied add-cube-cbrt0.6

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \color{blue}{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}\right)} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\]
    9. Applied associate-*l*0.7

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \color{blue}{\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)}\right)\]
    10. Using strategy rm
    11. Applied add-cube-cbrt0.7

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{\color{blue}{\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}}} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\right)\]
    12. Applied cbrt-prod0.9

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\color{blue}{\left(\sqrt[3]{\sqrt[3]{9} \cdot \sqrt[3]{9}} \cdot \sqrt[3]{\sqrt[3]{9}}\right)} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\right)\]
    13. Applied associate-*l*0.8

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \color{blue}{\left(\sqrt[3]{\sqrt[3]{9} \cdot \sqrt[3]{9}} \cdot \left(\sqrt[3]{\sqrt[3]{9}} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\right)}\right)\]

    if -1.0939677162331902e+80 < y < 6.392287508762893e+178

    1. Initial program 1.7

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified1.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    3. Taylor expanded around inf 1.6

      \[\leadsto \color{blue}{\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\]
    4. Simplified1.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)}\]
    5. Using strategy rm
    6. Applied associate-*r*4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \color{blue}{\left(\left(t \cdot z\right) \cdot y\right)}\right)\]
    7. Using strategy rm
    8. Applied add-cube-cbrt4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \color{blue}{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \sqrt[3]{9}\right)} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\]
    9. Applied associate-*l*4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \color{blue}{\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)}\right)\]
    10. Using strategy rm
    11. Applied pow14.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot \color{blue}{{y}^{1}}\right)\right)\right)\]
    12. Applied pow14.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(\left(t \cdot \color{blue}{{z}^{1}}\right) \cdot {y}^{1}\right)\right)\right)\]
    13. Applied pow14.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(\left(\color{blue}{{t}^{1}} \cdot {z}^{1}\right) \cdot {y}^{1}\right)\right)\right)\]
    14. Applied pow-prod-down4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(\color{blue}{{\left(t \cdot z\right)}^{1}} \cdot {y}^{1}\right)\right)\right)\]
    15. Applied pow-prod-down4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \color{blue}{{\left(\left(t \cdot z\right) \cdot y\right)}^{1}}\right)\right)\]
    16. Applied pow14.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\color{blue}{{\left(\sqrt[3]{9}\right)}^{1}} \cdot {\left(\left(t \cdot z\right) \cdot y\right)}^{1}\right)\right)\]
    17. Applied pow-prod-down4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \color{blue}{{\left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)}^{1}}\right)\]
    18. Applied pow14.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \color{blue}{{\left(\sqrt[3]{9}\right)}^{1}}\right) \cdot {\left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)}^{1}\right)\]
    19. Applied pow14.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\color{blue}{{\left(\sqrt[3]{9}\right)}^{1}} \cdot {\left(\sqrt[3]{9}\right)}^{1}\right) \cdot {\left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)}^{1}\right)\]
    20. Applied pow-prod-down4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \color{blue}{{\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right)}^{1}} \cdot {\left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)}^{1}\right)\]
    21. Applied pow-prod-down4.3

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \color{blue}{{\left(\left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\right)}^{1}}\right)\]
    22. Simplified1.5

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - {\color{blue}{\left(\left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right)}}^{1}\right)\]

    if 6.392287508762893e+178 < y

    1. Initial program 11.9

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified11.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)}\]
    3. Taylor expanded around inf 11.5

      \[\leadsto \color{blue}{\left(2 \cdot x + 27 \cdot \left(a \cdot b\right)\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)}\]
    4. Simplified11.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)}\]
    5. Using strategy rm
    6. Applied associate-*r*1.9

      \[\leadsto \mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \color{blue}{\left(\left(t \cdot z\right) \cdot y\right)}\right)\]
    7. Using strategy rm
    8. Applied associate-*r*2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.093967716233190167127795978495846537109 \cdot 10^{80}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{\sqrt[3]{9} \cdot \sqrt[3]{9}} \cdot \left(\sqrt[3]{\sqrt[3]{9}} \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\right)\right)\\ \mathbf{elif}\;y \le 6.392287508762893125747406036083933338353 \cdot 10^{178}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - {\left(\left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right)}^{1}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, x, \left(27 \cdot a\right) \cdot b - 9 \cdot \left(\left(t \cdot z\right) \cdot y\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019354 +o rules:numerics
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2) (* (* (* y 9) z) t)) (* a (* 27 b))) (+ (- (* x 2) (* 9 (* y (* t z)))) (* (* a 27) b)))

  (+ (- (* x 2) (* (* (* y 9) z) t)) (* (* a 27) b)))