Average Error: 26.9 → 16.5
Time: 17.2s
Precision: binary64
Cost: 1672
\[\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 \leq -3.020899892525743 \cdot 10^{+25} \lor \neg \left(y \leq 1.4535349447456728 \cdot 10^{+32}\right):\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(z \cdot \left(y + x\right) + a \cdot \left(y + t\right)\right) - y \cdot b}{y + \left(x + t\right)}\\ \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 \leq -3.020899892525743 \cdot 10^{+25} \lor \neg \left(y \leq 1.4535349447456728 \cdot 10^{+32}\right):\\
\;\;\;\;\left(z + a\right) - b\\

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

\end{array}
(FPCore (x y z t a b)
 :precision binary64
 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= y -3.020899892525743e+25) (not (<= y 1.4535349447456728e+32)))
   (- (+ z a) b)
   (/ (- (+ (* z (+ y x)) (* a (+ y t))) (* y b)) (+ y (+ x t)))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((y <= -3.020899892525743e+25) || !(y <= 1.4535349447456728e+32)) {
		tmp = (z + a) - b;
	} else {
		tmp = (((z * (y + x)) + (a * (y + t))) - (y * b)) / (y + (x + t));
	}
	return tmp;
}

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

Original26.9
Target11.5
Herbie16.5
\[\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} < -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} < 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}\]

Alternatives

Alternative 1
Error23.6
Cost1988
\[\begin{array}{l} \mathbf{if}\;y \leq -6.708649747238631 \cdot 10^{-97}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;y \leq 3.512505215968992 \cdot 10^{-60}:\\ \;\;\;\;\frac{a \cdot t + z \cdot x}{x + t}\\ \mathbf{elif}\;y \leq 25156763.674746964:\\ \;\;\;\;\frac{z \cdot \left(y + x\right) - y \cdot b}{x + \left(y + t\right)}\\ \mathbf{elif}\;y \leq 6.165091464796989 \cdot 10^{+31}:\\ \;\;\;\;\frac{a \cdot t + z \cdot x}{x + t}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array}\]
Alternative 2
Error23.2
Cost1032
\[\begin{array}{l} \mathbf{if}\;y \leq -4.614171903040435 \cdot 10^{-93} \lor \neg \left(y \leq 1.3790316293518516 \cdot 10^{-53}\right):\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{a \cdot t + z \cdot x}{x + t}\\ \end{array}\]
Alternative 3
Error27.6
Cost2181
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3823847032482697 \cdot 10^{-217}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;y \leq 9.09169720540087 \cdot 10^{-300}:\\ \;\;\;\;a\\ \mathbf{elif}\;y \leq 1.2394438071820847 \cdot 10^{-269}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 1.3233721394245132 \cdot 10^{-225}:\\ \;\;\;\;a\\ \mathbf{elif}\;y \leq 1.711922132535804 \cdot 10^{-199}:\\ \;\;\;\;\frac{z \cdot x}{y + \left(x + t\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array}\]
Alternative 4
Error26.0
Cost1604
\[\begin{array}{l} \mathbf{if}\;x \leq -2.140049187278291 \cdot 10^{+137}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 1.3749308130433322 \cdot 10^{-286}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;x \leq 6.437302581037496 \cdot 10^{-249}:\\ \;\;\;\;a\\ \mathbf{elif}\;x \leq 9.127253907026268 \cdot 10^{+129}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]
Alternative 5
Error35.7
Cost1348
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0044262308117548 \cdot 10^{+104}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq -4400682198416.613:\\ \;\;\;\;a\\ \mathbf{elif}\;x \leq -1.4299364003405532 \cdot 10^{-53}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 1.346567444899453 \cdot 10^{+37}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array}\]
Alternative 6
Error43.0
Cost64
\[a\]
Alternative 7
Error61.8
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if y < -3.02089989252574288e25 or 1.45353494474567276e32 < y

    1. Initial program 39.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. Taylor expanded around inf 16.7

      \[\leadsto \color{blue}{\left(a + z\right) - b}\]
    3. Simplified16.7

      \[\leadsto \color{blue}{\left(z + a\right) - b}\]
    4. Simplified16.7

      \[\leadsto \color{blue}{\left(z + a\right) - b}\]

    if -3.02089989252574288e25 < y < 1.45353494474567276e32

    1. Initial program 16.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. Simplified16.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.020899892525743 \cdot 10^{+25} \lor \neg \left(y \leq 1.4535349447456728 \cdot 10^{+32}\right):\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(z \cdot \left(y + x\right) + a \cdot \left(y + t\right)\right) - y \cdot b}{y + \left(x + t\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2021044 
(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.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)))