
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= y_m 5e-17)
(* (/ 1.0 (* x_m (hypot 1.0 z))) (/ (/ 1.0 y_m) (hypot 1.0 z)))
(/ (/ (/ (/ 1.0 x_m) y_m) (hypot 1.0 z)) (hypot 1.0 z))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if (y_m <= 5e-17) {
tmp = (1.0 / (x_m * hypot(1.0, z))) * ((1.0 / y_m) / hypot(1.0, z));
} else {
tmp = (((1.0 / x_m) / y_m) / hypot(1.0, z)) / hypot(1.0, z);
}
return y_s * (x_s * tmp);
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if (y_m <= 5e-17) {
tmp = (1.0 / (x_m * Math.hypot(1.0, z))) * ((1.0 / y_m) / Math.hypot(1.0, z));
} else {
tmp = (((1.0 / x_m) / y_m) / Math.hypot(1.0, z)) / Math.hypot(1.0, z);
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if y_m <= 5e-17: tmp = (1.0 / (x_m * math.hypot(1.0, z))) * ((1.0 / y_m) / math.hypot(1.0, z)) else: tmp = (((1.0 / x_m) / y_m) / math.hypot(1.0, z)) / math.hypot(1.0, z) return y_s * (x_s * tmp)
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (y_m <= 5e-17) tmp = Float64(Float64(1.0 / Float64(x_m * hypot(1.0, z))) * Float64(Float64(1.0 / y_m) / hypot(1.0, z))); else tmp = Float64(Float64(Float64(Float64(1.0 / x_m) / y_m) / hypot(1.0, z)) / hypot(1.0, z)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if (y_m <= 5e-17)
tmp = (1.0 / (x_m * hypot(1.0, z))) * ((1.0 / y_m) / hypot(1.0, z));
else
tmp = (((1.0 / x_m) / y_m) / hypot(1.0, z)) / hypot(1.0, z);
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[y$95$m, 5e-17], N[(N[(1.0 / N[(x$95$m * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / y$95$m), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 5 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{x\_m \cdot \mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{y\_m}}{\mathsf{hypot}\left(1, z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{x\_m}}{y\_m}}{\mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}\right)
\end{array}
if y < 4.9999999999999999e-17Initial program 86.7%
associate-/l/86.1%
remove-double-neg86.1%
distribute-rgt-neg-out86.1%
distribute-rgt-neg-out86.1%
remove-double-neg86.1%
associate-*l*85.6%
*-commutative85.6%
sqr-neg85.6%
+-commutative85.6%
sqr-neg85.6%
fma-define85.6%
Simplified85.6%
*-commutative85.6%
associate-*r*86.1%
fma-undefine86.1%
+-commutative86.1%
associate-/l/86.7%
add-sqr-sqrt58.7%
sqrt-div13.5%
inv-pow13.5%
sqrt-pow113.5%
metadata-eval13.5%
+-commutative13.5%
fma-undefine13.5%
*-commutative13.5%
sqrt-prod13.5%
fma-undefine13.5%
+-commutative13.5%
hypot-1-def13.5%
sqrt-div13.5%
Applied egg-rr15.0%
unpow215.0%
Simplified15.0%
unpow215.0%
frac-times14.5%
pow-prod-up25.3%
metadata-eval25.3%
metadata-eval25.3%
sqrt-pow113.3%
associate-/r*13.8%
sqrt-pow126.3%
metadata-eval26.3%
inv-pow26.3%
Applied egg-rr26.3%
associate-/r*25.2%
associate-/l/25.2%
div-inv25.2%
associate-*r*25.2%
add-sqr-sqrt96.9%
associate-*l/98.0%
associate-/l/92.3%
div-inv92.3%
associate-/l/86.9%
div-inv86.8%
times-frac97.0%
associate-/l/96.5%
Applied egg-rr96.5%
if 4.9999999999999999e-17 < y Initial program 91.9%
associate-/l/91.8%
remove-double-neg91.8%
distribute-rgt-neg-out91.8%
distribute-rgt-neg-out91.8%
remove-double-neg91.8%
associate-*l*97.2%
*-commutative97.2%
sqr-neg97.2%
+-commutative97.2%
sqr-neg97.2%
fma-define97.2%
Simplified97.2%
*-commutative97.2%
associate-*r*91.8%
fma-undefine91.8%
+-commutative91.8%
associate-/l/91.9%
add-sqr-sqrt70.6%
sqrt-div46.7%
inv-pow46.7%
sqrt-pow146.7%
metadata-eval46.7%
+-commutative46.7%
fma-undefine46.7%
*-commutative46.7%
sqrt-prod46.6%
fma-undefine46.6%
+-commutative46.6%
hypot-1-def46.6%
sqrt-div46.6%
Applied egg-rr51.8%
unpow251.8%
Simplified51.8%
metadata-eval51.8%
sqrt-pow151.8%
metadata-eval51.8%
sqrt-pow159.7%
*-commutative59.7%
hypot-1-def59.7%
sqrt-prod58.3%
sqrt-div58.3%
pow258.3%
add-sqr-sqrt58.4%
associate-/r*59.8%
sqrt-pow197.1%
metadata-eval97.1%
inv-pow97.1%
associate-/l/97.1%
add-sqr-sqrt97.1%
hypot-1-def97.1%
hypot-1-def97.1%
associate-/r*99.8%
Applied egg-rr99.8%
Final simplification97.4%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (let* ((t_0 (* (hypot 1.0 z) (sqrt y_m)))) (* y_s (* x_s (/ (/ (/ 1.0 x_m) t_0) t_0)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double t_0 = hypot(1.0, z) * sqrt(y_m);
return y_s * (x_s * (((1.0 / x_m) / t_0) / t_0));
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double t_0 = Math.hypot(1.0, z) * Math.sqrt(y_m);
return y_s * (x_s * (((1.0 / x_m) / t_0) / t_0));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): t_0 = math.hypot(1.0, z) * math.sqrt(y_m) return y_s * (x_s * (((1.0 / x_m) / t_0) / t_0))
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) t_0 = Float64(hypot(1.0, z) * sqrt(y_m)) return Float64(y_s * Float64(x_s * Float64(Float64(Float64(1.0 / x_m) / t_0) / t_0))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
t_0 = hypot(1.0, z) * sqrt(y_m);
tmp = y_s * (x_s * (((1.0 / x_m) / t_0) / t_0));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := Block[{t$95$0 = N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(x$95$s * N[(N[(N[(1.0 / x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(1, z\right) \cdot \sqrt{y\_m}\\
y\_s \cdot \left(x\_s \cdot \frac{\frac{\frac{1}{x\_m}}{t\_0}}{t\_0}\right)
\end{array}
\end{array}
Initial program 88.1%
associate-/l/87.7%
remove-double-neg87.7%
distribute-rgt-neg-out87.7%
distribute-rgt-neg-out87.7%
remove-double-neg87.7%
associate-*l*88.8%
*-commutative88.8%
sqr-neg88.8%
+-commutative88.8%
sqr-neg88.8%
fma-define88.8%
Simplified88.8%
*-commutative88.8%
associate-*r*87.7%
fma-undefine87.7%
+-commutative87.7%
associate-/l/88.1%
add-sqr-sqrt62.0%
sqrt-div22.7%
inv-pow22.7%
sqrt-pow122.7%
metadata-eval22.7%
+-commutative22.7%
fma-undefine22.7%
*-commutative22.7%
sqrt-prod22.7%
fma-undefine22.7%
+-commutative22.7%
hypot-1-def22.7%
sqrt-div22.7%
Applied egg-rr25.2%
unpow225.2%
Simplified25.2%
unpow225.2%
frac-times23.4%
pow-prod-up43.7%
metadata-eval43.7%
metadata-eval43.7%
sqrt-pow125.8%
associate-/r*26.5%
sqrt-pow146.6%
metadata-eval46.6%
inv-pow46.6%
Applied egg-rr46.6%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (pow (/ (pow x_m -0.5) (* (hypot 1.0 z) (sqrt y_m))) 2.0))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * pow((pow(x_m, -0.5) / (hypot(1.0, z) * sqrt(y_m))), 2.0));
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * Math.pow((Math.pow(x_m, -0.5) / (Math.hypot(1.0, z) * Math.sqrt(y_m))), 2.0));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): return y_s * (x_s * math.pow((math.pow(x_m, -0.5) / (math.hypot(1.0, z) * math.sqrt(y_m))), 2.0))
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) return Float64(y_s * Float64(x_s * (Float64((x_m ^ -0.5) / Float64(hypot(1.0, z) * sqrt(y_m))) ^ 2.0))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
tmp = y_s * (x_s * (((x_m ^ -0.5) / (hypot(1.0, z) * sqrt(y_m))) ^ 2.0));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[Power[N[(N[Power[x$95$m, -0.5], $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot {\left(\frac{{x\_m}^{-0.5}}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y\_m}}\right)}^{2}\right)
\end{array}
Initial program 88.1%
associate-/l/87.7%
remove-double-neg87.7%
distribute-rgt-neg-out87.7%
distribute-rgt-neg-out87.7%
remove-double-neg87.7%
associate-*l*88.8%
*-commutative88.8%
sqr-neg88.8%
+-commutative88.8%
sqr-neg88.8%
fma-define88.8%
Simplified88.8%
*-commutative88.8%
associate-*r*87.7%
fma-undefine87.7%
+-commutative87.7%
associate-/l/88.1%
add-sqr-sqrt62.0%
sqrt-div22.7%
inv-pow22.7%
sqrt-pow122.7%
metadata-eval22.7%
+-commutative22.7%
fma-undefine22.7%
*-commutative22.7%
sqrt-prod22.7%
fma-undefine22.7%
+-commutative22.7%
hypot-1-def22.7%
sqrt-div22.7%
Applied egg-rr25.2%
unpow225.2%
Simplified25.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 2e+18)
(/ (/ 1.0 x_m) (* y_m (+ 1.0 (* z z))))
(if (<= (* z z) 1e+295)
(/ (/ (pow z -2.0) x_m) y_m)
(/ (/ 1.0 (* x_m z)) (* z y_m)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 2e+18) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else if ((z * z) <= 1e+295) {
tmp = (pow(z, -2.0) / x_m) / y_m;
} else {
tmp = (1.0 / (x_m * z)) / (z * y_m);
}
return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d+18) then
tmp = (1.0d0 / x_m) / (y_m * (1.0d0 + (z * z)))
else if ((z * z) <= 1d+295) then
tmp = ((z ** (-2.0d0)) / x_m) / y_m
else
tmp = (1.0d0 / (x_m * z)) / (z * y_m)
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 2e+18) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else if ((z * z) <= 1e+295) {
tmp = (Math.pow(z, -2.0) / x_m) / y_m;
} else {
tmp = (1.0 / (x_m * z)) / (z * y_m);
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if (z * z) <= 2e+18: tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z))) elif (z * z) <= 1e+295: tmp = (math.pow(z, -2.0) / x_m) / y_m else: tmp = (1.0 / (x_m * z)) / (z * y_m) return y_s * (x_s * tmp)
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (Float64(z * z) <= 2e+18) tmp = Float64(Float64(1.0 / x_m) / Float64(y_m * Float64(1.0 + Float64(z * z)))); elseif (Float64(z * z) <= 1e+295) tmp = Float64(Float64((z ^ -2.0) / x_m) / y_m); else tmp = Float64(Float64(1.0 / Float64(x_m * z)) / Float64(z * y_m)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if ((z * z) <= 2e+18)
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
elseif ((z * z) <= 1e+295)
tmp = ((z ^ -2.0) / x_m) / y_m;
else
tmp = (1.0 / (x_m * z)) / (z * y_m);
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 2e+18], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+295], N[(N[(N[Power[z, -2.0], $MachinePrecision] / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / N[(x$95$m * z), $MachinePrecision]), $MachinePrecision] / N[(z * y$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z \cdot z\right)}\\
\mathbf{elif}\;z \cdot z \leq 10^{+295}:\\
\;\;\;\;\frac{\frac{{z}^{-2}}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x\_m \cdot z}}{z \cdot y\_m}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 2e18Initial program 99.7%
if 2e18 < (*.f64 z z) < 9.9999999999999998e294Initial program 86.8%
associate-/l/85.5%
remove-double-neg85.5%
distribute-rgt-neg-out85.5%
distribute-rgt-neg-out85.5%
remove-double-neg85.5%
associate-*l*91.0%
*-commutative91.0%
sqr-neg91.0%
+-commutative91.0%
sqr-neg91.0%
fma-define91.0%
Simplified91.0%
Taylor expanded in z around inf 85.5%
*-commutative85.5%
associate-*r*91.0%
*-commutative91.0%
Simplified91.0%
add-sqr-sqrt66.0%
sqrt-div55.7%
metadata-eval55.7%
pow255.7%
associate-*r*53.9%
sqrt-prod53.8%
*-commutative53.8%
sqrt-prod26.9%
add-sqr-sqrt35.1%
sqrt-div35.1%
metadata-eval35.1%
pow235.1%
associate-*r*38.6%
sqrt-prod38.6%
*-commutative38.6%
sqrt-prod30.5%
add-sqr-sqrt57.4%
Applied egg-rr57.4%
unpow-157.4%
unpow-157.4%
pow-sqr57.3%
*-commutative57.3%
metadata-eval57.3%
Simplified57.3%
unpow-prod-down57.4%
sqrt-pow296.0%
metadata-eval96.0%
inv-pow96.0%
div-inv96.1%
associate-/r*92.5%
Applied egg-rr92.5%
if 9.9999999999999998e294 < (*.f64 z z) Initial program 70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-rgt-neg-in70.7%
associate-/r*70.2%
associate-/l/70.2%
associate-/l/70.2%
distribute-lft-neg-out70.2%
distribute-rgt-neg-in70.2%
distribute-lft-neg-in70.2%
remove-double-neg70.2%
sqr-neg70.2%
+-commutative70.2%
sqr-neg70.2%
fma-define70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in z around inf 70.2%
pow270.2%
Applied egg-rr70.2%
inv-pow70.2%
associate-*l*84.8%
*-commutative84.8%
unpow-prod-down85.1%
inv-pow85.1%
pow185.1%
pow185.1%
associate-*l*98.2%
*-commutative98.2%
Applied egg-rr98.2%
associate-*r/98.3%
*-rgt-identity98.3%
associate-/r*99.4%
unpow-199.4%
associate-/r*99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification98.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 1e+295)
(/ 1.0 (* y_m (* x_m (fma z z 1.0))))
(/ (/ 1.0 (* x_m z)) (* z y_m))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 1e+295) {
tmp = 1.0 / (y_m * (x_m * fma(z, z, 1.0)));
} else {
tmp = (1.0 / (x_m * z)) / (z * y_m);
}
return y_s * (x_s * tmp);
}
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (Float64(z * z) <= 1e+295) tmp = Float64(1.0 / Float64(y_m * Float64(x_m * fma(z, z, 1.0)))); else tmp = Float64(Float64(1.0 / Float64(x_m * z)) / Float64(z * y_m)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 1e+295], N[(1.0 / N[(y$95$m * N[(x$95$m * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x$95$m * z), $MachinePrecision]), $MachinePrecision] / N[(z * y$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+295}:\\
\;\;\;\;\frac{1}{y\_m \cdot \left(x\_m \cdot \mathsf{fma}\left(z, z, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x\_m \cdot z}}{z \cdot y\_m}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 9.9999999999999998e294Initial program 95.9%
associate-/l/95.3%
remove-double-neg95.3%
distribute-rgt-neg-out95.3%
distribute-rgt-neg-out95.3%
remove-double-neg95.3%
associate-*l*96.9%
*-commutative96.9%
sqr-neg96.9%
+-commutative96.9%
sqr-neg96.9%
fma-define96.9%
Simplified96.9%
if 9.9999999999999998e294 < (*.f64 z z) Initial program 70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-rgt-neg-in70.7%
associate-/r*70.2%
associate-/l/70.2%
associate-/l/70.2%
distribute-lft-neg-out70.2%
distribute-rgt-neg-in70.2%
distribute-lft-neg-in70.2%
remove-double-neg70.2%
sqr-neg70.2%
+-commutative70.2%
sqr-neg70.2%
fma-define70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in z around inf 70.2%
pow270.2%
Applied egg-rr70.2%
inv-pow70.2%
associate-*l*84.8%
*-commutative84.8%
unpow-prod-down85.1%
inv-pow85.1%
pow185.1%
pow185.1%
associate-*l*98.2%
*-commutative98.2%
Applied egg-rr98.2%
associate-*r/98.3%
*-rgt-identity98.3%
associate-/r*99.4%
unpow-199.4%
associate-/r*99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification97.7%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 50000000000000.0)
(/ (/ 1.0 x_m) (* y_m (+ 1.0 (* z z))))
(if (<= (* z z) 1e+295)
(/ 1.0 (* y_m (* x_m (* z z))))
(/ (/ 1.0 (* x_m z)) (* z y_m)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 50000000000000.0) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else if ((z * z) <= 1e+295) {
tmp = 1.0 / (y_m * (x_m * (z * z)));
} else {
tmp = (1.0 / (x_m * z)) / (z * y_m);
}
return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 50000000000000.0d0) then
tmp = (1.0d0 / x_m) / (y_m * (1.0d0 + (z * z)))
else if ((z * z) <= 1d+295) then
tmp = 1.0d0 / (y_m * (x_m * (z * z)))
else
tmp = (1.0d0 / (x_m * z)) / (z * y_m)
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 50000000000000.0) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else if ((z * z) <= 1e+295) {
tmp = 1.0 / (y_m * (x_m * (z * z)));
} else {
tmp = (1.0 / (x_m * z)) / (z * y_m);
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if (z * z) <= 50000000000000.0: tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z))) elif (z * z) <= 1e+295: tmp = 1.0 / (y_m * (x_m * (z * z))) else: tmp = (1.0 / (x_m * z)) / (z * y_m) return y_s * (x_s * tmp)
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (Float64(z * z) <= 50000000000000.0) tmp = Float64(Float64(1.0 / x_m) / Float64(y_m * Float64(1.0 + Float64(z * z)))); elseif (Float64(z * z) <= 1e+295) tmp = Float64(1.0 / Float64(y_m * Float64(x_m * Float64(z * z)))); else tmp = Float64(Float64(1.0 / Float64(x_m * z)) / Float64(z * y_m)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if ((z * z) <= 50000000000000.0)
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
elseif ((z * z) <= 1e+295)
tmp = 1.0 / (y_m * (x_m * (z * z)));
else
tmp = (1.0 / (x_m * z)) / (z * y_m);
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 50000000000000.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+295], N[(1.0 / N[(y$95$m * N[(x$95$m * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x$95$m * z), $MachinePrecision]), $MachinePrecision] / N[(z * y$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 50000000000000:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z \cdot z\right)}\\
\mathbf{elif}\;z \cdot z \leq 10^{+295}:\\
\;\;\;\;\frac{1}{y\_m \cdot \left(x\_m \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x\_m \cdot z}}{z \cdot y\_m}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 5e13Initial program 99.7%
if 5e13 < (*.f64 z z) < 9.9999999999999998e294Initial program 87.0%
associate-/l/85.8%
remove-double-neg85.8%
distribute-rgt-neg-out85.8%
distribute-rgt-neg-out85.8%
remove-double-neg85.8%
associate-*l*91.2%
*-commutative91.2%
sqr-neg91.2%
+-commutative91.2%
sqr-neg91.2%
fma-define91.2%
Simplified91.2%
Taylor expanded in z around inf 85.8%
*-commutative85.8%
associate-*r*91.2%
*-commutative91.2%
Simplified91.2%
pow294.7%
Applied egg-rr91.2%
if 9.9999999999999998e294 < (*.f64 z z) Initial program 70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-rgt-neg-in70.7%
associate-/r*70.2%
associate-/l/70.2%
associate-/l/70.2%
distribute-lft-neg-out70.2%
distribute-rgt-neg-in70.2%
distribute-lft-neg-in70.2%
remove-double-neg70.2%
sqr-neg70.2%
+-commutative70.2%
sqr-neg70.2%
fma-define70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in z around inf 70.2%
pow270.2%
Applied egg-rr70.2%
inv-pow70.2%
associate-*l*84.8%
*-commutative84.8%
unpow-prod-down85.1%
inv-pow85.1%
pow185.1%
pow185.1%
associate-*l*98.2%
*-commutative98.2%
Applied egg-rr98.2%
associate-*r/98.3%
*-rgt-identity98.3%
associate-/r*99.4%
unpow-199.4%
associate-/r*99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification97.9%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 0.005)
(/ (/ 1.0 y_m) x_m)
(if (<= (* z z) 1e+295)
(/ 1.0 (* y_m (* x_m (* z z))))
(/ (/ 1.0 (* x_m z)) (* z y_m)))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 0.005) {
tmp = (1.0 / y_m) / x_m;
} else if ((z * z) <= 1e+295) {
tmp = 1.0 / (y_m * (x_m * (z * z)));
} else {
tmp = (1.0 / (x_m * z)) / (z * y_m);
}
return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 0.005d0) then
tmp = (1.0d0 / y_m) / x_m
else if ((z * z) <= 1d+295) then
tmp = 1.0d0 / (y_m * (x_m * (z * z)))
else
tmp = (1.0d0 / (x_m * z)) / (z * y_m)
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 0.005) {
tmp = (1.0 / y_m) / x_m;
} else if ((z * z) <= 1e+295) {
tmp = 1.0 / (y_m * (x_m * (z * z)));
} else {
tmp = (1.0 / (x_m * z)) / (z * y_m);
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if (z * z) <= 0.005: tmp = (1.0 / y_m) / x_m elif (z * z) <= 1e+295: tmp = 1.0 / (y_m * (x_m * (z * z))) else: tmp = (1.0 / (x_m * z)) / (z * y_m) return y_s * (x_s * tmp)
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (Float64(z * z) <= 0.005) tmp = Float64(Float64(1.0 / y_m) / x_m); elseif (Float64(z * z) <= 1e+295) tmp = Float64(1.0 / Float64(y_m * Float64(x_m * Float64(z * z)))); else tmp = Float64(Float64(1.0 / Float64(x_m * z)) / Float64(z * y_m)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if ((z * z) <= 0.005)
tmp = (1.0 / y_m) / x_m;
elseif ((z * z) <= 1e+295)
tmp = 1.0 / (y_m * (x_m * (z * z)));
else
tmp = (1.0 / (x_m * z)) / (z * y_m);
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 0.005], N[(N[(1.0 / y$95$m), $MachinePrecision] / x$95$m), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+295], N[(1.0 / N[(y$95$m * N[(x$95$m * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x$95$m * z), $MachinePrecision]), $MachinePrecision] / N[(z * y$95$m), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.005:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x\_m}\\
\mathbf{elif}\;z \cdot z \leq 10^{+295}:\\
\;\;\;\;\frac{1}{y\_m \cdot \left(x\_m \cdot \left(z \cdot z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x\_m \cdot z}}{z \cdot y\_m}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 0.0050000000000000001Initial program 99.7%
associate-/l/99.3%
remove-double-neg99.3%
distribute-rgt-neg-out99.3%
distribute-rgt-neg-out99.3%
remove-double-neg99.3%
associate-*l*99.4%
*-commutative99.4%
sqr-neg99.4%
+-commutative99.4%
sqr-neg99.4%
fma-define99.4%
Simplified99.4%
*-commutative99.4%
associate-*r*99.3%
fma-undefine99.3%
+-commutative99.3%
associate-/l/99.7%
add-sqr-sqrt56.7%
sqrt-div26.3%
inv-pow26.3%
sqrt-pow126.3%
metadata-eval26.3%
+-commutative26.3%
fma-undefine26.3%
*-commutative26.3%
sqrt-prod26.3%
fma-undefine26.3%
+-commutative26.3%
hypot-1-def26.3%
sqrt-div26.2%
Applied egg-rr26.2%
unpow226.2%
Simplified26.2%
unpow226.2%
frac-times26.2%
pow-prod-up46.0%
metadata-eval46.0%
metadata-eval46.0%
sqrt-pow121.8%
associate-/r*21.9%
sqrt-pow146.0%
metadata-eval46.0%
inv-pow46.0%
Applied egg-rr46.0%
associate-/r*46.0%
associate-/l/46.0%
div-inv46.0%
associate-*r*46.0%
add-sqr-sqrt99.7%
associate-*l/99.7%
associate-/l/99.7%
div-inv99.7%
associate-/l/99.7%
div-inv99.5%
times-frac99.5%
associate-/l/99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 98.4%
associate-/l/98.7%
Simplified98.7%
if 0.0050000000000000001 < (*.f64 z z) < 9.9999999999999998e294Initial program 87.7%
associate-/l/86.6%
remove-double-neg86.6%
distribute-rgt-neg-out86.6%
distribute-rgt-neg-out86.6%
remove-double-neg86.6%
associate-*l*91.7%
*-commutative91.7%
sqr-neg91.7%
+-commutative91.7%
sqr-neg91.7%
fma-define91.7%
Simplified91.7%
Taylor expanded in z around inf 85.2%
*-commutative85.2%
associate-*r*90.4%
*-commutative90.4%
Simplified90.4%
pow293.7%
Applied egg-rr90.4%
if 9.9999999999999998e294 < (*.f64 z z) Initial program 70.7%
remove-double-neg70.7%
distribute-lft-neg-out70.7%
distribute-rgt-neg-in70.7%
associate-/r*70.2%
associate-/l/70.2%
associate-/l/70.2%
distribute-lft-neg-out70.2%
distribute-rgt-neg-in70.2%
distribute-lft-neg-in70.2%
remove-double-neg70.2%
sqr-neg70.2%
+-commutative70.2%
sqr-neg70.2%
fma-define70.2%
*-commutative70.2%
Simplified70.2%
Taylor expanded in z around inf 70.2%
pow270.2%
Applied egg-rr70.2%
inv-pow70.2%
associate-*l*84.8%
*-commutative84.8%
unpow-prod-down85.1%
inv-pow85.1%
pow185.1%
pow185.1%
associate-*l*98.2%
*-commutative98.2%
Applied egg-rr98.2%
associate-*r/98.3%
*-rgt-identity98.3%
associate-/r*99.4%
unpow-199.4%
associate-/r*99.5%
*-commutative99.5%
*-commutative99.5%
Simplified99.5%
Final simplification97.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 0.005)
(/ (/ 1.0 y_m) x_m)
(/ 1.0 (* y_m (* x_m (* z z))))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 0.005) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = 1.0 / (y_m * (x_m * (z * z)));
}
return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 0.005d0) then
tmp = (1.0d0 / y_m) / x_m
else
tmp = 1.0d0 / (y_m * (x_m * (z * z)))
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 0.005) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = 1.0 / (y_m * (x_m * (z * z)));
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if (z * z) <= 0.005: tmp = (1.0 / y_m) / x_m else: tmp = 1.0 / (y_m * (x_m * (z * z))) return y_s * (x_s * tmp)
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (Float64(z * z) <= 0.005) tmp = Float64(Float64(1.0 / y_m) / x_m); else tmp = Float64(1.0 / Float64(y_m * Float64(x_m * Float64(z * z)))); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if ((z * z) <= 0.005)
tmp = (1.0 / y_m) / x_m;
else
tmp = 1.0 / (y_m * (x_m * (z * z)));
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 0.005], N[(N[(1.0 / y$95$m), $MachinePrecision] / x$95$m), $MachinePrecision], N[(1.0 / N[(y$95$m * N[(x$95$m * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.005:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m \cdot \left(x\_m \cdot \left(z \cdot z\right)\right)}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 0.0050000000000000001Initial program 99.7%
associate-/l/99.3%
remove-double-neg99.3%
distribute-rgt-neg-out99.3%
distribute-rgt-neg-out99.3%
remove-double-neg99.3%
associate-*l*99.4%
*-commutative99.4%
sqr-neg99.4%
+-commutative99.4%
sqr-neg99.4%
fma-define99.4%
Simplified99.4%
*-commutative99.4%
associate-*r*99.3%
fma-undefine99.3%
+-commutative99.3%
associate-/l/99.7%
add-sqr-sqrt56.7%
sqrt-div26.3%
inv-pow26.3%
sqrt-pow126.3%
metadata-eval26.3%
+-commutative26.3%
fma-undefine26.3%
*-commutative26.3%
sqrt-prod26.3%
fma-undefine26.3%
+-commutative26.3%
hypot-1-def26.3%
sqrt-div26.2%
Applied egg-rr26.2%
unpow226.2%
Simplified26.2%
unpow226.2%
frac-times26.2%
pow-prod-up46.0%
metadata-eval46.0%
metadata-eval46.0%
sqrt-pow121.8%
associate-/r*21.9%
sqrt-pow146.0%
metadata-eval46.0%
inv-pow46.0%
Applied egg-rr46.0%
associate-/r*46.0%
associate-/l/46.0%
div-inv46.0%
associate-*r*46.0%
add-sqr-sqrt99.7%
associate-*l/99.7%
associate-/l/99.7%
div-inv99.7%
associate-/l/99.7%
div-inv99.5%
times-frac99.5%
associate-/l/99.5%
Applied egg-rr99.5%
Taylor expanded in z around 0 98.4%
associate-/l/98.7%
Simplified98.7%
if 0.0050000000000000001 < (*.f64 z z) Initial program 77.8%
associate-/l/77.3%
remove-double-neg77.3%
distribute-rgt-neg-out77.3%
distribute-rgt-neg-out77.3%
remove-double-neg77.3%
associate-*l*79.4%
*-commutative79.4%
sqr-neg79.4%
+-commutative79.4%
sqr-neg79.4%
fma-define79.4%
Simplified79.4%
Taylor expanded in z around inf 76.7%
*-commutative76.7%
associate-*r*78.9%
*-commutative78.9%
Simplified78.9%
pow279.9%
Applied egg-rr78.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (if (<= z 1.0) (/ (/ 1.0 y_m) x_m) (/ 1.0 (* x_m (* z y_m)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = 1.0 / (x_m * (z * y_m));
}
return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1.0d0) then
tmp = (1.0d0 / y_m) / x_m
else
tmp = 1.0d0 / (x_m * (z * y_m))
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = 1.0 / (x_m * (z * y_m));
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if z <= 1.0: tmp = (1.0 / y_m) / x_m else: tmp = 1.0 / (x_m * (z * y_m)) return y_s * (x_s * tmp)
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (z <= 1.0) tmp = Float64(Float64(1.0 / y_m) / x_m); else tmp = Float64(1.0 / Float64(x_m * Float64(z * y_m))); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if (z <= 1.0)
tmp = (1.0 / y_m) / x_m;
else
tmp = 1.0 / (x_m * (z * y_m));
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z, 1.0], N[(N[(1.0 / y$95$m), $MachinePrecision] / x$95$m), $MachinePrecision], N[(1.0 / N[(x$95$m * N[(z * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x\_m \cdot \left(z \cdot y\_m\right)}\\
\end{array}\right)
\end{array}
if z < 1Initial program 90.9%
associate-/l/90.3%
remove-double-neg90.3%
distribute-rgt-neg-out90.3%
distribute-rgt-neg-out90.3%
remove-double-neg90.3%
associate-*l*92.4%
*-commutative92.4%
sqr-neg92.4%
+-commutative92.4%
sqr-neg92.4%
fma-define92.4%
Simplified92.4%
*-commutative92.4%
associate-*r*90.3%
fma-undefine90.3%
+-commutative90.3%
associate-/l/90.9%
add-sqr-sqrt59.4%
sqrt-div24.0%
inv-pow24.0%
sqrt-pow124.0%
metadata-eval24.0%
+-commutative24.0%
fma-undefine24.0%
*-commutative24.0%
sqrt-prod24.0%
fma-undefine24.0%
+-commutative24.0%
hypot-1-def24.0%
sqrt-div23.9%
Applied egg-rr25.9%
unpow225.9%
Simplified25.9%
unpow225.9%
frac-times24.9%
pow-prod-up44.4%
metadata-eval44.4%
metadata-eval44.4%
sqrt-pow124.7%
associate-/r*24.8%
sqrt-pow145.9%
metadata-eval45.9%
inv-pow45.9%
Applied egg-rr45.9%
associate-/r*45.9%
associate-/l/45.4%
div-inv45.4%
associate-*r*45.4%
add-sqr-sqrt97.6%
associate-*l/97.6%
associate-/l/95.5%
div-inv95.5%
associate-/l/92.8%
div-inv92.7%
times-frac97.5%
associate-/l/97.5%
Applied egg-rr97.5%
Taylor expanded in z around 0 70.4%
associate-/l/70.6%
Simplified70.6%
if 1 < z Initial program 81.0%
associate-/l/81.0%
remove-double-neg81.0%
distribute-rgt-neg-out81.0%
distribute-rgt-neg-out81.0%
remove-double-neg81.0%
associate-*l*79.8%
*-commutative79.8%
sqr-neg79.8%
+-commutative79.8%
sqr-neg79.8%
fma-define79.8%
Simplified79.8%
*-commutative79.8%
associate-*r*81.0%
fma-undefine81.0%
+-commutative81.0%
associate-/l/81.0%
add-sqr-sqrt68.6%
sqrt-div19.6%
inv-pow19.6%
sqrt-pow119.6%
metadata-eval19.6%
+-commutative19.6%
fma-undefine19.6%
*-commutative19.6%
sqrt-prod19.6%
fma-undefine19.6%
+-commutative19.6%
hypot-1-def19.6%
sqrt-div19.6%
Applied egg-rr23.4%
unpow223.4%
Simplified23.4%
metadata-eval23.4%
sqrt-pow123.4%
metadata-eval23.4%
sqrt-pow131.0%
*-commutative31.0%
hypot-1-def29.8%
sqrt-prod28.5%
sqrt-div49.6%
pow249.6%
add-sqr-sqrt55.3%
associate-/r*56.6%
sqrt-pow182.0%
metadata-eval82.0%
inv-pow82.0%
associate-/l/82.0%
add-sqr-sqrt82.0%
hypot-1-def82.0%
hypot-1-def82.0%
associate-/r*91.7%
Applied egg-rr91.7%
Taylor expanded in z around inf 97.0%
associate-*r*90.6%
Simplified90.6%
Taylor expanded in z around 0 41.1%
Final simplification62.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (/ 1.0 (* x_m y_m)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * (1.0 / (x_m * y_m)));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (x_s * (1.0d0 / (x_m * y_m)))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * (1.0 / (x_m * y_m)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): return y_s * (x_s * (1.0 / (x_m * y_m)))
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) return Float64(y_s * Float64(x_s * Float64(1.0 / Float64(x_m * y_m)))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
tmp = y_s * (x_s * (1.0 / (x_m * y_m)));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(1.0 / N[(x$95$m * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{1}{x\_m \cdot y\_m}\right)
\end{array}
Initial program 88.1%
associate-/l/87.7%
remove-double-neg87.7%
distribute-rgt-neg-out87.7%
distribute-rgt-neg-out87.7%
remove-double-neg87.7%
associate-*l*88.8%
*-commutative88.8%
sqr-neg88.8%
+-commutative88.8%
sqr-neg88.8%
fma-define88.8%
Simplified88.8%
Taylor expanded in z around 0 55.6%
Final simplification55.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z z))) (t_1 (* y t_0)) (t_2 (/ (/ 1.0 y) (* t_0 x))))
(if (< t_1 (- INFINITY))
t_2
(if (< t_1 8.680743250567252e+305) (/ (/ 1.0 x) (* t_0 y)) t_2))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * z);
double t_1 = y * t_0;
double t_2 = (1.0 / y) / (t_0 * x);
double tmp;
if (t_1 < -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 < 8.680743250567252e+305) {
tmp = (1.0 / x) / (t_0 * y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * z) t_1 = y * t_0 t_2 = (1.0 / y) / (t_0 * x) tmp = 0 if t_1 < -math.inf: tmp = t_2 elif t_1 < 8.680743250567252e+305: tmp = (1.0 / x) / (t_0 * y) else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * z)) t_1 = Float64(y * t_0) t_2 = Float64(Float64(1.0 / y) / Float64(t_0 * x)) tmp = 0.0 if (t_1 < Float64(-Inf)) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = Float64(Float64(1.0 / x) / Float64(t_0 * y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * z); t_1 = y * t_0; t_2 = (1.0 / y) / (t_0 * x); tmp = 0.0; if (t_1 < -Inf) tmp = t_2; elseif (t_1 < 8.680743250567252e+305) tmp = (1.0 / x) / (t_0 * y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / y), $MachinePrecision] / N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$1, (-Infinity)], t$95$2, If[Less[t$95$1, 8.680743250567252e+305], N[(N[(1.0 / x), $MachinePrecision] / N[(t$95$0 * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot z\\
t_1 := y \cdot t\_0\\
t_2 := \frac{\frac{1}{y}}{t\_0 \cdot x}\\
\mathbf{if}\;t\_1 < -\infty:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 < 8.680743250567252 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x}}{t\_0 \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
herbie shell --seed 2024130
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< (* y (+ 1 (* z z))) -inf.0) (/ (/ 1 y) (* (+ 1 (* z z)) x)) (if (< (* y (+ 1 (* z z))) 868074325056725200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (/ 1 x) (* (+ 1 (* z z)) y)) (/ (/ 1 y) (* (+ 1 (* z z)) x)))))
(/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))