Average Error: 23.1 → 5.8
Time: 15.9s
Precision: binary64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \]
\[\begin{array}{l} t_1 := y + z \cdot \left(b - y\right)\\ t_2 := z \cdot \left(t - a\right)\\ t_3 := {\left(b - y\right)}^{2}\\ t_4 := {\left(y - b\right)}^{2}\\ t_5 := \frac{x \cdot y + t_2}{t_1}\\ t_6 := \mathsf{fma}\left(\frac{y}{b - y}, \frac{x}{z}, \mathsf{fma}\left(\frac{a}{t_3}, \frac{y}{z}, \frac{t}{b - y}\right)\right) - \mathsf{fma}\left(\frac{y}{t_3}, \frac{t}{z}, \frac{a}{b - y}\right)\\ \mathbf{if}\;t_5 \leq -\infty:\\ \;\;\;\;t_6\\ \mathbf{elif}\;t_5 \leq -2.5166664989718633 \cdot 10^{-276}:\\ \;\;\;\;\frac{\mathsf{fma}\left(y, x, t_2\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{elif}\;t_5 \leq 0:\\ \;\;\;\;t_6\\ \mathbf{elif}\;t_5 \leq 2.9498941135532944 \cdot 10^{+280}:\\ \;\;\;\;\frac{z \cdot t}{\left(y + z \cdot b\right) - y \cdot z} + \frac{x \cdot y - z \cdot a}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, \frac{a}{t_4}, \frac{a}{y - b}\right) - \mathsf{fma}\left(\frac{y}{z}, \frac{x}{y - b}, \mathsf{fma}\left(\frac{y}{z}, \frac{t}{t_4}, \frac{t}{y - b}\right)\right)\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ y (* z (- b y))))
        (t_2 (* z (- t a)))
        (t_3 (pow (- b y) 2.0))
        (t_4 (pow (- y b) 2.0))
        (t_5 (/ (+ (* x y) t_2) t_1))
        (t_6
         (-
          (fma (/ y (- b y)) (/ x z) (fma (/ a t_3) (/ y z) (/ t (- b y))))
          (fma (/ y t_3) (/ t z) (/ a (- b y))))))
   (if (<= t_5 (- INFINITY))
     t_6
     (if (<= t_5 -2.5166664989718633e-276)
       (/ (fma y x t_2) (fma z (- b y) y))
       (if (<= t_5 0.0)
         t_6
         (if (<= t_5 2.9498941135532944e+280)
           (+
            (/ (* z t) (- (+ y (* z b)) (* y z)))
            (/ (- (* x y) (* z a)) t_1))
           (-
            (fma (/ y z) (/ a t_4) (/ a (- y b)))
            (fma
             (/ y z)
             (/ x (- y b))
             (fma (/ y z) (/ t t_4) (/ t (- y b)))))))))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = y + (z * (b - y));
	double t_2 = z * (t - a);
	double t_3 = pow((b - y), 2.0);
	double t_4 = pow((y - b), 2.0);
	double t_5 = ((x * y) + t_2) / t_1;
	double t_6 = fma((y / (b - y)), (x / z), fma((a / t_3), (y / z), (t / (b - y)))) - fma((y / t_3), (t / z), (a / (b - y)));
	double tmp;
	if (t_5 <= -((double) INFINITY)) {
		tmp = t_6;
	} else if (t_5 <= -2.5166664989718633e-276) {
		tmp = fma(y, x, t_2) / fma(z, (b - y), y);
	} else if (t_5 <= 0.0) {
		tmp = t_6;
	} else if (t_5 <= 2.9498941135532944e+280) {
		tmp = ((z * t) / ((y + (z * b)) - (y * z))) + (((x * y) - (z * a)) / t_1);
	} else {
		tmp = fma((y / z), (a / t_4), (a / (y - b))) - fma((y / z), (x / (y - b)), fma((y / z), (t / t_4), (t / (y - b))));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y))))
end
function code(x, y, z, t, a, b)
	t_1 = Float64(y + Float64(z * Float64(b - y)))
	t_2 = Float64(z * Float64(t - a))
	t_3 = Float64(b - y) ^ 2.0
	t_4 = Float64(y - b) ^ 2.0
	t_5 = Float64(Float64(Float64(x * y) + t_2) / t_1)
	t_6 = Float64(fma(Float64(y / Float64(b - y)), Float64(x / z), fma(Float64(a / t_3), Float64(y / z), Float64(t / Float64(b - y)))) - fma(Float64(y / t_3), Float64(t / z), Float64(a / Float64(b - y))))
	tmp = 0.0
	if (t_5 <= Float64(-Inf))
		tmp = t_6;
	elseif (t_5 <= -2.5166664989718633e-276)
		tmp = Float64(fma(y, x, t_2) / fma(z, Float64(b - y), y));
	elseif (t_5 <= 0.0)
		tmp = t_6;
	elseif (t_5 <= 2.9498941135532944e+280)
		tmp = Float64(Float64(Float64(z * t) / Float64(Float64(y + Float64(z * b)) - Float64(y * z))) + Float64(Float64(Float64(x * y) - Float64(z * a)) / t_1));
	else
		tmp = Float64(fma(Float64(y / z), Float64(a / t_4), Float64(a / Float64(y - b))) - fma(Float64(y / z), Float64(x / Float64(y - b)), fma(Float64(y / z), Float64(t / t_4), Float64(t / Float64(y - b)))));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(b - y), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(y - b), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[(x * y), $MachinePrecision] + t$95$2), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$6 = N[(N[(N[(y / N[(b - y), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision] + N[(N[(a / t$95$3), $MachinePrecision] * N[(y / z), $MachinePrecision] + N[(t / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y / t$95$3), $MachinePrecision] * N[(t / z), $MachinePrecision] + N[(a / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, (-Infinity)], t$95$6, If[LessEqual[t$95$5, -2.5166664989718633e-276], N[(N[(y * x + t$95$2), $MachinePrecision] / N[(z * N[(b - y), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 0.0], t$95$6, If[LessEqual[t$95$5, 2.9498941135532944e+280], N[(N[(N[(z * t), $MachinePrecision] / N[(N[(y + N[(z * b), $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x * y), $MachinePrecision] - N[(z * a), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] * N[(a / t$95$4), $MachinePrecision] + N[(a / N[(y - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y / z), $MachinePrecision] * N[(x / N[(y - b), $MachinePrecision]), $MachinePrecision] + N[(N[(y / z), $MachinePrecision] * N[(t / t$95$4), $MachinePrecision] + N[(t / N[(y - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
t_1 := y + z \cdot \left(b - y\right)\\
t_2 := z \cdot \left(t - a\right)\\
t_3 := {\left(b - y\right)}^{2}\\
t_4 := {\left(y - b\right)}^{2}\\
t_5 := \frac{x \cdot y + t_2}{t_1}\\
t_6 := \mathsf{fma}\left(\frac{y}{b - y}, \frac{x}{z}, \mathsf{fma}\left(\frac{a}{t_3}, \frac{y}{z}, \frac{t}{b - y}\right)\right) - \mathsf{fma}\left(\frac{y}{t_3}, \frac{t}{z}, \frac{a}{b - y}\right)\\
\mathbf{if}\;t_5 \leq -\infty:\\
\;\;\;\;t_6\\

\mathbf{elif}\;t_5 \leq -2.5166664989718633 \cdot 10^{-276}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, t_2\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\

\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;t_6\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, \frac{a}{t_4}, \frac{a}{y - b}\right) - \mathsf{fma}\left(\frac{y}{z}, \frac{x}{y - b}, \mathsf{fma}\left(\frac{y}{z}, \frac{t}{t_4}, \frac{t}{y - b}\right)\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

Original23.1
Target18.0
Herbie5.8
\[\frac{z \cdot t + y \cdot x}{y + z \cdot \left(b - y\right)} - \frac{a}{\left(b - y\right) + \frac{y}{z}} \]

Derivation

  1. Split input into 4 regimes
  2. if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0 or -2.51666649897186327e-276 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0

    1. Initial program 53.5

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

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

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

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

    if -inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -2.51666649897186327e-276

    1. Initial program 0.4

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \]
    2. Simplified0.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right) \cdot \frac{1}{\mathsf{fma}\left(z, b - y, y\right)}} \]
    4. Applied *-un-lft-identity_binary640.5

      \[\leadsto \color{blue}{\left(1 \cdot \mathsf{fma}\left(x, y, z \cdot \left(t - a\right)\right)\right)} \cdot \frac{1}{\mathsf{fma}\left(z, b - y, y\right)} \]
    5. Applied associate-*l*_binary640.5

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

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

    if 0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 2.94989411355329437e280

    1. Initial program 0.3

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

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

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

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

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

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

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

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

    1. Initial program 62.3

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \]
    2. Simplified62.3

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, \frac{a}{{\left(y - b\right)}^{2}}, \frac{a}{y - b}\right) - \mathsf{fma}\left(\frac{y}{z}, \frac{x}{y - b}, \mathsf{fma}\left(\frac{y}{z}, \frac{t}{{\left(y - b\right)}^{2}}, \frac{t}{y - b}\right)\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification5.8

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

Reproduce

herbie shell --seed 2022131 
(FPCore (x y z t a b)
  :name "Development.Shake.Progress:decay from shake-0.15.5"
  :precision binary64

  :herbie-target
  (- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z))))

  (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))