?

Average Error: 7.4 → 2.1
Time: 28.3s
Precision: binary64
Cost: 3848

?

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.4
Target0.4
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 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

      [Start]64.0

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

      rational.json-simplify-2 [=>]64.0

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

      \[\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)) < 2.0000000000000001e281

    1. Initial program 0.8

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

    if 2.0000000000000001e281 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 60.9

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

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

      [Start]60.9

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

      rational.json-simplify-2 [=>]60.9

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

      \[\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}} \]
    4. Simplified9.9

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

      [Start]9.9

      \[ -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.json-simplify-1 [=>]9.9

      \[ \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.json-simplify-1 [=>]9.9

      \[ \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.json-simplify-2 [=>]9.9

      \[ \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.json-simplify-9 [=>]9.9

      \[ \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.json-simplify-2 [=>]9.9

      \[ \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.json-simplify-52 [=>]9.9

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

      rational.json-simplify-1 [=>]9.9

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

      rational.json-simplify-2 [=>]9.9

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

      rational.json-simplify-1 [=>]9.9

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

    \[\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 2 \cdot 10^{+281}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1} + \left(-\frac{-1 \cdot \left(\frac{y}{x + 1} - \frac{x}{z \cdot \left(x + 1\right)}\right)}{t}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.1
Cost3784
\[\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 2 \cdot 10^{+281}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error2.2
Cost3400
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ 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 2 \cdot 10^{+281}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error16.6
Cost1300
\[\begin{array}{l} t_1 := 1 + \left(-y\right) \cdot \left(\frac{z}{x} - z\right)\\ t_2 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -2.4 \cdot 10^{-30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -9 \cdot 10^{-138}:\\ \;\;\;\;1\\ \mathbf{elif}\;t \leq -3.8 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -2 \cdot 10^{-301}:\\ \;\;\;\;1 - \frac{1}{x}\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{-73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error15.8
Cost1104
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -1 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.1 \cdot 10^{-206}:\\ \;\;\;\;1\\ \mathbf{elif}\;t \leq -5.5 \cdot 10^{-255}:\\ \;\;\;\;\frac{z}{x} \cdot \frac{y}{-1 - x}\\ \mathbf{elif}\;t \leq 4.05 \cdot 10^{-156}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error11.8
Cost1032
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -7.2 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-73}:\\ \;\;\;\;1 + \left(-z \cdot \frac{\frac{y}{x}}{x + 1}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error12.0
Cost968
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -2.02 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.8 \cdot 10^{-73}:\\ \;\;\;\;1 - \frac{y \cdot z}{x \cdot \left(x - -1\right)}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error20.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-46}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-71}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 8
Error20.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{-44}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-32}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error27.2
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-128}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error28.9
Cost64
\[1 \]

Error

Reproduce?

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