Average Error: 26.6 → 8.3
Time: 10.3s
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} t_1 := y + \left(x + t\right)\\ t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{t_1}\\ t_3 := \left(z + a\right) - b\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 2.3121383245545765 \cdot 10^{+227}:\\ \;\;\;\;\left(\frac{y \cdot z}{t_1} + \left(\frac{x \cdot z}{t_1} + \left(\frac{t \cdot a}{t_1} + \frac{y \cdot a}{t_1}\right)\right)\right) - b \cdot \frac{y}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \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
 (let* ((t_1 (+ y (+ x t)))
        (t_2 (/ (- (+ (* (+ x y) z) (* (+ y t) a)) (* y b)) t_1))
        (t_3 (- (+ z a) b)))
   (if (<= t_2 (- INFINITY))
     t_3
     (if (<= t_2 2.3121383245545765e+227)
       (-
        (+
         (/ (* y z) t_1)
         (+ (/ (* x z) t_1) (+ (/ (* t a) t_1) (/ (* y a) t_1))))
        (* b (/ y t_1)))
       t_3))))
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 t_1 = y + (x + t);
	double t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
	double t_3 = (z + a) - b;
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_3;
	} else if (t_2 <= 2.3121383245545765e+227) {
		tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - (b * (y / t_1));
	} else {
		tmp = t_3;
	}
	return tmp;
}
public static 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);
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = y + (x + t);
	double t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
	double t_3 = (z + a) - b;
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_3;
	} else if (t_2 <= 2.3121383245545765e+227) {
		tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - (b * (y / t_1));
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
def code(x, y, z, t, a, b):
	t_1 = y + (x + t)
	t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1
	t_3 = (z + a) - b
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_3
	elif t_2 <= 2.3121383245545765e+227:
		tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - (b * (y / t_1))
	else:
		tmp = t_3
	return tmp
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y))
end
function code(x, y, z, t, a, b)
	t_1 = Float64(y + Float64(x + t))
	t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(y + t) * a)) - Float64(y * b)) / t_1)
	t_3 = Float64(Float64(z + a) - b)
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_3;
	elseif (t_2 <= 2.3121383245545765e+227)
		tmp = Float64(Float64(Float64(Float64(y * z) / t_1) + Float64(Float64(Float64(x * z) / t_1) + Float64(Float64(Float64(t * a) / t_1) + Float64(Float64(y * a) / t_1)))) - Float64(b * Float64(y / t_1)));
	else
		tmp = t_3;
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = y + (x + t);
	t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
	t_3 = (z + a) - b;
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_3;
	elseif (t_2 <= 2.3121383245545765e+227)
		tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - (b * (y / t_1));
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$3, If[LessEqual[t$95$2, 2.3121383245545765e+227], N[(N[(N[(N[(y * z), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(N[(x * z), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(N[(t * a), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(y * a), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]
\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}
t_1 := y + \left(x + t\right)\\
t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{t_1}\\
t_3 := \left(z + a\right) - b\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 2.3121383245545765 \cdot 10^{+227}:\\
\;\;\;\;\left(\frac{y \cdot z}{t_1} + \left(\frac{x \cdot z}{t_1} + \left(\frac{t \cdot a}{t_1} + \frac{y \cdot a}{t_1}\right)\right)\right) - b \cdot \frac{y}{t_1}\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}

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.6
Target11.4
Herbie8.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} < -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 2 regimes
  2. if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 2.3121383245545765e227 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y))

    1. Initial program 61.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. Simplified61.2

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(x + y, z, t \cdot a\right)\right)}{x + \left(y + t\right)}} \]
    3. Taylor expanded in y around inf 18.0

      \[\leadsto \color{blue}{\left(a + z\right) - b} \]

    if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2.3121383245545765e227

    1. Initial program 0.3

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \]
    2. Simplified0.3

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(y, a - b, \mathsf{fma}\left(x + y, z, t \cdot a\right)\right)}{x + \left(y + t\right)}} \]
    3. Taylor expanded in a around 0 0.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{y + \left(x + t\right)} \leq -\infty:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;\frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{y + \left(x + t\right)} \leq 2.3121383245545765 \cdot 10^{+227}:\\ \;\;\;\;\left(\frac{y \cdot z}{y + \left(x + t\right)} + \left(\frac{x \cdot z}{y + \left(x + t\right)} + \left(\frac{t \cdot a}{y + \left(x + t\right)} + \frac{y \cdot a}{y + \left(x + t\right)}\right)\right)\right) - b \cdot \frac{y}{y + \left(x + t\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array} \]

Reproduce

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