?

Average Error: 11.8 → 4.4
Time: 8.1s
Precision: binary64
Cost: 1484

?

\[x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{-121}:\\ \;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-150}:\\ \;\;\;\;x - \frac{z \cdot -2}{t}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+65}:\\ \;\;\;\;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} \]
(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
 (if (<= z -1.05e-121)
   (- x (* (* y 2.0) (/ z (- (* z (* 2.0 z)) (* y t)))))
   (if (<= z 5e-150)
     (- x (/ (* z -2.0) t))
     (if (<= z 1.45e+65)
       (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t))))
       (- 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 tmp;
	if (z <= -1.05e-121) {
		tmp = x - ((y * 2.0) * (z / ((z * (2.0 * z)) - (y * t))));
	} else if (z <= 5e-150) {
		tmp = x - ((z * -2.0) / t);
	} else if (z <= 1.45e+65) {
		tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
	} 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) :: tmp
    if (z <= (-1.05d-121)) then
        tmp = x - ((y * 2.0d0) * (z / ((z * (2.0d0 * z)) - (y * t))))
    else if (z <= 5d-150) then
        tmp = x - ((z * (-2.0d0)) / t)
    else if (z <= 1.45d+65) then
        tmp = x - (((y * 2.0d0) * z) / (((z * 2.0d0) * z) - (y * t)))
    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 tmp;
	if (z <= -1.05e-121) {
		tmp = x - ((y * 2.0) * (z / ((z * (2.0 * z)) - (y * t))));
	} else if (z <= 5e-150) {
		tmp = x - ((z * -2.0) / t);
	} else if (z <= 1.45e+65) {
		tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
	} 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):
	tmp = 0
	if z <= -1.05e-121:
		tmp = x - ((y * 2.0) * (z / ((z * (2.0 * z)) - (y * t))))
	elif z <= 5e-150:
		tmp = x - ((z * -2.0) / t)
	elif z <= 1.45e+65:
		tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)))
	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)
	tmp = 0.0
	if (z <= -1.05e-121)
		tmp = Float64(x - Float64(Float64(y * 2.0) * Float64(z / Float64(Float64(z * Float64(2.0 * z)) - Float64(y * t)))));
	elseif (z <= 5e-150)
		tmp = Float64(x - Float64(Float64(z * -2.0) / t));
	elseif (z <= 1.45e+65)
		tmp = Float64(x - Float64(Float64(Float64(y * 2.0) * z) / Float64(Float64(Float64(z * 2.0) * z) - Float64(y * t))));
	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)
	tmp = 0.0;
	if (z <= -1.05e-121)
		tmp = x - ((y * 2.0) * (z / ((z * (2.0 * z)) - (y * t))));
	elseif (z <= 5e-150)
		tmp = x - ((z * -2.0) / t);
	elseif (z <= 1.45e+65)
		tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
	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_] := If[LessEqual[z, -1.05e-121], N[(x - N[(N[(y * 2.0), $MachinePrecision] * N[(z / N[(N[(z * N[(2.0 * z), $MachinePrecision]), $MachinePrecision] - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5e-150], N[(x - N[(N[(z * -2.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.45e+65], 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], 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}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-121}:\\
\;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\

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

\mathbf{elif}\;z \leq 1.45 \cdot 10^{+65}:\\
\;\;\;\;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}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Split input into 4 regimes
  2. if z < -1.0499999999999999e-121

    1. Initial program 13.9

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

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

      [Start]13.9

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

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

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

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

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

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

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

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

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

    if -1.0499999999999999e-121 < z < 4.9999999999999999e-150

    1. Initial program 7.7

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

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

      [Start]7.7

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

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

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

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

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

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

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

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

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

      \[\leadsto x - \color{blue}{-2 \cdot \frac{z}{t}} \]
    4. Simplified1.8

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

      [Start]1.8

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

      rational.json-simplify-48 [=>]1.8

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

    if 4.9999999999999999e-150 < z < 1.45e65

    1. Initial program 2.4

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

    if 1.45e65 < z

    1. Initial program 21.5

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

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

      [Start]21.5

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{-121}:\\ \;\;\;\;x - \left(y \cdot 2\right) \cdot \frac{z}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-150}:\\ \;\;\;\;x - \frac{z \cdot -2}{t}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+65}:\\ \;\;\;\;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
Error4.0
Cost1484
\[\begin{array}{l} t_1 := x - \left(y \cdot 2\right) \cdot \frac{z}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{if}\;z \leq -8.8 \cdot 10^{-122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8.1 \cdot 10^{-147}:\\ \;\;\;\;x - \frac{z \cdot -2}{t}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+95}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z}\\ \end{array} \]
Alternative 2
Error14.5
Cost848
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;x \leq -3 \cdot 10^{-257}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-307}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-240}:\\ \;\;\;\;2 \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-142}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error15.2
Cost716
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-265}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-307}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-259}:\\ \;\;\;\;2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error6.8
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-8}:\\ \;\;\;\;x - \frac{z \cdot -2}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error15.4
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-264}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-302}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error15.7
Cost64
\[x \]

Error

Reproduce?

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