Average Error: 7.4 → 0.6
Time: 7.8s
Precision: binary64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := z \cdot t - x\\ \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t_1}}{x + 1} \leq \infty:\\ \;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1} + \frac{z}{t_1} \cdot \frac{y}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := z \cdot t - x\\
\mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t_1}}{x + 1} \leq \infty:\\
\;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1} + \frac{z}{t_1} \cdot \frac{y}{x + 1}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{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
 (let* ((t_1 (- (* z t) x)))
   (if (<= (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0)) INFINITY)
     (+ (/ (- x (/ x t_1)) (+ x 1.0)) (* (/ z t_1) (/ y (+ x 1.0))))
     (/ (+ x (/ y t)) (+ 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 t_1 = (z * t) - x;
	double tmp;
	if (((x + (((y * z) - x) / t_1)) / (x + 1.0)) <= ((double) INFINITY)) {
		tmp = ((x - (x / t_1)) / (x + 1.0)) + ((z / t_1) * (y / (x + 1.0)));
	} else {
		tmp = (x + (y / t)) / (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.4
Target0.4
Herbie0.6
\[\frac{x + \left(\frac{y}{t - \frac{x}{z}} - \frac{x}{t \cdot z - x}\right)}{x + 1} \]

Derivation

  1. Split input into 2 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 5.0

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

      \[\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. Simplified5.0

      \[\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)}} \]
    4. Using strategy rm
    5. Applied times-frac_binary640.7

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

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

    1. Initial program 64.0

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

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

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

      \[\leadsto \frac{\left(-x\right) - \frac{z \cdot y - x}{t \cdot z - x}}{\color{blue}{-1 - x}} \]
    6. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\frac{\frac{y}{t} + x}{x + 1}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq \infty:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1} + \frac{z}{z \cdot t - x} \cdot \frac{y}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]

Reproduce

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