Average Error: 26.6 → 7.9
Time: 24.9s
Precision: binary64
Cost: 4168
\[\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 := \frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{y + \left(x + t\right)}\\ t_2 := \left(z + a\right) - b\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+265}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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 (/ (- (+ (* (+ x y) z) (* (+ y t) a)) (* y b)) (+ y (+ x t))))
        (t_2 (- (+ z a) b)))
   (if (<= t_1 (- INFINITY)) t_2 (if (<= t_1 2e+265) t_1 t_2))))
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 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / (y + (x + t));
	double t_2 = (z + a) - b;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_2;
	} else if (t_1 <= 2e+265) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / (y + (x + t));
	double t_2 = (z + a) - b;
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = t_2;
	} else if (t_1 <= 2e+265) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / (y + (x + t))
	t_2 = (z + a) - b
	tmp = 0
	if t_1 <= -math.inf:
		tmp = t_2
	elif t_1 <= 2e+265:
		tmp = t_1
	else:
		tmp = t_2
	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(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(y + t) * a)) - Float64(y * b)) / Float64(y + Float64(x + t)))
	t_2 = Float64(Float64(z + a) - b)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = t_2;
	elseif (t_1 <= 2e+265)
		tmp = t_1;
	else
		tmp = t_2;
	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 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / (y + (x + t));
	t_2 = (z + a) - b;
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = t_2;
	elseif (t_1 <= 2e+265)
		tmp = t_1;
	else
		tmp = t_2;
	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[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, 2e+265], t$95$1, t$95$2]]]]
\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 := \frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{y + \left(x + t\right)}\\
t_2 := \left(z + a\right) - b\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+265}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.6
Target11.6
Herbie7.9
\[\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.00000000000000013e265 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y))

    1. Initial program 62.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. Taylor expanded in y around inf 18.3

      \[\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.00000000000000013e265

    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} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.9

    \[\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 \cdot 10^{+265}:\\ \;\;\;\;\frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{y + \left(x + t\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array} \]

Alternatives

Alternative 1
Error18.0
Cost1872
\[\begin{array}{l} t_1 := x + \left(y + t\right)\\ t_2 := \frac{a}{\frac{y + \left(x + t\right)}{y + t}}\\ \mathbf{if}\;a \leq -5.165584876761538 \cdot 10^{+185}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -3.413222636486536 \cdot 10^{+145}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;a \leq -2.2722294335870315 \cdot 10^{-6}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 2.737854745205146 \cdot 10^{+99}:\\ \;\;\;\;\frac{z}{\frac{t_1}{x + y}} - b \cdot \frac{y}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error26.5
Cost1760
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := \left(z + a\right) - b\\ t_3 := z - \frac{b}{\frac{t_1}{y}}\\ t_4 := a + y \cdot \left(\frac{z}{t} - \frac{b}{t}\right)\\ \mathbf{if}\;t \leq -3.386635533550943 \cdot 10^{+181}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq -7.040431744883875 \cdot 10^{+91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.4325583970523464 \cdot 10^{-79}:\\ \;\;\;\;\frac{\left(y + t\right) \cdot a - y \cdot b}{t_1}\\ \mathbf{elif}\;t \leq -5.063280288209732 \cdot 10^{-214}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5.563960778783182 \cdot 10^{-279}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 6.4506071322825215 \cdot 10^{-99}:\\ \;\;\;\;\frac{\left(x + y\right) \cdot z + y \cdot \left(a - b\right)}{x + y}\\ \mathbf{elif}\;t \leq 1.8644303754555019 \cdot 10^{-28}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 6.3479541796143875 \cdot 10^{+162}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 3
Error24.9
Cost1628
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := \frac{a}{\frac{t_1}{y + t}}\\ \mathbf{if}\;a \leq -5.165584876761538 \cdot 10^{+185}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -3.413222636486536 \cdot 10^{+145}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;a \leq -2.2722294335870315 \cdot 10^{-6}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.6249174993372423 \cdot 10^{-33}:\\ \;\;\;\;z - \frac{b}{\frac{t_1}{y}}\\ \mathbf{elif}\;a \leq -9.189423167268964 \cdot 10^{-125}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.1059327485290067 \cdot 10^{-141}:\\ \;\;\;\;\frac{y}{\frac{y + t}{z - b}}\\ \mathbf{elif}\;a \leq 2.737854745205146 \cdot 10^{+99}:\\ \;\;\;\;z - b \cdot \frac{y}{x + \left(y + t\right)}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error24.9
Cost1496
\[\begin{array}{l} t_1 := \left(z + a\right) - b\\ t_2 := a + y \cdot \left(\frac{z}{t} - \frac{b}{t}\right)\\ t_3 := z - \frac{b}{\frac{y + \left(x + t\right)}{y}}\\ \mathbf{if}\;t \leq -3.386635533550943 \cdot 10^{+181}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5.063280288209732 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -5.563960778783182 \cdot 10^{-279}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 6.4506071322825215 \cdot 10^{-99}:\\ \;\;\;\;\frac{\left(x + y\right) \cdot z + y \cdot \left(a - b\right)}{x + y}\\ \mathbf{elif}\;t \leq 1.8644303754555019 \cdot 10^{-28}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 6.3479541796143875 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error27.7
Cost1368
\[\begin{array}{l} t_1 := a + \frac{y \cdot \left(z - b\right)}{t}\\ t_2 := \left(z + a\right) - b\\ \mathbf{if}\;y \leq -1.0663675074986367 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.1690666134572066 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6.146462715623689 \cdot 10^{-280}:\\ \;\;\;\;x \cdot \frac{z}{x + t}\\ \mathbf{elif}\;y \leq 7.393864601870037 \cdot 10^{-152}:\\ \;\;\;\;a \cdot \frac{t}{x + t}\\ \mathbf{elif}\;y \leq 2.5674782160930847 \cdot 10^{-93}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 7.1443872152869125 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error23.2
Cost1232
\[\begin{array}{l} t_1 := \left(z + a\right) - b\\ t_2 := a + y \cdot \left(\frac{z}{t} - \frac{b}{t}\right)\\ \mathbf{if}\;t \leq -3.386635533550943 \cdot 10^{+181}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5.063280288209732 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.8644303754555019 \cdot 10^{-28}:\\ \;\;\;\;z - \frac{b}{\frac{y + \left(x + t\right)}{y}}\\ \mathbf{elif}\;t \leq 6.3479541796143875 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error23.2
Cost1232
\[\begin{array}{l} t_1 := \left(z + a\right) - b\\ t_2 := a + y \cdot \left(\frac{z}{t} - \frac{b}{t}\right)\\ \mathbf{if}\;t \leq -3.386635533550943 \cdot 10^{+181}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5.063280288209732 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.8644303754555019 \cdot 10^{-28}:\\ \;\;\;\;z - b \cdot \frac{y}{x + \left(y + t\right)}\\ \mathbf{elif}\;t \leq 6.3479541796143875 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error36.1
Cost1116
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4624409022870438 \cdot 10^{+113}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 8.998260648836529 \cdot 10^{-272}:\\ \;\;\;\;a\\ \mathbf{elif}\;x \leq 1.7908752746267597 \cdot 10^{-235}:\\ \;\;\;\;z - b\\ \mathbf{elif}\;x \leq 1.1049033243516477 \cdot 10^{+23}:\\ \;\;\;\;a\\ \mathbf{elif}\;x \leq 2.0314387222890384 \cdot 10^{+60}:\\ \;\;\;\;z - b\\ \mathbf{elif}\;x \leq 2.223107330732618 \cdot 10^{+120}:\\ \;\;\;\;a\\ \mathbf{elif}\;x \leq 8.314130750744302 \cdot 10^{+163}:\\ \;\;\;\;z - b\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 9
Error28.1
Cost1108
\[\begin{array}{l} t_1 := \left(z + a\right) - b\\ \mathbf{if}\;y \leq -1.0663675074986367 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.393864601870037 \cdot 10^{-152}:\\ \;\;\;\;a \cdot \frac{t}{x + t}\\ \mathbf{elif}\;y \leq 2.5674782160930847 \cdot 10^{-93}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 7.671948669350393 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.5369221564575107 \cdot 10^{-34}:\\ \;\;\;\;\frac{y \cdot z}{y + t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error25.0
Cost1104
\[\begin{array}{l} t_1 := \left(z + a\right) - b\\ t_2 := a + \frac{y \cdot \left(z - b\right)}{t}\\ \mathbf{if}\;t \leq -1.9954221122396024 \cdot 10^{+186}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5.063280288209732 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.8644303754555019 \cdot 10^{-28}:\\ \;\;\;\;z - \frac{b}{\frac{y + \left(x + t\right)}{y}}\\ \mathbf{elif}\;t \leq 5.541141729505965 \cdot 10^{+171}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error29.1
Cost976
\[\begin{array}{l} t_1 := \left(z + a\right) - b\\ \mathbf{if}\;y \leq -1.0663675074986367 \cdot 10^{-42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -9.39228910852717 \cdot 10^{-102}:\\ \;\;\;\;t \cdot \frac{a}{x + t}\\ \mathbf{elif}\;y \leq -3.44935181060129 \cdot 10^{-250}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.5674782160930847 \cdot 10^{-93}:\\ \;\;\;\;z - b \cdot \frac{y}{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error26.8
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -1.9954221122396024 \cdot 10^{+186}:\\ \;\;\;\;a\\ \mathbf{elif}\;t \leq 5.541141729505965 \cdot 10^{+171}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 13
Error26.0
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.717893546901478 \cdot 10^{+155}:\\ \;\;\;\;z - b \cdot \frac{y}{x}\\ \mathbf{elif}\;x \leq 2.142045309796453 \cdot 10^{+181}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 14
Error35.9
Cost328
\[\begin{array}{l} \mathbf{if}\;t \leq -1.1423871181838777 \cdot 10^{-86}:\\ \;\;\;\;a\\ \mathbf{elif}\;t \leq 1.4072954451855146 \cdot 10^{-16}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 15
Error43.6
Cost64
\[a \]

Error

Reproduce

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