Average Error: 26.9 → 20.4
Time: 6.6s
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}\;y \le -4.660037093288080049495086170480533192476 \cdot 10^{169}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le -7.346408580041242408048369962778013704383 \cdot 10^{109}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1} \cdot \frac{1}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le -1.071889904333067857356772339828913438893 \cdot 10^{63}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le 3.547257675943682261124762635597949918261 \cdot 10^{-19}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\\ \mathbf{elif}\;y \le 2.049883034481177769453874093256491989537 \cdot 10^{97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1} \cdot \frac{1}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - 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}\;y \le -4.660037093288080049495086170480533192476 \cdot 10^{169}:\\
\;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\

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

\mathbf{elif}\;y \le -1.071889904333067857356772339828913438893 \cdot 10^{63}:\\
\;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\

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

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

\mathbf{else}:\\
\;\;\;\;z - 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 r797257 = x;
        double r797258 = y;
        double r797259 = r797257 + r797258;
        double r797260 = z;
        double r797261 = r797259 * r797260;
        double r797262 = t;
        double r797263 = r797262 + r797258;
        double r797264 = a;
        double r797265 = r797263 * r797264;
        double r797266 = r797261 + r797265;
        double r797267 = b;
        double r797268 = r797258 * r797267;
        double r797269 = r797266 - r797268;
        double r797270 = r797257 + r797262;
        double r797271 = r797270 + r797258;
        double r797272 = r797269 / r797271;
        return r797272;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r797273 = y;
        double r797274 = -4.66003709328808e+169;
        bool r797275 = r797273 <= r797274;
        double r797276 = z;
        double r797277 = b;
        double r797278 = x;
        double r797279 = t;
        double r797280 = r797278 + r797279;
        double r797281 = r797280 + r797273;
        double r797282 = r797277 / r797281;
        double r797283 = r797273 * r797282;
        double r797284 = r797276 - r797283;
        double r797285 = -7.346408580041242e+109;
        bool r797286 = r797273 <= r797285;
        double r797287 = r797278 + r797273;
        double r797288 = r797279 + r797273;
        double r797289 = a;
        double r797290 = r797288 * r797289;
        double r797291 = fma(r797287, r797276, r797290);
        double r797292 = 1.0;
        double r797293 = r797291 / r797292;
        double r797294 = r797292 / r797281;
        double r797295 = r797293 * r797294;
        double r797296 = r797295 - r797283;
        double r797297 = -1.0718899043330679e+63;
        bool r797298 = r797273 <= r797297;
        double r797299 = r797289 - r797283;
        double r797300 = 3.5472576759436823e-19;
        bool r797301 = r797273 <= r797300;
        double r797302 = r797273 * r797277;
        double r797303 = r797290 - r797302;
        double r797304 = fma(r797276, r797287, r797303);
        double r797305 = r797281 / r797304;
        double r797306 = r797292 / r797305;
        double r797307 = 2.0498830344811778e+97;
        bool r797308 = r797273 <= r797307;
        double r797309 = r797308 ? r797296 : r797284;
        double r797310 = r797301 ? r797306 : r797309;
        double r797311 = r797298 ? r797299 : r797310;
        double r797312 = r797286 ? r797296 : r797311;
        double r797313 = r797275 ? r797284 : r797312;
        return r797313;
}

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

Original26.9
Target11.1
Herbie20.4
\[\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.581311708415056427521064305370896655752 \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.228596430831560895857110658734089400289 \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 4 regimes
  2. if y < -4.66003709328808e+169 or 2.0498830344811778e+97 < y

    1. Initial program 46.7

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

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

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

      \[\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-frac38.6

      \[\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. Simplified38.6

      \[\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 inf 26.1

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

    if -4.66003709328808e+169 < y < -7.346408580041242e+109 or 3.5472576759436823e-19 < y < 2.0498830344811778e+97

    1. Initial program 28.1

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

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

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

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

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

      \[\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 div-inv23.8

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

    if -7.346408580041242e+109 < y < -1.0718899043330679e+63

    1. Initial program 30.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-sub30.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. Simplified30.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-identity30.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-frac24.8

      \[\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. Simplified24.8

      \[\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 29.4

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

    if -1.0718899043330679e+63 < y < 3.5472576759436823e-19

    1. Initial program 15.7

      \[\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 clear-num15.9

      \[\leadsto \color{blue}{\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}}}\]
    4. Simplified15.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.660037093288080049495086170480533192476 \cdot 10^{169}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le -7.346408580041242408048369962778013704383 \cdot 10^{109}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1} \cdot \frac{1}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le -1.071889904333067857356772339828913438893 \cdot 10^{63}:\\ \;\;\;\;a - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{elif}\;y \le 3.547257675943682261124762635597949918261 \cdot 10^{-19}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(z, x + y, \left(t + y\right) \cdot a - y \cdot b\right)}}\\ \mathbf{elif}\;y \le 2.049883034481177769453874093256491989537 \cdot 10^{97}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, \left(t + y\right) \cdot a\right)}{1} \cdot \frac{1}{\left(x + t\right) + y} - y \cdot \frac{b}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z - y \cdot \frac{b}{\left(x + t\right) + y}\\ \end{array}\]

Reproduce

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