Average Error: 7.3 → 2.6
Time: 10.9s
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 -\infty:\\ \;\;\;\;1 + \frac{z}{x} \cdot \left(\frac{t}{x} - \frac{y}{x}\right)\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 2.7344248573128045 \cdot 10^{+246}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1} + \frac{y \cdot z}{\left(z \cdot t - x\right) \cdot \left(x + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{t \cdot \left(z \cdot \left(x + 1\right)\right)}\\ \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 -\infty:\\
\;\;\;\;1 + \frac{z}{x} \cdot \left(\frac{t}{x} - \frac{y}{x}\right)\\

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

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

\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)) (- INFINITY))
   (+ 1.0 (* (/ z x) (- (/ t x) (/ y x))))
   (if (<=
        (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))
        2.7344248573128045e+246)
     (+
      (/ (- x (/ x (- (* z t) x))) (+ x 1.0))
      (/ (* y z) (* (- (* z t) x) (+ x 1.0))))
     (-
      (+ (/ y (* t (+ x 1.0))) (/ x (+ x 1.0)))
      (/ x (* t (* z (+ 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)) <= -((double) INFINITY)) {
		tmp = 1.0 + ((z / x) * ((t / x) - (y / x)));
	} else if (((x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)) <= 2.7344248573128045e+246) {
		tmp = ((x - (x / ((z * t) - x))) / (x + 1.0)) + ((y * z) / (((z * t) - x) * (x + 1.0)));
	} else {
		tmp = ((y / (t * (x + 1.0))) + (x / (x + 1.0))) - (x / (t * (z * (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.3
Target0.3
Herbie2.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)) < -inf.0

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\left(\frac{t \cdot z}{{x}^{2}} + 1\right) - \frac{z \cdot y}{{x}^{2}}}\]
    3. Simplified35.6

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

    if -inf.0 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 2.7344248573128045e246

    1. Initial program 0.8

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

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

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

    if 2.7344248573128045e246 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 57.5

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

      \[\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. Recombined 3 regimes into one program.
  4. Final simplification2.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -\infty:\\ \;\;\;\;1 + \frac{z}{x} \cdot \left(\frac{t}{x} - \frac{y}{x}\right)\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 2.7344248573128045 \cdot 10^{+246}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1} + \frac{y \cdot z}{\left(z \cdot t - x\right) \cdot \left(x + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{t \cdot \left(z \cdot \left(x + 1\right)\right)}\\ \end{array}\]

Reproduce

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