?

Average Error: 7.6 → 2.7
Time: 1.5min
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}{t \cdot z - x}}{x + 1}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{y}{\left(1 + x\right) \cdot t}\\ \mathbf{elif}\;t_1 \leq 10^{+238}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{t} + x}{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) (- (* t z) x))) (+ x 1.0))))
   (if (<= t_1 (- INFINITY))
     (/ y (* (+ 1.0 x) t))
     (if (<= t_1 1e+238) t_1 (/ (+ (/ y t) x) (+ 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) / ((t * z) - x))) / (x + 1.0);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = y / ((1.0 + x) * t);
	} else if (t_1 <= 1e+238) {
		tmp = t_1;
	} else {
		tmp = ((y / t) + x) / (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) / ((t * z) - x))) / (x + 1.0);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = y / ((1.0 + x) * t);
	} else if (t_1 <= 1e+238) {
		tmp = t_1;
	} else {
		tmp = ((y / t) + x) / (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) / ((t * z) - x))) / (x + 1.0)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = y / ((1.0 + x) * t)
	elif t_1 <= 1e+238:
		tmp = t_1
	else:
		tmp = ((y / t) + x) / (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(t * z) - x))) / Float64(x + 1.0))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(y / Float64(Float64(1.0 + x) * t));
	elseif (t_1 <= 1e+238)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(y / t) + x) / 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) / ((t * z) - x))) / (x + 1.0);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = y / ((1.0 + x) * t);
	elseif (t_1 <= 1e+238)
		tmp = t_1;
	else
		tmp = ((y / t) + x) / (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[(t * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(y / N[(N[(1.0 + x), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+238], t$95$1, N[(N[(N[(y / t), $MachinePrecision] + x), $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}{t \cdot z - x}}{x + 1}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{y}{\left(1 + x\right) \cdot t}\\

\mathbf{elif}\;t_1 \leq 10^{+238}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.6
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 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 64.0

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

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

      [Start]64.0

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

      rational_best-simplify-1 [=>]64.0

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

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

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

      [Start]64.0

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

      rational_best-simplify-1 [=>]64.0

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

      rational_best-simplify-1 [=>]64.0

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

      rational_best-simplify-3 [=>]64.0

      \[ \frac{z \cdot y}{\color{blue}{\left(x + 1\right)} \cdot \left(t \cdot z - x\right)} \]
    5. Taylor expanded in z around inf 29.6

      \[\leadsto \color{blue}{\frac{y}{\left(1 + x\right) \cdot t}} \]

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

    1. Initial program 0.8

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

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

    1. Initial program 57.1

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

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

      [Start]57.1

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

      rational_best-simplify-1 [=>]57.1

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

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

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

Alternatives

Alternative 1
Error12.1
Cost1424
\[\begin{array}{l} t_1 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -1.5 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -4.3 \cdot 10^{-19}:\\ \;\;\;\;1 + \left(-\frac{y \cdot z}{x \cdot \left(1 + x\right)}\right)\\ \mathbf{elif}\;t \leq -4.3 \cdot 10^{-113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-118}:\\ \;\;\;\;\frac{\left(-\frac{z \cdot y}{x}\right) + \left(x + 1\right)}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error12.1
Cost1296
\[\begin{array}{l} t_1 := 1 + \left(-\frac{y \cdot z}{x \cdot \left(1 + x\right)}\right)\\ t_2 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -1.5 \cdot 10^{+19}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.2 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -8.8 \cdot 10^{-116}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.8 \cdot 10^{-118}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error13.8
Cost1104
\[\begin{array}{l} t_1 := 1 + \frac{\left(t - y\right) \cdot z}{x}\\ t_2 := \frac{\frac{y}{t} + x}{x + 1}\\ \mathbf{if}\;t \leq -500000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -4.25 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.9 \cdot 10^{-119}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{-118}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error20.1
Cost712
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-65}:\\ \;\;\;\;\frac{\frac{y}{t}}{x + 1}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error20.1
Cost588
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-14}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-119}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-62}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 6
Error20.1
Cost584
\[\begin{array}{l} t_1 := \frac{x}{x + 1}\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-66}:\\ \;\;\;\;\frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error26.8
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-13}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \leq 2.65 \cdot 10^{-188}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 8
Error28.1
Cost64
\[1 \]

Error

Reproduce?

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