Average Error: 27.0 → 20.9
Time: 7.8s
Precision: 64
\[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
\[\begin{array}{l} \mathbf{if}\;a \le -2.26327786327634281 \cdot 10^{115}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -4.41531368986651466 \cdot 10^{-105}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \left(\sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}} \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\right) \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\\ \mathbf{elif}\;a \le 2.017571219391953 \cdot 10^{-297}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 1.7662230389581438 \cdot 10^{70}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \left(\sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}} \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\right) \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\\ \mathbf{else}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \end{array}\]
\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\begin{array}{l}
\mathbf{if}\;a \le -2.26327786327634281 \cdot 10^{115}:\\
\;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\

\mathbf{elif}\;a \le -4.41531368986651466 \cdot 10^{-105}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \left(\sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}} \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\right) \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\\

\mathbf{elif}\;a \le 2.017571219391953 \cdot 10^{-297}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\

\mathbf{elif}\;a \le 1.7662230389581438 \cdot 10^{70}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \left(\sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}} \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\right) \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\\

\mathbf{else}:\\
\;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r884756 = x;
        double r884757 = y;
        double r884758 = r884756 + r884757;
        double r884759 = z;
        double r884760 = r884758 * r884759;
        double r884761 = t;
        double r884762 = r884761 + r884757;
        double r884763 = a;
        double r884764 = r884762 * r884763;
        double r884765 = r884760 + r884764;
        double r884766 = b;
        double r884767 = r884757 * r884766;
        double r884768 = r884765 - r884767;
        double r884769 = r884756 + r884761;
        double r884770 = r884769 + r884757;
        double r884771 = r884768 / r884770;
        return r884771;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r884772 = a;
        double r884773 = -2.263277863276343e+115;
        bool r884774 = r884772 <= r884773;
        double r884775 = y;
        double r884776 = b;
        double r884777 = x;
        double r884778 = t;
        double r884779 = r884777 + r884778;
        double r884780 = r884779 + r884775;
        double r884781 = r884776 / r884780;
        double r884782 = r884775 * r884781;
        double r884783 = r884772 - r884782;
        double r884784 = -4.415313689866515e-105;
        bool r884785 = r884772 <= r884784;
        double r884786 = r884777 + r884775;
        double r884787 = z;
        double r884788 = r884778 + r884775;
        double r884789 = r884788 * r884772;
        double r884790 = fma(r884786, r884787, r884789);
        double r884791 = 1.0;
        double r884792 = r884790 / r884791;
        double r884793 = r884792 / r884780;
        double r884794 = cbrt(r884782);
        double r884795 = r884794 * r884794;
        double r884796 = r884795 * r884794;
        double r884797 = r884793 - r884796;
        double r884798 = 2.017571219391953e-297;
        bool r884799 = r884772 <= r884798;
        double r884800 = r884775 * r884776;
        double r884801 = r884800 / r884780;
        double r884802 = r884793 - r884801;
        double r884803 = 1.7662230389581438e+70;
        bool r884804 = r884772 <= r884803;
        double r884805 = r884804 ? r884797 : r884783;
        double r884806 = r884799 ? r884802 : r884805;
        double r884807 = r884785 ? r884797 : r884806;
        double r884808 = r884774 ? r884783 : r884807;
        return r884808;
}

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

Original27.0
Target11.6
Herbie20.9
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \lt -3.5813117084150564 \cdot 10^{153}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \lt 1.2285964308315609 \cdot 10^{82}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if a < -2.263277863276343e+115 or 1.7662230389581438e+70 < a

    1. Initial program 39.8

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied div-sub39.8

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Simplified39.8

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity39.8

      \[\leadsto \frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y \cdot b}{\color{blue}{1 \cdot \left(\left(x + t\right) + y\right)}}\]
    7. Applied times-frac40.2

      \[\leadsto \frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \color{blue}{\frac{y}{1} \cdot \frac{b}{\left(x + t\right) + y}}\]
    8. Simplified40.2

      \[\leadsto \frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \color{blue}{y} \cdot \frac{b}{\left(x + t\right) + y}\]
    9. Taylor expanded around 0 26.2

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

    if -2.263277863276343e+115 < a < -4.415313689866515e-105 or 2.017571219391953e-297 < a < 1.7662230389581438e+70

    1. Initial program 20.3

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied div-sub20.3

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Simplified20.3

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y}} - \frac{y \cdot b}{\left(x + t\right) + y}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity20.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y \cdot b}{\color{blue}{1 \cdot \left(\left(x + t\right) + y\right)}}\]
    7. Applied times-frac17.0

      \[\leadsto \frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \color{blue}{\frac{y}{1} \cdot \frac{b}{\left(x + t\right) + y}}\]
    8. Simplified17.0

      \[\leadsto \frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \color{blue}{y} \cdot \frac{b}{\left(x + t\right) + y}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt17.3

      \[\leadsto \frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \color{blue}{\left(\sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}} \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\right) \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}}\]

    if -4.415313689866515e-105 < a < 2.017571219391953e-297

    1. Initial program 20.4

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Using strategy rm
    3. Applied div-sub20.4

      \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}}\]
    4. Simplified20.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -2.26327786327634281 \cdot 10^{115}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -4.41531368986651466 \cdot 10^{-105}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \left(\sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}} \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\right) \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\\ \mathbf{elif}\;a \le 2.017571219391953 \cdot 10^{-297}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \frac{y \cdot b}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 1.7662230389581438 \cdot 10^{70}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1}}{\left(x + t\right) + y} - \left(\sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}} \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\right) \cdot \sqrt[3]{y \cdot \frac{b}{\left(x + t\right) + y}}\\ \mathbf{else}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020081 +o rules:numerics
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
  :precision binary64

  :herbie-target
  (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3.5813117084150564e+153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e+82) (/ 1 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b)))

  (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))