Average Error: 27.1 → 21.3
Time: 5.8s
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}\;a \le -1.2192263232079549 \cdot 10^{244}:\\ \;\;\;\;a - \frac{b}{\frac{\left(x + t\right) + y}{y}}\\ \mathbf{elif}\;a \le -2.1529316069315559 \cdot 10^{134}:\\ \;\;\;\;\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) \cdot \frac{1}{\left(x + t\right) + y} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -2.4075371916051229 \cdot 10^{-5}:\\ \;\;\;\;a - \frac{b}{\frac{\left(x + t\right) + y}{y}}\\ \mathbf{elif}\;a \le -1.76681565249545171 \cdot 10^{-85}:\\ \;\;\;\;\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) \cdot \frac{1}{\left(x + t\right) + y} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -1.27994229446098491 \cdot 10^{-129}:\\ \;\;\;\;z - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -1.6811233784297703 \cdot 10^{-292}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 2.92090303831041133 \cdot 10^{-291}:\\ \;\;\;\;z\\ \mathbf{elif}\;a \le 9247920914101468920000:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;a - \frac{b}{\frac{\left(x + t\right) + y}{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}\;a \le -1.2192263232079549 \cdot 10^{244}:\\
\;\;\;\;a - \frac{b}{\frac{\left(x + t\right) + y}{y}}\\

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

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

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

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

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

\mathbf{elif}\;a \le 2.92090303831041133 \cdot 10^{-291}:\\
\;\;\;\;z\\

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

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

\end{array}
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 VAR;
	if ((a <= -1.2192263232079549e+244)) {
		VAR = (a - (b / (((x + t) + y) / y)));
	} else {
		double VAR_1;
		if ((a <= -2.152931606931556e+134)) {
			VAR_1 = (((((x + y) * z) + ((t + y) * a)) * (1.0 / ((x + t) + y))) - (b * (y / ((x + t) + y))));
		} else {
			double VAR_2;
			if ((a <= -2.407537191605123e-05)) {
				VAR_2 = (a - (b / (((x + t) + y) / y)));
			} else {
				double VAR_3;
				if ((a <= -1.7668156524954517e-85)) {
					VAR_3 = (((((x + y) * z) + ((t + y) * a)) * (1.0 / ((x + t) + y))) - (b * (y / ((x + t) + y))));
				} else {
					double VAR_4;
					if ((a <= -1.2799422944609849e-129)) {
						VAR_4 = (z - (b * (y / ((x + t) + y))));
					} else {
						double VAR_5;
						if ((a <= -1.6811233784297703e-292)) {
							VAR_5 = ((1.0 / (((x + t) + y) / (((x + y) * z) + ((t + y) * a)))) - (b * (y / ((x + t) + y))));
						} else {
							double VAR_6;
							if ((a <= 2.9209030383104113e-291)) {
								VAR_6 = z;
							} else {
								double VAR_7;
								if ((a <= 9.247920914101469e+21)) {
									VAR_7 = ((1.0 / (((x + t) + y) / (((x + y) * z) + ((t + y) * a)))) - (b * (y / ((x + t) + y))));
								} else {
									VAR_7 = (a - (b / (((x + t) + y) / y)));
								}
								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.1
Target11.3
Herbie21.3
\[\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 5 regimes
  2. if a < -1.2192263232079549e+244 or -2.152931606931556e+134 < a < -2.407537191605123e-05 or 9.247920914101469e+21 < a

    1. Initial program 34.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-sub34.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. Using strategy rm
    5. Applied *-commutative34.9

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

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

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

    if -1.2192263232079549e+244 < a < -2.152931606931556e+134 or -2.407537191605123e-05 < a < -1.7668156524954517e-85

    1. Initial program 29.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-sub29.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. Using strategy rm
    5. Applied *-commutative29.6

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

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

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

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

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

    if -1.7668156524954517e-85 < a < -1.2799422944609849e-129

    1. Initial program 20.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-sub20.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. Using strategy rm
    5. Applied *-commutative20.5

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

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

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

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

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

    if -1.2799422944609849e-129 < a < -1.6811233784297703e-292 or 2.9209030383104113e-291 < a < 9.247920914101469e+21

    1. Initial program 18.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-sub18.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. Using strategy rm
    5. Applied *-commutative18.9

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

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

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

      \[\leadsto \frac{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}{\left(x + t\right) + y} - b \cdot \color{blue}{\frac{y}{\left(x + t\right) + y}}\]
    10. Using strategy rm
    11. Applied clear-num14.1

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

    if -1.6811233784297703e-292 < a < 2.9209030383104113e-291

    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. Taylor expanded around inf 31.2

      \[\leadsto \color{blue}{z}\]
  3. Recombined 5 regimes into one program.
  4. Final simplification21.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.2192263232079549 \cdot 10^{244}:\\ \;\;\;\;a - \frac{b}{\frac{\left(x + t\right) + y}{y}}\\ \mathbf{elif}\;a \le -2.1529316069315559 \cdot 10^{134}:\\ \;\;\;\;\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) \cdot \frac{1}{\left(x + t\right) + y} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -2.4075371916051229 \cdot 10^{-5}:\\ \;\;\;\;a - \frac{b}{\frac{\left(x + t\right) + y}{y}}\\ \mathbf{elif}\;a \le -1.76681565249545171 \cdot 10^{-85}:\\ \;\;\;\;\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) \cdot \frac{1}{\left(x + t\right) + y} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -1.27994229446098491 \cdot 10^{-129}:\\ \;\;\;\;z - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le -1.6811233784297703 \cdot 10^{-292}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{elif}\;a \le 2.92090303831041133 \cdot 10^{-291}:\\ \;\;\;\;z\\ \mathbf{elif}\;a \le 9247920914101468920000:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\left(x + y\right) \cdot z + \left(t + y\right) \cdot a}} - b \cdot \frac{y}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;a - \frac{b}{\frac{\left(x + t\right) + y}{y}}\\ \end{array}\]

Reproduce

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