?

Average Error: 4.5 → 1.7
Time: 14.5s
Precision: binary64
Cost: 2764

?

\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ t_2 := x \cdot t_1\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;t_1 \leq -5 \cdot 10^{-276}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{-257}:\\ \;\;\;\;\left(y + t\right) \cdot \left(x \cdot \left(\frac{-2}{z} + \frac{3}{z}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (- (/ y z) (/ t (- 1.0 z)))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (/ y z) (/ t (- 1.0 z)))) (t_2 (* x t_1)))
   (if (<= t_1 (- INFINITY))
     (/ (* y x) z)
     (if (<= t_1 -5e-276)
       t_2
       (if (<= t_1 2e-257) (* (+ y t) (* x (+ (/ -2.0 z) (/ 3.0 z)))) t_2)))))
double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
double code(double x, double y, double z, double t) {
	double t_1 = (y / z) - (t / (1.0 - z));
	double t_2 = x * t_1;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (y * x) / z;
	} else if (t_1 <= -5e-276) {
		tmp = t_2;
	} else if (t_1 <= 2e-257) {
		tmp = (y + t) * (x * ((-2.0 / z) + (3.0 / z)));
	} else {
		tmp = t_2;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return x * ((y / z) - (t / (1.0 - z)));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (y / z) - (t / (1.0 - z));
	double t_2 = x * t_1;
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = (y * x) / z;
	} else if (t_1 <= -5e-276) {
		tmp = t_2;
	} else if (t_1 <= 2e-257) {
		tmp = (y + t) * (x * ((-2.0 / z) + (3.0 / z)));
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	return x * ((y / z) - (t / (1.0 - z)))
def code(x, y, z, t):
	t_1 = (y / z) - (t / (1.0 - z))
	t_2 = x * t_1
	tmp = 0
	if t_1 <= -math.inf:
		tmp = (y * x) / z
	elif t_1 <= -5e-276:
		tmp = t_2
	elif t_1 <= 2e-257:
		tmp = (y + t) * (x * ((-2.0 / z) + (3.0 / z)))
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	return Float64(x * Float64(Float64(y / z) - Float64(t / Float64(1.0 - z))))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(y / z) - Float64(t / Float64(1.0 - z)))
	t_2 = Float64(x * t_1)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(y * x) / z);
	elseif (t_1 <= -5e-276)
		tmp = t_2;
	elseif (t_1 <= 2e-257)
		tmp = Float64(Float64(y + t) * Float64(x * Float64(Float64(-2.0 / z) + Float64(3.0 / z))));
	else
		tmp = t_2;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x * ((y / z) - (t / (1.0 - z)));
end
function tmp_2 = code(x, y, z, t)
	t_1 = (y / z) - (t / (1.0 - z));
	t_2 = x * t_1;
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = (y * x) / z;
	elseif (t_1 <= -5e-276)
		tmp = t_2;
	elseif (t_1 <= 2e-257)
		tmp = (y + t) * (x * ((-2.0 / z) + (3.0 / z)));
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x * N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] - N[(t / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t$95$1, -5e-276], t$95$2, If[LessEqual[t$95$1, 2e-257], N[(N[(y + t), $MachinePrecision] * N[(x * N[(N[(-2.0 / z), $MachinePrecision] + N[(3.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
t_2 := x \cdot t_1\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;t_1 \leq -5 \cdot 10^{-276}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-257}:\\
\;\;\;\;\left(y + t\right) \cdot \left(x \cdot \left(\frac{-2}{z} + \frac{3}{z}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.5
Target4.2
Herbie1.7
\[\begin{array}{l} \mathbf{if}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) < -7.623226303312042 \cdot 10^{-196}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \mathbf{elif}\;x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) < 1.4133944927702302 \cdot 10^{-211}:\\ \;\;\;\;\frac{y \cdot x}{z} + \left(-\frac{t \cdot x}{1 - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t \cdot \frac{1}{1 - z}\right)\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -inf.0

    1. Initial program 64.0

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Taylor expanded in y around inf 0.3

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]

    if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -4.99999999999999967e-276 or 2e-257 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 1.8

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

    if -4.99999999999999967e-276 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 2e-257

    1. Initial program 13.8

      \[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
    2. Taylor expanded in z around inf 13.7

      \[\leadsto x \cdot \color{blue}{\frac{y - -1 \cdot t}{z}} \]
    3. Simplified13.7

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

      [Start]13.7

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

      rational_best-simplify-2 [=>]13.7

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

      rational_best-simplify-13 [<=]13.7

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

      rational_best-simplify-10 [=>]13.7

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

      rational_best-simplify-49 [=>]13.7

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

      rational_best-simplify-4 [=>]13.7

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

      trig-simplify-13 [=>]13.7

      \[ x \cdot \frac{\color{blue}{y + t}}{z} \]
    4. Applied egg-rr13.8

      \[\leadsto x \cdot \color{blue}{\left(\left(y + t\right) \cdot \left(\frac{-2}{z} + \left(\frac{1}{z} - \frac{-2}{z}\right)\right)\right)} \]
    5. Simplified13.8

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

      [Start]13.8

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

      rational_best-simplify-52 [=>]13.8

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

      metadata-eval [=>]13.8

      \[ x \cdot \left(\left(y + t\right) \cdot \left(\frac{-2}{z} + \frac{\color{blue}{3}}{z}\right)\right) \]
    6. Applied egg-rr0.4

      \[\leadsto \color{blue}{\left(\frac{-2}{z} + \frac{3}{z}\right) \cdot \left(x \cdot \left(y + t\right)\right) + 0} \]
    7. Simplified0.4

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

      [Start]0.4

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

      rational_best-simplify-3 [=>]0.4

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

      rational_best-simplify-44 [=>]13.8

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

      rational_best-simplify-2 [<=]13.8

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

      rational_best-simplify-44 [=>]0.4

      \[ \color{blue}{\left(y + t\right) \cdot \left(x \cdot \left(\frac{-2}{z} + \frac{3}{z}\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.7

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

Alternatives

Alternative 1
Error1.9
Cost2636
\[\begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ t_2 := x \cdot t_1\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-166}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{-252}:\\ \;\;\;\;\left(y + t\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error16.8
Cost1240
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z + -1}\\ \mathbf{if}\;t \leq -4.9 \cdot 10^{+113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.2 \cdot 10^{+15}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{elif}\;t \leq -95000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-242}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{+40}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;t \leq 3.35 \cdot 10^{+69}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error19.8
Cost980
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z}\\ t_2 := x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -36000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+39}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+46}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+160}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 9.6 \cdot 10^{+209}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error22.1
Cost848
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z}\\ \mathbf{if}\;t \leq -1.55 \cdot 10^{+120}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.3 \cdot 10^{-242}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{+41}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;t \leq 1.02 \cdot 10^{+70}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error5.2
Cost712
\[\begin{array}{l} t_1 := x \cdot \frac{y + t}{z}\\ \mathbf{if}\;z \leq -7800000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 0.006:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error35.7
Cost584
\[\begin{array}{l} t_1 := t \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error33.9
Cost584
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z}\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error21.7
Cost584
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z}\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+73}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error50.8
Cost256
\[x \cdot \left(-t\right) \]

Error

Reproduce?

herbie shell --seed 2023096 
(FPCore (x y z t)
  :name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, C"
  :precision binary64

  :herbie-target
  (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) -7.623226303312042e-196) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z))))) (if (< (* x (- (/ y z) (/ t (- 1.0 z)))) 1.4133944927702302e-211) (+ (/ (* y x) z) (- (/ (* t x) (- 1.0 z)))) (* x (- (/ y z) (* t (/ 1.0 (- 1.0 z)))))))

  (* x (- (/ y z) (/ t (- 1.0 z)))))