Average Error: 3.8 → 1.4
Time: 4.3s
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}\;t \le -6.4129760095180493 \cdot 10^{-217}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{elif}\;t \le 2.4602073916559479 \cdot 10^{-15}:\\ \;\;\;\;\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, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\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}\;t \le -6.4129760095180493 \cdot 10^{-217}:\\
\;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\

\mathbf{elif}\;t \le 2.4602073916559479 \cdot 10^{-15}:\\
\;\;\;\;\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, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r847720 = x;
        double r847721 = 2.0;
        double r847722 = r847720 * r847721;
        double r847723 = y;
        double r847724 = 9.0;
        double r847725 = r847723 * r847724;
        double r847726 = z;
        double r847727 = r847725 * r847726;
        double r847728 = t;
        double r847729 = r847727 * r847728;
        double r847730 = r847722 - r847729;
        double r847731 = a;
        double r847732 = 27.0;
        double r847733 = r847731 * r847732;
        double r847734 = b;
        double r847735 = r847733 * r847734;
        double r847736 = r847730 + r847735;
        return r847736;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r847737 = t;
        double r847738 = -6.412976009518049e-217;
        bool r847739 = r847737 <= r847738;
        double r847740 = 2.0;
        double r847741 = x;
        double r847742 = 27.0;
        double r847743 = a;
        double r847744 = b;
        double r847745 = r847743 * r847744;
        double r847746 = r847742 * r847745;
        double r847747 = 9.0;
        double r847748 = z;
        double r847749 = y;
        double r847750 = r847748 * r847749;
        double r847751 = r847737 * r847750;
        double r847752 = r847747 * r847751;
        double r847753 = r847746 - r847752;
        double r847754 = fma(r847740, r847741, r847753);
        double r847755 = 2.460207391655948e-15;
        bool r847756 = r847737 <= r847755;
        double r847757 = r847737 * r847749;
        double r847758 = r847747 * r847757;
        double r847759 = r847758 * r847748;
        double r847760 = 1.0;
        double r847761 = pow(r847759, r847760);
        double r847762 = r847746 - r847761;
        double r847763 = fma(r847740, r847741, r847762);
        double r847764 = cbrt(r847747);
        double r847765 = r847764 * r847764;
        double r847766 = r847764 * r847751;
        double r847767 = r847765 * r847766;
        double r847768 = r847746 - r847767;
        double r847769 = fma(r847740, r847741, r847768);
        double r847770 = r847756 ? r847763 : r847769;
        double r847771 = r847739 ? r847754 : r847770;
        return r847771;
}

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.8
Target2.5
Herbie1.4
\[\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 t < -6.412976009518049e-217

    1. Initial program 2.8

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\]
    2. Simplified2.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 2.7

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

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

    if -6.412976009518049e-217 < t < 2.460207391655948e-15

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

      \[\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 6.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. Simplified6.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 add-cube-cbrt6.5

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)\]
    7. Applied associate-*l*6.5

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)}\right)\]
    8. Using strategy rm
    9. Applied pow16.5

      \[\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(t \cdot \left(z \cdot \color{blue}{{y}^{1}}\right)\right)\right)\right)\]
    10. Applied pow16.5

      \[\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(t \cdot \left(\color{blue}{{z}^{1}} \cdot {y}^{1}\right)\right)\right)\right)\]
    11. Applied pow-prod-down6.5

      \[\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(t \cdot \color{blue}{{\left(z \cdot y\right)}^{1}}\right)\right)\right)\]
    12. Applied pow16.5

      \[\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}{{t}^{1}} \cdot {\left(z \cdot y\right)}^{1}\right)\right)\right)\]
    13. Applied pow-prod-down6.5

      \[\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(t \cdot \left(z \cdot y\right)\right)}^{1}}\right)\right)\]
    14. Applied pow16.5

      \[\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(t \cdot \left(z \cdot y\right)\right)}^{1}\right)\right)\]
    15. Applied pow-prod-down6.5

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)}^{1}}\right)\]
    16. Applied pow16.5

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)}^{1}\right)\]
    17. Applied pow16.5

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)}^{1}\right)\]
    18. Applied pow-prod-down6.5

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)}^{1}\right)\]
    19. Applied pow-prod-down6.5

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)\right)}^{1}}\right)\]
    20. Simplified0.4

      \[\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 2.460207391655948e-15 < t

    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. Simplified0.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 0.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. Simplified0.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 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(t \cdot \left(z \cdot y\right)\right)\right)\]
    7. Applied associate-*l*0.6

      \[\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(t \cdot \left(z \cdot y\right)\right)\right)}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -6.4129760095180493 \cdot 10^{-217}:\\ \;\;\;\;\mathsf{fma}\left(2, x, 27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{elif}\;t \le 2.4602073916559479 \cdot 10^{-15}:\\ \;\;\;\;\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, 27 \cdot \left(a \cdot b\right) - \left(\sqrt[3]{9} \cdot \sqrt[3]{9}\right) \cdot \left(\sqrt[3]{9} \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\right)\\ \end{array}\]

Reproduce

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