Average Error: 26.5 → 0.5
Time: 10.7s
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(x + t\right)\\ t_2 := \frac{\left(\left(x + y\right) \cdot z + a \cdot \left(y + t\right)\right) - y \cdot b}{t_1}\\ t_3 := \frac{a}{t_1}\\ t_4 := y \cdot t_3\\ t_5 := b \cdot \frac{y}{t_1}\\ t_6 := \left(x + y\right) + t\\ t_7 := \sqrt[3]{\frac{z}{t_6}}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_7 \cdot \left(y \cdot {t_7}^{2}\right) + \left(\left(x \cdot \frac{z}{t_1} + \left(\frac{a}{\frac{t_6}{t}} + t_4\right)\right) - t_5\right)\\ \mathbf{elif}\;t_2 \leq 4.453220551121422 \cdot 10^{+271}:\\ \;\;\;\;\frac{\mathsf{fma}\left(t, a, \mathsf{fma}\left(y, \left(z + a\right) - b, x \cdot z\right)\right)}{x + \left(y + t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{t_1}{z}} + \left(\left(\frac{z}{\frac{t_6}{x}} + \left(t_4 + t \cdot t_3\right)\right) - t_5\right)\\ \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 (+ x t)))
        (t_2 (/ (- (+ (* (+ x y) z) (* a (+ y t))) (* y b)) t_1))
        (t_3 (/ a t_1))
        (t_4 (* y t_3))
        (t_5 (* b (/ y t_1)))
        (t_6 (+ (+ x y) t))
        (t_7 (cbrt (/ z t_6))))
   (if (<= t_2 (- INFINITY))
     (+
      (* t_7 (* y (pow t_7 2.0)))
      (- (+ (* x (/ z t_1)) (+ (/ a (/ t_6 t)) t_4)) t_5))
     (if (<= t_2 4.453220551121422e+271)
       (/ (fma t a (fma y (- (+ z a) b) (* x z))) (+ x (+ y t)))
       (+ (/ y (/ t_1 z)) (- (+ (/ z (/ t_6 x)) (+ t_4 (* t t_3))) 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 = y + (x + t);
	double t_2 = ((((x + y) * z) + (a * (y + t))) - (y * b)) / t_1;
	double t_3 = a / t_1;
	double t_4 = y * t_3;
	double t_5 = b * (y / t_1);
	double t_6 = (x + y) + t;
	double t_7 = cbrt((z / t_6));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (t_7 * (y * pow(t_7, 2.0))) + (((x * (z / t_1)) + ((a / (t_6 / t)) + t_4)) - t_5);
	} else if (t_2 <= 4.453220551121422e+271) {
		tmp = fma(t, a, fma(y, ((z + a) - b), (x * z))) / (x + (y + t));
	} else {
		tmp = (y / (t_1 / z)) + (((z / (t_6 / x)) + (t_4 + (t * t_3))) - 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(y + Float64(x + t))
	t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(a * Float64(y + t))) - Float64(y * b)) / t_1)
	t_3 = Float64(a / t_1)
	t_4 = Float64(y * t_3)
	t_5 = Float64(b * Float64(y / t_1))
	t_6 = Float64(Float64(x + y) + t)
	t_7 = cbrt(Float64(z / t_6))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(Float64(t_7 * Float64(y * (t_7 ^ 2.0))) + Float64(Float64(Float64(x * Float64(z / t_1)) + Float64(Float64(a / Float64(t_6 / t)) + t_4)) - t_5));
	elseif (t_2 <= 4.453220551121422e+271)
		tmp = Float64(fma(t, a, fma(y, Float64(Float64(z + a) - b), Float64(x * z))) / Float64(x + Float64(y + t)));
	else
		tmp = Float64(Float64(y / Float64(t_1 / z)) + Float64(Float64(Float64(z / Float64(t_6 / x)) + Float64(t_4 + Float64(t * t_3))) - t_5));
	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[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(a * N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(a / t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(y * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(b * N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[(x + y), $MachinePrecision] + t), $MachinePrecision]}, Block[{t$95$7 = N[Power[N[(z / t$95$6), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(t$95$7 * N[(y * N[Power[t$95$7, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(a / N[(t$95$6 / t), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision] - t$95$5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4.453220551121422e+271], N[(N[(t * a + N[(y * N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(z / N[(t$95$6 / x), $MachinePrecision]), $MachinePrecision] + N[(t$95$4 + N[(t * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$5), $MachinePrecision]), $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(x + t\right)\\
t_2 := \frac{\left(\left(x + y\right) \cdot z + a \cdot \left(y + t\right)\right) - y \cdot b}{t_1}\\
t_3 := \frac{a}{t_1}\\
t_4 := y \cdot t_3\\
t_5 := b \cdot \frac{y}{t_1}\\
t_6 := \left(x + y\right) + t\\
t_7 := \sqrt[3]{\frac{z}{t_6}}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_7 \cdot \left(y \cdot {t_7}^{2}\right) + \left(\left(x \cdot \frac{z}{t_1} + \left(\frac{a}{\frac{t_6}{t}} + t_4\right)\right) - t_5\right)\\

\mathbf{elif}\;t_2 \leq 4.453220551121422 \cdot 10^{+271}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t, a, \mathsf{fma}\left(y, \left(z + a\right) - b, x \cdot z\right)\right)}{x + \left(y + t\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{t_1}{z}} + \left(\left(\frac{z}{\frac{t_6}{x}} + \left(t_4 + t \cdot t_3\right)\right) - t_5\right)\\


\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.5
Target11.9
Herbie0.5
\[\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. Simplified64.0

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

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

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

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

      \[\leadsto \left(y \cdot {\left(\sqrt[3]{\frac{z}{\left(y + x\right) + t}}\right)}^{2}\right) \cdot \sqrt[3]{\frac{z}{\left(y + x\right) + t}} + \left(\left(\frac{z}{y + \left(x + t\right)} \cdot x + \left(\color{blue}{\frac{a}{\frac{\left(y + x\right) + t}{t}}} + \frac{a}{y + \left(x + t\right)} \cdot y\right)\right) - \frac{y}{y + \left(x + t\right)} \cdot b\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.45322055112142224e271

    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. Simplified0.3

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

    if 4.45322055112142224e271 < (/.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.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. Simplified62.2

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

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

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

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

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

Reproduce

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