Average Error: 27.0 → 17.8
Time: 24.4s
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}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} = -\infty:\\ \;\;\;\;z\\ \mathbf{elif}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} \le 7.242628122926377025945827678791511079783 \cdot 10^{301}:\\ \;\;\;\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z\\ \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}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} = -\infty:\\
\;\;\;\;z\\

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

\mathbf{else}:\\
\;\;\;\;z\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r43024336 = x;
        double r43024337 = y;
        double r43024338 = r43024336 + r43024337;
        double r43024339 = z;
        double r43024340 = r43024338 * r43024339;
        double r43024341 = t;
        double r43024342 = r43024341 + r43024337;
        double r43024343 = a;
        double r43024344 = r43024342 * r43024343;
        double r43024345 = r43024340 + r43024344;
        double r43024346 = b;
        double r43024347 = r43024337 * r43024346;
        double r43024348 = r43024345 - r43024347;
        double r43024349 = r43024336 + r43024341;
        double r43024350 = r43024349 + r43024337;
        double r43024351 = r43024348 / r43024350;
        return r43024351;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r43024352 = a;
        double r43024353 = y;
        double r43024354 = t;
        double r43024355 = r43024353 + r43024354;
        double r43024356 = r43024352 * r43024355;
        double r43024357 = x;
        double r43024358 = r43024353 + r43024357;
        double r43024359 = z;
        double r43024360 = r43024358 * r43024359;
        double r43024361 = r43024356 + r43024360;
        double r43024362 = b;
        double r43024363 = r43024362 * r43024353;
        double r43024364 = r43024361 - r43024363;
        double r43024365 = r43024354 + r43024357;
        double r43024366 = r43024365 + r43024353;
        double r43024367 = r43024364 / r43024366;
        double r43024368 = -inf.0;
        bool r43024369 = r43024367 <= r43024368;
        double r43024370 = 7.242628122926377e+301;
        bool r43024371 = r43024367 <= r43024370;
        double r43024372 = r43024371 ? r43024367 : r43024359;
        double r43024373 = r43024369 ? r43024359 : r43024372;
        return r43024373;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original27.0
Target11.2
Herbie17.8
\[\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 2 regimes
  2. if (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) < -inf.0 or 7.242628122926377e+301 < (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y))

    1. Initial program 63.9

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    2. Taylor expanded around inf 42.0

      \[\leadsto \color{blue}{z}\]

    if -inf.0 < (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) < 7.242628122926377e+301

    1. Initial program 0.3

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification17.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} = -\infty:\\ \;\;\;\;z\\ \mathbf{elif}\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y} \le 7.242628122926377025945827678791511079783 \cdot 10^{301}:\\ \;\;\;\;\frac{\left(a \cdot \left(y + t\right) + \left(y + x\right) \cdot z\right) - b \cdot y}{\left(t + x\right) + y}\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]

Reproduce

herbie shell --seed 2019192 
(FPCore (x y z t a b)
  :name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"

  :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.0 (/ (+ (+ 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)))