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

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+199}:\\
\;\;\;\;t_4 + \frac{t_1 - y \cdot b}{t_2}\\

\mathbf{else}:\\
\;\;\;\;\left(z + a\right) - b\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.7
Target11.4
Herbie8.2
\[\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 3 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

    1. Initial program 64.0

      \[\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 z around inf 64.0

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

      \[\leadsto \color{blue}{\frac{a \cdot \left(y + t\right) - y \cdot b}{y + \left(t + x\right)} + \frac{z}{\frac{y + \left(t + x\right)}{y + x}}} \]
      Proof
      (+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (/.f64 z (/.f64 (+.f64 y (+.f64 t x)) (+.f64 y x)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z (+.f64 y x)) (+.f64 y (+.f64 t x))))): 37 points increase in error, 5 points decrease in error
      (+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 y x) z)) (+.f64 y (+.f64 t x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (Rewrite=> div-sub_binary64 (-.f64 (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x)))))): 2 points increase in error, 1 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x)))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error
    4. Taylor expanded in t around inf 17.1

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

    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.00000000000000019e199

    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. Taylor expanded in z around inf 0.3

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

      \[\leadsto \color{blue}{\frac{a \cdot \left(y + t\right) - y \cdot b}{y + \left(t + x\right)} + \frac{z}{\frac{y + \left(t + x\right)}{y + x}}} \]
      Proof
      (+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (/.f64 z (/.f64 (+.f64 y (+.f64 t x)) (+.f64 y x)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z (+.f64 y x)) (+.f64 y (+.f64 t x))))): 37 points increase in error, 5 points decrease in error
      (+.f64 (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 y x) z)) (+.f64 y (+.f64 t x)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (-.f64 (*.f64 a (+.f64 y t)) (*.f64 y b)) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (Rewrite=> div-sub_binary64 (-.f64 (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x)))))): 2 points increase in error, 1 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (/.f64 (*.f64 (+.f64 y x) z) (+.f64 y (+.f64 t x))) (/.f64 (*.f64 a (+.f64 y t)) (+.f64 y (+.f64 t x)))) (/.f64 (*.f64 y b) (+.f64 y (+.f64 t x))))): 0 points increase in error, 0 points decrease in error

    if 2.00000000000000019e199 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y))

    1. Initial program 56.1

      \[\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.2

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

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

Alternatives

Alternative 1
Error8.1
Cost4168
\[\begin{array}{l} t_1 := y + \left(x + t\right)\\ t_2 := \frac{\left(z \cdot \left(x + y\right) + a \cdot \left(y + t\right)\right) - y \cdot b}{t_1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;a + \frac{z}{\frac{t_1}{x + y}}\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+199}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array} \]
Alternative 2
Error28.1
Cost1632
\[\begin{array}{l} t_1 := z - y \cdot \frac{b}{x + y}\\ t_2 := y + \left(x + t\right)\\ t_3 := \frac{y + t}{\frac{t_2}{a}}\\ \mathbf{if}\;b \leq -2.3263194015726037 \cdot 10^{+226}:\\ \;\;\;\;\frac{-b}{\frac{t_2}{y}}\\ \mathbf{elif}\;b \leq -6.014881960433071 \cdot 10^{+185}:\\ \;\;\;\;z + a\\ \mathbf{elif}\;b \leq -1.4058382669458662 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -5.510064642156693 \cdot 10^{+57}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq -2.642076015819162 \cdot 10^{+36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -2.2832217786185752 \cdot 10^{-17}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 7.863212058714221 \cdot 10^{-199}:\\ \;\;\;\;\left(z + a\right) - b\\ \mathbf{elif}\;b \leq 1.1130175982118083 \cdot 10^{+27}:\\ \;\;\;\;a + z \cdot \frac{y}{y + t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.3
Cost1096
\[\begin{array}{l} t_1 := a + \frac{z}{\frac{y + \left(x + t\right)}{x + y}}\\ \mathbf{if}\;t \leq -1.5783194749149942 \cdot 10^{+77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.82987100547634 \cdot 10^{+72}:\\ \;\;\;\;z + \frac{y}{\frac{x + y}{a - b}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error17.3
Cost968
\[\begin{array}{l} t_1 := a + z \cdot \frac{y}{y + t}\\ \mathbf{if}\;t \leq -1.3715418520234542 \cdot 10^{+160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.919015797739138 \cdot 10^{+162}:\\ \;\;\;\;z + \frac{y}{\frac{x + y}{a - b}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error27.8
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -1.0219562218598174 \cdot 10^{-24}:\\ \;\;\;\;z + a\\ \mathbf{elif}\;t \leq 1.002543824153307 \cdot 10^{-102}:\\ \;\;\;\;z - y \cdot \frac{b}{x + y}\\ \mathbf{else}:\\ \;\;\;\;z + a\\ \end{array} \]
Alternative 6
Error25.8
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -9.92412508360816 \cdot 10^{+109}:\\ \;\;\;\;z - y \cdot \frac{b}{x + y}\\ \mathbf{elif}\;x \leq 5.179953766527592 \cdot 10^{-242}:\\ \;\;\;\;a + z \cdot \frac{y}{y + t}\\ \mathbf{else}:\\ \;\;\;\;\left(z + a\right) - b\\ \end{array} \]
Alternative 7
Error26.6
Cost584
\[\begin{array}{l} t_1 := \left(z + a\right) - b\\ \mathbf{if}\;y \leq -2.928431849429818 \cdot 10^{+82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.807531681655879 \cdot 10^{+129}:\\ \;\;\;\;z + a\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error35.5
Cost328
\[\begin{array}{l} \mathbf{if}\;z \leq -11334928133946884000:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 3.658642481475674 \cdot 10^{+97}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 9
Error30.5
Cost324
\[\begin{array}{l} \mathbf{if}\;x \leq -9.076024841318623 \cdot 10^{+117}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;z + a\\ \end{array} \]
Alternative 10
Error42.8
Cost64
\[z \]

Error

Reproduce

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