?

Average Error: 11.41% → 5.22%
Time: 15.1s
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 \cdot z - x}{z \cdot t - 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{x + \frac{y}{t}}{x + 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 z) x) (- (* z t) x))) (+ x 1.0))))
   (if (<= t_1 (- INFINITY))
     (+ 1.0 (/ -1.0 x))
     (if (<= t_1 5e+221) t_1 (/ (+ x (/ y t)) (+ x 1.0))))))
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 tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = 1.0 + (-1.0 / x);
	} else if (t_1 <= 5e+221) {
		tmp = t_1;
	} else {
		tmp = (x + (y / t)) / (x + 1.0);
	}
	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 tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = 1.0 + (-1.0 / x);
	} else if (t_1 <= 5e+221) {
		tmp = t_1;
	} else {
		tmp = (x + (y / t)) / (x + 1.0);
	}
	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)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = 1.0 + (-1.0 / x)
	elif t_1 <= 5e+221:
		tmp = t_1
	else:
		tmp = (x + (y / t)) / (x + 1.0)
	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))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(1.0 + Float64(-1.0 / x));
	elseif (t_1 <= 5e+221)
		tmp = t_1;
	else
		tmp = Float64(Float64(x + Float64(y / t)) / Float64(x + 1.0));
	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);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = 1.0 + (-1.0 / x);
	elseif (t_1 <= 5e+221)
		tmp = t_1;
	else
		tmp = (x + (y / t)) / (x + 1.0);
	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]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+221], t$95$1, N[(N[(x + N[(y / t), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $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}{z \cdot t - 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{x + \frac{y}{t}}{x + 1}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.41%
Target0.54%
Herbie5.22%
\[\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 100

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

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

      [Start]100

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

      *-commutative [=>]100

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

      \[\leadsto \color{blue}{\frac{x}{1 + x}} \]
    4. Simplified74.7

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

      [Start]74.7

      \[ \frac{x}{1 + x} \]

      +-commutative [=>]74.7

      \[ \frac{x}{\color{blue}{x + 1}} \]
    5. Taylor expanded in x around inf 74.44

      \[\leadsto \color{blue}{1 - \frac{1}{x}} \]

    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 1.13

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

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

    1. Initial program 83.95

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

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

      [Start]83.95

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

      *-commutative [=>]83.95

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

      \[\leadsto \frac{\color{blue}{\frac{y}{t} + x}}{x + 1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification5.22

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq -\infty:\\ \;\;\;\;1 + \frac{-1}{x}\\ \mathbf{elif}\;\frac{x + \frac{y \cdot z - x}{z \cdot t - x}}{x + 1} \leq 5 \cdot 10^{+221}:\\ \;\;\;\;\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
Error13.98%
Cost1616
\[\begin{array}{l} t_1 := z \cdot t - x\\ t_2 := \frac{x + \frac{1}{\frac{t_1}{y \cdot z}}}{x + 1}\\ t_3 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;z \leq -1.85 \cdot 10^{+134}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-191}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-154}:\\ \;\;\;\;\frac{x - \frac{x}{t_1}}{x + 1}\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{+54}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Error18.37%
Cost1361
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.35 \cdot 10^{+130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.14 \cdot 10^{+58}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{elif}\;t \leq -1.15 \cdot 10^{-65} \lor \neg \left(t \leq 1.06 \cdot 10^{-108}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \frac{x - y \cdot z}{x}}{x + 1}\\ \end{array} \]
Alternative 3
Error23.71%
Cost1105
\[\begin{array}{l} t_1 := \frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{if}\;t \leq -1.35 \cdot 10^{+130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.08 \cdot 10^{+54}:\\ \;\;\;\;\frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{elif}\;t \leq -1.45 \cdot 10^{-65} \lor \neg \left(t \leq 4.8 \cdot 10^{-109}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error32.3%
Cost976
\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-160}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-116}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-35}:\\ \;\;\;\;x - x \cdot x\\ \mathbf{elif}\;x \leq 44:\\ \;\;\;\;\frac{y}{t \cdot \left(x + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error32.15%
Cost976
\[\begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-162}:\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-158}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-38}:\\ \;\;\;\;z \cdot \frac{y}{z \cdot t - x}\\ \mathbf{elif}\;x \leq 41:\\ \;\;\;\;\frac{y}{t \cdot \left(x + 1\right)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error32.49%
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-28}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-162}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.7 \cdot 10^{-115}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-36}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 41:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 7
Error32.45%
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{-29}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-159}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-115}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-35}:\\ \;\;\;\;x - x \cdot x\\ \mathbf{elif}\;x \leq 41:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error22.84%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-27}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 13200:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 9
Error31.95%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-158} \lor \neg \left(x \leq 3.9 \cdot 10^{-115}\right):\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t}\\ \end{array} \]
Alternative 10
Error41.12%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.7 \cdot 10^{-27}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-82}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 11
Error43.53%
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)))