Average Error: 23.9 → 6.4
Time: 23.7s
Precision: binary64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \]
\[\begin{array}{l} t_1 := z \cdot \left(t - a\right)\\ t_2 := \frac{x \cdot y + t_1}{y + z \cdot \left(b - y\right)}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;x\\ \mathbf{elif}\;t_2 \leq -2.2057944836670588 \cdot 10^{-269}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, t_1\right)}{\mathsf{fma}\left(z, b - y, y\right)}\\ \mathbf{elif}\;t_2 \leq 2.1560368786804746 \cdot 10^{-245}:\\ \;\;\;\;\begin{array}{l} t_3 := {\left(y - b\right)}^{2}\\ \mathsf{fma}\left(\frac{y}{z}, \frac{a}{t_3}, \frac{a}{y - b}\right) - \mathsf{fma}\left(\frac{y}{z}, \frac{x}{y - b}, \mathsf{fma}\left(\frac{y}{z}, \frac{t}{t_3}, \frac{t}{y - b}\right)\right) \end{array}\\ \mathbf{elif}\;t_2 \leq 7.965570100955554 \cdot 10^{+305}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_4 := {\left(b - y\right)}^{2}\\ \mathsf{fma}\left(\frac{y}{b - y}, \frac{x}{z}, \mathsf{fma}\left(\frac{a}{t_4}, \frac{y}{z}, \frac{t}{b - y}\right)\right) - \mathsf{fma}\left(\frac{y}{t_4}, \frac{t}{z}, \frac{a}{b - y}\right) \end{array}\\ \end{array} \]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
t_1 := z \cdot \left(t - a\right)\\
t_2 := \frac{x \cdot y + t_1}{y + z \cdot \left(b - y\right)}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;x\\

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

\mathbf{elif}\;t_2 \leq 2.1560368786804746 \cdot 10^{-245}:\\
\;\;\;\;\begin{array}{l}
t_3 := {\left(y - b\right)}^{2}\\
\mathsf{fma}\left(\frac{y}{z}, \frac{a}{t_3}, \frac{a}{y - b}\right) - \mathsf{fma}\left(\frac{y}{z}, \frac{x}{y - b}, \mathsf{fma}\left(\frac{y}{z}, \frac{t}{t_3}, \frac{t}{y - b}\right)\right)
\end{array}\\

\mathbf{elif}\;t_2 \leq 7.965570100955554 \cdot 10^{+305}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_4 := {\left(b - y\right)}^{2}\\
\mathsf{fma}\left(\frac{y}{b - y}, \frac{x}{z}, \mathsf{fma}\left(\frac{a}{t_4}, \frac{y}{z}, \frac{t}{b - y}\right)\right) - \mathsf{fma}\left(\frac{y}{t_4}, \frac{t}{z}, \frac{a}{b - y}\right)
\end{array}\\


\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 (* z (- t a))) (t_2 (/ (+ (* x y) t_1) (+ y (* z (- b y))))))
   (if (<= t_2 (- INFINITY))
     x
     (if (<= t_2 -2.2057944836670588e-269)
       (/ (fma x y t_1) (fma z (- b y) y))
       (if (<= t_2 2.1560368786804746e-245)
         (let* ((t_3 (pow (- y b) 2.0)))
           (-
            (fma (/ y z) (/ a t_3) (/ a (- y b)))
            (fma (/ y z) (/ x (- y b)) (fma (/ y z) (/ t t_3) (/ t (- y b))))))
         (if (<= t_2 7.965570100955554e+305)
           t_2
           (let* ((t_4 (pow (- b y) 2.0)))
             (-
              (fma (/ y (- b y)) (/ x z) (fma (/ a t_4) (/ y z) (/ t (- b y))))
              (fma (/ y t_4) (/ t z) (/ a (- b y)))))))))))
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 = z * (t - a);
	double t_2 = ((x * y) + t_1) / (y + (z * (b - y)));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = x;
	} else if (t_2 <= -2.2057944836670588e-269) {
		tmp = fma(x, y, t_1) / fma(z, (b - y), y);
	} else if (t_2 <= 2.1560368786804746e-245) {
		double t_3 = pow((y - b), 2.0);
		tmp = fma((y / z), (a / t_3), (a / (y - b))) - fma((y / z), (x / (y - b)), fma((y / z), (t / t_3), (t / (y - b))));
	} else if (t_2 <= 7.965570100955554e+305) {
		tmp = t_2;
	} else {
		double t_4 = pow((b - y), 2.0);
		tmp = fma((y / (b - y)), (x / z), fma((a / t_4), (y / z), (t / (b - y)))) - fma((y / t_4), (t / z), (a / (b - y)));
	}
	return tmp;
}

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.9
Target18.6
Herbie6.4
\[\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 5 regimes
  2. if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0

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

      \[\leadsto \color{blue}{x} \]

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

    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 *-un-lft-identity_binary640.3

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

    if -2.20579448366705878e-269 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 2.15603687868047463e-245

    1. Initial program 40.1

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

      \[\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 22.4

      \[\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. Simplified8.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)} \]

    if 2.15603687868047463e-245 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 7.965570100955554e305

    1. Initial program 0.3

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

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

    1. Initial program 63.8

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

      \[\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 40.6

      \[\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. Simplified10.3

      \[\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)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification6.4

    \[\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:\\ \;\;\;\;x\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq -2.2057944836670588 \cdot 10^{-269}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, y, 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 2.1560368786804746 \cdot 10^{-245}:\\ \;\;\;\;\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)\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq 7.965570100955554 \cdot 10^{+305}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\ \mathbf{else}:\\ \;\;\;\;\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)\\ \end{array} \]

Reproduce

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