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

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+190}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.2
Target0.4
Herbie2.7
\[\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.00000000000000036e190 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 52.7

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

      \[\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 16.3

      \[\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)}} \]
    4. Simplified16.3

      \[\leadsto \color{blue}{\frac{y}{t \cdot \left(x + 1\right)} + \left(\frac{x}{x + 1} - \frac{\frac{x}{x + 1}}{t \cdot z}\right)} \]
      Proof
      (+.f64 (/.f64 y (*.f64 t (+.f64 x 1))) (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (/.f64 x (+.f64 x 1)) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 y (*.f64 t (Rewrite<= +-commutative_binary64 (+.f64 1 x)))) (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (/.f64 x (+.f64 x 1)) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 y (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 1 x) t))) (-.f64 (/.f64 x (+.f64 x 1)) (/.f64 (/.f64 x (+.f64 x 1)) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 y (*.f64 (+.f64 1 x) t)) (-.f64 (/.f64 x (Rewrite<= +-commutative_binary64 (+.f64 1 x))) (/.f64 (/.f64 x (+.f64 x 1)) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 y (*.f64 (+.f64 1 x) t)) (-.f64 (/.f64 x (+.f64 1 x)) (/.f64 (/.f64 x (Rewrite<= +-commutative_binary64 (+.f64 1 x))) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 y (*.f64 (+.f64 1 x) t)) (-.f64 (/.f64 x (+.f64 1 x)) (Rewrite<= associate-/r*_binary64 (/.f64 x (*.f64 (+.f64 1 x) (*.f64 t z)))))): 5 points increase in error, 12 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (/.f64 y (*.f64 (+.f64 1 x) t)) (/.f64 x (+.f64 1 x))) (/.f64 x (*.f64 (+.f64 1 x) (*.f64 t z))))): 1 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 (/.f64 x (+.f64 1 x)) (/.f64 y (*.f64 (+.f64 1 x) t)))) (/.f64 x (*.f64 (+.f64 1 x) (*.f64 t z)))): 0 points increase in error, 0 points decrease in error

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

    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.7

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

Alternatives

Alternative 1
Error2.8
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 5 \cdot 10^{+190}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error13.1
Cost1096
\[\begin{array}{l} \mathbf{if}\;x \leq -5333034850.064622:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 9.144401768774862 \cdot 10^{-26}:\\ \;\;\;\;\frac{x + \frac{y - \frac{x}{z}}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error12.5
Cost1096
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -2.2937095761760183 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.416122823150749 \cdot 10^{-6}:\\ \;\;\;\;\frac{x + \left(1 - z \cdot \frac{y}{x}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error16.6
Cost840
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.28 \cdot 10^{-223}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.416122823150749 \cdot 10^{-6}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error20.7
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5797083100913775 \cdot 10^{-14}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -9.300213501336031 \cdot 10^{-113}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8749316189455024 \cdot 10^{-26}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error20.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -9.300213501336031 \cdot 10^{-113}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 2.8749316189455024 \cdot 10^{-26}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error28.4
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5797083100913775 \cdot 10^{-14}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -9.300213501336031 \cdot 10^{-113}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error28.6
Cost64
\[1 \]

Error

Reproduce

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