Average Error: 26.5 → 24.5
Time: 6.0s
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 -7.12837458361738554 \cdot 10^{195}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \le -9.28547134870867658 \cdot 10^{124}:\\ \;\;\;\;z\\ \mathbf{elif}\;a \le -2.607767836228133 \cdot 10^{105}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \le 1.33433320957664826 \cdot 10^{227}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(x, z, z \cdot y\right) + \left(\left(t + y\right) \cdot a - y \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;a\\ \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 -7.12837458361738554 \cdot 10^{195}:\\
\;\;\;\;a\\

\mathbf{elif}\;a \le -9.28547134870867658 \cdot 10^{124}:\\
\;\;\;\;z\\

\mathbf{elif}\;a \le -2.607767836228133 \cdot 10^{105}:\\
\;\;\;\;a\\

\mathbf{elif}\;a \le 1.33433320957664826 \cdot 10^{227}:\\
\;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(x, z, z \cdot y\right) + \left(\left(t + y\right) \cdot a - y \cdot b\right)}}\\

\mathbf{else}:\\
\;\;\;\;a\\

\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 <= -7.128374583617386e+195)) {
		VAR = a;
	} else {
		double VAR_1;
		if ((a <= -9.285471348708677e+124)) {
			VAR_1 = z;
		} else {
			double VAR_2;
			if ((a <= -2.607767836228133e+105)) {
				VAR_2 = a;
			} else {
				double VAR_3;
				if ((a <= 1.3343332095766483e+227)) {
					VAR_3 = (1.0 / (((x + t) + y) / (fma(x, z, (z * y)) + (((t + y) * a) - (y * b)))));
				} else {
					VAR_3 = a;
				}
				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.5
Target11.5
Herbie24.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} \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 < -7.128374583617386e+195 or -9.285471348708677e+124 < a < -2.607767836228133e+105 or 1.3343332095766483e+227 < a

    1. Initial program 43.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. Taylor expanded around 0 27.0

      \[\leadsto \color{blue}{a}\]

    if -7.128374583617386e+195 < a < -9.285471348708677e+124

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

      \[\leadsto \color{blue}{z}\]

    if -2.607767836228133e+105 < a < 1.3343332095766483e+227

    1. Initial program 22.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 *-un-lft-identity22.2

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

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

      \[\leadsto \frac{\left(1 \cdot \color{blue}{\mathsf{fma}\left(x, z, z \cdot y\right)} + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}\]
    6. Using strategy rm
    7. Applied clear-num22.3

      \[\leadsto \color{blue}{\frac{1}{\frac{\left(x + t\right) + y}{\left(1 \cdot \mathsf{fma}\left(x, z, z \cdot y\right) + \left(t + y\right) \cdot a\right) - y \cdot b}}}\]
    8. Simplified22.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -7.12837458361738554 \cdot 10^{195}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \le -9.28547134870867658 \cdot 10^{124}:\\ \;\;\;\;z\\ \mathbf{elif}\;a \le -2.607767836228133 \cdot 10^{105}:\\ \;\;\;\;a\\ \mathbf{elif}\;a \le 1.33433320957664826 \cdot 10^{227}:\\ \;\;\;\;\frac{1}{\frac{\left(x + t\right) + y}{\mathsf{fma}\left(x, z, z \cdot y\right) + \left(\left(t + y\right) \cdot a - y \cdot b\right)}}\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array}\]

Reproduce

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