Average Error: 26.2 → 8.1
Time: 8.6s
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 := \left(y + t\right) \cdot a\\ t_2 := y + \left(x + t\right)\\ t_3 := \frac{\left(\left(x + y\right) \cdot z + t_1\right) - y \cdot b}{t_2}\\ t_4 := x + \left(y + t\right)\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;\frac{y \cdot z}{t_2} + \left(\frac{a}{\frac{y + t}{y}} + \left(\left(x \cdot \frac{z}{t_2} + t \cdot \frac{a}{x + t}\right) - b \cdot \frac{y}{t_2}\right)\right)\\ \mathbf{elif}\;t_3 \leq 4.0686503761068925 \cdot 10^{+289}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x + y, z, t_1\right)}{t_4} - \frac{y \cdot b}{t_4}\\ \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) a))
        (t_2 (+ y (+ x t)))
        (t_3 (/ (- (+ (* (+ x y) z) t_1) (* y b)) t_2))
        (t_4 (+ x (+ y t))))
   (if (<= t_3 (- INFINITY))
     (+
      (/ (* y z) t_2)
      (+
       (/ a (/ (+ y t) y))
       (- (+ (* x (/ z t_2)) (* t (/ a (+ x t)))) (* b (/ y t_2)))))
     (if (<= t_3 4.0686503761068925e+289)
       (- (/ (fma (+ x y) z t_1) t_4) (/ (* y b) t_4))
       (- (+ 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) * a;
	double t_2 = y + (x + t);
	double t_3 = ((((x + y) * z) + t_1) - (y * b)) / t_2;
	double t_4 = x + (y + t);
	double tmp;
	if (t_3 <= -((double) INFINITY)) {
		tmp = ((y * z) / t_2) + ((a / ((y + t) / y)) + (((x * (z / t_2)) + (t * (a / (x + t)))) - (b * (y / t_2))));
	} else if (t_3 <= 4.0686503761068925e+289) {
		tmp = (fma((x + y), z, t_1) / t_4) - ((y * b) / t_4);
	} 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(Float64(y + t) * a)
	t_2 = Float64(y + Float64(x + t))
	t_3 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + t_1) - Float64(y * b)) / t_2)
	t_4 = Float64(x + Float64(y + t))
	tmp = 0.0
	if (t_3 <= Float64(-Inf))
		tmp = Float64(Float64(Float64(y * z) / t_2) + Float64(Float64(a / Float64(Float64(y + t) / y)) + Float64(Float64(Float64(x * Float64(z / t_2)) + Float64(t * Float64(a / Float64(x + t)))) - Float64(b * Float64(y / t_2)))));
	elseif (t_3 <= 4.0686503761068925e+289)
		tmp = Float64(Float64(fma(Float64(x + y), z, t_1) / t_4) - Float64(Float64(y * b) / t_4));
	else
		tmp = Float64(Float64(z + a) - b);
	end
	return 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[(y + t), $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$2 = N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(x + N[(y + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(N[(y * z), $MachinePrecision] / t$95$2), $MachinePrecision] + N[(N[(a / N[(N[(y + t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x * N[(z / t$95$2), $MachinePrecision]), $MachinePrecision] + N[(t * N[(a / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 4.0686503761068925e+289], N[(N[(N[(N[(x + y), $MachinePrecision] * z + t$95$1), $MachinePrecision] / t$95$4), $MachinePrecision] - N[(N[(y * b), $MachinePrecision] / t$95$4), $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 := \left(y + t\right) \cdot a\\
t_2 := y + \left(x + t\right)\\
t_3 := \frac{\left(\left(x + y\right) \cdot z + t_1\right) - y \cdot b}{t_2}\\
t_4 := x + \left(y + t\right)\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{y \cdot z}{t_2} + \left(\frac{a}{\frac{y + t}{y}} + \left(\left(x \cdot \frac{z}{t_2} + t \cdot \frac{a}{x + t}\right) - b \cdot \frac{y}{t_2}\right)\right)\\

\mathbf{elif}\;t_3 \leq 4.0686503761068925 \cdot 10^{+289}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x + y, z, t_1\right)}{t_4} - \frac{y \cdot b}{t_4}\\

\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

Target

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

      \[\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)}} \]
    3. Simplified41.0

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

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

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

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

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

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

    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. Applied egg-rr0.3

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

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

    1. Initial program 63.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 y around inf 17.5

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

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

Reproduce

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