Average Error: 7.6 → 2.1
Time: 6.1s
Precision: binary64
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := t \cdot z - x\\ \mathbf{if}\;t \leq 4.21312888900773 \cdot 10^{-16}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x + 1}, \frac{z}{t_1}, \frac{x}{x + 1}\right) - \frac{x}{\left(x + 1\right) \cdot t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(\frac{y}{t} - \frac{x}{t_1}\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
 (let* ((t_1 (- (* t z) x)))
   (if (<= t 4.21312888900773e-16)
     (-
      (fma (/ y (+ x 1.0)) (/ z t_1) (/ x (+ x 1.0)))
      (/ x (* (+ x 1.0) t_1)))
     (/ (+ x (- (/ y t) (/ x t_1))) (+ 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 = (t * z) - x;
	double tmp;
	if (t <= 4.21312888900773e-16) {
		tmp = fma((y / (x + 1.0)), (z / t_1), (x / (x + 1.0))) - (x / ((x + 1.0) * t_1));
	} else {
		tmp = (x + ((y / t) - (x / t_1))) / (x + 1.0);
	}
	return tmp;
}
function code(x, y, z, t)
	return Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(t * z) - x)
	tmp = 0.0
	if (t <= 4.21312888900773e-16)
		tmp = Float64(fma(Float64(y / Float64(x + 1.0)), Float64(z / t_1), Float64(x / Float64(x + 1.0))) - Float64(x / Float64(Float64(x + 1.0) * t_1)));
	else
		tmp = Float64(Float64(x + Float64(Float64(y / t) - Float64(x / t_1))) / Float64(x + 1.0));
	end
	return tmp
end
code[x_, y_, z_, t_] := N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t * z), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[t, 4.21312888900773e-16], N[(N[(N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] * N[(z / t$95$1), $MachinePrecision] + N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[(x + 1.0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(y / t), $MachinePrecision] - N[(x / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := t \cdot z - x\\
\mathbf{if}\;t \leq 4.21312888900773 \cdot 10^{-16}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{x + 1}, \frac{z}{t_1}, \frac{x}{x + 1}\right) - \frac{x}{\left(x + 1\right) \cdot t_1}\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original7.6
Target0.3
Herbie2.1
\[\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 t < 4.2131288890077302e-16

    1. Initial program 7.0

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

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

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

    if 4.2131288890077302e-16 < t

    1. Initial program 9.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq 4.21312888900773 \cdot 10^{-16}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{x + 1}, \frac{z}{t \cdot z - x}, \frac{x}{x + 1}\right) - \frac{x}{\left(x + 1\right) \cdot \left(t \cdot z - x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(\frac{y}{t} - \frac{x}{t \cdot z - x}\right)}{x + 1}\\ \end{array} \]

Reproduce

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