?

Average Error: 11.4 → 4.3
Time: 5.5s
Precision: binary64
Cost: 2116

?

\[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 10^{+231}:\\ \;\;\;\;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 1e+231) (- 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 <= 1e+231) {
		tmp = x - t_1;
	} else {
		tmp = x - (y / z);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x - (((y * 2.0d0) * z) / (((z * 2.0d0) * z) - (y * t)))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((y * 2.0d0) * z) / (((z * 2.0d0) * z) - (y * t))
    if (t_1 <= 1d+231) then
        tmp = x - t_1
    else
        tmp = x - (y / z)
    end if
    code = tmp
end function
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 <= 1e+231) {
		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 <= 1e+231:
		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 <= 1e+231)
		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 <= 1e+231)
		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, 1e+231], 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 10^{+231}:\\
\;\;\;\;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.4
Target0.1
Herbie4.3
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}} \]

Derivation?

  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 (*.f64 y 2) z) (-.f64 (*.f64 (*.f64 z 2) z) (*.f64 y t))) < 1.0000000000000001e231

    1. Initial program 2.9

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

    if 1.0000000000000001e231 < (/.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 12.7

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

    \[\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 10^{+231}:\\ \;\;\;\;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
Error7.1
Cost976
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ t_2 := x - -2 \cdot \frac{z}{t}\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-46}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 0.0092:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+61}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error15.8
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{-257}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-184}:\\ \;\;\;\;2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error11.1
Cost584
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -1.65 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-47}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error16.1
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq 2.55 \cdot 10^{-291}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-189}:\\ \;\;\;\;-\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error15.6
Cost64
\[x \]

Error

Reproduce?

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