Average Error: 7.1 → 3.4
Time: 3.5s
Precision: 64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.9414234727317655 \cdot 10^{118}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{elif}\;z \le 1.5589187164770912 \cdot 10^{-160}:\\ \;\;\;\;\frac{1}{\frac{x + 1}{x + \left(y \cdot z - x\right) \cdot \frac{1}{t \cdot z - x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right) - \frac{-x}{\mathsf{fma}\left(-z, 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}\;z \le -1.9414234727317655 \cdot 10^{118}:\\
\;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\

\mathbf{elif}\;z \le 1.5589187164770912 \cdot 10^{-160}:\\
\;\;\;\;\frac{1}{\frac{x + 1}{x + \left(y \cdot z - x\right) \cdot \frac{1}{t \cdot z - x}}}\\

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

\end{array}
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 VAR;
	if ((z <= -1.9414234727317655e+118)) {
		VAR = ((x + (y / t)) / (x + 1.0));
	} else {
		double VAR_1;
		if ((z <= 1.5589187164770912e-160)) {
			VAR_1 = (1.0 / ((x + 1.0) / (x + (((y * z) - x) * (1.0 / ((t * z) - x))))));
		} else {
			VAR_1 = ((fma((y / ((t * z) - x)), z, x) - (-x / fma(-z, t, x))) / (x + 1.0));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.1
Target0.4
Herbie3.4
\[\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 z < -1.9414234727317655e+118

    1. Initial program 21.6

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

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

    if -1.9414234727317655e+118 < z < 1.5589187164770912e-160

    1. Initial program 1.1

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

      \[\leadsto \frac{x + \color{blue}{\left(y \cdot z - x\right) \cdot \frac{1}{t \cdot z - x}}}{x + 1}\]
    4. Using strategy rm
    5. Applied clear-num1.2

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

    if 1.5589187164770912e-160 < z

    1. Initial program 8.9

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right)} - \frac{x}{t \cdot z - x}}{x + 1}\]
    6. Using strategy rm
    7. Applied frac-2neg4.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.9414234727317655 \cdot 10^{118}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{elif}\;z \le 1.5589187164770912 \cdot 10^{-160}:\\ \;\;\;\;\frac{1}{\frac{x + 1}{x + \left(y \cdot z - x\right) \cdot \frac{1}{t \cdot z - x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\frac{y}{t \cdot z - x}, z, x\right) - \frac{-x}{\mathsf{fma}\left(-z, t, x\right)}}{x + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020071 +o rules:numerics
(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))

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