Average Error: 4.1 → 1.1
Time: 12.1s
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 \cdot 9 \le -3.68671894795848607 \cdot 10^{-77}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{elif}\;y \cdot 9 \le 4.4323646665533492 \cdot 10^{-78}:\\ \;\;\;\;\mathsf{fma}\left(x, 2, -t \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right) + \mathsf{fma}\left(27 \cdot b, a, \left(\left(y \cdot 9\right) \cdot z\right) \cdot \left(\left(-t\right) + t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \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 \cdot 9 \le -3.68671894795848607 \cdot 10^{-77}:\\
\;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r3852 = x;
        double r3853 = 2.0;
        double r3854 = r3852 * r3853;
        double r3855 = y;
        double r3856 = 9.0;
        double r3857 = r3855 * r3856;
        double r3858 = z;
        double r3859 = r3857 * r3858;
        double r3860 = t;
        double r3861 = r3859 * r3860;
        double r3862 = r3854 - r3861;
        double r3863 = a;
        double r3864 = 27.0;
        double r3865 = r3863 * r3864;
        double r3866 = b;
        double r3867 = r3865 * r3866;
        double r3868 = r3862 + r3867;
        return r3868;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r3869 = y;
        double r3870 = 9.0;
        double r3871 = r3869 * r3870;
        double r3872 = -3.686718947958486e-77;
        bool r3873 = r3871 <= r3872;
        double r3874 = x;
        double r3875 = 2.0;
        double r3876 = r3874 * r3875;
        double r3877 = z;
        double r3878 = t;
        double r3879 = r3877 * r3878;
        double r3880 = r3870 * r3879;
        double r3881 = r3869 * r3880;
        double r3882 = r3876 - r3881;
        double r3883 = a;
        double r3884 = 27.0;
        double r3885 = r3883 * r3884;
        double r3886 = b;
        double r3887 = r3885 * r3886;
        double r3888 = r3882 + r3887;
        double r3889 = 4.432364666553349e-78;
        bool r3890 = r3871 <= r3889;
        double r3891 = r3871 * r3877;
        double r3892 = r3878 * r3891;
        double r3893 = -r3892;
        double r3894 = fma(r3874, r3875, r3893);
        double r3895 = r3884 * r3886;
        double r3896 = -r3878;
        double r3897 = r3896 + r3878;
        double r3898 = r3891 * r3897;
        double r3899 = fma(r3895, r3883, r3898);
        double r3900 = r3894 + r3899;
        double r3901 = r3870 * r3877;
        double r3902 = r3901 * r3878;
        double r3903 = r3869 * r3902;
        double r3904 = r3876 - r3903;
        double r3905 = r3904 + r3887;
        double r3906 = r3890 ? r3900 : r3905;
        double r3907 = r3873 ? r3888 : r3906;
        return r3907;
}

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

Original4.1
Target2.8
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;y \lt 7.590524218811189 \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 9.0) < -3.686718947958486e-77

    1. Initial program 6.6

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*1.3

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b\]
    4. Using strategy rm
    5. Applied associate-*l*1.3

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

    if -3.686718947958486e-77 < (* y 9.0) < 4.432364666553349e-78

    1. Initial program 0.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. Using strategy rm
    3. Applied pow10.7

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot \color{blue}{{b}^{1}}\]
    4. Applied pow10.7

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot \color{blue}{{27}^{1}}\right) \cdot {b}^{1}\]
    5. Applied pow10.7

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(\color{blue}{{a}^{1}} \cdot {27}^{1}\right) \cdot {b}^{1}\]
    6. Applied pow-prod-down0.7

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{{\left(a \cdot 27\right)}^{1}} \cdot {b}^{1}\]
    7. Applied pow-prod-down0.7

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

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + {\color{blue}{\left(27 \cdot \left(a \cdot b\right)\right)}}^{1}\]
    9. Using strategy rm
    10. Applied prod-diff0.6

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

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

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

    if 4.432364666553349e-78 < (* y 9.0)

    1. Initial program 7.0

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-*l*1.4

      \[\leadsto \left(x \cdot 2 - \color{blue}{\left(y \cdot 9\right) \cdot \left(z \cdot t\right)}\right) + \left(a \cdot 27\right) \cdot b\]
    4. Using strategy rm
    5. Applied associate-*l*1.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 9 \le -3.68671894795848607 \cdot 10^{-77}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{elif}\;y \cdot 9 \le 4.4323646665533492 \cdot 10^{-78}:\\ \;\;\;\;\mathsf{fma}\left(x, 2, -t \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right) + \mathsf{fma}\left(27 \cdot b, a, \left(\left(y \cdot 9\right) \cdot z\right) \cdot \left(\left(-t\right) + t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(\left(9 \cdot z\right) \cdot t\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array}\]

Reproduce

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