Average Error: 26.4 → 6.0
Time: 1.4min
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(t + x\right)\\ t_2 := \frac{y}{t_1}\\ \mathbf{if}\;y \leq -1 \cdot 10^{+49}:\\ \;\;\;\;\left(x \cdot \frac{z}{t_1} + \left(t_2 \cdot a + \frac{t \cdot a}{t_1}\right)\right) + \left(z \cdot t_2 - t_2 \cdot b\right)\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{+133}:\\ \;\;\;\;\frac{y}{\frac{t_1}{z}} + \left(\left(\left(\frac{y \cdot a}{t_1} + \frac{z}{\frac{t_1}{x}}\right) + \frac{a}{\frac{t_1}{t}}\right) - \frac{y}{\frac{t_1}{b}}\right)\\ \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 (+ y (+ t x))) (t_2 (/ y t_1)))
   (if (<= y -1e+49)
     (+
      (+ (* x (/ z t_1)) (+ (* t_2 a) (/ (* t a) t_1)))
      (- (* z t_2) (* t_2 b)))
     (if (<= y 3.7e+133)
       (+
        (/ y (/ t_1 z))
        (-
         (+ (+ (/ (* y a) t_1) (/ z (/ t_1 x))) (/ a (/ t_1 t)))
         (/ y (/ t_1 b))))
       (- (+ 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 = y + (t + x);
	double t_2 = y / t_1;
	double tmp;
	if (y <= -1e+49) {
		tmp = ((x * (z / t_1)) + ((t_2 * a) + ((t * a) / t_1))) + ((z * t_2) - (t_2 * b));
	} else if (y <= 3.7e+133) {
		tmp = (y / (t_1 / z)) + (((((y * a) / t_1) + (z / (t_1 / x))) + (a / (t_1 / t))) - (y / (t_1 / b)));
	} else {
		tmp = (z + a) - b;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
end function
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = y + (t + x)
    t_2 = y / t_1
    if (y <= (-1d+49)) then
        tmp = ((x * (z / t_1)) + ((t_2 * a) + ((t * a) / t_1))) + ((z * t_2) - (t_2 * b))
    else if (y <= 3.7d+133) then
        tmp = (y / (t_1 / z)) + (((((y * a) / t_1) + (z / (t_1 / x))) + (a / (t_1 / t))) - (y / (t_1 / b)))
    else
        tmp = (z + a) - b
    end if
    code = tmp
end function
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 + (t + x);
	double t_2 = y / t_1;
	double tmp;
	if (y <= -1e+49) {
		tmp = ((x * (z / t_1)) + ((t_2 * a) + ((t * a) / t_1))) + ((z * t_2) - (t_2 * b));
	} else if (y <= 3.7e+133) {
		tmp = (y / (t_1 / z)) + (((((y * a) / t_1) + (z / (t_1 / x))) + (a / (t_1 / t))) - (y / (t_1 / b)));
	} 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 = y + (t + x)
	t_2 = y / t_1
	tmp = 0
	if y <= -1e+49:
		tmp = ((x * (z / t_1)) + ((t_2 * a) + ((t * a) / t_1))) + ((z * t_2) - (t_2 * b))
	elif y <= 3.7e+133:
		tmp = (y / (t_1 / z)) + (((((y * a) / t_1) + (z / (t_1 / x))) + (a / (t_1 / t))) - (y / (t_1 / b)))
	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(y + Float64(t + x))
	t_2 = Float64(y / t_1)
	tmp = 0.0
	if (y <= -1e+49)
		tmp = Float64(Float64(Float64(x * Float64(z / t_1)) + Float64(Float64(t_2 * a) + Float64(Float64(t * a) / t_1))) + Float64(Float64(z * t_2) - Float64(t_2 * b)));
	elseif (y <= 3.7e+133)
		tmp = Float64(Float64(y / Float64(t_1 / z)) + Float64(Float64(Float64(Float64(Float64(y * a) / t_1) + Float64(z / Float64(t_1 / x))) + Float64(a / Float64(t_1 / t))) - Float64(y / Float64(t_1 / b))));
	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 = y + (t + x);
	t_2 = y / t_1;
	tmp = 0.0;
	if (y <= -1e+49)
		tmp = ((x * (z / t_1)) + ((t_2 * a) + ((t * a) / t_1))) + ((z * t_2) - (t_2 * b));
	elseif (y <= 3.7e+133)
		tmp = (y / (t_1 / z)) + (((((y * a) / t_1) + (z / (t_1 / x))) + (a / (t_1 / t))) - (y / (t_1 / b)));
	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[(y + N[(t + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / t$95$1), $MachinePrecision]}, If[LessEqual[y, -1e+49], N[(N[(N[(x * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$2 * a), $MachinePrecision] + N[(N[(t * a), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(z * t$95$2), $MachinePrecision] - N[(t$95$2 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+133], N[(N[(y / N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(y * a), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(z / N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(a / N[(t$95$1 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y / N[(t$95$1 / b), $MachinePrecision]), $MachinePrecision]), $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 := y + \left(t + x\right)\\
t_2 := \frac{y}{t_1}\\
\mathbf{if}\;y \leq -1 \cdot 10^{+49}:\\
\;\;\;\;\left(x \cdot \frac{z}{t_1} + \left(t_2 \cdot a + \frac{t \cdot a}{t_1}\right)\right) + \left(z \cdot t_2 - t_2 \cdot b\right)\\

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

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


\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.4
Target11.2
Herbie6.0
\[\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 y < -9.99999999999999946e48

    1. Initial program 41.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. Applied egg-rr41.6

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

      \[\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{y \cdot a}{y + \left(t + x\right)} + \frac{a \cdot t}{y + \left(t + x\right)}\right)\right)\right) - \frac{y \cdot b}{y + \left(t + x\right)}} \]
    4. Simplified8.8

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

    if -9.99999999999999946e48 < y < 3.70000000000000023e133

    1. Initial program 16.7

      \[\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y} \]
    2. Applied egg-rr16.8

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

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

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

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

    if 3.70000000000000023e133 < y

    1. Initial program 47.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 in y around inf 11.7

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

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

Reproduce

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