Average Error: 7.5 → 2.2
Time: 18.9s
Precision: binary64
Cost: 3784
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\begin{array}{l} t_1 := \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)}\\ t_2 := \frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 10^{+278}:\\ \;\;\;\;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
         (-
          (+ (/ y (* t (+ x 1.0))) (/ x (+ x 1.0)))
          (/ x (* (* z t) (+ x 1.0)))))
        (t_2 (/ (+ x (/ (- (* y z) x) (- (* z t) x))) (+ x 1.0))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 1e+278) 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 = ((y / (t * (x + 1.0))) + (x / (x + 1.0))) - (x / ((z * t) * (x + 1.0)));
	double t_2 = (x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 1e+278) {
		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 = ((y / (t * (x + 1.0))) + (x / (x + 1.0))) - (x / ((z * t) * (x + 1.0)));
	double t_2 = (x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 1e+278) {
		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 = ((y / (t * (x + 1.0))) + (x / (x + 1.0))) - (x / ((z * t) * (x + 1.0)))
	t_2 = (x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 1e+278:
		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(y / Float64(t * Float64(x + 1.0))) + Float64(x / Float64(x + 1.0))) - Float64(x / Float64(Float64(z * t) * Float64(x + 1.0))))
	t_2 = Float64(Float64(x + Float64(Float64(Float64(y * z) - x) / Float64(Float64(z * t) - x))) / Float64(x + 1.0))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 1e+278)
		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 = ((y / (t * (x + 1.0))) + (x / (x + 1.0))) - (x / ((z * t) * (x + 1.0)));
	t_2 = (x + (((y * z) - x) / ((z * t) - x))) / (x + 1.0);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 1e+278)
		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[(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]}, Block[{t$95$2 = N[(N[(x + N[(N[(N[(y * z), $MachinePrecision] - x), $MachinePrecision] / N[(N[(z * t), $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, 1e+278], 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{y}{t \cdot \left(x + 1\right)} + \frac{x}{x + 1}\right) - \frac{x}{\left(z \cdot t\right) \cdot \left(x + 1\right)}\\
t_2 := \frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 10^{+278}:\\
\;\;\;\;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.5
Target0.4
Herbie2.2
\[\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 9.99999999999999964e277 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 61.9

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

      \[\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 t around inf 13.5

      \[\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)) < 9.99999999999999964e277

    1. Initial program 0.8

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

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -\infty:\\ \;\;\;\;\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)}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 10^{+278}:\\ \;\;\;\;\frac{x + \frac{y \cdot z - x}{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
Error2.3
Cost3400
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ t_2 := \frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 10^{+278}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error13.9
Cost1360
\[\begin{array}{l} t_1 := z \cdot t - x\\ t_2 := \frac{x - \frac{x}{t_1}}{x + 1}\\ \mathbf{if}\;x \leq -8.995750141755671 \cdot 10^{-63}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.9282946274464312 \cdot 10^{-91}:\\ \;\;\;\;y \cdot \frac{z}{t_1}\\ \mathbf{elif}\;x \leq -3.072771583033836 \cdot 10^{-123}:\\ \;\;\;\;x \cdot \left(1 + \frac{\frac{-1}{z}}{t}\right)\\ \mathbf{elif}\;x \leq 2.0948010372728394 \cdot 10^{-100}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error20.3
Cost1236
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ t_2 := 1 + y \cdot \left(z - \frac{z}{x}\right)\\ \mathbf{if}\;x \leq -5.28010707707518 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.9282946274464312 \cdot 10^{-91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -7.575027596272219 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(1 + \frac{\frac{-1}{z}}{t}\right)\\ \mathbf{elif}\;x \leq 1.7396242402067136 \cdot 10^{-139}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 5.494935524419325 \cdot 10^{-12}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error19.9
Cost1104
\[\begin{array}{l} t_1 := y \cdot \frac{z}{z \cdot t - x}\\ \mathbf{if}\;x \leq -8.995750141755671 \cdot 10^{-63}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq -1.9282946274464312 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -7.575027596272219 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(1 + \frac{\frac{-1}{z}}{t}\right)\\ \mathbf{elif}\;x \leq 2.178655461091866 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error11.7
Cost1096
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -3.0352929313663287 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.2178718728324227 \cdot 10^{-70}:\\ \;\;\;\;\frac{x + \left(1 - z \cdot \frac{y}{x}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error14.7
Cost972
\[\begin{array}{l} \mathbf{if}\;x \leq -8018167.077057074:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.793082503786783 \cdot 10^{-59}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{elif}\;x \leq 5.494935524419325 \cdot 10^{-12}:\\ \;\;\;\;1 + y \cdot \left(z - \frac{z}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 7
Error14.9
Cost972
\[\begin{array}{l} \mathbf{if}\;x \leq -8018167.077057074:\\ \;\;\;\;\frac{x - y \cdot \frac{z}{x}}{x + 1}\\ \mathbf{elif}\;x \leq 3.793082503786783 \cdot 10^{-59}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{elif}\;x \leq 5.494935524419325 \cdot 10^{-12}:\\ \;\;\;\;1 + y \cdot \left(z - \frac{z}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x + 1}\\ \end{array} \]
Alternative 8
Error20.7
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -8018167.077057074:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -4.870188304647993 \cdot 10^{-56}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -9.352685892369103 \cdot 10^{-62}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.8035368829637316 \cdot 10^{-69}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error20.6
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -8018167.077057074:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -4.870188304647993 \cdot 10^{-56}:\\ \;\;\;\;x \cdot \left(1 - x\right)\\ \mathbf{elif}\;x \leq -9.352685892369103 \cdot 10^{-62}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.8035368829637316 \cdot 10^{-69}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error20.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -4.870188304647993 \cdot 10^{-56}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 3.8035368829637316 \cdot 10^{-69}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error27.1
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -8018167.077057074:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.793082503786783 \cdot 10^{-59}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 12
Error55.5
Cost64
\[x \]

Error

Reproduce

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