?

Average Error: 11.7 → 2.1
Time: 9.2s
Precision: binary64
Cost: 1616

?

\[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t} \]
\[\begin{array}{l} t_1 := y \cdot t - 2 \cdot \left(z \cdot z\right)\\ t_2 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -8.6 \cdot 10^{+139}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-119}:\\ \;\;\;\;x - y \cdot \left(z \cdot \frac{-2}{t_1}\right)\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-205}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 10^{+134}:\\ \;\;\;\;x - y \cdot \frac{z \cdot -2}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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 t) (* 2.0 (* z z)))) (t_2 (- x (/ y z))))
   (if (<= z -8.6e+139)
     t_2
     (if (<= z -1.1e-119)
       (- x (* y (* z (/ -2.0 t_1))))
       (if (<= z 1.5e-205)
         (- x (* -2.0 (/ z t)))
         (if (<= z 1e+134) (- x (* y (/ (* z -2.0) t_1))) t_2))))))
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 * t) - (2.0 * (z * z));
	double t_2 = x - (y / z);
	double tmp;
	if (z <= -8.6e+139) {
		tmp = t_2;
	} else if (z <= -1.1e-119) {
		tmp = x - (y * (z * (-2.0 / t_1)));
	} else if (z <= 1.5e-205) {
		tmp = x - (-2.0 * (z / t));
	} else if (z <= 1e+134) {
		tmp = x - (y * ((z * -2.0) / t_1));
	} else {
		tmp = t_2;
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = (y * t) - (2.0d0 * (z * z))
    t_2 = x - (y / z)
    if (z <= (-8.6d+139)) then
        tmp = t_2
    else if (z <= (-1.1d-119)) then
        tmp = x - (y * (z * ((-2.0d0) / t_1)))
    else if (z <= 1.5d-205) then
        tmp = x - ((-2.0d0) * (z / t))
    else if (z <= 1d+134) then
        tmp = x - (y * ((z * (-2.0d0)) / t_1))
    else
        tmp = t_2
    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 * t) - (2.0 * (z * z));
	double t_2 = x - (y / z);
	double tmp;
	if (z <= -8.6e+139) {
		tmp = t_2;
	} else if (z <= -1.1e-119) {
		tmp = x - (y * (z * (-2.0 / t_1)));
	} else if (z <= 1.5e-205) {
		tmp = x - (-2.0 * (z / t));
	} else if (z <= 1e+134) {
		tmp = x - (y * ((z * -2.0) / t_1));
	} else {
		tmp = t_2;
	}
	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 * t) - (2.0 * (z * z))
	t_2 = x - (y / z)
	tmp = 0
	if z <= -8.6e+139:
		tmp = t_2
	elif z <= -1.1e-119:
		tmp = x - (y * (z * (-2.0 / t_1)))
	elif z <= 1.5e-205:
		tmp = x - (-2.0 * (z / t))
	elif z <= 1e+134:
		tmp = x - (y * ((z * -2.0) / t_1))
	else:
		tmp = t_2
	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(y * t) - Float64(2.0 * Float64(z * z)))
	t_2 = Float64(x - Float64(y / z))
	tmp = 0.0
	if (z <= -8.6e+139)
		tmp = t_2;
	elseif (z <= -1.1e-119)
		tmp = Float64(x - Float64(y * Float64(z * Float64(-2.0 / t_1))));
	elseif (z <= 1.5e-205)
		tmp = Float64(x - Float64(-2.0 * Float64(z / t)));
	elseif (z <= 1e+134)
		tmp = Float64(x - Float64(y * Float64(Float64(z * -2.0) / t_1)));
	else
		tmp = t_2;
	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 * t) - (2.0 * (z * z));
	t_2 = x - (y / z);
	tmp = 0.0;
	if (z <= -8.6e+139)
		tmp = t_2;
	elseif (z <= -1.1e-119)
		tmp = x - (y * (z * (-2.0 / t_1)));
	elseif (z <= 1.5e-205)
		tmp = x - (-2.0 * (z / t));
	elseif (z <= 1e+134)
		tmp = x - (y * ((z * -2.0) / t_1));
	else
		tmp = t_2;
	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[(y * t), $MachinePrecision] - N[(2.0 * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.6e+139], t$95$2, If[LessEqual[z, -1.1e-119], N[(x - N[(y * N[(z * N[(-2.0 / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e-205], N[(x - N[(-2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1e+134], N[(x - N[(y * N[(N[(z * -2.0), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\begin{array}{l}
t_1 := y \cdot t - 2 \cdot \left(z \cdot z\right)\\
t_2 := x - \frac{y}{z}\\
\mathbf{if}\;z \leq -8.6 \cdot 10^{+139}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;z \leq -1.1 \cdot 10^{-119}:\\
\;\;\;\;x - y \cdot \left(z \cdot \frac{-2}{t_1}\right)\\

\mathbf{elif}\;z \leq 1.5 \cdot 10^{-205}:\\
\;\;\;\;x - -2 \cdot \frac{z}{t}\\

\mathbf{elif}\;z \leq 10^{+134}:\\
\;\;\;\;x - y \cdot \frac{z \cdot -2}{t_1}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.7
Target0.1
Herbie2.1
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}} \]

Derivation?

  1. Split input into 4 regimes
  2. if z < -8.5999999999999996e139 or 9.99999999999999921e133 < z

    1. Initial program 25.5

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

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

      [Start]25.5

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

      rational.json-simplify-49 [=>]13.0

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

      rational.json-simplify-2 [=>]13.0

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

      rational.json-simplify-49 [=>]13.0

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

      rational.json-simplify-43 [=>]12.9

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

      rational.json-simplify-2 [=>]12.9

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

      rational.json-simplify-50 [=>]12.9

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

      metadata-eval [=>]12.9

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

      rational.json-simplify-2 [=>]12.9

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

      rational.json-simplify-43 [<=]12.9

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

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

    if -8.5999999999999996e139 < z < -1.1e-119

    1. Initial program 5.4

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

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

      [Start]5.4

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

      rational.json-simplify-49 [=>]2.0

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

      rational.json-simplify-2 [=>]2.0

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

      rational.json-simplify-49 [=>]2.0

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

      rational.json-simplify-43 [=>]2.0

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

      rational.json-simplify-2 [=>]2.0

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

      rational.json-simplify-50 [=>]2.0

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

      metadata-eval [=>]2.0

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

      rational.json-simplify-2 [=>]2.0

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

      rational.json-simplify-43 [<=]2.0

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

    if -1.1e-119 < z < 1.5e-205

    1. Initial program 7.8

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

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

      [Start]7.8

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

      rational.json-simplify-49 [=>]6.2

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

      rational.json-simplify-2 [=>]6.2

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

      rational.json-simplify-49 [=>]7.0

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

      rational.json-simplify-43 [=>]8.1

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

      rational.json-simplify-2 [=>]8.1

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

      rational.json-simplify-50 [=>]8.1

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

      metadata-eval [=>]8.1

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

      rational.json-simplify-2 [=>]8.1

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

      rational.json-simplify-43 [<=]8.1

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

      \[\leadsto x - \color{blue}{-2 \cdot \frac{z}{t}} \]

    if 1.5e-205 < z < 9.99999999999999921e133

    1. Initial program 5.3

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

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

      [Start]5.3

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

      rational.json-simplify-50 [=>]5.3

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

      rational.json-simplify-10 [=>]5.3

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

      rational.json-simplify-47 [=>]5.3

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

      rational.json-simplify-2 [=>]5.3

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

      rational.json-simplify-43 [=>]5.2

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

      rational.json-simplify-2 [<=]5.2

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

      rational.json-simplify-2 [=>]5.2

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

      rational.json-simplify-49 [=>]2.6

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

      rational.json-simplify-46 [=>]2.6

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

      rational.json-simplify-2 [=>]2.6

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

      rational.json-simplify-49 [=>]2.6

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

      metadata-eval [=>]2.6

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

      rational.json-simplify-2 [=>]2.6

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

      rational.json-simplify-43 [<=]2.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.6 \cdot 10^{+139}:\\ \;\;\;\;x - \frac{y}{z}\\ \mathbf{elif}\;z \leq -1.1 \cdot 10^{-119}:\\ \;\;\;\;x - y \cdot \left(z \cdot \frac{-2}{y \cdot t - 2 \cdot \left(z \cdot z\right)}\right)\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-205}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 10^{+134}:\\ \;\;\;\;x - y \cdot \frac{z \cdot -2}{y \cdot t - 2 \cdot \left(z \cdot z\right)}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error4.3
Cost2116
\[\begin{array}{l} \mathbf{if}\;\frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t} \leq 2 \cdot 10^{+64}:\\ \;\;\;\;x - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z}\\ \end{array} \]
Alternative 2
Error2.5
Cost1616
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ t_2 := x - y \cdot \left(z \cdot \frac{-2}{y \cdot t - 2 \cdot \left(z \cdot z\right)}\right)\\ \mathbf{if}\;z \leq -5 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-250}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{+127}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error12.6
Cost848
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -4.4 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-93}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-142}:\\ \;\;\;\;2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+55}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error7.2
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.4 \cdot 10^{+55}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error15.8
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{-301}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-211}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error15.8
Cost64
\[x \]

Error

Reproduce?

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