?

Average Error: 11.8 → 1.8
Time: 10.0s
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 := x - \frac{y}{z}\\ t_2 := x - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{if}\;z \leq -9 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-134}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-187}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+147}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (- x (/ y z)))
        (t_2 (- x (* z (/ (* y 2.0) (- (* z (* 2.0 z)) (* y t)))))))
   (if (<= z -9e+162)
     t_1
     (if (<= z -4.3e-134)
       t_2
       (if (<= z 2e-187)
         (- x (* -2.0 (/ z t)))
         (if (<= z 1.25e+147) t_2 t_1))))))
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 = x - (y / z);
	double t_2 = x - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))));
	double tmp;
	if (z <= -9e+162) {
		tmp = t_1;
	} else if (z <= -4.3e-134) {
		tmp = t_2;
	} else if (z <= 2e-187) {
		tmp = x - (-2.0 * (z / t));
	} else if (z <= 1.25e+147) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	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 = x - (y / z)
    t_2 = x - (z * ((y * 2.0d0) / ((z * (2.0d0 * z)) - (y * t))))
    if (z <= (-9d+162)) then
        tmp = t_1
    else if (z <= (-4.3d-134)) then
        tmp = t_2
    else if (z <= 2d-187) then
        tmp = x - ((-2.0d0) * (z / t))
    else if (z <= 1.25d+147) then
        tmp = t_2
    else
        tmp = t_1
    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 = x - (y / z);
	double t_2 = x - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))));
	double tmp;
	if (z <= -9e+162) {
		tmp = t_1;
	} else if (z <= -4.3e-134) {
		tmp = t_2;
	} else if (z <= 2e-187) {
		tmp = x - (-2.0 * (z / t));
	} else if (z <= 1.25e+147) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	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 = x - (y / z)
	t_2 = x - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))))
	tmp = 0
	if z <= -9e+162:
		tmp = t_1
	elif z <= -4.3e-134:
		tmp = t_2
	elif z <= 2e-187:
		tmp = x - (-2.0 * (z / t))
	elif z <= 1.25e+147:
		tmp = t_2
	else:
		tmp = t_1
	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(x - Float64(y / z))
	t_2 = Float64(x - Float64(z * Float64(Float64(y * 2.0) / Float64(Float64(z * Float64(2.0 * z)) - Float64(y * t)))))
	tmp = 0.0
	if (z <= -9e+162)
		tmp = t_1;
	elseif (z <= -4.3e-134)
		tmp = t_2;
	elseif (z <= 2e-187)
		tmp = Float64(x - Float64(-2.0 * Float64(z / t)));
	elseif (z <= 1.25e+147)
		tmp = t_2;
	else
		tmp = t_1;
	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 = x - (y / z);
	t_2 = x - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))));
	tmp = 0.0;
	if (z <= -9e+162)
		tmp = t_1;
	elseif (z <= -4.3e-134)
		tmp = t_2;
	elseif (z <= 2e-187)
		tmp = x - (-2.0 * (z / t));
	elseif (z <= 1.25e+147)
		tmp = t_2;
	else
		tmp = t_1;
	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[(x - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(z * N[(N[(y * 2.0), $MachinePrecision] / N[(N[(z * N[(2.0 * z), $MachinePrecision]), $MachinePrecision] - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9e+162], t$95$1, If[LessEqual[z, -4.3e-134], t$95$2, If[LessEqual[z, 2e-187], N[(x - N[(-2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.25e+147], t$95$2, t$95$1]]]]]]
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\begin{array}{l}
t_1 := x - \frac{y}{z}\\
t_2 := x - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\
\mathbf{if}\;z \leq -9 \cdot 10^{+162}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -4.3 \cdot 10^{-134}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;z \leq 1.25 \cdot 10^{+147}:\\
\;\;\;\;t_2\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Split input into 3 regimes
  2. if z < -8.99999999999999944e162 or 1.2500000000000001e147 < z

    1. Initial program 27.2

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

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

      [Start]27.2

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

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

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

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

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

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

      \[ 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 [=>]14.7

      \[ 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 [=>]14.7

      \[ 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 [=>]14.7

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

      metadata-eval [=>]14.7

      \[ 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 [=>]14.7

      \[ 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 [<=]14.7

      \[ 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 1.5

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

    if -8.99999999999999944e162 < z < -4.29999999999999987e-134 or 2e-187 < z < 1.2500000000000001e147

    1. Initial program 5.7

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

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

      [Start]5.7

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

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

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

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

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

      rational.json-simplify-5 [<=]2.2

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

      rational.json-simplify-50 [<=]2.2

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

      rational.json-simplify-45 [=>]2.2

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

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

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

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

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

      rational.json-simplify-5 [=>]2.2

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

    if -4.29999999999999987e-134 < z < 2e-187

    1. Initial program 8.8

      \[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t} \]
    2. Simplified9.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]8.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.9

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

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

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

      rational.json-simplify-49 [=>]8.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 [=>]9.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 [=>]9.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 [=>]9.1

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

      metadata-eval [=>]9.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 [=>]9.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 [<=]9.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.5

      \[\leadsto x - \color{blue}{-2 \cdot \frac{z}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+162}:\\ \;\;\;\;x - \frac{y}{z}\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-134}:\\ \;\;\;\;x - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-187}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+147}:\\ \;\;\;\;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} \]

Alternatives

Alternative 1
Error1.9
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 -9 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-134}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-144}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{+149}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error1.9
Cost1616
\[\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 -9 \cdot 10^{+162}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-134}:\\ \;\;\;\;x - y \cdot \left(z \cdot \frac{-2}{t_1}\right)\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-185}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+151}:\\ \;\;\;\;x - y \cdot \frac{z \cdot -2}{t_1}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error6.9
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -1.55 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-63}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error11.6
Cost584
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -4.6 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-63}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error16.3
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{-205}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-198}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error16.1
Cost64
\[x \]

Error

Reproduce?

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