?

Average Error: 11.9 → 3.5
Time: 37.2s
Precision: binary64
Cost: 1224

?

\[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 -5.5 \cdot 10^{+128}:\\ \;\;\;\;\left(x + x\right) - \left(x + \frac{y}{z}\right)\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+116}:\\ \;\;\;\;x - y \cdot \frac{z}{z \cdot z - \frac{y \cdot t}{2}}\\ \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 -5.5e+128)
   (- (+ x x) (+ x (/ y z)))
   (if (<= z 1.4e+116)
     (- x (* y (/ z (- (* z z) (/ (* y t) 2.0)))))
     (- 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 <= -5.5e+128) {
		tmp = (x + x) - (x + (y / z));
	} else if (z <= 1.4e+116) {
		tmp = x - (y * (z / ((z * z) - ((y * t) / 2.0))));
	} 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 <= (-5.5d+128)) then
        tmp = (x + x) - (x + (y / z))
    else if (z <= 1.4d+116) then
        tmp = x - (y * (z / ((z * z) - ((y * t) / 2.0d0))))
    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 <= -5.5e+128) {
		tmp = (x + x) - (x + (y / z));
	} else if (z <= 1.4e+116) {
		tmp = x - (y * (z / ((z * z) - ((y * t) / 2.0))));
	} 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 <= -5.5e+128:
		tmp = (x + x) - (x + (y / z))
	elif z <= 1.4e+116:
		tmp = x - (y * (z / ((z * z) - ((y * t) / 2.0))))
	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 <= -5.5e+128)
		tmp = Float64(Float64(x + x) - Float64(x + Float64(y / z)));
	elseif (z <= 1.4e+116)
		tmp = Float64(x - Float64(y * Float64(z / Float64(Float64(z * z) - Float64(Float64(y * t) / 2.0)))));
	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 <= -5.5e+128)
		tmp = (x + x) - (x + (y / z));
	elseif (z <= 1.4e+116)
		tmp = x - (y * (z / ((z * z) - ((y * t) / 2.0))));
	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, -5.5e+128], N[(N[(x + x), $MachinePrecision] - N[(x + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.4e+116], N[(x - N[(y * N[(z / N[(N[(z * z), $MachinePrecision] - N[(N[(y * t), $MachinePrecision] / 2.0), $MachinePrecision]), $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 -5.5 \cdot 10^{+128}:\\
\;\;\;\;\left(x + x\right) - \left(x + \frac{y}{z}\right)\\

\mathbf{elif}\;z \leq 1.4 \cdot 10^{+116}:\\
\;\;\;\;x - y \cdot \frac{z}{z \cdot z - \frac{y \cdot t}{2}}\\

\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.9
Target0.1
Herbie3.5
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}} \]

Derivation?

  1. Split input into 3 regimes
  2. if z < -5.4999999999999998e128

    1. Initial program 26.3

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{z} + x} \]
    3. Simplified2.1

      \[\leadsto \color{blue}{x + y \cdot \frac{-1}{z}} \]
      Proof

      [Start]2.1

      \[ -1 \cdot \frac{y}{z} + x \]

      rational_best-simplify-3 [=>]2.1

      \[ \color{blue}{x + -1 \cdot \frac{y}{z}} \]

      rational_best-simplify-55 [=>]2.1

      \[ x + \color{blue}{y \cdot \frac{-1}{z}} \]
    4. Applied egg-rr2.1

      \[\leadsto \color{blue}{\left(x + x\right) - \left(x + \frac{y}{z}\right)} \]

    if -5.4999999999999998e128 < z < 1.40000000000000002e116

    1. Initial program 5.8

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

      \[\leadsto x - \color{blue}{\frac{z}{y \cdot t + \frac{z \cdot z}{-0.5}} \cdot \frac{y}{-0.5}} \]
    3. Applied egg-rr3.5

      \[\leadsto x - \color{blue}{\left(z \cdot \frac{-y}{\frac{y \cdot t}{2} - z \cdot z} + 0\right)} \]
    4. Simplified3.9

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

      [Start]3.5

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

      rational_best-simplify-3 [=>]3.5

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

      rational_best-simplify-6 [=>]3.5

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

      rational_best-simplify-55 [=>]3.9

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

      rational_best-simplify-1 [=>]3.9

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

      rational_best-simplify-13 [=>]3.9

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

      rational_best-simplify-55 [<=]3.9

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

      rational_best-simplify-53 [=>]3.9

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

      rational_best-simplify-11 [<=]3.9

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

      rational_best-simplify-14 [=>]3.9

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

      rational_best-simplify-51 [=>]3.9

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

      rational_best-simplify-9 [=>]3.9

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

    if 1.40000000000000002e116 < z

    1. Initial program 24.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+128}:\\ \;\;\;\;\left(x + x\right) - \left(x + \frac{y}{z}\right)\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+116}:\\ \;\;\;\;x - y \cdot \frac{z}{z \cdot z - \frac{y \cdot t}{2}}\\ \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 -1950:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 0.035:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error6.6
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -7.7:\\ \;\;\;\;\left(x + x\right) - \left(x + \frac{y}{z}\right)\\ \mathbf{elif}\;z \leq 16.5:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{z}\\ \end{array} \]
Alternative 3
Error12.1
Cost584
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -8.6 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+108}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error15.8
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{-192}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.15 \cdot 10^{-236}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error15.8
Cost64
\[x \]

Error

Reproduce?

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