Average Error: 7.6 → 2.5
Time: 13.7s
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 -9.9994706219759 \cdot 10^{+306}:\\ \;\;\;\;\frac{x}{x + 1} + \frac{\frac{y}{x + 1} - \frac{x}{z + x \cdot z}}{t}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 1.864267776294181 \cdot 10^{+223}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(\frac{y}{t} + \left(\frac{x}{t \cdot \left(z \cdot t\right)} \cdot \left(y - \frac{x}{z}\right) - \frac{x}{z \cdot t}\right)\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 -9.9994706219759 \cdot 10^{+306}:\\
\;\;\;\;\frac{x}{x + 1} + \frac{\frac{y}{x + 1} - \frac{x}{z + x \cdot z}}{t}\\

\mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 1.864267776294181 \cdot 10^{+223}:\\
\;\;\;\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + \left(\frac{y}{t} + \left(\frac{x}{t \cdot \left(z \cdot t\right)} \cdot \left(y - \frac{x}{z}\right) - \frac{x}{z \cdot t}\right)\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))
      -9.9994706219759e+306)
   (+ (/ x (+ x 1.0)) (/ (- (/ y (+ x 1.0)) (/ x (+ z (* x z)))) t))
   (if (<=
        (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))
        1.864267776294181e+223)
     (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))
     (/
      (+ x (+ (/ y t) (- (* (/ x (* t (* z t))) (- y (/ x z))) (/ x (* z 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 tmp;
	if (((x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)) <= -9.9994706219759e+306) {
		tmp = (x / (x + 1.0)) + (((y / (x + 1.0)) - (x / (z + (x * z)))) / t);
	} else if (((x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)) <= 1.864267776294181e+223) {
		tmp = (x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0);
	} else {
		tmp = (x + ((y / t) + (((x / (t * (z * t))) * (y - (x / z))) - (x / (z * 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.6
Target0.4
Herbie2.5
\[\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)) < -9.9994706219759e306

    1. Initial program 63.5

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

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

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

      \[\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)}}\]
    5. Simplified21.3

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

    if -9.9994706219759e306 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < 1.864267776294181e223

    1. Initial program 0.6

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

    if 1.864267776294181e223 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 56.6

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

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

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

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

Reproduce

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