Average Error: 7.6 → 1.6
Time: 16.4s
Precision: binary64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -1.1130146121076096 \cdot 10^{+286}:\\ \;\;\;\;\left(\frac{x}{x + 1} + \frac{y}{t \cdot \left(x + 1\right)}\right) - \frac{x}{z \cdot \left(t \cdot \left(x + 1\right)\right)}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -0.0023831738495721276:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x \cdot x - 1} \cdot \left(x - 1\right)\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 2.5040233921767497 \cdot 10^{-08} \lor \neg \left(\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 7.6995530812136 \cdot 10^{+279}\right):\\ \;\;\;\;\left(\frac{x}{x + 1} + \frac{y}{t \cdot \left(x + 1\right)}\right) - \frac{x}{z \cdot \left(t \cdot \left(x + 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(\frac{y \cdot z}{z \cdot t - x} - \frac{x}{z \cdot t - x}\right)}{x + 1}\\ \end{array}\]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
\mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -1.1130146121076096 \cdot 10^{+286}:\\
\;\;\;\;\left(\frac{x}{x + 1} + \frac{y}{t \cdot \left(x + 1\right)}\right) - \frac{x}{z \cdot \left(t \cdot \left(x + 1\right)\right)}\\

\mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -0.0023831738495721276:\\
\;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x \cdot x - 1} \cdot \left(x - 1\right)\\

\mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 2.5040233921767497 \cdot 10^{-08} \lor \neg \left(\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 7.6995530812136 \cdot 10^{+279}\right):\\
\;\;\;\;\left(\frac{x}{x + 1} + \frac{y}{t \cdot \left(x + 1\right)}\right) - \frac{x}{z \cdot \left(t \cdot \left(x + 1\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + \left(\frac{y \cdot z}{z \cdot t - x} - \frac{x}{z \cdot t - x}\right)}{x + 1}\\

\end{array}
(FPCore (x y z t)
 :precision binary64
 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))
(FPCore (x y z t)
 :precision binary64
 (if (<=
      (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))
      -1.1130146121076096e+286)
   (- (+ (/ x (+ x 1.0)) (/ y (* t (+ x 1.0)))) (/ x (* z (* t (+ x 1.0)))))
   (if (<=
        (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))
        -0.0023831738495721276)
     (* (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (- (* x x) 1.0)) (- x 1.0))
     (if (or (<=
              (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))
              2.5040233921767497e-08)
             (not
              (<=
               (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))
               7.6995530812136e+279)))
       (-
        (+ (/ x (+ x 1.0)) (/ y (* t (+ x 1.0))))
        (/ x (* z (* t (+ x 1.0)))))
       (/
        (+ x (- (/ (* y z) (- (* z t) x)) (/ x (- (* z t) x))))
        (+ x 1.0))))))
double code(double x, double y, double z, double t) {
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (((x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)) <= -1.1130146121076096e+286) {
		tmp = ((x / (x + 1.0)) + (y / (t * (x + 1.0)))) - (x / (z * (t * (x + 1.0))));
	} else if (((x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)) <= -0.0023831738495721276) {
		tmp = ((x + (((y * z) - x) / ((z * t) - x))) / ((x * x) - 1.0)) * (x - 1.0);
	} else if ((((x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)) <= 2.5040233921767497e-08) || !(((x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)) <= 7.6995530812136e+279)) {
		tmp = ((x / (x + 1.0)) + (y / (t * (x + 1.0)))) - (x / (z * (t * (x + 1.0))));
	} else {
		tmp = (x + (((y * z) / ((z * t) - x)) - (x / ((z * t) - x)))) / (x + 1.0);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.6
Target0.3
Herbie1.6
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -1.11301461210760956e286 or -0.0023831738495721276 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 2.50402339217674974e-8 or 7.6995530812136002e279 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 24.2

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
    2. Taylor expanded around inf 4.9

      \[\leadsto \color{blue}{\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{t \cdot \left(\left(x + 1\right) \cdot z\right)}}\]
    3. Simplified4.9

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

    if -1.11301461210760956e286 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -0.0023831738495721276

    1. Initial program 0.4

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
    2. Using strategy rm
    3. Applied flip-+_binary64_177840.4

      \[\leadsto \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x - 1}}}\]
    4. Applied associate-/r/_binary64_177560.4

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

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

    if 2.50402339217674974e-8 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 7.6995530812136002e279

    1. Initial program 0.1

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
    2. Using strategy rm
    3. Applied div-sub_binary64_178150.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -1.1130146121076096 \cdot 10^{+286}:\\ \;\;\;\;\left(\frac{x}{x + 1} + \frac{y}{t \cdot \left(x + 1\right)}\right) - \frac{x}{z \cdot \left(t \cdot \left(x + 1\right)\right)}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -0.0023831738495721276:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x \cdot x - 1} \cdot \left(x - 1\right)\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 2.5040233921767497 \cdot 10^{-08} \lor \neg \left(\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 7.6995530812136 \cdot 10^{+279}\right):\\ \;\;\;\;\left(\frac{x}{x + 1} + \frac{y}{t \cdot \left(x + 1\right)}\right) - \frac{x}{z \cdot \left(t \cdot \left(x + 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(\frac{y \cdot z}{z \cdot t - x} - \frac{x}{z \cdot t - x}\right)}{x + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2021007 
(FPCore (x y z t)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, A"
  :precision binary64

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

  (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0)))