Average Error: 27.6 → 24.0
Time: 5.6s
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 \le -9.05620262188057754 \cdot 10^{158}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;x \le -2.23161864608348525 \cdot 10^{110}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le -7.90176254867761558 \cdot 10^{77}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;x \le -1.1948563734800308 \cdot 10^{-70}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right) + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - b \cdot \left(y \cdot \frac{1}{x + \left(y + t\right)}\right)\\ \mathbf{elif}\;x \le -4.93673133800222456 \cdot 10^{-160}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le -1.4559921776831976 \cdot 10^{-235}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;x \le 6.98701547105213913 \cdot 10^{-217}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le 2.11574371481320974 \cdot 10^{-74}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right) + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le 1.28406373207817062 \cdot 10^{82}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le 1.05828271745642337 \cdot 10^{165}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right) + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{else}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \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 \le -9.05620262188057754 \cdot 10^{158}:\\
\;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\

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

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

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

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

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

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

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

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

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

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

\end{array}
double code(double x, double y, double z, double t, double a, double b) {
	return (((double) (((double) (((double) (((double) (x + y)) * z)) + ((double) (((double) (t + y)) * a)))) - ((double) (y * b)))) / ((double) (((double) (x + t)) + y)));
}
double code(double x, double y, double z, double t, double a, double b) {
	double VAR;
	if ((x <= -9.056202621880578e+158)) {
		VAR = ((double) (z - ((double) ((y / ((double) (x + ((double) (y + t))))) * b))));
	} else {
		double VAR_1;
		if ((x <= -2.2316186460834853e+110)) {
			VAR_1 = ((double) (a - ((double) (y * (b / ((double) (x + ((double) (y + t)))))))));
		} else {
			double VAR_2;
			if ((x <= -7.901762548677616e+77)) {
				VAR_2 = ((double) (z - ((double) ((y / ((double) (x + ((double) (y + t))))) * b))));
			} else {
				double VAR_3;
				if ((x <= -1.1948563734800308e-70)) {
					VAR_3 = ((double) ((((double) (((double) (z * ((double) (x + y)))) + ((double) (((double) (y + t)) * a)))) / ((double) (x + ((double) (y + t))))) - ((double) (b * ((double) (y * (1.0 / ((double) (x + ((double) (y + t)))))))))));
				} else {
					double VAR_4;
					if ((x <= -4.9367313380022246e-160)) {
						VAR_4 = ((double) (a - ((double) (y * (b / ((double) (x + ((double) (y + t)))))))));
					} else {
						double VAR_5;
						if ((x <= -1.4559921776831976e-235)) {
							VAR_5 = ((double) (z - ((double) ((y / ((double) (x + ((double) (y + t))))) * b))));
						} else {
							double VAR_6;
							if ((x <= 6.987015471052139e-217)) {
								VAR_6 = ((double) (a - ((double) (y * (b / ((double) (x + ((double) (y + t)))))))));
							} else {
								double VAR_7;
								if ((x <= 2.1157437148132097e-74)) {
									VAR_7 = ((double) ((((double) (((double) (z * ((double) (x + y)))) + ((double) (((double) (y + t)) * a)))) / ((double) (x + ((double) (y + t))))) - ((double) (y * (b / ((double) (x + ((double) (y + t)))))))));
								} else {
									double VAR_8;
									if ((x <= 1.2840637320781706e+82)) {
										VAR_8 = ((double) (a - ((double) (y * (b / ((double) (x + ((double) (y + t)))))))));
									} else {
										double VAR_9;
										if ((x <= 1.0582827174564234e+165)) {
											VAR_9 = ((double) ((((double) (((double) (z * ((double) (x + y)))) + ((double) (((double) (y + t)) * a)))) / ((double) (x + ((double) (y + t))))) - ((double) (y * (b / ((double) (x + ((double) (y + t)))))))));
										} else {
											VAR_9 = ((double) (z - ((double) ((y / ((double) (x + ((double) (y + t))))) * b))));
										}
										VAR_8 = VAR_9;
									}
									VAR_7 = VAR_8;
								}
								VAR_6 = VAR_7;
							}
							VAR_5 = VAR_6;
						}
						VAR_4 = VAR_5;
					}
					VAR_3 = VAR_4;
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.6
Target11.4
Herbie24.0
\[\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 4 regimes
  2. if x < -9.05620262188057754e158 or -2.23161864608348525e110 < x < -7.90176254867761558e77 or -4.93673133800222456e-160 < x < -1.4559921776831976e-235 or 1.05828271745642337e165 < x

    1. Initial program 33.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-sub33.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. Simplified33.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. Simplified31.0

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

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

    if -9.05620262188057754e158 < x < -2.23161864608348525e110 or -1.1948563734800308e-70 < x < -4.93673133800222456e-160 or -1.4559921776831976e-235 < x < 6.98701547105213913e-217 or 2.11574371481320974e-74 < x < 1.28406373207817062e82

    1. Initial program 24.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-sub24.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. Simplified24.7

      \[\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. Simplified21.2

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{\frac{y}{x + \left(y + t\right)} \cdot b}\]
    6. Using strategy rm
    7. Applied div-inv21.2

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{\left(y \cdot \frac{1}{x + \left(y + t\right)}\right)} \cdot b\]
    8. Applied associate-*l*22.4

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

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

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

    if -7.90176254867761558e77 < x < -1.1948563734800308e-70

    1. Initial program 24.6

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

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

      \[\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. Simplified21.0

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{\frac{y}{x + \left(y + t\right)} \cdot b}\]
    6. Using strategy rm
    7. Applied div-inv21.0

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

    if 6.98701547105213913e-217 < x < 2.11574371481320974e-74 or 1.28406373207817062e82 < x < 1.05828271745642337e165

    1. Initial program 24.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. Using strategy rm
    3. Applied div-sub24.9

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

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

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

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - \color{blue}{\left(y \cdot \frac{1}{x + \left(y + t\right)}\right)} \cdot b\]
    8. Applied associate-*l*23.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9.05620262188057754 \cdot 10^{158}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;x \le -2.23161864608348525 \cdot 10^{110}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le -7.90176254867761558 \cdot 10^{77}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;x \le -1.1948563734800308 \cdot 10^{-70}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right) + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - b \cdot \left(y \cdot \frac{1}{x + \left(y + t\right)}\right)\\ \mathbf{elif}\;x \le -4.93673133800222456 \cdot 10^{-160}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le -1.4559921776831976 \cdot 10^{-235}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;x \le 6.98701547105213913 \cdot 10^{-217}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le 2.11574371481320974 \cdot 10^{-74}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right) + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le 1.28406373207817062 \cdot 10^{82}:\\ \;\;\;\;a - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;x \le 1.05828271745642337 \cdot 10^{165}:\\ \;\;\;\;\frac{z \cdot \left(x + y\right) + \left(y + t\right) \cdot a}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{else}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \end{array}\]

Reproduce

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