Average Error: 23.2 → 8.9
Time: 16.5s
Precision: binary64
\[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq -\infty:\\ \;\;\;\;\frac{x}{1 - z}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq -1.2518050200414045 \cdot 10^{-287}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{\left(y + z \cdot b\right) - y \cdot z}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq 0 \lor \neg \left(\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq 1.5989585898603193 \cdot 10^{+286}\right):\\ \;\;\;\;\frac{t - a}{b - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\ \end{array}\]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq -\infty:\\
\;\;\;\;\frac{x}{1 - z}\\

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

\mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq 0 \lor \neg \left(\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq 1.5989585898603193 \cdot 10^{+286}\right):\\
\;\;\;\;\frac{t - a}{b - y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\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
 (if (<= (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) (- INFINITY))
   (/ x (- 1.0 z))
   (if (<=
        (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y))))
        -1.2518050200414045e-287)
     (/ (+ (* x y) (* z (- t a))) (- (+ y (* z b)) (* y z)))
     (if (or (<= (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))) 0.0)
             (not
              (<=
               (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y))))
               1.5989585898603193e+286)))
       (/ (- t a) (- b y))
       (/ (+ (* x y) (* z (- t a))) (+ y (* z (- 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 tmp;
	if ((((x * y) + (z * (t - a))) / (y + (z * (b - y)))) <= -((double) INFINITY)) {
		tmp = x / (1.0 - z);
	} else if ((((x * y) + (z * (t - a))) / (y + (z * (b - y)))) <= -1.2518050200414045e-287) {
		tmp = ((x * y) + (z * (t - a))) / ((y + (z * b)) - (y * z));
	} else if (((((x * y) + (z * (t - a))) / (y + (z * (b - y)))) <= 0.0) || !((((x * y) + (z * (t - a))) / (y + (z * (b - y)))) <= 1.5989585898603193e+286)) {
		tmp = (t - a) / (b - y);
	} else {
		tmp = ((x * y) + (z * (t - a))) / (y + (z * (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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original23.2
Target17.7
Herbie8.9
\[\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

    1. Initial program 64.0

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
    2. Taylor expanded around inf 30.7

      \[\leadsto \color{blue}{\frac{x}{1 - z}}\]

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

    1. Initial program 0.3

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
    2. Using strategy rm
    3. Applied sub-neg_binary640.3

      \[\leadsto \frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \color{blue}{\left(b + \left(-y\right)\right)}}\]
    4. Applied distribute-rgt-in_binary640.3

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

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

      \[\leadsto \frac{x \cdot y + z \cdot \left(t - a\right)}{\color{blue}{\left(y + z \cdot b\right)} + \left(-y\right) \cdot z}\]
    7. Using strategy rm
    8. Applied distribute-lft-neg-out_binary640.3

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

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

    if -1.2518050200414045e-287 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 0.0 or 1.5989585898603193e286 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y))))

    1. Initial program 57.1

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
    2. Taylor expanded around inf 20.1

      \[\leadsto \color{blue}{\frac{t - a}{b - y}}\]

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

    1. Initial program 0.3

      \[\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary640.3

      \[\leadsto \frac{x \cdot y + z \cdot \left(t - a\right)}{\color{blue}{1 \cdot \left(y + z \cdot \left(b - y\right)\right)}}\]
    4. Applied add-cube-cbrt_binary641.4

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{x \cdot y + z \cdot \left(t - a\right)} \cdot \sqrt[3]{x \cdot y + z \cdot \left(t - a\right)}\right) \cdot \sqrt[3]{x \cdot y + z \cdot \left(t - a\right)}}}{1 \cdot \left(y + z \cdot \left(b - y\right)\right)}\]
    5. Applied times-frac_binary641.4

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x \cdot y + z \cdot \left(t - a\right)} \cdot \sqrt[3]{x \cdot y + z \cdot \left(t - a\right)}}{1} \cdot \frac{\sqrt[3]{x \cdot y + z \cdot \left(t - a\right)}}{y + z \cdot \left(b - y\right)}}\]
    6. Simplified1.4

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

      \[\leadsto \left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x} \cdot \sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}\right) \cdot \color{blue}{\frac{\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}}{y + z \cdot \left(b - y\right)}}\]
    8. Using strategy rm
    9. Applied pow1_binary641.4

      \[\leadsto \left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x} \cdot \sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}\right) \cdot \color{blue}{{\left(\frac{\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}}{y + z \cdot \left(b - y\right)}\right)}^{1}}\]
    10. Applied pow1_binary641.4

      \[\leadsto \left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x} \cdot \color{blue}{{\left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}\right)}^{1}}\right) \cdot {\left(\frac{\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}}{y + z \cdot \left(b - y\right)}\right)}^{1}\]
    11. Applied pow1_binary641.4

      \[\leadsto \left(\color{blue}{{\left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}\right)}^{1}} \cdot {\left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}\right)}^{1}\right) \cdot {\left(\frac{\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}}{y + z \cdot \left(b - y\right)}\right)}^{1}\]
    12. Applied pow-prod-down_binary641.4

      \[\leadsto \color{blue}{{\left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x} \cdot \sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}\right)}^{1}} \cdot {\left(\frac{\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}}{y + z \cdot \left(b - y\right)}\right)}^{1}\]
    13. Applied pow-prod-down_binary641.4

      \[\leadsto \color{blue}{{\left(\left(\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x} \cdot \sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}\right) \cdot \frac{\sqrt[3]{z \cdot \left(t - a\right) + y \cdot x}}{y + z \cdot \left(b - y\right)}\right)}^{1}}\]
    14. Simplified0.3

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

    \[\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:\\ \;\;\;\;\frac{x}{1 - z}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq -1.2518050200414045 \cdot 10^{-287}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{\left(y + z \cdot b\right) - y \cdot z}\\ \mathbf{elif}\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq 0 \lor \neg \left(\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)} \leq 1.5989585898603193 \cdot 10^{+286}\right):\\ \;\;\;\;\frac{t - a}{b - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}\\ \end{array}\]

Alternatives

Reproduce

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