Average Error: 3.6 → 0.8
Time: 17.4s
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.282694253457456491082437216456679883163 \cdot 10^{-23} \lor \neg \left(y \cdot 9 \le 1.656597507920291123155500369549806061406 \cdot 10^{-81}\right):\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\sqrt{27}} \cdot \left(\sqrt{\sqrt{27}} \cdot \left(\sqrt{27} \cdot \left(a \cdot b\right)\right)\right) + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\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.282694253457456491082437216456679883163 \cdot 10^{-23} \lor \neg \left(y \cdot 9 \le 1.656597507920291123155500369549806061406 \cdot 10^{-81}\right):\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r65741 = x;
        double r65742 = 2.0;
        double r65743 = r65741 * r65742;
        double r65744 = y;
        double r65745 = 9.0;
        double r65746 = r65744 * r65745;
        double r65747 = z;
        double r65748 = r65746 * r65747;
        double r65749 = t;
        double r65750 = r65748 * r65749;
        double r65751 = r65743 - r65750;
        double r65752 = a;
        double r65753 = 27.0;
        double r65754 = r65752 * r65753;
        double r65755 = b;
        double r65756 = r65754 * r65755;
        double r65757 = r65751 + r65756;
        return r65757;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r65758 = y;
        double r65759 = 9.0;
        double r65760 = r65758 * r65759;
        double r65761 = -1.2826942534574565e-23;
        bool r65762 = r65760 <= r65761;
        double r65763 = 1.6565975079202911e-81;
        bool r65764 = r65760 <= r65763;
        double r65765 = !r65764;
        bool r65766 = r65762 || r65765;
        double r65767 = a;
        double r65768 = 27.0;
        double r65769 = r65767 * r65768;
        double r65770 = b;
        double r65771 = x;
        double r65772 = 2.0;
        double r65773 = r65771 * r65772;
        double r65774 = z;
        double r65775 = t;
        double r65776 = r65774 * r65775;
        double r65777 = r65760 * r65776;
        double r65778 = r65773 - r65777;
        double r65779 = fma(r65769, r65770, r65778);
        double r65780 = sqrt(r65768);
        double r65781 = sqrt(r65780);
        double r65782 = r65767 * r65770;
        double r65783 = r65780 * r65782;
        double r65784 = r65781 * r65783;
        double r65785 = r65781 * r65784;
        double r65786 = r65760 * r65774;
        double r65787 = r65786 * r65775;
        double r65788 = r65773 - r65787;
        double r65789 = r65785 + r65788;
        double r65790 = r65766 ? r65779 : r65789;
        return r65790;
}

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.6
Herbie0.8
\[\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 2 regimes
  2. if (* y 9.0) < -1.2826942534574565e-23 or 1.6565975079202911e-81 < (* y 9.0)

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

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

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

    if -1.2826942534574565e-23 < (* y 9.0) < 1.6565975079202911e-81

    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. Simplified0.5

      \[\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 fma-udef0.5

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot 9 \le -1.282694253457456491082437216456679883163 \cdot 10^{-23} \lor \neg \left(y \cdot 9 \le 1.656597507920291123155500369549806061406 \cdot 10^{-81}\right):\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, x \cdot 2 - \left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\sqrt{27}} \cdot \left(\sqrt{\sqrt{27}} \cdot \left(\sqrt{27} \cdot \left(a \cdot b\right)\right)\right) + \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\\ \end{array}\]

Reproduce

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