?

Average Error: 11.24% → 2.98%
Time: 15.9s
Precision: binary64
Cost: 3400

?

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

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+282}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x + 1}{x + \frac{y}{t}}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.24%
Target0.54%
Herbie2.98%
\[\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 y around inf 100

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

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

      [Start]100

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

      times-frac [=>]27.7

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

      +-commutative [=>]27.7

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

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

    1. Initial program 0.91

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

    if 4.99999999999999978e282 < (/.f64 (+.f64 x (/.f64 (-.f64 (*.f64 y z) x) (-.f64 (*.f64 t z) x))) (+.f64 x 1))

    1. Initial program 95.43

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

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

      [Start]95.43

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

      *-commutative [=>]95.43

      \[ \frac{x + \frac{y \cdot z - x}{\color{blue}{z \cdot t} - x}}{x + 1} \]
    3. Applied egg-rr95.44

      \[\leadsto \color{blue}{{\left(\frac{x + 1}{x + \frac{y \cdot z - x}{z \cdot t - x}}\right)}^{-1}} \]
    4. Simplified95.44

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

      [Start]95.44

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

      unpow-1 [=>]95.44

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

      *-commutative [=>]95.44

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

      *-commutative [=>]95.44

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

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

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

Alternatives

Alternative 1
Error22.64%
Cost1232
\[\begin{array}{l} t_1 := x + \frac{y}{t}\\ t_2 := \frac{x - \frac{x}{z \cdot t - x}}{x + 1}\\ \mathbf{if}\;x \leq -1.45 \cdot 10^{-32}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-138}:\\ \;\;\;\;\frac{t_1}{x + 1}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-63}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-7}:\\ \;\;\;\;\frac{1}{\frac{x + 1}{t_1}}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y \cdot \frac{z}{x}}{x}\\ \end{array} \]
Alternative 2
Error19.81%
Cost1097
\[\begin{array}{l} \mathbf{if}\;t \leq -2.15 \cdot 10^{-133} \lor \neg \left(t \leq 9.5 \cdot 10^{+19}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \frac{y \cdot z - x}{x}}{x + 1}\\ \end{array} \]
Alternative 3
Error32.28%
Cost848
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -1.75 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{-211}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-229}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-127}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error32.21%
Cost848
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -3.6 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-211}:\\ \;\;\;\;z \cdot \frac{y}{z \cdot t - x}\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-229}:\\ \;\;\;\;x - \frac{x}{z \cdot t}\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-127}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error25.1%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -1.9 \cdot 10^{-133} \lor \neg \left(t \leq 4.1 \cdot 10^{+46}\right):\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error22.53%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -7800000000:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-7}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y}{\frac{x \cdot x}{z}}\\ \end{array} \]
Alternative 7
Error23.16%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -1.02 \cdot 10^{+72}:\\ \;\;\;\;1 - \frac{z}{\frac{x \cdot x}{y}}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-8}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y}{\frac{x \cdot x}{z}}\\ \end{array} \]
Alternative 8
Error23.32%
Cost840
\[\begin{array}{l} \mathbf{if}\;x \leq -4.35 \cdot 10^{+71}:\\ \;\;\;\;1 - \frac{z}{\frac{x \cdot x}{y}}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-9}:\\ \;\;\;\;\frac{x + \frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{y \cdot \frac{z}{x}}{x}\\ \end{array} \]
Alternative 9
Error32.14%
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -3.05 \cdot 10^{-31}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-127}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{elif}\;x \leq 2.02 \cdot 10^{-23}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-17}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 10
Error31.9%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-73} \lor \neg \left(x \leq 2.25 \cdot 10^{-127}\right):\\ \;\;\;\;\frac{x}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t}\\ \end{array} \]
Alternative 11
Error41.66%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-29}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-21}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 12
Error44.06%
Cost64
\[1 \]

Error

Reproduce?

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