Average Error: 7.4 → 2.3
Time: 20.2s
Precision: binary64
Cost: 3400
\[\frac{x + \frac{y \cdot z - x}{t \cdot z - x}}{x + 1} \]
\[\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^{+275}:\\ \;\;\;\;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 (/ y 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 5e+275) 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 + (y / 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 <= 5e+275) {
		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 + (y / 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 <= 5e+275) {
		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 + (y / 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 <= 5e+275:
		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(y / 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 <= 5e+275)
		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 + (y / 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 <= 5e+275)
		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[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $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, 5e+275], 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 + \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^{+275}:\\
\;\;\;\;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.4
Target0.4
Herbie2.3
\[\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.0000000000000003e275 < (/.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
      (/.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 z around inf 15.4

      \[\leadsto \color{blue}{\frac{\frac{y}{t} + x}{1 + x}} \]

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

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

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

Alternatives

Alternative 1
Error19.9
Cost1632
\[\begin{array}{l} \mathbf{if}\;x \leq -2.564936450431088 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq -2.7888260161797056 \cdot 10^{-71}:\\ \;\;\;\;1 + y \cdot \left(z - \frac{z}{x}\right)\\ \mathbf{elif}\;x \leq -2.555734171242155 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.271893677701026 \cdot 10^{-171}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.1342497414739622 \cdot 10^{-101}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{elif}\;x \leq 1.8698021407294366 \cdot 10^{-76}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 7.215547610645187 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.0766771859540445 \cdot 10^{+57}:\\ \;\;\;\;1 - y \cdot \frac{\frac{z}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error20.3
Cost1368
\[\begin{array}{l} \mathbf{if}\;x \leq -2.555734171242155 \cdot 10^{-91}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 4.271893677701026 \cdot 10^{-171}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.1342497414739622 \cdot 10^{-101}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{elif}\;x \leq 1.8698021407294366 \cdot 10^{-76}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 7.215547610645187 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.0766771859540445 \cdot 10^{+57}:\\ \;\;\;\;1 - y \cdot \frac{\frac{z}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error16.0
Cost1368
\[\begin{array}{l} t_1 := 1 - y \cdot \frac{\frac{z}{x}}{x}\\ t_2 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -4.431320620602458 \cdot 10^{-192}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{-216}:\\ \;\;\;\;\frac{y \cdot z}{x \cdot \left(-1 - x\right)}\\ \mathbf{elif}\;t \leq 9.414188655452685 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.9704135634555555 \cdot 10^{-81}:\\ \;\;\;\;1 + y \cdot \left(z - \frac{z}{x}\right)\\ \mathbf{elif}\;t \leq 1.0664364095115274 \cdot 10^{-72}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error12.5
Cost1224
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.9801942302587264 \cdot 10^{-189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.0664364095115274 \cdot 10^{-72}:\\ \;\;\;\;\frac{x + \left(1 - \frac{z}{\frac{x}{y - t}}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error13.0
Cost1096
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;z \leq -9.172767347795777 \cdot 10^{+88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.8380174864497257 \cdot 10^{-76}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error12.6
Cost1096
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.9801942302587264 \cdot 10^{-189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.0664364095115274 \cdot 10^{-72}:\\ \;\;\;\;\frac{x + \left(1 - z \cdot \frac{y}{x}\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error20.2
Cost848
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -2.555734171242155 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.271893677701026 \cdot 10^{-171}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 1.1342497414739622 \cdot 10^{-101}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{elif}\;x \leq 1.8698021407294366 \cdot 10^{-76}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error20.1
Cost584
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -2.555734171242155 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.8698021407294366 \cdot 10^{-76}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error20.4
Cost460
\[\begin{array}{l} \mathbf{if}\;x \leq -6.398900357724687 \cdot 10^{-8}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.8698021407294366 \cdot 10^{-76}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 7.215547610645187 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error26.3
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.7888260161797056 \cdot 10^{-71}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 7.215547610645187 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error55.6
Cost64
\[x \]

Error

Reproduce

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