Average Error: 3.7 → 1.1
Time: 17.5s
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 -1.65080179810688769428131751588925655089 \cdot 10^{150}:\\ \;\;\;\;\sqrt{27} \cdot \left(\left(\sqrt{27} \cdot a\right) \cdot b\right) + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{elif}\;y \cdot 9 \le 1.032571546706587909940161920783675142294 \cdot 10^{-68}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - 9 \cdot \left(t \cdot \left(z \cdot y\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{27} \cdot \left(\sqrt{27} \cdot \left(a \cdot b\right)\right) + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\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 \cdot 9 \le -1.65080179810688769428131751588925655089 \cdot 10^{150}:\\
\;\;\;\;\sqrt{27} \cdot \left(\left(\sqrt{27} \cdot a\right) \cdot b\right) + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r65643 = x;
        double r65644 = 2.0;
        double r65645 = r65643 * r65644;
        double r65646 = y;
        double r65647 = 9.0;
        double r65648 = r65646 * r65647;
        double r65649 = z;
        double r65650 = r65648 * r65649;
        double r65651 = t;
        double r65652 = r65650 * r65651;
        double r65653 = r65645 - r65652;
        double r65654 = a;
        double r65655 = 27.0;
        double r65656 = r65654 * r65655;
        double r65657 = b;
        double r65658 = r65656 * r65657;
        double r65659 = r65653 + r65658;
        return r65659;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r65660 = y;
        double r65661 = 9.0;
        double r65662 = r65660 * r65661;
        double r65663 = -1.6508017981068877e+150;
        bool r65664 = r65662 <= r65663;
        double r65665 = 27.0;
        double r65666 = sqrt(r65665);
        double r65667 = a;
        double r65668 = r65666 * r65667;
        double r65669 = b;
        double r65670 = r65668 * r65669;
        double r65671 = r65666 * r65670;
        double r65672 = x;
        double r65673 = 2.0;
        double r65674 = r65672 * r65673;
        double r65675 = z;
        double r65676 = t;
        double r65677 = r65675 * r65676;
        double r65678 = r65662 * r65677;
        double r65679 = r65674 - r65678;
        double r65680 = r65671 + r65679;
        double r65681 = 1.032571546706588e-68;
        bool r65682 = r65662 <= r65681;
        double r65683 = r65667 * r65665;
        double r65684 = r65675 * r65660;
        double r65685 = r65676 * r65684;
        double r65686 = r65661 * r65685;
        double r65687 = r65674 - r65686;
        double r65688 = fma(r65683, r65669, r65687);
        double r65689 = r65667 * r65669;
        double r65690 = r65666 * r65689;
        double r65691 = r65666 * r65690;
        double r65692 = r65691 + r65679;
        double r65693 = r65682 ? r65688 : r65692;
        double r65694 = r65664 ? r65680 : r65693;
        return r65694;
}

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.6
Herbie1.1
\[\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) < -1.6508017981068877e+150

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

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

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

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

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt1.5

      \[\leadsto \color{blue}{\left(\sqrt{27} \cdot \sqrt{27}\right)} \cdot \left(a \cdot b\right) + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\]
    10. Applied associate-*l*1.5

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

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

    if -1.6508017981068877e+150 < (* y 9.0) < 1.032571546706588e-68

    1. Initial program 1.2

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

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

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

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

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

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

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

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

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

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

    if 1.032571546706588e-68 < (* y 9.0)

    1. Initial program 6.3

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

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

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

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

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt0.8

      \[\leadsto \color{blue}{\left(\sqrt{27} \cdot \sqrt{27}\right)} \cdot \left(a \cdot b\right) + \left(x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\]
    10. Applied associate-*l*0.9

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

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

Reproduce

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