
(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 1 x)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 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 (+ 1.0 (* z z))) 5e+305)
(/ (/ (/ 1.0 y_m) (fma z z 1.0)) x_m)
(pow (* (pow x_m -0.5) (/ (pow y_m -0.5) z)) 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) {
double tmp;
if ((y_m * (1.0 + (z * z))) <= 5e+305) {
tmp = ((1.0 / y_m) / fma(z, z, 1.0)) / x_m;
} else {
tmp = pow((pow(x_m, -0.5) * (pow(y_m, -0.5) / z)), 2.0);
}
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(y_m * Float64(1.0 + Float64(z * z))) <= 5e+305) tmp = Float64(Float64(Float64(1.0 / y_m) / fma(z, z, 1.0)) / x_m); else tmp = Float64((x_m ^ -0.5) * Float64((y_m ^ -0.5) / z)) ^ 2.0; 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[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision], N[Power[N[(N[Power[x$95$m, -0.5], $MachinePrecision] * N[(N[Power[y$95$m, -0.5], $MachinePrecision] / z), $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 \begin{array}{l}
\mathbf{if}\;y_m \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{\frac{1}{y_m}}{\mathsf{fma}\left(z, z, 1\right)}}{x_m}\\
\mathbf{else}:\\
\;\;\;\;{\left({x_m}^{-0.5} \cdot \frac{{y_m}^{-0.5}}{z}\right)}^{2}\\
\end{array}\right)
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 5.00000000000000009e305Initial program 95.8%
associate-/l/95.5%
metadata-eval95.5%
associate-*r/95.5%
associate-/l/95.8%
associate-*r/95.8%
associate-/l*95.4%
associate-/r/95.5%
/-rgt-identity95.5%
associate-*l*94.6%
*-commutative94.6%
sqr-neg94.6%
+-commutative94.6%
sqr-neg94.6%
fma-def94.6%
Simplified94.6%
associate-/r*95.0%
div-inv94.8%
Applied egg-rr94.8%
un-div-inv95.0%
*-commutative95.0%
associate-/r*95.8%
Applied egg-rr95.8%
if 5.00000000000000009e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 68.1%
associate-/l/68.1%
metadata-eval68.1%
associate-*r/68.1%
associate-/l/68.1%
associate-*r/68.1%
associate-/l*68.1%
associate-/r/68.1%
/-rgt-identity68.1%
associate-*l*79.9%
*-commutative79.9%
sqr-neg79.9%
+-commutative79.9%
sqr-neg79.9%
fma-def79.9%
Simplified79.9%
fma-udef79.9%
+-commutative79.9%
*-commutative79.9%
associate-*l*68.1%
associate-/l/68.1%
add-sqr-sqrt68.1%
sqrt-div39.4%
inv-pow39.4%
sqrt-pow139.4%
metadata-eval39.4%
*-commutative39.4%
sqrt-prod39.4%
hypot-1-def39.4%
sqrt-div39.4%
inv-pow39.4%
sqrt-pow139.4%
metadata-eval39.4%
*-commutative39.4%
Applied egg-rr63.9%
unpow263.9%
Simplified63.9%
Taylor expanded in z around inf 63.9%
div-inv63.6%
associate-/r*63.8%
pow1/263.8%
pow-flip63.9%
metadata-eval63.9%
Applied egg-rr63.9%
Final simplification90.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) y_m = (fabs.f64 y) y_s = (copysign.f64 1 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(Float64((x_m ^ -0.5) / 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[(N[Power[x$95$m, -0.5], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$95$m], $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{\frac{{x_m}^{-0.5}}{\mathsf{hypot}\left(1, z\right)}}{\sqrt{y_m}}\right)}^{2}\right)
\end{array}
Initial program 91.6%
associate-/l/91.3%
metadata-eval91.3%
associate-*r/91.3%
associate-/l/91.6%
associate-*r/91.6%
associate-/l*91.3%
associate-/r/91.3%
/-rgt-identity91.3%
associate-*l*92.4%
*-commutative92.4%
sqr-neg92.4%
+-commutative92.4%
sqr-neg92.4%
fma-def92.4%
Simplified92.4%
fma-udef92.4%
+-commutative92.4%
*-commutative92.4%
associate-*l*91.3%
associate-/l/91.6%
add-sqr-sqrt66.6%
sqrt-div24.3%
inv-pow24.3%
sqrt-pow124.3%
metadata-eval24.3%
*-commutative24.3%
sqrt-prod24.3%
hypot-1-def24.3%
sqrt-div24.2%
inv-pow24.2%
sqrt-pow124.2%
metadata-eval24.2%
*-commutative24.2%
Applied egg-rr27.9%
unpow227.9%
Simplified27.9%
expm1-log1p-u27.4%
expm1-udef18.8%
associate-/r*18.8%
Applied egg-rr18.8%
expm1-def27.4%
expm1-log1p27.9%
Simplified27.9%
Final simplification27.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 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 (+ 1.0 (* z z))) 5e+305)
(/ (/ (/ 1.0 y_m) (fma z z 1.0)) x_m)
(pow (/ (/ (pow x_m -0.5) 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) {
double tmp;
if ((y_m * (1.0 + (z * z))) <= 5e+305) {
tmp = ((1.0 / y_m) / fma(z, z, 1.0)) / x_m;
} else {
tmp = pow(((pow(x_m, -0.5) / z) / sqrt(y_m)), 2.0);
}
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(y_m * Float64(1.0 + Float64(z * z))) <= 5e+305) tmp = Float64(Float64(Float64(1.0 / y_m) / fma(z, z, 1.0)) / x_m); else tmp = Float64(Float64((x_m ^ -0.5) / z) / sqrt(y_m)) ^ 2.0; 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[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision], N[Power[N[(N[(N[Power[x$95$m, -0.5], $MachinePrecision] / z), $MachinePrecision] / N[Sqrt[y$95$m], $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 \begin{array}{l}
\mathbf{if}\;y_m \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{\frac{1}{y_m}}{\mathsf{fma}\left(z, z, 1\right)}}{x_m}\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{\frac{{x_m}^{-0.5}}{z}}{\sqrt{y_m}}\right)}^{2}\\
\end{array}\right)
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 5.00000000000000009e305Initial program 95.8%
associate-/l/95.5%
metadata-eval95.5%
associate-*r/95.5%
associate-/l/95.8%
associate-*r/95.8%
associate-/l*95.4%
associate-/r/95.5%
/-rgt-identity95.5%
associate-*l*94.6%
*-commutative94.6%
sqr-neg94.6%
+-commutative94.6%
sqr-neg94.6%
fma-def94.6%
Simplified94.6%
associate-/r*95.0%
div-inv94.8%
Applied egg-rr94.8%
un-div-inv95.0%
*-commutative95.0%
associate-/r*95.8%
Applied egg-rr95.8%
if 5.00000000000000009e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 68.1%
associate-/l/68.1%
metadata-eval68.1%
associate-*r/68.1%
associate-/l/68.1%
associate-*r/68.1%
associate-/l*68.1%
associate-/r/68.1%
/-rgt-identity68.1%
associate-*l*79.9%
*-commutative79.9%
sqr-neg79.9%
+-commutative79.9%
sqr-neg79.9%
fma-def79.9%
Simplified79.9%
add-sqr-sqrt48.9%
pow248.9%
associate-*r*48.9%
fma-udef48.9%
+-commutative48.9%
sqrt-prod48.9%
*-commutative48.9%
hypot-1-def63.2%
Applied egg-rr63.2%
*-commutative63.2%
Simplified63.2%
Taylor expanded in z around inf 63.2%
unpow263.2%
swap-sqr48.9%
add-sqr-sqrt79.9%
unpow279.9%
associate-/r*79.9%
associate-/r*79.9%
inv-pow79.9%
metadata-eval79.9%
pow-prod-up49.0%
add-sqr-sqrt48.8%
times-frac48.9%
unpow248.9%
frac-times63.6%
associate-/r*63.7%
associate-/r*63.9%
*-commutative63.9%
*-commutative63.9%
Applied egg-rr63.9%
unpow263.9%
associate-/r*63.8%
Simplified63.8%
Final simplification90.9%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 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) 4e+295)
(* (/ 1.0 y_m) (/ 1.0 (* x_m (fma z z 1.0))))
(* (/ (/ 1.0 y_m) z) (/ (/ 1.0 x_m) 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) <= 4e+295) {
tmp = (1.0 / y_m) * (1.0 / (x_m * fma(z, z, 1.0)));
} else {
tmp = ((1.0 / y_m) / z) * ((1.0 / x_m) / 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) <= 4e+295) tmp = Float64(Float64(1.0 / y_m) * Float64(1.0 / Float64(x_m * fma(z, z, 1.0)))); else tmp = Float64(Float64(Float64(1.0 / y_m) / z) * Float64(Float64(1.0 / x_m) / z)); 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], 4e+295], N[(N[(1.0 / y$95$m), $MachinePrecision] * N[(1.0 / N[(x$95$m * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y$95$m), $MachinePrecision] / z), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z), $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 4 \cdot 10^{+295}:\\
\;\;\;\;\frac{1}{y_m} \cdot \frac{1}{x_m \cdot \mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y_m}}{z} \cdot \frac{\frac{1}{x_m}}{z}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 3.9999999999999999e295Initial program 96.3%
associate-/l/95.9%
metadata-eval95.9%
associate-*r/95.9%
associate-/l/96.3%
associate-*r/96.3%
associate-/l*95.9%
associate-/r/95.9%
/-rgt-identity95.9%
associate-*l*97.4%
*-commutative97.4%
sqr-neg97.4%
+-commutative97.4%
sqr-neg97.4%
fma-def97.4%
Simplified97.4%
associate-/r*97.7%
div-inv97.6%
Applied egg-rr97.6%
if 3.9999999999999999e295 < (*.f64 z z) Initial program 77.2%
associate-/l/77.2%
metadata-eval77.2%
associate-*r/77.2%
associate-/l/77.2%
associate-*r/77.2%
associate-/l*77.2%
associate-/r/77.2%
/-rgt-identity77.2%
associate-*l*77.2%
*-commutative77.2%
sqr-neg77.2%
+-commutative77.2%
sqr-neg77.2%
fma-def77.2%
Simplified77.2%
fma-udef77.2%
+-commutative77.2%
*-commutative77.2%
associate-*l*77.2%
associate-/l/77.2%
add-sqr-sqrt77.2%
sqrt-div20.8%
inv-pow20.8%
sqrt-pow120.8%
metadata-eval20.8%
*-commutative20.8%
sqrt-prod20.8%
hypot-1-def20.8%
sqrt-div20.8%
inv-pow20.8%
sqrt-pow120.8%
metadata-eval20.8%
*-commutative20.8%
Applied egg-rr30.1%
unpow230.1%
Simplified30.1%
Taylor expanded in z around inf 30.1%
unpow230.1%
associate-/r*30.0%
associate-/r*30.0%
frac-times20.8%
times-frac20.8%
add-sqr-sqrt44.9%
pow-prod-up76.9%
metadata-eval76.9%
inv-pow76.9%
associate-/r*76.9%
unpow276.9%
Applied egg-rr76.9%
associate-/l/76.9%
div-inv76.9%
unpow276.9%
times-frac98.0%
Applied egg-rr98.0%
Final simplification97.7%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 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) 4e+295)
(/ 1.0 (* y_m (* x_m (fma z z 1.0))))
(* (/ (/ 1.0 y_m) z) (/ (/ 1.0 x_m) 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) <= 4e+295) {
tmp = 1.0 / (y_m * (x_m * fma(z, z, 1.0)));
} else {
tmp = ((1.0 / y_m) / z) * ((1.0 / x_m) / 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) <= 4e+295) tmp = Float64(1.0 / Float64(y_m * Float64(x_m * fma(z, z, 1.0)))); else tmp = Float64(Float64(Float64(1.0 / y_m) / z) * Float64(Float64(1.0 / x_m) / z)); 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], 4e+295], N[(1.0 / N[(y$95$m * N[(x$95$m * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y$95$m), $MachinePrecision] / z), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z), $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 4 \cdot 10^{+295}:\\
\;\;\;\;\frac{1}{y_m \cdot \left(x_m \cdot \mathsf{fma}\left(z, z, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y_m}}{z} \cdot \frac{\frac{1}{x_m}}{z}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 3.9999999999999999e295Initial program 96.3%
associate-/l/95.9%
metadata-eval95.9%
associate-*r/95.9%
associate-/l/96.3%
associate-*r/96.3%
associate-/l*95.9%
associate-/r/95.9%
/-rgt-identity95.9%
associate-*l*97.4%
*-commutative97.4%
sqr-neg97.4%
+-commutative97.4%
sqr-neg97.4%
fma-def97.4%
Simplified97.4%
if 3.9999999999999999e295 < (*.f64 z z) Initial program 77.2%
associate-/l/77.2%
metadata-eval77.2%
associate-*r/77.2%
associate-/l/77.2%
associate-*r/77.2%
associate-/l*77.2%
associate-/r/77.2%
/-rgt-identity77.2%
associate-*l*77.2%
*-commutative77.2%
sqr-neg77.2%
+-commutative77.2%
sqr-neg77.2%
fma-def77.2%
Simplified77.2%
fma-udef77.2%
+-commutative77.2%
*-commutative77.2%
associate-*l*77.2%
associate-/l/77.2%
add-sqr-sqrt77.2%
sqrt-div20.8%
inv-pow20.8%
sqrt-pow120.8%
metadata-eval20.8%
*-commutative20.8%
sqrt-prod20.8%
hypot-1-def20.8%
sqrt-div20.8%
inv-pow20.8%
sqrt-pow120.8%
metadata-eval20.8%
*-commutative20.8%
Applied egg-rr30.1%
unpow230.1%
Simplified30.1%
Taylor expanded in z around inf 30.1%
unpow230.1%
associate-/r*30.0%
associate-/r*30.0%
frac-times20.8%
times-frac20.8%
add-sqr-sqrt44.9%
pow-prod-up76.9%
metadata-eval76.9%
inv-pow76.9%
associate-/r*76.9%
unpow276.9%
Applied egg-rr76.9%
associate-/l/76.9%
div-inv76.9%
unpow276.9%
times-frac98.0%
Applied egg-rr98.0%
Final simplification97.5%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 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 (* y_m (+ 1.0 (* z z)))))
(*
y_s
(*
x_s
(if (<= t_0 5e+305)
(/ 1.0 (* x_m t_0))
(/ 1.0 (* z (* z (* 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) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 5e+305) {
tmp = 1.0 / (x_m * t_0);
} else {
tmp = 1.0 / (z * (z * (x_m * 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) :: t_0
real(8) :: tmp
t_0 = y_m * (1.0d0 + (z * z))
if (t_0 <= 5d+305) then
tmp = 1.0d0 / (x_m * t_0)
else
tmp = 1.0d0 / (z * (z * (x_m * 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 t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 5e+305) {
tmp = 1.0 / (x_m * t_0);
} else {
tmp = 1.0 / (z * (z * (x_m * 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): t_0 = y_m * (1.0 + (z * z)) tmp = 0 if t_0 <= 5e+305: tmp = 1.0 / (x_m * t_0) else: tmp = 1.0 / (z * (z * (x_m * 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) t_0 = Float64(y_m * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 5e+305) tmp = Float64(1.0 / Float64(x_m * t_0)); else tmp = Float64(1.0 / Float64(z * Float64(z * Float64(x_m * 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)
t_0 = y_m * (1.0 + (z * z));
tmp = 0.0;
if (t_0 <= 5e+305)
tmp = 1.0 / (x_m * t_0);
else
tmp = 1.0 / (z * (z * (x_m * 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_] := Block[{t$95$0 = N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(x$95$s * If[LessEqual[t$95$0, 5e+305], N[(1.0 / N[(x$95$m * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(z * N[(z * N[(x$95$m * y$95$m), $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])\\
\\
\begin{array}{l}
t_0 := y_m \cdot \left(1 + z \cdot z\right)\\
y_s \cdot \left(x_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\frac{1}{x_m \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(x_m \cdot y_m\right)\right)}\\
\end{array}\right)
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 5.00000000000000009e305Initial program 95.8%
associate-/l/95.5%
Simplified95.5%
if 5.00000000000000009e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 68.1%
associate-/l/68.1%
metadata-eval68.1%
associate-*r/68.1%
associate-/l/68.1%
associate-*r/68.1%
associate-/l*68.1%
associate-/r/68.1%
/-rgt-identity68.1%
associate-*l*79.9%
*-commutative79.9%
sqr-neg79.9%
+-commutative79.9%
sqr-neg79.9%
fma-def79.9%
Simplified79.9%
add-sqr-sqrt48.9%
pow248.9%
associate-*r*48.9%
fma-udef48.9%
+-commutative48.9%
sqrt-prod48.9%
*-commutative48.9%
hypot-1-def63.2%
Applied egg-rr63.2%
*-commutative63.2%
Simplified63.2%
Taylor expanded in z around inf 63.2%
unpow263.2%
swap-sqr48.9%
add-sqr-sqrt79.9%
associate-*r*96.7%
Applied egg-rr96.7%
Final simplification95.7%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 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 (* y_m (+ 1.0 (* z z)))))
(*
y_s
(*
x_s
(if (<= t_0 5e+305)
(/ (/ 1.0 x_m) t_0)
(/ 1.0 (* z (* z (* 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) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 5e+305) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = 1.0 / (z * (z * (x_m * 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) :: t_0
real(8) :: tmp
t_0 = y_m * (1.0d0 + (z * z))
if (t_0 <= 5d+305) then
tmp = (1.0d0 / x_m) / t_0
else
tmp = 1.0d0 / (z * (z * (x_m * 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 t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 5e+305) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = 1.0 / (z * (z * (x_m * 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): t_0 = y_m * (1.0 + (z * z)) tmp = 0 if t_0 <= 5e+305: tmp = (1.0 / x_m) / t_0 else: tmp = 1.0 / (z * (z * (x_m * 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) t_0 = Float64(y_m * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 5e+305) tmp = Float64(Float64(1.0 / x_m) / t_0); else tmp = Float64(1.0 / Float64(z * Float64(z * Float64(x_m * 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)
t_0 = y_m * (1.0 + (z * z));
tmp = 0.0;
if (t_0 <= 5e+305)
tmp = (1.0 / x_m) / t_0;
else
tmp = 1.0 / (z * (z * (x_m * 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_] := Block[{t$95$0 = N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(x$95$s * If[LessEqual[t$95$0, 5e+305], N[(N[(1.0 / x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision], N[(1.0 / N[(z * N[(z * N[(x$95$m * y$95$m), $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])\\
\\
\begin{array}{l}
t_0 := y_m \cdot \left(1 + z \cdot z\right)\\
y_s \cdot \left(x_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\frac{\frac{1}{x_m}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(x_m \cdot y_m\right)\right)}\\
\end{array}\right)
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 5.00000000000000009e305Initial program 95.8%
if 5.00000000000000009e305 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 68.1%
associate-/l/68.1%
metadata-eval68.1%
associate-*r/68.1%
associate-/l/68.1%
associate-*r/68.1%
associate-/l*68.1%
associate-/r/68.1%
/-rgt-identity68.1%
associate-*l*79.9%
*-commutative79.9%
sqr-neg79.9%
+-commutative79.9%
sqr-neg79.9%
fma-def79.9%
Simplified79.9%
add-sqr-sqrt48.9%
pow248.9%
associate-*r*48.9%
fma-udef48.9%
+-commutative48.9%
sqrt-prod48.9%
*-commutative48.9%
hypot-1-def63.2%
Applied egg-rr63.2%
*-commutative63.2%
Simplified63.2%
Taylor expanded in z around inf 63.2%
unpow263.2%
swap-sqr48.9%
add-sqr-sqrt79.9%
associate-*r*96.7%
Applied egg-rr96.7%
Final simplification96.0%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 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 0.46)
(/ (/ 1.0 y_m) x_m)
(* (/ (/ 1.0 y_m) z) (/ (/ 1.0 x_m) 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 <= 0.46) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = ((1.0 / y_m) / z) * ((1.0 / x_m) / 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 <= 0.46d0) then
tmp = (1.0d0 / y_m) / x_m
else
tmp = ((1.0d0 / y_m) / z) * ((1.0d0 / x_m) / 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 <= 0.46) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = ((1.0 / y_m) / z) * ((1.0 / x_m) / 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 <= 0.46: tmp = (1.0 / y_m) / x_m else: tmp = ((1.0 / y_m) / z) * ((1.0 / x_m) / 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 (z <= 0.46) tmp = Float64(Float64(1.0 / y_m) / x_m); else tmp = Float64(Float64(Float64(1.0 / y_m) / z) * Float64(Float64(1.0 / x_m) / 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 <= 0.46)
tmp = (1.0 / y_m) / x_m;
else
tmp = ((1.0 / y_m) / z) * ((1.0 / x_m) / 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[z, 0.46], N[(N[(1.0 / y$95$m), $MachinePrecision] / x$95$m), $MachinePrecision], N[(N[(N[(1.0 / y$95$m), $MachinePrecision] / z), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z), $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 0.46:\\
\;\;\;\;\frac{\frac{1}{y_m}}{x_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y_m}}{z} \cdot \frac{\frac{1}{x_m}}{z}\\
\end{array}\right)
\end{array}
if z < 0.46000000000000002Initial program 93.9%
associate-/l/93.5%
metadata-eval93.5%
associate-*r/93.5%
associate-/l/93.9%
associate-*r/93.9%
associate-/l*93.4%
associate-/r/93.5%
/-rgt-identity93.5%
associate-*l*94.9%
*-commutative94.9%
sqr-neg94.9%
+-commutative94.9%
sqr-neg94.9%
fma-def94.9%
Simplified94.9%
associate-/r*95.3%
div-inv95.1%
Applied egg-rr95.1%
Taylor expanded in z around 0 71.7%
associate-/l/71.6%
Simplified71.6%
if 0.46000000000000002 < z Initial program 84.2%
associate-/l/84.2%
metadata-eval84.2%
associate-*r/84.2%
associate-/l/84.2%
associate-*r/84.2%
associate-/l*84.2%
associate-/r/84.2%
/-rgt-identity84.2%
associate-*l*84.2%
*-commutative84.2%
sqr-neg84.2%
+-commutative84.2%
sqr-neg84.2%
fma-def84.2%
Simplified84.2%
fma-udef84.2%
+-commutative84.2%
*-commutative84.2%
associate-*l*84.2%
associate-/l/84.2%
add-sqr-sqrt70.9%
sqrt-div13.8%
inv-pow13.8%
sqrt-pow113.8%
metadata-eval13.8%
*-commutative13.8%
sqrt-prod13.8%
hypot-1-def13.8%
sqrt-div13.7%
inv-pow13.7%
sqrt-pow113.7%
metadata-eval13.7%
*-commutative13.7%
Applied egg-rr21.6%
unpow221.6%
Simplified21.6%
Taylor expanded in z around inf 21.6%
unpow221.6%
associate-/r*21.5%
associate-/r*21.4%
frac-times15.3%
times-frac15.3%
add-sqr-sqrt43.8%
pow-prod-up82.6%
metadata-eval82.6%
inv-pow82.6%
associate-/r*82.5%
unpow282.5%
Applied egg-rr82.5%
associate-/l/82.4%
div-inv82.5%
unpow282.5%
times-frac98.2%
Applied egg-rr98.2%
Final simplification77.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) y_m = (fabs.f64 y) y_s = (copysign.f64 1 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 0.46) (/ (/ 1.0 y_m) x_m) (/ 1.0 (* z (* z (* 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) {
double tmp;
if (z <= 0.46) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = 1.0 / (z * (z * (x_m * 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 <= 0.46d0) then
tmp = (1.0d0 / y_m) / x_m
else
tmp = 1.0d0 / (z * (z * (x_m * 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 <= 0.46) {
tmp = (1.0 / y_m) / x_m;
} else {
tmp = 1.0 / (z * (z * (x_m * 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 <= 0.46: tmp = (1.0 / y_m) / x_m else: tmp = 1.0 / (z * (z * (x_m * 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 <= 0.46) tmp = Float64(Float64(1.0 / y_m) / x_m); else tmp = Float64(1.0 / Float64(z * Float64(z * Float64(x_m * 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 <= 0.46)
tmp = (1.0 / y_m) / x_m;
else
tmp = 1.0 / (z * (z * (x_m * 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, 0.46], N[(N[(1.0 / y$95$m), $MachinePrecision] / x$95$m), $MachinePrecision], N[(1.0 / N[(z * N[(z * N[(x$95$m * y$95$m), $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 \leq 0.46:\\
\;\;\;\;\frac{\frac{1}{y_m}}{x_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(x_m \cdot y_m\right)\right)}\\
\end{array}\right)
\end{array}
if z < 0.46000000000000002Initial program 93.9%
associate-/l/93.5%
metadata-eval93.5%
associate-*r/93.5%
associate-/l/93.9%
associate-*r/93.9%
associate-/l*93.4%
associate-/r/93.5%
/-rgt-identity93.5%
associate-*l*94.9%
*-commutative94.9%
sqr-neg94.9%
+-commutative94.9%
sqr-neg94.9%
fma-def94.9%
Simplified94.9%
associate-/r*95.3%
div-inv95.1%
Applied egg-rr95.1%
Taylor expanded in z around 0 71.7%
associate-/l/71.6%
Simplified71.6%
if 0.46000000000000002 < z Initial program 84.2%
associate-/l/84.2%
metadata-eval84.2%
associate-*r/84.2%
associate-/l/84.2%
associate-*r/84.2%
associate-/l*84.2%
associate-/r/84.2%
/-rgt-identity84.2%
associate-*l*84.2%
*-commutative84.2%
sqr-neg84.2%
+-commutative84.2%
sqr-neg84.2%
fma-def84.2%
Simplified84.2%
add-sqr-sqrt35.4%
pow235.4%
associate-*r*33.4%
fma-udef33.4%
+-commutative33.4%
sqrt-prod33.4%
*-commutative33.4%
hypot-1-def42.3%
Applied egg-rr42.3%
*-commutative42.3%
Simplified42.3%
Taylor expanded in z around inf 42.3%
unpow242.3%
swap-sqr33.4%
add-sqr-sqrt83.7%
associate-*r*95.6%
Applied egg-rr95.6%
Final simplification77.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) y_m = (fabs.f64 y) y_s = (copysign.f64 1 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 91.6%
associate-/l/91.3%
metadata-eval91.3%
associate-*r/91.3%
associate-/l/91.6%
associate-*r/91.6%
associate-/l*91.3%
associate-/r/91.3%
/-rgt-identity91.3%
associate-*l*92.4%
*-commutative92.4%
sqr-neg92.4%
+-commutative92.4%
sqr-neg92.4%
fma-def92.4%
Simplified92.4%
Taylor expanded in z around 0 60.1%
Final simplification60.1%
(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 2024024
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< (* y (+ 1.0 (* z z))) (- INFINITY)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x)) (if (< (* y (+ 1.0 (* z z))) 8.680743250567252e+305) (/ (/ 1.0 x) (* (+ 1.0 (* z z)) y)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x))))
(/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))