Average Error: 26.7 → 22.3
Time: 5.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}\;a \le -2.3261654035714339 \cdot 10^{143}:\\ \;\;\;\;a - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;a \le -1.4552852751360911 \cdot 10^{-44}:\\ \;\;\;\;\frac{\left(y + x\right) \cdot z + a \cdot \left(y + t\right)}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;a \le -1.0403241314872403 \cdot 10^{-176}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;a \le 2.74574753970520639 \cdot 10^{-210}:\\ \;\;\;\;\frac{\left(y + x\right) \cdot z + a \cdot \left(y + t\right)}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;a \le 1983.13573974047836 \lor \neg \left(a \le 2.91328404020521664 \cdot 10^{142}\right) \land a \le 8.28460359291410148 \cdot 10^{175}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;a - \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}\;a \le -2.3261654035714339 \cdot 10^{143}:\\
\;\;\;\;a - \frac{y}{x + \left(y + t\right)} \cdot b\\

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

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

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

\mathbf{elif}\;a \le 1983.13573974047836 \lor \neg \left(a \le 2.91328404020521664 \cdot 10^{142}\right) \land a \le 8.28460359291410148 \cdot 10^{175}:\\
\;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\

\mathbf{else}:\\
\;\;\;\;a - \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) (((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 ((a <= -2.326165403571434e+143)) {
		VAR = ((double) (a - ((double) (((double) (y / ((double) (x + ((double) (y + t)))))) * b))));
	} else {
		double VAR_1;
		if ((a <= -1.455285275136091e-44)) {
			VAR_1 = ((double) (((double) (((double) (((double) (((double) (y + x)) * z)) + ((double) (a * ((double) (y + t)))))) / ((double) (x + ((double) (y + t)))))) - ((double) (y * ((double) (b / ((double) (x + ((double) (y + t))))))))));
		} else {
			double VAR_2;
			if ((a <= -1.0403241314872403e-176)) {
				VAR_2 = ((double) (z - ((double) (((double) (y / ((double) (x + ((double) (y + t)))))) * b))));
			} else {
				double VAR_3;
				if ((a <= 2.7457475397052064e-210)) {
					VAR_3 = ((double) (((double) (((double) (((double) (((double) (y + x)) * z)) + ((double) (a * ((double) (y + t)))))) / ((double) (x + ((double) (y + t)))))) - ((double) (y * ((double) (b / ((double) (x + ((double) (y + t))))))))));
				} else {
					double VAR_4;
					if (((a <= 1983.1357397404784) || (!(a <= 2.9132840402052166e+142) && (a <= 8.284603592914101e+175)))) {
						VAR_4 = ((double) (z - ((double) (((double) (y / ((double) (x + ((double) (y + t)))))) * b))));
					} else {
						VAR_4 = ((double) (a - ((double) (((double) (y / ((double) (x + ((double) (y + t)))))) * b))));
					}
					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

Original26.7
Target11.0
Herbie22.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 3 regimes
  2. if a < -2.3261654035714339e143 or 1983.13573974047836 < a < 2.91328404020521664e142 or 8.28460359291410148e175 < a

    1. Initial program 37.8

      \[\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-sub37.8

      \[\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. Simplified37.8

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

      \[\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 0 25.2

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

    if -2.3261654035714339e143 < a < -1.4552852751360911e-44 or -1.0403241314872403e-176 < a < 2.74574753970520639e-210

    1. Initial program 21.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-sub21.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. Simplified21.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. Simplified18.1

      \[\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-inv18.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*18.9

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

      \[\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)}}\]

    if -1.4552852751360911e-44 < a < -1.0403241314872403e-176 or 2.74574753970520639e-210 < a < 1983.13573974047836 or 2.91328404020521664e142 < a < 8.28460359291410148e175

    1. Initial program 19.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-sub19.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. Simplified19.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. Simplified15.1

      \[\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 22.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -2.3261654035714339 \cdot 10^{143}:\\ \;\;\;\;a - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;a \le -1.4552852751360911 \cdot 10^{-44}:\\ \;\;\;\;\frac{\left(y + x\right) \cdot z + a \cdot \left(y + t\right)}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;a \le -1.0403241314872403 \cdot 10^{-176}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{elif}\;a \le 2.74574753970520639 \cdot 10^{-210}:\\ \;\;\;\;\frac{\left(y + x\right) \cdot z + a \cdot \left(y + t\right)}{x + \left(y + t\right)} - y \cdot \frac{b}{x + \left(y + t\right)}\\ \mathbf{elif}\;a \le 1983.13573974047836 \lor \neg \left(a \le 2.91328404020521664 \cdot 10^{142}\right) \land a \le 8.28460359291410148 \cdot 10^{175}:\\ \;\;\;\;z - \frac{y}{x + \left(y + t\right)} \cdot b\\ \mathbf{else}:\\ \;\;\;\;a - \frac{y}{x + \left(y + t\right)} \cdot b\\ \end{array}\]

Reproduce

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