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

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

\mathbf{else}:\\
\;\;\;\;t_5\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original26.1
Target10.9
Herbie2.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 7.99999999999999956e194 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y))

    1. Initial program 58.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. Taylor expanded in z around 0 42.0

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

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

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

      \[\leadsto \left(\left(\frac{x}{y + \left(t + x\right)} + \frac{y}{y + \left(t + x\right)}\right) \cdot z + a\right) - \color{blue}{\frac{y}{y + \left(t + x\right)} \cdot 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)) < 7.99999999999999956e194

    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 y around 0 0.3

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

Alternatives

Alternative 1
Error3.2
Cost4680
\[\begin{array}{l} t_1 := \left(x + t\right) + y\\ t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{t_1}\\ t_3 := y + \left(t + x\right)\\ t_4 := \left(\left(\frac{x}{t_3} + \frac{y}{t_3}\right) \cdot z + a\right) - \frac{b}{t_3} \cdot y\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_2 \leq 8 \cdot 10^{+194}:\\ \;\;\;\;\frac{z \cdot x + \left(y \cdot \left(\left(a + z\right) - b\right) + a \cdot t\right)}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 2
Error3.0
Cost4296
\[\begin{array}{l} t_1 := \left(x + t\right) + y\\ t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{t_1}\\ t_3 := y + \left(t + x\right)\\ t_4 := \left(z + \frac{a}{t_3} \cdot \left(y + t\right)\right) - \frac{b}{t_3} \cdot y\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_2 \leq 8 \cdot 10^{+194}:\\ \;\;\;\;\frac{z \cdot x + \left(y \cdot \left(\left(a + z\right) - b\right) + a \cdot t\right)}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 3
Error5.3
Cost4168
\[\begin{array}{l} t_1 := \left(x + t\right) + y\\ t_2 := \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{t_1}\\ t_3 := \left(z + a\right) - \frac{b}{y + \left(t + x\right)} \cdot y\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 8 \cdot 10^{+194}:\\ \;\;\;\;\frac{z \cdot x + \left(y \cdot \left(\left(a + z\right) - b\right) + a \cdot t\right)}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error18.3
Cost1744
\[\begin{array}{l} t_1 := y + \left(t + x\right)\\ t_2 := \left(z + \frac{a \cdot \left(y + t\right)}{t_1}\right) - \frac{b}{x} \cdot y\\ t_3 := \left(\frac{z \cdot x}{t + x} + a\right) - \frac{b}{t_1} \cdot y\\ \mathbf{if}\;x \leq -2.1 \cdot 10^{+133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1900000000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{+60}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+172}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error26.9
Cost1496
\[\begin{array}{l} t_1 := \left(a + z\right) - b\\ t_2 := \frac{t}{t + x} \cdot a\\ \mathbf{if}\;t \leq -5.8 \cdot 10^{+145}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{-245}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.4 \cdot 10^{-176}:\\ \;\;\;\;\left(\frac{a}{x} - \frac{z}{x}\right) \cdot t + z\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+201}:\\ \;\;\;\;\frac{z}{\left(x + t\right) + y} \cdot \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;a + \frac{z - a}{t} \cdot x\\ \end{array} \]
Alternative 6
Error17.2
Cost1352
\[\begin{array}{l} t_1 := \left(z + a\right) - \frac{b}{y + \left(t + x\right)} \cdot y\\ \mathbf{if}\;y \leq -6.2 \cdot 10^{-113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-66}:\\ \;\;\;\;\frac{a \cdot \left(y + t\right) + \left(y + x\right) \cdot z}{\left(x + t\right) + y}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error26.0
Cost1232
\[\begin{array}{l} t_1 := \frac{t}{t + x} \cdot a\\ \mathbf{if}\;t \leq -1.62 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{+67}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{+152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+201}:\\ \;\;\;\;\frac{z}{\left(x + t\right) + y} \cdot \left(y + x\right)\\ \mathbf{else}:\\ \;\;\;\;a + \frac{z - a}{t} \cdot x\\ \end{array} \]
Alternative 8
Error23.9
Cost1232
\[\begin{array}{l} t_1 := \left(a + z\right) - b\\ \mathbf{if}\;y \leq -4.1 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-124}:\\ \;\;\;\;\frac{x}{t + x} \cdot z\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-145}:\\ \;\;\;\;a\\ \mathbf{elif}\;y \leq 7.1 \cdot 10^{-93}:\\ \;\;\;\;\frac{z \cdot x + a \cdot t}{t + x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error25.9
Cost1104
\[\begin{array}{l} t_1 := \frac{t}{t + x} \cdot a\\ \mathbf{if}\;t \leq -1.55 \cdot 10^{+146}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.5 \cdot 10^{+67}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{elif}\;t \leq 2.6 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{+168}:\\ \;\;\;\;\frac{x}{t + x} \cdot z\\ \mathbf{else}:\\ \;\;\;\;a + \frac{z - a}{t} \cdot x\\ \end{array} \]
Alternative 10
Error18.6
Cost1096
\[\begin{array}{l} t_1 := \left(z + a\right) - \frac{b}{y + \left(t + x\right)} \cdot y\\ \mathbf{if}\;y \leq -9 \cdot 10^{-115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-92}:\\ \;\;\;\;\frac{z \cdot x + a \cdot t}{t + x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error26.9
Cost848
\[\begin{array}{l} t_1 := \left(a + z\right) - b\\ \mathbf{if}\;t \leq -1.5 \cdot 10^{+151}:\\ \;\;\;\;a\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.9 \cdot 10^{+181}:\\ \;\;\;\;\frac{a}{t + x} \cdot t\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{+200}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 12
Error27.5
Cost844
\[\begin{array}{l} t_1 := \left(a + z\right) - b\\ \mathbf{if}\;y \leq -2.65 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6.2 \cdot 10^{-242}:\\ \;\;\;\;\frac{x}{t + x} \cdot z\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-72}:\\ \;\;\;\;\frac{t}{t + x} \cdot a\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error26.2
Cost712
\[\begin{array}{l} t_1 := \frac{t}{t + x} \cdot a\\ \mathbf{if}\;t \leq -3.15 \cdot 10^{+146}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{+67}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error27.2
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -2.2 \cdot 10^{+155}:\\ \;\;\;\;a\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{+67}:\\ \;\;\;\;\left(a + z\right) - b\\ \mathbf{else}:\\ \;\;\;\;a\\ \end{array} \]
Alternative 15
Error35.7
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -7.6 \cdot 10^{-10}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 6.4 \cdot 10^{-27}:\\ \;\;\;\;a\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 16
Error43.3
Cost64
\[a \]

Error

Reproduce

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