?

Average Error: 4.8 → 1.5
Time: 11.4s
Precision: binary64
Cost: 1993

?

\[x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right) \]
\[\begin{array}{l} t_1 := \frac{y}{z} - \frac{t}{1 - z}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+296}\right):\\ \;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot x\\ \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)))))
   (if (or (<= t_1 (- INFINITY)) (not (<= t_1 5e+296)))
     (/ 1.0 (/ z (* y x)))
     (* t_1 x))))
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 tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5e+296)) {
		tmp = 1.0 / (z / (y * x));
	} else {
		tmp = t_1 * x;
	}
	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 tmp;
	if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 5e+296)) {
		tmp = 1.0 / (z / (y * x));
	} else {
		tmp = t_1 * x;
	}
	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))
	tmp = 0
	if (t_1 <= -math.inf) or not (t_1 <= 5e+296):
		tmp = 1.0 / (z / (y * x))
	else:
		tmp = t_1 * x
	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)))
	tmp = 0.0
	if ((t_1 <= Float64(-Inf)) || !(t_1 <= 5e+296))
		tmp = Float64(1.0 / Float64(z / Float64(y * x)));
	else
		tmp = Float64(t_1 * x);
	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));
	tmp = 0.0;
	if ((t_1 <= -Inf) || ~((t_1 <= 5e+296)))
		tmp = 1.0 / (z / (y * x));
	else
		tmp = t_1 * x;
	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]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 5e+296]], $MachinePrecision]], N[(1.0 / N[(z / N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * x), $MachinePrecision]]]
x \cdot \left(\frac{y}{z} - \frac{t}{1 - z}\right)
\begin{array}{l}
t_1 := \frac{y}{z} - \frac{t}{1 - z}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+296}\right):\\
\;\;\;\;\frac{1}{\frac{z}{y \cdot x}}\\

\mathbf{else}:\\
\;\;\;\;t_1 \cdot x\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.8
Target4.3
Herbie1.5
\[\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 2 regimes
  2. if (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < -inf.0 or 5.0000000000000001e296 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z)))

    1. Initial program 58.9

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Simplified61.1

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

      [Start]2.4

      \[ \frac{y \cdot x}{z} \]

      associate-*l/ [<=]61.1

      \[ \color{blue}{\frac{y}{z} \cdot x} \]
    4. Applied egg-rr2.5

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

    if -inf.0 < (-.f64 (/.f64 y z) (/.f64 t (-.f64 1 z))) < 5.0000000000000001e296

    1. Initial program 1.5

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

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

Alternatives

Alternative 1
Error20.5
Cost1108
\[\begin{array}{l} t_1 := \frac{y}{z} \cdot x\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{+253}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{elif}\;z \leq -9 \cdot 10^{+210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{+80}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;z \leq 1.08 \cdot 10^{-20}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+54}:\\ \;\;\;\;\frac{t}{\frac{z + -1}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error19.9
Cost976
\[\begin{array}{l} t_1 := \frac{y}{z} \cdot x\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{+253}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{+211}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7.5 \cdot 10^{+78}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error4.4
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -0.98 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;x \cdot \frac{y + t}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z} - t \cdot x\\ \end{array} \]
Alternative 4
Error5.5
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.95 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\frac{x}{\frac{z}{y + t}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \end{array} \]
Alternative 5
Error5.4
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;x \cdot \frac{y + t}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} - t\right)\\ \end{array} \]
Alternative 6
Error27.3
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-205} \lor \neg \left(y \leq 3.4 \cdot 10^{-157}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;-t \cdot x\\ \end{array} \]
Alternative 7
Error23.0
Cost585
\[\begin{array}{l} \mathbf{if}\;t \leq -2.75 \cdot 10^{+153} \lor \neg \left(t \leq 2.7 \cdot 10^{+84}\right):\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
Alternative 8
Error21.9
Cost585
\[\begin{array}{l} \mathbf{if}\;t \leq -2.75 \cdot 10^{+153} \lor \neg \left(t \leq 8.2 \cdot 10^{+85}\right):\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \end{array} \]
Alternative 9
Error21.9
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -3.1 \cdot 10^{+153}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;t \leq 1.06 \cdot 10^{+82}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \end{array} \]
Alternative 10
Error21.7
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -2.8 \cdot 10^{+153}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;t \leq 8.6 \cdot 10^{+77}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \end{array} \]
Alternative 11
Error51.1
Cost256
\[-t \cdot x \]

Error

Reproduce?

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