?

Average Error: 12.0 → 3.7
Time: 8.5s
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} t_1 := x - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{+172}:\\ \;\;\;\;x - \frac{y}{z}\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-103}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \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 (* z (/ (* y 2.0) (- (* z (* 2.0 z)) (* y t)))))))
   (if (<= z -1.8e+172)
     (- x (/ y z))
     (if (<= z -1e-151) t_1 (if (<= z 3.6e-103) (- x (* -2.0 (/ z t))) 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 - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))));
	double tmp;
	if (z <= -1.8e+172) {
		tmp = x - (y / z);
	} else if (z <= -1e-151) {
		tmp = t_1;
	} else if (z <= 3.6e-103) {
		tmp = x - (-2.0 * (z / t));
	} 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) :: tmp
    t_1 = x - (z * ((y * 2.0d0) / ((z * (2.0d0 * z)) - (y * t))))
    if (z <= (-1.8d+172)) then
        tmp = x - (y / z)
    else if (z <= (-1d-151)) then
        tmp = t_1
    else if (z <= 3.6d-103) then
        tmp = x - ((-2.0d0) * (z / t))
    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 - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))));
	double tmp;
	if (z <= -1.8e+172) {
		tmp = x - (y / z);
	} else if (z <= -1e-151) {
		tmp = t_1;
	} else if (z <= 3.6e-103) {
		tmp = x - (-2.0 * (z / t));
	} 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 - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))))
	tmp = 0
	if z <= -1.8e+172:
		tmp = x - (y / z)
	elif z <= -1e-151:
		tmp = t_1
	elif z <= 3.6e-103:
		tmp = x - (-2.0 * (z / t))
	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(z * Float64(Float64(y * 2.0) / Float64(Float64(z * Float64(2.0 * z)) - Float64(y * t)))))
	tmp = 0.0
	if (z <= -1.8e+172)
		tmp = Float64(x - Float64(y / z));
	elseif (z <= -1e-151)
		tmp = t_1;
	elseif (z <= 3.6e-103)
		tmp = Float64(x - Float64(-2.0 * Float64(z / t)));
	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 - (z * ((y * 2.0) / ((z * (2.0 * z)) - (y * t))));
	tmp = 0.0;
	if (z <= -1.8e+172)
		tmp = x - (y / z);
	elseif (z <= -1e-151)
		tmp = t_1;
	elseif (z <= 3.6e-103)
		tmp = x - (-2.0 * (z / t));
	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[(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, -1.8e+172], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1e-151], t$95$1, If[LessEqual[z, 3.6e-103], N[(x - N[(-2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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 - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\
\mathbf{if}\;z \leq -1.8 \cdot 10^{+172}:\\
\;\;\;\;x - \frac{y}{z}\\

\mathbf{elif}\;z \leq -1 \cdot 10^{-151}:\\
\;\;\;\;t_1\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.0
Target0.1
Herbie3.7
\[x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}} \]

Derivation?

  1. Split input into 3 regimes
  2. if z < -1.79999999999999987e172

    1. Initial program 27.1

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

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

      [Start]27.1

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

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

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

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

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

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

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

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

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

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

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

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

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

      metadata-eval [=>]14.4

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

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

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

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

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

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

    if -1.79999999999999987e172 < z < -9.9999999999999994e-152 or 3.5999999999999998e-103 < z

    1. Initial program 10.9

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

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

      [Start]10.9

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999994e-152 < z < 3.5999999999999998e-103

    1. Initial program 8.3

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

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

      [Start]8.3

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

      rational.json-simplify-50 [=>]8.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 [=>]8.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 [=>]8.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 [=>]8.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 [=>]8.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 [<=]8.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 [=>]8.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 [=>]7.5

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

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

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

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

      metadata-eval [=>]7.5

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+172}:\\ \;\;\;\;x - \frac{y}{z}\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-151}:\\ \;\;\;\;x - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-103}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{y \cdot 2}{z \cdot \left(2 \cdot z\right) - y \cdot t}\\ \end{array} \]

Alternatives

Alternative 1
Error3.7
Cost1484
\[\begin{array}{l} t_1 := x - y \cdot \frac{z \cdot -2}{y \cdot t - 2 \cdot \left(z \cdot z\right)}\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{+172}:\\ \;\;\;\;x - \frac{y}{z}\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-103}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error7.3
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-69}:\\ \;\;\;\;x - -2 \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error11.9
Cost584
\[\begin{array}{l} t_1 := x - \frac{y}{z}\\ \mathbf{if}\;z \leq -1.15 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+36}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error16.0
Cost64
\[x \]

Error

Reproduce?

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