Average Error: 7.4 → 1.6
Time: 34.5s
Precision: binary64
Cost: 9736
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := y \cdot z - x\\ t_2 := z \cdot t - x\\ t_3 := \frac{x + \frac{t_1}{t_2}}{x + 1}\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;\frac{x + \frac{z}{\frac{t_2}{y}}}{x + 1}\\ \mathbf{elif}\;t_3 \leq 10^{+282}:\\ \;\;\;\;\frac{x + \frac{t_1}{\mathsf{fma}\left(z, t, -x\right)}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \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 (- (* y z) x))
        (t_2 (- (* z t) x))
        (t_3 (/ (+ x (/ t_1 t_2)) (+ x 1.0))))
   (if (<= t_3 (- INFINITY))
     (/ (+ x (/ z (/ t_2 y))) (+ x 1.0))
     (if (<= t_3 1e+282)
       (/ (+ x (/ t_1 (fma z t (- x)))) (+ x 1.0))
       (+ (/ x (+ x 1.0)) (/ y (+ t (* x t))))))))
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 = (y * z) - x;
	double t_2 = (z * t) - x;
	double t_3 = (x + (t_1 / t_2)) / (x + 1.0);
	double tmp;
	if (t_3 <= -((double) INFINITY)) {
		tmp = (x + (z / (t_2 / y))) / (x + 1.0);
	} else if (t_3 <= 1e+282) {
		tmp = (x + (t_1 / fma(z, t, -x))) / (x + 1.0);
	} else {
		tmp = (x / (x + 1.0)) + (y / (t + (x * t)));
	}
	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(y * z) - x)
	t_2 = Float64(Float64(z * t) - x)
	t_3 = Float64(Float64(x + Float64(t_1 / t_2)) / Float64(x + 1.0))
	tmp = 0.0
	if (t_3 <= Float64(-Inf))
		tmp = Float64(Float64(x + Float64(z / Float64(t_2 / y))) / Float64(x + 1.0));
	elseif (t_3 <= 1e+282)
		tmp = Float64(Float64(x + Float64(t_1 / fma(z, t, Float64(-x)))) / Float64(x + 1.0));
	else
		tmp = Float64(Float64(x / Float64(x + 1.0)) + Float64(y / Float64(t + Float64(x * t))));
	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[(y * z), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x + N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(x + N[(z / N[(t$95$2 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1e+282], N[(N[(x + N[(t$95$1 / N[(z * t + (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + N[(y / N[(t + N[(x * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := y \cdot z - x\\
t_2 := z \cdot t - x\\
t_3 := \frac{x + \frac{t_1}{t_2}}{x + 1}\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{x + \frac{z}{\frac{t_2}{y}}}{x + 1}\\

\mathbf{elif}\;t_3 \leq 10^{+282}:\\
\;\;\;\;\frac{x + \frac{t_1}{\mathsf{fma}\left(z, t, -x\right)}}{x + 1}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\


\end{array}

Error

Target

Original7.4
Target0.5
Herbie1.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. Simplified64.0

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Proof
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 z t) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in y around inf 64.0

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

      \[\leadsto \frac{x + \color{blue}{\frac{z}{\frac{t \cdot z - x}{y}}}}{x + 1} \]
      Proof
      (/.f64 z (/.f64 (-.f64 (*.f64 t z) x) y)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z y) (-.f64 (*.f64 t z) x))): 64 points increase in error, 44 points decrease in error
      (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y z)) (-.f64 (*.f64 t z) x)): 0 points increase in error, 0 points decrease in error

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

    1. Initial program 0.6

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified0.6

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Proof
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 z t) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr0.6

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

    if 1.00000000000000003e282 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 61.4

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified61.4

      \[\leadsto \color{blue}{\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}} \]
      Proof
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 z t) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 t z)) x))) (+.f64 x 1)): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in y around inf 61.4

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

      \[\leadsto \frac{x + \color{blue}{\frac{z}{\frac{t \cdot z - x}{y}}}}{x + 1} \]
      Proof
      (/.f64 z (/.f64 (-.f64 (*.f64 t z) x) y)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z y) (-.f64 (*.f64 t z) x))): 64 points increase in error, 44 points decrease in error
      (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y z)) (-.f64 (*.f64 t z) x)): 0 points increase in error, 0 points decrease in error
    5. Taylor expanded in t around inf 10.6

      \[\leadsto \color{blue}{\frac{x}{1 + x} + \frac{y}{\left(1 + x\right) \cdot t}} \]
    6. Simplified10.6

      \[\leadsto \color{blue}{\frac{x}{x + 1} + \frac{y}{t + x \cdot t}} \]
      Proof
      (+.f64 (/.f64 x (+.f64 x 1)) (/.f64 y (+.f64 t (*.f64 x t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (Rewrite<= +-commutative_binary64 (+.f64 1 x))) (/.f64 y (+.f64 t (*.f64 x t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (+.f64 1 x)) (/.f64 y (+.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 t)) (*.f64 x t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (+.f64 1 x)) (/.f64 y (Rewrite<= distribute-rgt-in_binary64 (*.f64 t (+.f64 1 x))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 x (+.f64 1 x)) (/.f64 y (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 1 x) t)))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification1.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{z}{\frac{z \cdot t - x}{y}}}{x + 1}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 10^{+282}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{\mathsf{fma}\left(z, t, -x\right)}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \end{array} \]

Alternatives

Alternative 1
Error1.6
Cost3400
\[\begin{array}{l} t_1 := z \cdot t - x\\ t_2 := \frac{x + \frac{y \cdot z - x}{t_1}}{x + 1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\frac{x + \frac{z}{\frac{t_1}{y}}}{x + 1}\\ \mathbf{elif}\;t_2 \leq 10^{+282}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \end{array} \]
Alternative 2
Error13.8
Cost2020
\[\begin{array}{l} t_1 := \frac{\left(x + \frac{y}{t}\right) - \frac{x}{z \cdot t}}{x + 1}\\ t_2 := z \cdot t - x\\ t_3 := \frac{x - \frac{x}{t_2}}{x + 1}\\ \mathbf{if}\;x \leq -6.887705382306288 \cdot 10^{+74}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.0761435828174995 \cdot 10^{+40}:\\ \;\;\;\;\frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \mathbf{elif}\;x \leq -1.5688815587199482 \cdot 10^{-59}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 10^{-256}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.2086834044636752 \cdot 10^{-134}:\\ \;\;\;\;\frac{y}{\frac{t_2}{z}}\\ \mathbf{elif}\;x \leq 6.596125118855046 \cdot 10^{-92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.654216558508042 \cdot 10^{-44}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.3956183577640305 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.016652422823319548:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y \cdot \frac{z}{x}}{x + 1}\\ \end{array} \]
Alternative 3
Error17.4
Cost1628
\[\begin{array}{l} t_1 := \frac{x - y \cdot \frac{z}{x}}{x + 1}\\ t_2 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;z \leq -5.167911586690149 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8.981190451292246 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.786002014018926 \cdot 10^{-137}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.535661008139169 \cdot 10^{-306}:\\ \;\;\;\;1 + \frac{z \cdot t}{x \cdot \left(x + 1\right)}\\ \mathbf{elif}\;z \leq 5.120152805560747 \cdot 10^{-145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.1299883578351495 \cdot 10^{-23}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.9861371040586805 \cdot 10^{+117}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error13.1
Cost1360
\[\begin{array}{l} t_1 := \frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \mathbf{if}\;z \leq -8.118648557324262 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.185221968561826 \cdot 10^{-58}:\\ \;\;\;\;\frac{x + \left(1 - \frac{y \cdot z}{x}\right)}{x + 1}\\ \mathbf{elif}\;z \leq 1.9876460610958757 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.9861371040586805 \cdot 10^{+117}:\\ \;\;\;\;\frac{x - y \cdot \frac{z}{x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error13.3
Cost1232
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;z \leq -8.118648557324262 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.185221968561826 \cdot 10^{-58}:\\ \;\;\;\;\frac{x + \left(1 - \frac{y \cdot z}{x}\right)}{x + 1}\\ \mathbf{elif}\;z \leq 1.9876460610958757 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.9861371040586805 \cdot 10^{+117}:\\ \;\;\;\;\frac{x - y \cdot \frac{z}{x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error8.9
Cost1224
\[\begin{array}{l} t_1 := \frac{x + \frac{z}{\frac{z \cdot t - x}{y}}}{x + 1}\\ \mathbf{if}\;z \leq -2.786002014018926 \cdot 10^{-137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.120152805560747 \cdot 10^{-145}:\\ \;\;\;\;\frac{x + \left(1 - \frac{y \cdot z}{x}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error12.3
Cost1096
\[\begin{array}{l} t_1 := \frac{x}{x + 1} + \frac{y}{t + x \cdot t}\\ \mathbf{if}\;t \leq -1.4366467864211509 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.651423834107203 \cdot 10^{-99}:\\ \;\;\;\;\frac{x + \left(1 - z \cdot \frac{y}{x}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error20.5
Cost844
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5688815587199482 \cdot 10^{-59}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.577640958499193 \cdot 10^{-140}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 6.596125118855046 \cdot 10^{-92}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error19.4
Cost844
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5688815587199482 \cdot 10^{-59}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.2086834044636752 \cdot 10^{-134}:\\ \;\;\;\;\frac{y}{\frac{z \cdot t - x}{z}}\\ \mathbf{elif}\;x \leq 6.596125118855046 \cdot 10^{-92}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error14.9
Cost840
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -3.219786113698548 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.651423834107203 \cdot 10^{-99}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error20.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5688815587199482 \cdot 10^{-59}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.577640958499193 \cdot 10^{-140}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 12
Error20.6
Cost460
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5688815587199482 \cdot 10^{-59}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 5.577640958499193 \cdot 10^{-140}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 6.596125118855046 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 13
Error27.5
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-246}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6.596125118855046 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 14
Error55.8
Cost64
\[x \]

Error

Reproduce

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