Average Error: 22.9 → 5.1
Time: 12.6s
Precision: binary64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \]
\[\begin{array}{l} t_1 := \frac{t}{y - b}\\ t_2 := y + z \cdot \left(b - y\right)\\ t_3 := {\left(y - b\right)}^{2}\\ t_4 := \left(x \cdot y + z \cdot t\right) - z \cdot a\\ t_5 := {\left(b - y\right)}^{2}\\ t_6 := \frac{z \cdot \left(t - a\right) + x \cdot y}{t_2}\\ t_7 := \frac{a}{y - b}\\ t_8 := \frac{x}{y - b}\\ t_9 := \mathsf{fma}\left(z, b - y, y\right)\\ \mathbf{if}\;t_6 \leq -1 \cdot 10^{+305}:\\ \;\;\;\;t_7 - \mathsf{fma}\left(\frac{y}{z}, t_8, \mathsf{fma}\left(\frac{y}{z}, \frac{t}{t_3}, t_1\right)\right)\\ \mathbf{elif}\;t_6 \leq -4 \cdot 10^{-289}:\\ \;\;\;\;t_4 \cdot \frac{1}{t_9}\\ \mathbf{elif}\;t_6 \leq 0:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{b - y}, \frac{x}{z}, \mathsf{fma}\left(\frac{a}{t_5}, \frac{y}{z}, \frac{t}{b - y}\right)\right) - \mathsf{fma}\left(\frac{y}{t_5}, \frac{t}{z}, \frac{a}{b - y}\right)\\ \mathbf{elif}\;t_6 \leq 10^{+289}:\\ \;\;\;\;\frac{t_4}{t_9}\\ \mathbf{elif}\;t_6 \leq \infty:\\ \;\;\;\;x \cdot \frac{y}{t_2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, \frac{a}{t_3}, t_7\right) - \mathsf{fma}\left(\frac{y}{z}, t_8, \mathsf{fma}\left(\frac{y}{z}, t \cdot {\left(y - b\right)}^{-2}, t_1\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 (/ t (- y b)))
        (t_2 (+ y (* z (- b y))))
        (t_3 (pow (- y b) 2.0))
        (t_4 (- (+ (* x y) (* z t)) (* z a)))
        (t_5 (pow (- b y) 2.0))
        (t_6 (/ (+ (* z (- t a)) (* x y)) t_2))
        (t_7 (/ a (- y b)))
        (t_8 (/ x (- y b)))
        (t_9 (fma z (- b y) y)))
   (if (<= t_6 -1e+305)
     (- t_7 (fma (/ y z) t_8 (fma (/ y z) (/ t t_3) t_1)))
     (if (<= t_6 -4e-289)
       (* t_4 (/ 1.0 t_9))
       (if (<= t_6 0.0)
         (-
          (fma (/ y (- b y)) (/ x z) (fma (/ a t_5) (/ y z) (/ t (- b y))))
          (fma (/ y t_5) (/ t z) (/ a (- b y))))
         (if (<= t_6 1e+289)
           (/ t_4 t_9)
           (if (<= t_6 INFINITY)
             (* x (/ y t_2))
             (-
              (fma (/ y z) (/ a t_3) t_7)
              (fma
               (/ y z)
               t_8
               (fma (/ y z) (* t (pow (- y b) -2.0)) t_1))))))))))
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 = t / (y - b);
	double t_2 = y + (z * (b - y));
	double t_3 = pow((y - b), 2.0);
	double t_4 = ((x * y) + (z * t)) - (z * a);
	double t_5 = pow((b - y), 2.0);
	double t_6 = ((z * (t - a)) + (x * y)) / t_2;
	double t_7 = a / (y - b);
	double t_8 = x / (y - b);
	double t_9 = fma(z, (b - y), y);
	double tmp;
	if (t_6 <= -1e+305) {
		tmp = t_7 - fma((y / z), t_8, fma((y / z), (t / t_3), t_1));
	} else if (t_6 <= -4e-289) {
		tmp = t_4 * (1.0 / t_9);
	} else if (t_6 <= 0.0) {
		tmp = fma((y / (b - y)), (x / z), fma((a / t_5), (y / z), (t / (b - y)))) - fma((y / t_5), (t / z), (a / (b - y)));
	} else if (t_6 <= 1e+289) {
		tmp = t_4 / t_9;
	} else if (t_6 <= ((double) INFINITY)) {
		tmp = x * (y / t_2);
	} else {
		tmp = fma((y / z), (a / t_3), t_7) - fma((y / z), t_8, fma((y / z), (t * pow((y - b), -2.0)), t_1));
	}
	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(t / Float64(y - b))
	t_2 = Float64(y + Float64(z * Float64(b - y)))
	t_3 = Float64(y - b) ^ 2.0
	t_4 = Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(z * a))
	t_5 = Float64(b - y) ^ 2.0
	t_6 = Float64(Float64(Float64(z * Float64(t - a)) + Float64(x * y)) / t_2)
	t_7 = Float64(a / Float64(y - b))
	t_8 = Float64(x / Float64(y - b))
	t_9 = fma(z, Float64(b - y), y)
	tmp = 0.0
	if (t_6 <= -1e+305)
		tmp = Float64(t_7 - fma(Float64(y / z), t_8, fma(Float64(y / z), Float64(t / t_3), t_1)));
	elseif (t_6 <= -4e-289)
		tmp = Float64(t_4 * Float64(1.0 / t_9));
	elseif (t_6 <= 0.0)
		tmp = Float64(fma(Float64(y / Float64(b - y)), Float64(x / z), fma(Float64(a / t_5), Float64(y / z), Float64(t / Float64(b - y)))) - fma(Float64(y / t_5), Float64(t / z), Float64(a / Float64(b - y))));
	elseif (t_6 <= 1e+289)
		tmp = Float64(t_4 / t_9);
	elseif (t_6 <= Inf)
		tmp = Float64(x * Float64(y / t_2));
	else
		tmp = Float64(fma(Float64(y / z), Float64(a / t_3), t_7) - fma(Float64(y / z), t_8, fma(Float64(y / z), Float64(t * (Float64(y - b) ^ -2.0)), t_1)));
	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[(t / N[(y - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(y - b), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(z * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Power[N[(b - y), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$6 = N[(N[(N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]}, Block[{t$95$7 = N[(a / N[(y - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$8 = N[(x / N[(y - b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$9 = N[(z * N[(b - y), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[t$95$6, -1e+305], N[(t$95$7 - N[(N[(y / z), $MachinePrecision] * t$95$8 + N[(N[(y / z), $MachinePrecision] * N[(t / t$95$3), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, -4e-289], N[(t$95$4 * N[(1.0 / t$95$9), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 0.0], N[(N[(N[(y / N[(b - y), $MachinePrecision]), $MachinePrecision] * N[(x / z), $MachinePrecision] + N[(N[(a / t$95$5), $MachinePrecision] * N[(y / z), $MachinePrecision] + N[(t / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y / t$95$5), $MachinePrecision] * N[(t / z), $MachinePrecision] + N[(a / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 1e+289], N[(t$95$4 / t$95$9), $MachinePrecision], If[LessEqual[t$95$6, Infinity], N[(x * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] * N[(a / t$95$3), $MachinePrecision] + t$95$7), $MachinePrecision] - N[(N[(y / z), $MachinePrecision] * t$95$8 + N[(N[(y / z), $MachinePrecision] * N[(t * N[Power[N[(y - b), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $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 := \frac{t}{y - b}\\
t_2 := y + z \cdot \left(b - y\right)\\
t_3 := {\left(y - b\right)}^{2}\\
t_4 := \left(x \cdot y + z \cdot t\right) - z \cdot a\\
t_5 := {\left(b - y\right)}^{2}\\
t_6 := \frac{z \cdot \left(t - a\right) + x \cdot y}{t_2}\\
t_7 := \frac{a}{y - b}\\
t_8 := \frac{x}{y - b}\\
t_9 := \mathsf{fma}\left(z, b - y, y\right)\\
\mathbf{if}\;t_6 \leq -1 \cdot 10^{+305}:\\
\;\;\;\;t_7 - \mathsf{fma}\left(\frac{y}{z}, t_8, \mathsf{fma}\left(\frac{y}{z}, \frac{t}{t_3}, t_1\right)\right)\\

\mathbf{elif}\;t_6 \leq -4 \cdot 10^{-289}:\\
\;\;\;\;t_4 \cdot \frac{1}{t_9}\\

\mathbf{elif}\;t_6 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{b - y}, \frac{x}{z}, \mathsf{fma}\left(\frac{a}{t_5}, \frac{y}{z}, \frac{t}{b - y}\right)\right) - \mathsf{fma}\left(\frac{y}{t_5}, \frac{t}{z}, \frac{a}{b - y}\right)\\

\mathbf{elif}\;t_6 \leq 10^{+289}:\\
\;\;\;\;\frac{t_4}{t_9}\\

\mathbf{elif}\;t_6 \leq \infty:\\
\;\;\;\;x \cdot \frac{y}{t_2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, \frac{a}{t_3}, t_7\right) - \mathsf{fma}\left(\frac{y}{z}, t_8, \mathsf{fma}\left(\frac{y}{z}, t \cdot {\left(y - b\right)}^{-2}, t_1\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

Original22.9
Target17.8
Herbie5.1
\[\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 6 regimes
  2. if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -9.9999999999999994e304

    1. Initial program 63.5

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

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

      \[\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. Simplified31.5

      \[\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)} \]
    5. Taylor expanded in z around inf 29.4

      \[\leadsto \color{blue}{\frac{a}{y - b}} - \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) \]

    if -9.9999999999999994e304 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -4e-289

    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(z, t - a, x \cdot y\right)}{\mathsf{fma}\left(z, b - y, y\right)}} \]
    3. Applied egg-rr0.4

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

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

    if -4e-289 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -0.0

    1. Initial program 47.1

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

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

      \[\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. Simplified3.5

      \[\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 -0.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 1.0000000000000001e289

    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(z, t - a, x \cdot y\right)}{\mathsf{fma}\left(z, b - y, y\right)}} \]
    3. Taylor expanded in z around 0 0.3

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

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

    1. Initial program 60.6

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

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

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

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

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

    1. Initial program 64.0

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

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

      \[\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. Simplified0.1

      \[\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)} \]
    5. Applied egg-rr0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{z \cdot \left(t - a\right) + x \cdot y}{y + z \cdot \left(b - y\right)} \leq -1 \cdot 10^{+305}:\\ \;\;\;\;\frac{a}{y - b} - \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)\\ \mathbf{elif}\;\frac{z \cdot \left(t - a\right) + x \cdot y}{y + z \cdot \left(b - y\right)} \leq -4 \cdot 10^{-289}:\\ \;\;\;\;\left(\left(x \cdot y + z \cdot t\right) - z \cdot a\right) \cdot \frac{1}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{elif}\;\frac{z \cdot \left(t - a\right) + x \cdot y}{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{z \cdot \left(t - a\right) + x \cdot y}{y + z \cdot \left(b - y\right)} \leq 10^{+289}:\\ \;\;\;\;\frac{\left(x \cdot y + z \cdot t\right) - z \cdot a}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{elif}\;\frac{z \cdot \left(t - a\right) + x \cdot y}{y + z \cdot \left(b - y\right)} \leq \infty:\\ \;\;\;\;x \cdot \frac{y}{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}, t \cdot {\left(y - b\right)}^{-2}, \frac{t}{y - b}\right)\right)\\ \end{array} \]

Reproduce

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