Average Error: 26.3 → 22.6
Time: 6.5s
Precision: binary64
\[\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}\;x \leq -7.641226480775408 \cdot 10^{+152}:\\ \;\;\;\;z - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \leq -1.8247044229002758 \cdot 10^{-63}:\\ \;\;\;\;\frac{1}{\frac{x + \left(y + t\right)}{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}}\\ \mathbf{elif}\;x \leq -8.356989394689423 \cdot 10^{-155}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \leq 4.7718969032047944 \cdot 10^{-259}:\\ \;\;\;\;\frac{1}{\frac{x + \left(y + t\right)}{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}}\\ \mathbf{elif}\;x \leq 4.42050953563121 \cdot 10^{-70}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \leq 1.3074456987728244 \cdot 10^{+23} \lor \neg \left(x \leq 5.097253656774694 \cdot 10^{+222}\right) \land x \leq 2.6713640281165073 \cdot 10^{+251}:\\ \;\;\;\;\left(\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{x + \left(y + t\right)}\\ \mathbf{else}:\\ \;\;\;\;z - y \cdot \frac{b}{x + \left(y + 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}\;x \leq -7.641226480775408 \cdot 10^{+152}:\\
\;\;\;\;z - y \cdot \frac{b}{x + \left(y + t\right)}\\

\mathbf{elif}\;x \leq -1.8247044229002758 \cdot 10^{-63}:\\
\;\;\;\;\frac{1}{\frac{x + \left(y + t\right)}{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}}\\

\mathbf{elif}\;x \leq -8.356989394689423 \cdot 10^{-155}:\\
\;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\

\mathbf{elif}\;x \leq 4.7718969032047944 \cdot 10^{-259}:\\
\;\;\;\;\frac{1}{\frac{x + \left(y + t\right)}{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}}\\

\mathbf{elif}\;x \leq 4.42050953563121 \cdot 10^{-70}:\\
\;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\

\mathbf{elif}\;x \leq 1.3074456987728244 \cdot 10^{+23} \lor \neg \left(x \leq 5.097253656774694 \cdot 10^{+222}\right) \land x \leq 2.6713640281165073 \cdot 10^{+251}:\\
\;\;\;\;\left(\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{x + \left(y + t\right)}\\

\mathbf{else}:\\
\;\;\;\;z - y \cdot \frac{b}{x + \left(y + 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 (<= x -7.641226480775408e+152)
   (- z (* y (/ b (+ x (+ y t)))))
   (if (<= x -1.8247044229002758e-63)
     (/ 1.0 (/ (+ x (+ y t)) (- (+ (* z (+ x y)) (* (+ y t) a)) (* y b))))
     (if (<= x -8.356989394689423e-155)
       (- a (* y (/ b (+ x (+ y t)))))
       (if (<= x 4.7718969032047944e-259)
         (/ 1.0 (/ (+ x (+ y t)) (- (+ (* z (+ x y)) (* (+ y t) a)) (* y b))))
         (if (<= x 4.42050953563121e-70)
           (- a (* y (/ b (+ x (+ y t)))))
           (if (or (<= x 1.3074456987728244e+23)
                   (and (not (<= x 5.097253656774694e+222))
                        (<= x 2.6713640281165073e+251)))
             (*
              (- (+ (* z (+ x y)) (* (+ y t) a)) (* y b))
              (/ 1.0 (+ x (+ y t))))
             (- z (* y (/ b (+ x (+ y 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 (x <= -7.641226480775408e+152) {
		tmp = z - (y * (b / (x + (y + t))));
	} else if (x <= -1.8247044229002758e-63) {
		tmp = 1.0 / ((x + (y + t)) / (((z * (x + y)) + ((y + t) * a)) - (y * b)));
	} else if (x <= -8.356989394689423e-155) {
		tmp = a - (y * (b / (x + (y + t))));
	} else if (x <= 4.7718969032047944e-259) {
		tmp = 1.0 / ((x + (y + t)) / (((z * (x + y)) + ((y + t) * a)) - (y * b)));
	} else if (x <= 4.42050953563121e-70) {
		tmp = a - (y * (b / (x + (y + t))));
	} else if ((x <= 1.3074456987728244e+23) || (!(x <= 5.097253656774694e+222) && (x <= 2.6713640281165073e+251))) {
		tmp = (((z * (x + y)) + ((y + t) * a)) - (y * b)) * (1.0 / (x + (y + t)));
	} else {
		tmp = z - (y * (b / (x + (y + 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.3
Target11.2
Herbie22.6
\[\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}\]

Derivation

  1. Split input into 4 regimes
  2. if x < -7.6412264807754081e152 or 1.30744569877282435e23 < x < 5.09725365677469421e222 or 2.6713640281165073e251 < x

    1. Initial program 32.5

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

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

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

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

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \frac{y \cdot b}{\color{blue}{1 \cdot \left(x + \left(y + t\right)\right)}}\]
    8. Applied times-frac_binary6429.6

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{\frac{y}{1} \cdot \frac{b}{x + \left(y + t\right)}}\]
    9. Simplified29.6

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{y} \cdot \frac{b}{x + \left(y + t\right)}\]
    10. Taylor expanded around inf 22.8

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

    if -7.6412264807754081e152 < x < -1.82470442290027577e-63 or -8.356989394689423e-155 < x < 4.7718969032047944e-259

    1. Initial program 23.2

      \[\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-num_binary6423.3

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

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

    if -1.82470442290027577e-63 < x < -8.356989394689423e-155 or 4.7718969032047944e-259 < x < 4.4205095356312101e-70

    1. Initial program 22.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-sub_binary6422.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. Simplified22.4

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

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{\frac{y \cdot b}{x + \left(y + t\right)}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary6422.4

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \frac{y \cdot b}{\color{blue}{1 \cdot \left(x + \left(y + t\right)\right)}}\]
    8. Applied times-frac_binary6422.0

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{\frac{y}{1} \cdot \frac{b}{x + \left(y + t\right)}}\]
    9. Simplified22.0

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{y} \cdot \frac{b}{x + \left(y + t\right)}\]
    10. Taylor expanded around 0 20.7

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

    if 4.4205095356312101e-70 < x < 1.30744569877282435e23 or 5.09725365677469421e222 < x < 2.6713640281165073e251

    1. Initial program 24.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.641226480775408 \cdot 10^{+152}:\\ \;\;\;\;z - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \leq -1.8247044229002758 \cdot 10^{-63}:\\ \;\;\;\;\frac{1}{\frac{x + \left(y + t\right)}{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}}\\ \mathbf{elif}\;x \leq -8.356989394689423 \cdot 10^{-155}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \leq 4.7718969032047944 \cdot 10^{-259}:\\ \;\;\;\;\frac{1}{\frac{x + \left(y + t\right)}{\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b}}\\ \mathbf{elif}\;x \leq 4.42050953563121 \cdot 10^{-70}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \leq 1.3074456987728244 \cdot 10^{+23} \lor \neg \left(x \leq 5.097253656774694 \cdot 10^{+222}\right) \land x \leq 2.6713640281165073 \cdot 10^{+251}:\\ \;\;\;\;\left(\left(z \cdot \left(x + y\right) + \left(y + t\right) \cdot a\right) - y \cdot b\right) \cdot \frac{1}{x + \left(y + t\right)}\\ \mathbf{else}:\\ \;\;\;\;z - y \cdot \frac{b}{x + \left(y + t\right)}\\ \end{array}\]

Reproduce

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