?

Average Error: 7.3 → 2.4
Time: 12.0s
Precision: binary64
Cost: 3784

?

\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := \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)}\\ 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^{+221}:\\ \;\;\;\;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 (+ 1.0 x)) (/ y (* (+ 1.0 x) t)))
          (/ x (* (+ 1.0 x) (* t z)))))
        (t_2 (/ (+ x (/ (- (* y z) x) (- (* t z) x))) (+ x 1.0))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+221) 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 / (1.0 + x)) + (y / ((1.0 + x) * t))) - (x / ((1.0 + x) * (t * z)));
	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+221) {
		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 / (1.0 + x)) + (y / ((1.0 + x) * t))) - (x / ((1.0 + x) * (t * z)));
	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+221) {
		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 / (1.0 + x)) + (y / ((1.0 + x) * t))) - (x / ((1.0 + x) * (t * z)))
	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+221:
		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(Float64(x / Float64(1.0 + x)) + Float64(y / Float64(Float64(1.0 + x) * t))) - Float64(x / Float64(Float64(1.0 + x) * Float64(t * z))))
	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+221)
		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 / (1.0 + x)) + (y / ((1.0 + x) * t))) - (x / ((1.0 + x) * (t * z)));
	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+221)
		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[(N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] + N[(y / N[(N[(1.0 + x), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(x / N[(N[(1.0 + x), $MachinePrecision] * N[(t * z), $MachinePrecision]), $MachinePrecision]), $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+221], t$95$2, t$95$1]]]]
\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}
\begin{array}{l}
t_1 := \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)}\\
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^{+221}:\\
\;\;\;\;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.3
Target0.3
Herbie2.4
\[\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.0000000000000002e221 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 56.4

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

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

      [Start]56.4

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]56.4

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

      \[\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)}} \]

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

    1. Initial program 0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \leq -\infty:\\ \;\;\;\;\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)}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \leq 5 \cdot 10^{+221}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\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)}\\ \end{array} \]

Alternatives

Alternative 1
Error3.3
Cost3400
\[\begin{array}{l} t_1 := \frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;1 - \frac{1}{x}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+221}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{x + 1}\\ \end{array} \]
Alternative 2
Error11.8
Cost1296
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -1.75 \cdot 10^{+130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2.3 \cdot 10^{+55}:\\ \;\;\;\;\frac{x - \frac{x}{t \cdot z - x}}{x + 1}\\ \mathbf{elif}\;t \leq -4.3 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{-108}:\\ \;\;\;\;1 + \left(-\frac{y \cdot z}{x + x \cdot x}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error19.8
Cost1172
\[\begin{array}{l} t_1 := \left(1 - \frac{1}{t \cdot z}\right) \cdot x\\ \mathbf{if}\;x \leq -1.75 \cdot 10^{-28}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -3.35 \cdot 10^{-162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-133}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-89}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-25}:\\ \;\;\;\;1 + \left(-\frac{y \cdot z}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 4
Error11.2
Cost1032
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -1.16 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.05 \cdot 10^{-111}:\\ \;\;\;\;1 + \left(-\frac{y \cdot z}{x + x \cdot x}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error20.7
Cost976
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{-158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-115}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 41:\\ \;\;\;\;\frac{y}{t + x \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error20.2
Cost976
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-158}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 2.95 \cdot 10^{-115}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-38}:\\ \;\;\;\;1 + \left(-\frac{y \cdot z}{x}\right)\\ \mathbf{elif}\;x \leq 41:\\ \;\;\;\;\frac{y}{t + x \cdot t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error20.8
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-27}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.56 \cdot 10^{-115}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 41:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error14.6
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-27}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 56000000:\\ \;\;\;\;\frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error20.4
Cost584
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -5.8 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-115}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error26.3
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-29}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-81}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error27.9
Cost64
\[1 \]

Error

Reproduce?

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