?

Average Error: 7.1 → 1.9
Time: 21.4s
Precision: binary64
Cost: 3400

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := \frac{x}{x + 1} + \left(-\frac{-\frac{y}{x + 1}}{t}\right)\\ t_2 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+279}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_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 (+ (/ x (+ x 1.0)) (- (/ (- (/ y (+ x 1.0))) t))))
        (t_2 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+279) t_2 t_1))))
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 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t);
	double t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 5e+279) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t);
	double t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 5e+279) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
def code(x, y, z, t):
	t_1 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t)
	t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 5e+279:
		tmp = t_2
	else:
		tmp = t_1
	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(x / Float64(x + 1.0)) + Float64(-Float64(Float64(-Float64(y / Float64(x + 1.0))) / t)))
	t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(t * z) - x))) / Float64(x + 1.0))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 5e+279)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x / (x + 1.0)) + -(-(y / (x + 1.0)) / t);
	t_2 = (x + (((y * z) - x) / ((t * z) - x))) / (x + 1.0);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 5e+279)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = 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[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision] + (-N[((-N[(y / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]) / t), $MachinePrecision])), $MachinePrecision]}, Block[{t$95$2 = 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]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+279], t$95$2, t$95$1]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := \frac{x}{x + 1} + \left(-\frac{-\frac{y}{x + 1}}{t}\right)\\
t_2 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+279}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.1
Target0.3
Herbie1.9
\[\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 (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1)) < -inf.0 or 5.0000000000000002e279 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 62.0

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

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

      [Start]62.0

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

      rational_best.json-simplify-2 [=>]62.0

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

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

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

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

      [Start]13.0

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

      rational_best.json-simplify-1 [=>]13.0

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

      rational_best.json-simplify-1 [=>]13.0

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

      rational_best.json-simplify-2 [=>]13.0

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

      rational_best.json-simplify-12 [=>]13.0

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

      rational_best.json-simplify-2 [=>]13.0

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

      rational_best.json-simplify-12 [=>]13.0

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

      rational_best.json-simplify-11 [=>]13.0

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

      rational_best.json-simplify-46 [=>]13.0

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

      rational_best.json-simplify-2 [=>]13.0

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

      rational_best.json-simplify-1 [=>]13.0

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

      rational_best.json-simplify-6 [=>]13.0

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

      rational_best.json-simplify-2 [=>]13.0

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

      rational_best.json-simplify-12 [=>]13.0

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

      rational_best.json-simplify-1 [=>]13.0

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

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

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

      [Start]13.0

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

      rational_best.json-simplify-2 [=>]13.0

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

      rational_best.json-simplify-1 [<=]13.0

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

      rational_best.json-simplify-13 [<=]13.0

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

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

    1. Initial program 0.6

      \[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.9

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

Alternatives

Alternative 1
Error12.3
Cost1488
\[\begin{array}{l} t_1 := \frac{x}{x + 1} + \left(-\frac{-\frac{y}{x + 1}}{t}\right)\\ \mathbf{if}\;t \leq -5 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4 \cdot 10^{-91}:\\ \;\;\;\;\frac{x - \frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;t \leq -1.25 \cdot 10^{-137}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{elif}\;t \leq 1.56 \cdot 10^{-86}:\\ \;\;\;\;\frac{\left(-\frac{z \cdot y}{x}\right) + \left(x + 1\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error12.2
Cost1424
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{if}\;t \leq -5.2 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.9 \cdot 10^{-91}:\\ \;\;\;\;\frac{x - \frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;t \leq -2.7 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.9 \cdot 10^{-86}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{-x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error12.3
Cost1424
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{if}\;t \leq -2.6 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-91}:\\ \;\;\;\;\frac{x - \frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;t \leq -5 \cdot 10^{-137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{-88}:\\ \;\;\;\;\frac{\left(-\frac{z \cdot y}{x}\right) + \left(x + 1\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error12.3
Cost1296
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{if}\;t \leq -2.5 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.65 \cdot 10^{-91}:\\ \;\;\;\;\frac{x - \frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;t \leq -8.6 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-86}:\\ \;\;\;\;1 + z \cdot \left(-\frac{y}{x \cdot \left(x - -1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error12.4
Cost1032
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{if}\;t \leq -2.3 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.42 \cdot 10^{-86}:\\ \;\;\;\;1 + z \cdot \left(-\frac{y}{x \cdot \left(x - -1\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error14.9
Cost840
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{1 + x}\\ \mathbf{if}\;t \leq -1.75 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.5 \cdot 10^{-87}:\\ \;\;\;\;1 + z \cdot \left(-\frac{y}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error21.6
Cost780
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-129}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-152}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-111}:\\ \;\;\;\;-\frac{y \cdot z}{x}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-53}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error21.2
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -3.7 \cdot 10^{-46}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-129}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{-55}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error21.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{-130}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-51}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error27.6
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-46}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-99}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error29.0
Cost64
\[1 \]

Error

Reproduce?

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