Average Error: 3.7 → 0.9
Time: 5.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}\;\left(\left(y \cdot 9\right) \cdot z\right) \cdot t = -\infty:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{elif}\;\left(\left(y \cdot 9\right) \cdot z\right) \cdot t \le 1.588315458735516209839785250754881007712 \cdot 10^{300}:\\ \;\;\;\;x \cdot 2 - \mathsf{fma}\left(9 \cdot \left(z \cdot y\right), t, \left(-27\right) \cdot \left(a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \sqrt[3]{{\left(\left(a \cdot 27\right) \cdot b\right)}^{3}}\\ \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}\;\left(\left(y \cdot 9\right) \cdot z\right) \cdot t = -\infty:\\
\;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r660776 = x;
        double r660777 = 2.0;
        double r660778 = r660776 * r660777;
        double r660779 = y;
        double r660780 = 9.0;
        double r660781 = r660779 * r660780;
        double r660782 = z;
        double r660783 = r660781 * r660782;
        double r660784 = t;
        double r660785 = r660783 * r660784;
        double r660786 = r660778 - r660785;
        double r660787 = a;
        double r660788 = 27.0;
        double r660789 = r660787 * r660788;
        double r660790 = b;
        double r660791 = r660789 * r660790;
        double r660792 = r660786 + r660791;
        return r660792;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r660793 = y;
        double r660794 = 9.0;
        double r660795 = r660793 * r660794;
        double r660796 = z;
        double r660797 = r660795 * r660796;
        double r660798 = t;
        double r660799 = r660797 * r660798;
        double r660800 = -inf.0;
        bool r660801 = r660799 <= r660800;
        double r660802 = a;
        double r660803 = 27.0;
        double r660804 = b;
        double r660805 = r660803 * r660804;
        double r660806 = x;
        double r660807 = 2.0;
        double r660808 = r660806 * r660807;
        double r660809 = r660796 * r660798;
        double r660810 = r660795 * r660809;
        double r660811 = r660808 - r660810;
        double r660812 = fma(r660802, r660805, r660811);
        double r660813 = 1.5883154587355162e+300;
        bool r660814 = r660799 <= r660813;
        double r660815 = r660796 * r660793;
        double r660816 = r660794 * r660815;
        double r660817 = -r660803;
        double r660818 = r660802 * r660804;
        double r660819 = r660817 * r660818;
        double r660820 = fma(r660816, r660798, r660819);
        double r660821 = r660808 - r660820;
        double r660822 = r660794 * r660809;
        double r660823 = r660793 * r660822;
        double r660824 = r660808 - r660823;
        double r660825 = r660802 * r660803;
        double r660826 = r660825 * r660804;
        double r660827 = 3.0;
        double r660828 = pow(r660826, r660827);
        double r660829 = cbrt(r660828);
        double r660830 = r660824 + r660829;
        double r660831 = r660814 ? r660821 : r660830;
        double r660832 = r660801 ? r660812 : r660831;
        return r660832;
}

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.7
Target2.8
Herbie0.9
\[\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 9.0) z) t) < -inf.0

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

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

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

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

    if -inf.0 < (* (* (* y 9.0) z) t) < 1.5883154587355162e+300

    1. Initial program 0.5

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

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

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

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

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

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

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

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

      \[\leadsto \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + {\color{blue}{\left(27 \cdot \left(a \cdot b\right)\right)}}^{1}\]
    13. Using strategy rm
    14. Applied associate-+l-4.1

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

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

    if 1.5883154587355162e+300 < (* (* (* y 9.0) z) t)

    1. Initial program 58.4

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

      \[\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 add-cbrt-cube21.1

      \[\leadsto \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \left(a \cdot 27\right) \cdot \color{blue}{\sqrt[3]{\left(b \cdot b\right) \cdot b}}\]
    8. Applied add-cbrt-cube21.1

      \[\leadsto \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \left(a \cdot \color{blue}{\sqrt[3]{\left(27 \cdot 27\right) \cdot 27}}\right) \cdot \sqrt[3]{\left(b \cdot b\right) \cdot b}\]
    9. Applied add-cbrt-cube35.4

      \[\leadsto \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \left(\color{blue}{\sqrt[3]{\left(a \cdot a\right) \cdot a}} \cdot \sqrt[3]{\left(27 \cdot 27\right) \cdot 27}\right) \cdot \sqrt[3]{\left(b \cdot b\right) \cdot b}\]
    10. Applied cbrt-unprod35.4

      \[\leadsto \left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \color{blue}{\sqrt[3]{\left(\left(a \cdot a\right) \cdot a\right) \cdot \left(\left(27 \cdot 27\right) \cdot 27\right)}} \cdot \sqrt[3]{\left(b \cdot b\right) \cdot b}\]
    11. Applied cbrt-unprod36.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(\left(y \cdot 9\right) \cdot z\right) \cdot t = -\infty:\\ \;\;\;\;\mathsf{fma}\left(a, 27 \cdot b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{elif}\;\left(\left(y \cdot 9\right) \cdot z\right) \cdot t \le 1.588315458735516209839785250754881007712 \cdot 10^{300}:\\ \;\;\;\;x \cdot 2 - \mathsf{fma}\left(9 \cdot \left(z \cdot y\right), t, \left(-27\right) \cdot \left(a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - y \cdot \left(9 \cdot \left(z \cdot t\right)\right)\right) + \sqrt[3]{{\left(\left(a \cdot 27\right) \cdot b\right)}^{3}}\\ \end{array}\]

Reproduce

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