?

Average Accuracy: 89.0% → 97.1%
Time: 17.4s
Precision: binary64
Cost: 9736

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\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{y}{t_1} \cdot \frac{z}{x + 1}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+273}:\\ \;\;\;\;\frac{x + \frac{\mathsf{fma}\left(z, y, -x\right)}{t_1}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{\left(z \cdot t\right) \cdot \left(x + 1\right)}\\ \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)) (t_2 (/ (+ x (/ (- (* y z) x) t_1)) (+ x 1.0))))
   (if (<= t_2 (- INFINITY))
     (* (/ y t_1) (/ z (+ x 1.0)))
     (if (<= t_2 5e+273)
       (/ (+ x (/ (fma z y (- x)) t_1)) (+ x 1.0))
       (-
        (+ (/ y (* t (+ x 1.0))) (/ x (+ x 1.0)))
        (/ 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 t_1 = (z * t) - x;
	double t_2 = (x + (((y * z) - x) / t_1)) / (x + 1.0);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (y / t_1) * (z / (x + 1.0));
	} else if (t_2 <= 5e+273) {
		tmp = (x + (fma(z, y, -x) / t_1)) / (x + 1.0);
	} else {
		tmp = ((y / (t * (x + 1.0))) + (x / (x + 1.0))) - (x / ((z * t) * (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(z * t) - x)
	t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / t_1)) / Float64(x + 1.0))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(Float64(y / t_1) * Float64(z / Float64(x + 1.0)));
	elseif (t_2 <= 5e+273)
		tmp = Float64(Float64(x + Float64(fma(z, y, Float64(-x)) / t_1)) / Float64(x + 1.0));
	else
		tmp = Float64(Float64(Float64(y / Float64(t * Float64(x + 1.0))) + Float64(x / Float64(x + 1.0))) - Float64(x / Float64(Float64(z * t) * 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[(z * t), $MachinePrecision] - x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(y / t$95$1), $MachinePrecision] * N[(z / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+273], N[(N[(x + N[(N[(z * y + (-x)), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / N[(t * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[(z * t), $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\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{y}{t_1} \cdot \frac{z}{x + 1}\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+273}:\\
\;\;\;\;\frac{x + \frac{\mathsf{fma}\left(z, y, -x\right)}{t_1}}{x + 1}\\

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


\end{array}

Error?

Target

Original89.0%
Target99.5%
Herbie97.1%
\[\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 0.0%

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

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

      [Start]0.0

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

      *-commutative [=>]0.0

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Taylor expanded in y around inf 0.0%

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

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

      [Start]0.0

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

      times-frac [=>]75.0

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

      +-commutative [=>]75.0

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

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

    1. Initial program 98.8%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified98.8%

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

      [Start]98.8

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

      *-commutative [=>]98.8

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Applied egg-rr98.8%

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

      [Start]98.8

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

      *-commutative [=>]98.8

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

      fma-neg [=>]98.8

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

    if 4.99999999999999961e273 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 5.7%

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
    2. Simplified5.7%

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

      [Start]5.7

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

      *-commutative [=>]5.7

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Taylor expanded in t around inf 85.2%

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

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

Alternatives

Alternative 1
Accuracy97.1%
Cost3784
\[\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{y}{t_1} \cdot \frac{z}{x + 1}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+273}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{\left(z \cdot t\right) \cdot \left(x + 1\right)}\\ \end{array} \]
Alternative 2
Accuracy97.0%
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{y}{t_1} \cdot \frac{z}{x + 1}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+273}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \end{array} \]
Alternative 3
Accuracy77.3%
Cost1361
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.05 \cdot 10^{-138}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.7 \cdot 10^{-83}:\\ \;\;\;\;1 + \frac{t - y}{\frac{x}{z}}\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{+29} \lor \neg \left(t \leq 6.69 \cdot 10^{+143}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \end{array} \]
Alternative 4
Accuracy61.5%
Cost1240
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ t_2 := \frac{y}{t \cdot \left(x + 1\right)}\\ \mathbf{if}\;t \leq -2.15 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -9.5 \cdot 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9.5 \cdot 10^{-138}:\\ \;\;\;\;1\\ \mathbf{elif}\;t \leq -1.05 \cdot 10^{-138}:\\ \;\;\;\;\frac{y}{x + 1} \cdot \frac{1}{t}\\ \mathbf{elif}\;t \leq 1.02 \cdot 10^{-82}:\\ \;\;\;\;1 + z \cdot \frac{t - y}{x}\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+16}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Accuracy68.9%
Cost972
\[\begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{-98}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-128}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-11}:\\ \;\;\;\;1 + \frac{t - y}{\frac{x}{z}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Accuracy78.8%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -1.05 \cdot 10^{-138} \lor \neg \left(t \leq 2.35 \cdot 10^{-85}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{t - y}{\frac{x}{z}}\\ \end{array} \]
Alternative 7
Accuracy67.8%
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-43}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-98}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-128}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Accuracy68.0%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{-98}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-127}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Accuracy57.9%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -3.9 \cdot 10^{-44}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-177}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Accuracy55.4%
Cost64
\[1 \]

Error

Reproduce?

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