?

Average Error: 11.6 → 3.8
Time: 11.2s
Precision: binary64
Cost: 3144

?

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

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+207}:\\
\;\;\;\;x - t_1\\

\mathbf{else}:\\
\;\;\;\;x - \frac{y}{z}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.6
Target0.1
Herbie3.8
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}} \]

Derivation?

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

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{x} \]

    if -inf.0 < (/.f64 (*.f64 (*.f64 y 2) z) (-.f64 (*.f64 (*.f64 z 2) z) (*.f64 y t))) < 4.9999999999999999e207

    1. Initial program 2.0

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

    if 4.9999999999999999e207 < (/.f64 (*.f64 (*.f64 y 2) z) (-.f64 (*.f64 (*.f64 z 2) z) (*.f64 y t)))

    1. Initial program 63.4

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

      \[\leadsto x - \color{blue}{\frac{y}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.8

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

Alternatives

Alternative 1
Error6.6
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -1.58 \cdot 10^{-12}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-29}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error11.6
Cost584
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -4.8 \cdot 10^{+35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-72}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error15.6
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{-238}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-256}:\\ \;\;\;\;-\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error16.0
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (x y z t)
  :name "Numeric.AD.Rank1.Halley:findZero from ad-4.2.4"
  :precision binary64

  :herbie-target
  (- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z))))

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