
(FPCore (x y z t) :precision binary64 (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))
double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
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
public static double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
def code(x, y, z, t): return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)))
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 tmp = code(x, y, z, t) tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t))); 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]
\begin{array}{l}
\\
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- x (/ (* (* y 2.0) z) (- (* (* z 2.0) z) (* y t)))))
double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
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
public static double code(double x, double y, double z, double t) {
return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)));
}
def code(x, y, z, t): return x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t)))
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 tmp = code(x, y, z, t) tmp = x - (((y * 2.0) * z) / (((z * 2.0) * z) - (y * t))); 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]
\begin{array}{l}
\\
x - \frac{\left(y \cdot 2\right) \cdot z}{\left(z \cdot 2\right) \cdot z - y \cdot t}
\end{array}
(FPCore (x y z t) :precision binary64 (+ x (/ -2.0 (- (* z (/ 2.0 y)) (/ t z)))))
double code(double x, double y, double z, double t) {
return x + (-2.0 / ((z * (2.0 / y)) - (t / z)));
}
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 + ((-2.0d0) / ((z * (2.0d0 / y)) - (t / z)))
end function
public static double code(double x, double y, double z, double t) {
return x + (-2.0 / ((z * (2.0 / y)) - (t / z)));
}
def code(x, y, z, t): return x + (-2.0 / ((z * (2.0 / y)) - (t / z)))
function code(x, y, z, t) return Float64(x + Float64(-2.0 / Float64(Float64(z * Float64(2.0 / y)) - Float64(t / z)))) end
function tmp = code(x, y, z, t) tmp = x + (-2.0 / ((z * (2.0 / y)) - (t / z))); end
code[x_, y_, z_, t_] := N[(x + N[(-2.0 / N[(N[(z * N[(2.0 / y), $MachinePrecision]), $MachinePrecision] - N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-2}{z \cdot \frac{2}{y} - \frac{t}{z}}
\end{array}
Initial program 81.1%
sub-neg81.1%
associate-/l*90.4%
*-commutative90.4%
associate-/l*90.4%
distribute-neg-frac90.4%
metadata-eval90.4%
associate-/l/81.1%
div-sub73.2%
times-frac91.8%
*-inverses91.8%
*-rgt-identity91.8%
*-commutative91.8%
associate-*l/91.8%
*-commutative91.8%
times-frac99.8%
*-inverses99.8%
*-lft-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.05e-9) (not (<= z 7e-22))) (- x (/ y z)) (+ x (* z (/ 2.0 t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.05e-9) || !(z <= 7e-22)) {
tmp = x - (y / z);
} else {
tmp = x + (z * (2.0 / t));
}
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
real(8) :: tmp
if ((z <= (-1.05d-9)) .or. (.not. (z <= 7d-22))) then
tmp = x - (y / z)
else
tmp = x + (z * (2.0d0 / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.05e-9) || !(z <= 7e-22)) {
tmp = x - (y / z);
} else {
tmp = x + (z * (2.0 / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.05e-9) or not (z <= 7e-22): tmp = x - (y / z) else: tmp = x + (z * (2.0 / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.05e-9) || !(z <= 7e-22)) tmp = Float64(x - Float64(y / z)); else tmp = Float64(x + Float64(z * Float64(2.0 / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.05e-9) || ~((z <= 7e-22))) tmp = x - (y / z); else tmp = x + (z * (2.0 / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.05e-9], N[Not[LessEqual[z, 7e-22]], $MachinePrecision]], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-9} \lor \neg \left(z \leq 7 \cdot 10^{-22}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{2}{t}\\
\end{array}
\end{array}
if z < -1.0500000000000001e-9 or 7.00000000000000011e-22 < z Initial program 71.1%
sub-neg71.1%
associate-/l*88.2%
*-commutative88.2%
associate-/l*88.1%
distribute-neg-frac88.1%
metadata-eval88.1%
associate-/l/71.1%
div-sub71.0%
times-frac91.4%
*-inverses91.4%
*-rgt-identity91.4%
*-commutative91.4%
associate-*l/91.3%
*-commutative91.3%
times-frac99.8%
*-inverses99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in z around inf 90.3%
+-commutative90.3%
mul-1-neg90.3%
sub-neg90.3%
Simplified90.3%
if -1.0500000000000001e-9 < z < 7.00000000000000011e-22Initial program 93.2%
sub-neg93.2%
associate-/l*93.1%
distribute-neg-frac93.1%
associate-/r/94.9%
distribute-rgt-neg-in94.9%
metadata-eval94.9%
associate-*l*94.9%
Simplified94.9%
Taylor expanded in y around inf 92.3%
Final simplification91.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.3e-12) (not (<= z 2.5e-19))) (- x (/ y z)) (- x (/ z (* t -0.5)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.3e-12) || !(z <= 2.5e-19)) {
tmp = x - (y / z);
} else {
tmp = x - (z / (t * -0.5));
}
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
real(8) :: tmp
if ((z <= (-3.3d-12)) .or. (.not. (z <= 2.5d-19))) then
tmp = x - (y / z)
else
tmp = x - (z / (t * (-0.5d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.3e-12) || !(z <= 2.5e-19)) {
tmp = x - (y / z);
} else {
tmp = x - (z / (t * -0.5));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.3e-12) or not (z <= 2.5e-19): tmp = x - (y / z) else: tmp = x - (z / (t * -0.5)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.3e-12) || !(z <= 2.5e-19)) tmp = Float64(x - Float64(y / z)); else tmp = Float64(x - Float64(z / Float64(t * -0.5))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.3e-12) || ~((z <= 2.5e-19))) tmp = x - (y / z); else tmp = x - (z / (t * -0.5)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.3e-12], N[Not[LessEqual[z, 2.5e-19]], $MachinePrecision]], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x - N[(z / N[(t * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{-12} \lor \neg \left(z \leq 2.5 \cdot 10^{-19}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z}{t \cdot -0.5}\\
\end{array}
\end{array}
if z < -3.3000000000000001e-12 or 2.5000000000000002e-19 < z Initial program 71.1%
sub-neg71.1%
associate-/l*88.2%
*-commutative88.2%
associate-/l*88.1%
distribute-neg-frac88.1%
metadata-eval88.1%
associate-/l/71.1%
div-sub71.0%
times-frac91.4%
*-inverses91.4%
*-rgt-identity91.4%
*-commutative91.4%
associate-*l/91.3%
*-commutative91.3%
times-frac99.8%
*-inverses99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in z around inf 90.3%
+-commutative90.3%
mul-1-neg90.3%
sub-neg90.3%
Simplified90.3%
if -3.3000000000000001e-12 < z < 2.5000000000000002e-19Initial program 93.2%
*-commutative93.2%
associate-/l*95.0%
div-sub95.0%
sub-neg95.0%
*-commutative95.0%
associate-*l*95.0%
*-commutative95.0%
times-frac95.0%
metadata-eval95.0%
*-lft-identity95.0%
associate-*r/97.5%
fma-def97.5%
associate-/r*97.5%
distribute-neg-frac97.5%
*-commutative97.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 92.4%
*-commutative92.4%
Simplified92.4%
Final simplification91.2%
(FPCore (x y z t) :precision binary64 (if (<= x -1.95e-124) x (if (<= x -2.7e-187) (* z (/ 2.0 t)) (if (<= x 2.7e-237) (/ (- y) z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.95e-124) {
tmp = x;
} else if (x <= -2.7e-187) {
tmp = z * (2.0 / t);
} else if (x <= 2.7e-237) {
tmp = -y / z;
} else {
tmp = x;
}
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
real(8) :: tmp
if (x <= (-1.95d-124)) then
tmp = x
else if (x <= (-2.7d-187)) then
tmp = z * (2.0d0 / t)
else if (x <= 2.7d-237) then
tmp = -y / z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.95e-124) {
tmp = x;
} else if (x <= -2.7e-187) {
tmp = z * (2.0 / t);
} else if (x <= 2.7e-237) {
tmp = -y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.95e-124: tmp = x elif x <= -2.7e-187: tmp = z * (2.0 / t) elif x <= 2.7e-237: tmp = -y / z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.95e-124) tmp = x; elseif (x <= -2.7e-187) tmp = Float64(z * Float64(2.0 / t)); elseif (x <= 2.7e-237) tmp = Float64(Float64(-y) / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.95e-124) tmp = x; elseif (x <= -2.7e-187) tmp = z * (2.0 / t); elseif (x <= 2.7e-237) tmp = -y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.95e-124], x, If[LessEqual[x, -2.7e-187], N[(z * N[(2.0 / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.7e-237], N[((-y) / z), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{-124}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -2.7 \cdot 10^{-187}:\\
\;\;\;\;z \cdot \frac{2}{t}\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-237}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.94999999999999996e-124 or 2.69999999999999984e-237 < x Initial program 85.8%
sub-neg85.8%
associate-/l*96.6%
*-commutative96.6%
associate-/l*96.6%
distribute-neg-frac96.6%
metadata-eval96.6%
associate-/l/85.8%
div-sub76.9%
times-frac94.5%
*-inverses94.5%
*-rgt-identity94.5%
*-commutative94.5%
associate-*l/94.5%
*-commutative94.5%
times-frac99.9%
*-inverses99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 88.0%
if -1.94999999999999996e-124 < x < -2.7000000000000001e-187Initial program 80.4%
*-commutative80.4%
associate-/l*93.5%
div-sub93.5%
sub-neg93.5%
*-commutative93.5%
associate-*l*93.5%
*-commutative93.5%
times-frac93.5%
metadata-eval93.5%
*-lft-identity93.5%
associate-*r/93.5%
fma-def93.5%
associate-/r*93.5%
distribute-neg-frac93.5%
*-commutative93.5%
associate-/l*100.0%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 93.4%
*-commutative93.4%
Simplified93.4%
Taylor expanded in x around 0 68.2%
*-commutative68.2%
Simplified68.2%
Taylor expanded in z around 0 68.2%
*-commutative68.2%
associate-*l/68.2%
associate-*r/67.8%
Simplified67.8%
if -2.7000000000000001e-187 < x < 2.69999999999999984e-237Initial program 56.2%
sub-neg56.2%
associate-/l*56.3%
*-commutative56.3%
associate-/l*56.2%
distribute-neg-frac56.2%
metadata-eval56.2%
associate-/l/56.3%
div-sub51.0%
times-frac81.9%
*-inverses81.9%
*-rgt-identity81.9%
*-commutative81.9%
associate-*l/81.8%
*-commutative81.8%
times-frac99.5%
*-inverses99.5%
*-lft-identity99.5%
Simplified99.5%
Taylor expanded in z around inf 64.2%
+-commutative64.2%
mul-1-neg64.2%
sub-neg64.2%
Simplified64.2%
Taylor expanded in x around 0 59.3%
neg-mul-159.3%
distribute-neg-frac59.3%
Simplified59.3%
Final simplification82.6%
(FPCore (x y z t) :precision binary64 (if (<= x -1.95e-124) x (if (<= x -1.55e-187) (* 2.0 (/ z t)) (if (<= x 5.8e-239) (/ (- y) z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.95e-124) {
tmp = x;
} else if (x <= -1.55e-187) {
tmp = 2.0 * (z / t);
} else if (x <= 5.8e-239) {
tmp = -y / z;
} else {
tmp = x;
}
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
real(8) :: tmp
if (x <= (-1.95d-124)) then
tmp = x
else if (x <= (-1.55d-187)) then
tmp = 2.0d0 * (z / t)
else if (x <= 5.8d-239) then
tmp = -y / z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -1.95e-124) {
tmp = x;
} else if (x <= -1.55e-187) {
tmp = 2.0 * (z / t);
} else if (x <= 5.8e-239) {
tmp = -y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -1.95e-124: tmp = x elif x <= -1.55e-187: tmp = 2.0 * (z / t) elif x <= 5.8e-239: tmp = -y / z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -1.95e-124) tmp = x; elseif (x <= -1.55e-187) tmp = Float64(2.0 * Float64(z / t)); elseif (x <= 5.8e-239) tmp = Float64(Float64(-y) / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -1.95e-124) tmp = x; elseif (x <= -1.55e-187) tmp = 2.0 * (z / t); elseif (x <= 5.8e-239) tmp = -y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -1.95e-124], x, If[LessEqual[x, -1.55e-187], N[(2.0 * N[(z / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e-239], N[((-y) / z), $MachinePrecision], x]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.95 \cdot 10^{-124}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-187}:\\
\;\;\;\;2 \cdot \frac{z}{t}\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-239}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.94999999999999996e-124 or 5.8000000000000004e-239 < x Initial program 85.8%
sub-neg85.8%
associate-/l*96.6%
*-commutative96.6%
associate-/l*96.6%
distribute-neg-frac96.6%
metadata-eval96.6%
associate-/l/85.8%
div-sub76.9%
times-frac94.5%
*-inverses94.5%
*-rgt-identity94.5%
*-commutative94.5%
associate-*l/94.5%
*-commutative94.5%
times-frac99.9%
*-inverses99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 88.0%
if -1.94999999999999996e-124 < x < -1.5500000000000001e-187Initial program 80.4%
*-commutative80.4%
associate-/l*93.5%
div-sub93.5%
sub-neg93.5%
*-commutative93.5%
associate-*l*93.5%
*-commutative93.5%
times-frac93.5%
metadata-eval93.5%
*-lft-identity93.5%
associate-*r/93.5%
fma-def93.5%
associate-/r*93.5%
distribute-neg-frac93.5%
*-commutative93.5%
associate-/l*100.0%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 93.4%
*-commutative93.4%
Simplified93.4%
Taylor expanded in x around 0 68.2%
*-commutative68.2%
Simplified68.2%
if -1.5500000000000001e-187 < x < 5.8000000000000004e-239Initial program 56.2%
sub-neg56.2%
associate-/l*56.3%
*-commutative56.3%
associate-/l*56.2%
distribute-neg-frac56.2%
metadata-eval56.2%
associate-/l/56.3%
div-sub51.0%
times-frac81.9%
*-inverses81.9%
*-rgt-identity81.9%
*-commutative81.9%
associate-*l/81.8%
*-commutative81.8%
times-frac99.5%
*-inverses99.5%
*-lft-identity99.5%
Simplified99.5%
Taylor expanded in z around inf 64.2%
+-commutative64.2%
mul-1-neg64.2%
sub-neg64.2%
Simplified64.2%
Taylor expanded in x around 0 59.3%
neg-mul-159.3%
distribute-neg-frac59.3%
Simplified59.3%
Final simplification82.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.7e-11) (not (<= z 3.5e-32))) (- x (/ y z)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.7e-11) || !(z <= 3.5e-32)) {
tmp = x - (y / z);
} else {
tmp = x;
}
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
real(8) :: tmp
if ((z <= (-3.7d-11)) .or. (.not. (z <= 3.5d-32))) then
tmp = x - (y / z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.7e-11) || !(z <= 3.5e-32)) {
tmp = x - (y / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.7e-11) or not (z <= 3.5e-32): tmp = x - (y / z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.7e-11) || !(z <= 3.5e-32)) tmp = Float64(x - Float64(y / z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.7e-11) || ~((z <= 3.5e-32))) tmp = x - (y / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.7e-11], N[Not[LessEqual[z, 3.5e-32]], $MachinePrecision]], N[(x - N[(y / z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{-11} \lor \neg \left(z \leq 3.5 \cdot 10^{-32}\right):\\
\;\;\;\;x - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.7000000000000001e-11 or 3.4999999999999999e-32 < z Initial program 70.8%
sub-neg70.8%
associate-/l*87.7%
*-commutative87.7%
associate-/l*87.6%
distribute-neg-frac87.6%
metadata-eval87.6%
associate-/l/70.8%
div-sub70.8%
times-frac90.8%
*-inverses90.8%
*-rgt-identity90.8%
*-commutative90.8%
associate-*l/90.8%
*-commutative90.8%
times-frac99.8%
*-inverses99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in z around inf 89.7%
+-commutative89.7%
mul-1-neg89.7%
sub-neg89.7%
Simplified89.7%
if -3.7000000000000001e-11 < z < 3.4999999999999999e-32Initial program 93.9%
sub-neg93.9%
associate-/l*93.8%
*-commutative93.8%
associate-/l*93.7%
distribute-neg-frac93.7%
metadata-eval93.7%
associate-/l/93.9%
div-sub76.3%
times-frac93.0%
*-inverses93.0%
*-rgt-identity93.0%
*-commutative93.0%
associate-*l/93.0%
*-commutative93.0%
times-frac99.9%
*-inverses99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 77.5%
Final simplification84.3%
(FPCore (x y z t) :precision binary64 (if (<= x -2.7e-184) x (if (<= x 1.9e-237) (/ (- y) z) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.7e-184) {
tmp = x;
} else if (x <= 1.9e-237) {
tmp = -y / z;
} else {
tmp = x;
}
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
real(8) :: tmp
if (x <= (-2.7d-184)) then
tmp = x
else if (x <= 1.9d-237) then
tmp = -y / z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.7e-184) {
tmp = x;
} else if (x <= 1.9e-237) {
tmp = -y / z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -2.7e-184: tmp = x elif x <= 1.9e-237: tmp = -y / z else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -2.7e-184) tmp = x; elseif (x <= 1.9e-237) tmp = Float64(Float64(-y) / z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.7e-184) tmp = x; elseif (x <= 1.9e-237) tmp = -y / z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.7e-184], x, If[LessEqual[x, 1.9e-237], N[((-y) / z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-184}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-237}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.7000000000000001e-184 or 1.90000000000000012e-237 < x Initial program 85.3%
sub-neg85.3%
associate-/l*96.3%
*-commutative96.3%
associate-/l*96.3%
distribute-neg-frac96.3%
metadata-eval96.3%
associate-/l/85.3%
div-sub76.9%
times-frac93.5%
*-inverses93.5%
*-rgt-identity93.5%
*-commutative93.5%
associate-*l/93.5%
*-commutative93.5%
times-frac99.9%
*-inverses99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around inf 85.2%
if -2.7000000000000001e-184 < x < 1.90000000000000012e-237Initial program 58.4%
sub-neg58.4%
associate-/l*58.5%
*-commutative58.5%
associate-/l*58.3%
distribute-neg-frac58.3%
metadata-eval58.3%
associate-/l/58.4%
div-sub53.4%
times-frac82.7%
*-inverses82.7%
*-rgt-identity82.7%
*-commutative82.7%
associate-*l/82.7%
*-commutative82.7%
times-frac99.5%
*-inverses99.5%
*-lft-identity99.5%
Simplified99.5%
Taylor expanded in z around inf 61.1%
+-commutative61.1%
mul-1-neg61.1%
sub-neg61.1%
Simplified61.1%
Taylor expanded in x around 0 56.5%
neg-mul-156.5%
distribute-neg-frac56.5%
Simplified56.5%
Final simplification80.7%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 81.1%
sub-neg81.1%
associate-/l*90.4%
*-commutative90.4%
associate-/l*90.4%
distribute-neg-frac90.4%
metadata-eval90.4%
associate-/l/81.1%
div-sub73.2%
times-frac91.8%
*-inverses91.8%
*-rgt-identity91.8%
*-commutative91.8%
associate-*l/91.8%
*-commutative91.8%
times-frac99.8%
*-inverses99.8%
*-lft-identity99.8%
Simplified99.8%
Taylor expanded in x around inf 74.7%
Final simplification74.7%
(FPCore (x y z t) :precision binary64 (- x (/ 1.0 (- (/ z y) (/ (/ t 2.0) z)))))
double code(double x, double y, double z, double t) {
return x - (1.0 / ((z / y) - ((t / 2.0) / z)));
}
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 - (1.0d0 / ((z / y) - ((t / 2.0d0) / z)))
end function
public static double code(double x, double y, double z, double t) {
return x - (1.0 / ((z / y) - ((t / 2.0) / z)));
}
def code(x, y, z, t): return x - (1.0 / ((z / y) - ((t / 2.0) / z)))
function code(x, y, z, t) return Float64(x - Float64(1.0 / Float64(Float64(z / y) - Float64(Float64(t / 2.0) / z)))) end
function tmp = code(x, y, z, t) tmp = x - (1.0 / ((z / y) - ((t / 2.0) / z))); end
code[x_, y_, z_, t_] := N[(x - N[(1.0 / N[(N[(z / y), $MachinePrecision] - N[(N[(t / 2.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{1}{\frac{z}{y} - \frac{\frac{t}{2}}{z}}
\end{array}
herbie shell --seed 2023240
(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)))))