
(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 11 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}
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* y_m (+ 1.0 (* z_m z_m))) 1.2e+307)
(/ (/ 1.0 x_m) (fma (* y_m z_m) z_m y_m))
(/ (/ (/ (/ 1.0 x_m) (hypot 1.0 z_m)) y_m) z_m)))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if ((y_m * (1.0 + (z_m * z_m))) <= 1.2e+307) {
tmp = (1.0 / x_m) / fma((y_m * z_m), z_m, y_m);
} else {
tmp = (((1.0 / x_m) / hypot(1.0, z_m)) / y_m) / z_m;
}
return y_s * (x_s * tmp);
}
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (Float64(y_m * Float64(1.0 + Float64(z_m * z_m))) <= 1.2e+307) tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y_m * z_m), z_m, y_m)); else tmp = Float64(Float64(Float64(Float64(1.0 / x_m) / hypot(1.0, z_m)) / y_m) / z_m); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(y$95$m * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.2e+307], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y$95$m * z$95$m), $MachinePrecision] * z$95$m + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / x$95$m), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision] / z$95$m), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \cdot \left(1 + z\_m \cdot z\_m\right) \leq 1.2 \cdot 10^{+307}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y\_m \cdot z\_m, z\_m, y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{1}{x\_m}}{\mathsf{hypot}\left(1, z\_m\right)}}{y\_m}}{z\_m}\\
\end{array}\right)
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 1.20000000000000008e307Initial program 95.9%
+-commutative95.9%
distribute-lft-in95.9%
associate-*r*97.2%
*-rgt-identity97.2%
fma-define97.2%
Applied egg-rr97.2%
if 1.20000000000000008e307 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 91.2%
associate-/l/91.2%
remove-double-neg91.2%
distribute-rgt-neg-out91.2%
distribute-rgt-neg-out91.2%
remove-double-neg91.2%
associate-*l*91.2%
*-commutative91.2%
sqr-neg91.2%
+-commutative91.2%
sqr-neg91.2%
fma-define91.2%
Simplified91.2%
add-sqr-sqrt57.6%
pow257.6%
*-commutative57.6%
sqrt-prod57.6%
fma-undefine57.6%
+-commutative57.6%
hypot-1-def57.6%
Applied egg-rr57.6%
Applied egg-rr99.9%
Taylor expanded in z around inf 93.9%
associate-*l/93.9%
*-un-lft-identity93.9%
associate-/r*93.9%
associate-/l/93.9%
associate-/r*93.9%
Applied egg-rr93.9%
Final simplification96.7%
z_m = (fabs.f64 z) 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_m should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z_m) :precision binary64 (* y_s (* x_s (/ 1.0 (* y_m (pow (* (hypot 1.0 z_m) (sqrt x_m)) 2.0))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
return y_s * (x_s * (1.0 / (y_m * pow((hypot(1.0, z_m) * sqrt(x_m)), 2.0))));
}
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
return y_s * (x_s * (1.0 / (y_m * Math.pow((Math.hypot(1.0, z_m) * Math.sqrt(x_m)), 2.0))));
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): return y_s * (x_s * (1.0 / (y_m * math.pow((math.hypot(1.0, z_m) * math.sqrt(x_m)), 2.0))))
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) return Float64(y_s * Float64(x_s * Float64(1.0 / Float64(y_m * (Float64(hypot(1.0, z_m) * sqrt(x_m)) ^ 2.0))))) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp = code(y_s, x_s, x_m, y_m, z_m)
tmp = y_s * (x_s * (1.0 / (y_m * ((hypot(1.0, z_m) * sqrt(x_m)) ^ 2.0))));
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * N[(1.0 / N[(y$95$m * N[Power[N[(N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $MachinePrecision] * N[Sqrt[x$95$m], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{1}{y\_m \cdot {\left(\mathsf{hypot}\left(1, z\_m\right) \cdot \sqrt{x\_m}\right)}^{2}}\right)
\end{array}
Initial program 95.3%
associate-/l/95.0%
remove-double-neg95.0%
distribute-rgt-neg-out95.0%
distribute-rgt-neg-out95.0%
remove-double-neg95.0%
associate-*l*93.9%
*-commutative93.9%
sqr-neg93.9%
+-commutative93.9%
sqr-neg93.9%
fma-define93.9%
Simplified93.9%
add-sqr-sqrt48.3%
pow248.3%
*-commutative48.3%
sqrt-prod48.3%
fma-undefine48.3%
+-commutative48.3%
hypot-1-def49.4%
Applied egg-rr49.4%
Final simplification49.4%
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z_m z_m) 1e+36)
(/ (/ 1.0 x_m) (fma (* y_m z_m) z_m y_m))
(* (/ 1.0 y_m) (* (/ 1.0 z_m) (/ (/ 1.0 z_m) x_m)))))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if ((z_m * z_m) <= 1e+36) {
tmp = (1.0 / x_m) / fma((y_m * z_m), z_m, y_m);
} else {
tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
}
return y_s * (x_s * tmp);
}
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (Float64(z_m * z_m) <= 1e+36) tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y_m * z_m), z_m, y_m)); else tmp = Float64(Float64(1.0 / y_m) * Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / x_m))); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 1e+36], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y$95$m * z$95$m), $MachinePrecision] * z$95$m + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 10^{+36}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y\_m \cdot z\_m, z\_m, y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m} \cdot \left(\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{x\_m}\right)\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 1.00000000000000004e36Initial program 99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-*r*99.7%
*-rgt-identity99.7%
fma-define99.7%
Applied egg-rr99.7%
if 1.00000000000000004e36 < (*.f64 z z) Initial program 88.8%
associate-/l/88.8%
remove-double-neg88.8%
distribute-rgt-neg-out88.8%
distribute-rgt-neg-out88.8%
remove-double-neg88.8%
associate-*l*86.2%
*-commutative86.2%
sqr-neg86.2%
+-commutative86.2%
sqr-neg86.2%
fma-define86.2%
Simplified86.2%
Taylor expanded in z around inf 88.8%
*-commutative88.8%
Simplified88.8%
inv-pow88.8%
*-commutative88.8%
associate-*l*84.5%
unpow284.5%
*-commutative84.5%
add-sqr-sqrt43.7%
swap-sqr48.2%
pow-prod-down48.2%
pow-sqr48.2%
*-commutative48.2%
metadata-eval48.2%
unpow-prod-down44.2%
sqrt-pow284.9%
metadata-eval84.9%
inv-pow84.9%
*-commutative84.9%
associate-/r*84.9%
Applied egg-rr84.9%
associate-*l/89.1%
associate-/l*86.9%
Simplified86.9%
sqr-pow86.9%
associate-/l*93.8%
metadata-eval93.8%
unpow-193.8%
metadata-eval93.8%
unpow-193.8%
Applied egg-rr93.8%
Final simplification97.3%
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(let* ((t_0 (* y_m (+ 1.0 (* z_m z_m)))))
(*
y_s
(*
x_s
(if (<= t_0 1.2e+307)
(/ (/ 1.0 x_m) t_0)
(* (/ 1.0 z_m) (/ (/ 1.0 z_m) (* y_m x_m))))))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double t_0 = y_m * (1.0 + (z_m * z_m));
double tmp;
if (t_0 <= 1.2e+307) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
}
return y_s * (x_s * tmp);
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
real(8) :: t_0
real(8) :: tmp
t_0 = y_m * (1.0d0 + (z_m * z_m))
if (t_0 <= 1.2d+307) then
tmp = (1.0d0 / x_m) / t_0
else
tmp = (1.0d0 / z_m) * ((1.0d0 / z_m) / (y_m * x_m))
end if
code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double t_0 = y_m * (1.0 + (z_m * z_m));
double tmp;
if (t_0 <= 1.2e+307) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
}
return y_s * (x_s * tmp);
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): t_0 = y_m * (1.0 + (z_m * z_m)) tmp = 0 if t_0 <= 1.2e+307: tmp = (1.0 / x_m) / t_0 else: tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m)) return y_s * (x_s * tmp)
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) t_0 = Float64(y_m * Float64(1.0 + Float64(z_m * z_m))) tmp = 0.0 if (t_0 <= 1.2e+307) tmp = Float64(Float64(1.0 / x_m) / t_0); else tmp = Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / Float64(y_m * x_m))); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
t_0 = y_m * (1.0 + (z_m * z_m));
tmp = 0.0;
if (t_0 <= 1.2e+307)
tmp = (1.0 / x_m) / t_0;
else
tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
end
tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := Block[{t$95$0 = N[(y$95$m * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(x$95$s * If[LessEqual[t$95$0, 1.2e+307], N[(N[(1.0 / x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / N[(y$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(1 + z\_m \cdot z\_m\right)\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 1.2 \cdot 10^{+307}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{y\_m \cdot x\_m}\\
\end{array}\right)
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 1.20000000000000008e307Initial program 95.9%
if 1.20000000000000008e307 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 91.2%
associate-/l/91.2%
remove-double-neg91.2%
distribute-rgt-neg-out91.2%
distribute-rgt-neg-out91.2%
remove-double-neg91.2%
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 88.4%
add-sqr-sqrt88.4%
sqrt-div54.8%
metadata-eval54.8%
associate-*r*57.6%
*-commutative57.6%
sqrt-prod57.6%
*-commutative57.6%
sqrt-pow157.6%
metadata-eval57.6%
pow157.6%
sqrt-div57.6%
metadata-eval57.6%
associate-*r*57.6%
*-commutative57.6%
sqrt-prod57.6%
*-commutative57.6%
sqrt-pow160.6%
metadata-eval60.6%
pow160.6%
Applied egg-rr60.6%
unpow-160.6%
unpow-160.6%
pow-sqr60.6%
*-commutative60.6%
*-commutative60.6%
metadata-eval60.6%
Simplified60.6%
metadata-eval60.6%
pow-prod-up60.6%
pow-prod-down60.5%
swap-sqr57.6%
unpow257.6%
add-sqr-sqrt91.2%
*-commutative91.2%
associate-*l*88.4%
*-commutative88.4%
inv-pow88.4%
associate-*r*88.4%
associate-/r*88.4%
Applied egg-rr88.4%
inv-pow88.4%
unpow-prod-down88.4%
inv-pow88.4%
unpow288.4%
pow-prod-down88.5%
pow-sqr88.5%
metadata-eval88.5%
*-commutative88.5%
div-inv88.5%
associate-/l/91.3%
sqr-pow91.3%
associate-/l*97.0%
metadata-eval97.0%
unpow-197.0%
metadata-eval97.0%
unpow-197.0%
*-commutative97.0%
Applied egg-rr97.0%
Final simplification96.0%
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z_m z_m) 2e+28)
(/ (/ 1.0 x_m) (* y_m (+ 1.0 (* z_m z_m))))
(* (/ 1.0 y_m) (* (/ 1.0 z_m) (/ (/ 1.0 z_m) x_m)))))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if ((z_m * z_m) <= 2e+28) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m)));
} else {
tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
}
return y_s * (x_s * tmp);
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
real(8) :: tmp
if ((z_m * z_m) <= 2d+28) then
tmp = (1.0d0 / x_m) / (y_m * (1.0d0 + (z_m * z_m)))
else
tmp = (1.0d0 / y_m) * ((1.0d0 / z_m) * ((1.0d0 / z_m) / x_m))
end if
code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if ((z_m * z_m) <= 2e+28) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m)));
} else {
tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
}
return y_s * (x_s * tmp);
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): tmp = 0 if (z_m * z_m) <= 2e+28: tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m))) else: tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m)) return y_s * (x_s * tmp)
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (Float64(z_m * z_m) <= 2e+28) tmp = Float64(Float64(1.0 / x_m) / Float64(y_m * Float64(1.0 + Float64(z_m * z_m)))); else tmp = Float64(Float64(1.0 / y_m) * Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / x_m))); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
tmp = 0.0;
if ((z_m * z_m) <= 2e+28)
tmp = (1.0 / x_m) / (y_m * (1.0 + (z_m * z_m)));
else
tmp = (1.0 / y_m) * ((1.0 / z_m) * ((1.0 / z_m) / x_m));
end
tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 2e+28], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y$95$m * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 2 \cdot 10^{+28}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z\_m \cdot z\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m} \cdot \left(\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{x\_m}\right)\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 1.99999999999999992e28Initial program 99.7%
if 1.99999999999999992e28 < (*.f64 z z) Initial program 89.2%
associate-/l/89.2%
remove-double-neg89.2%
distribute-rgt-neg-out89.2%
distribute-rgt-neg-out89.2%
remove-double-neg89.2%
associate-*l*86.6%
*-commutative86.6%
sqr-neg86.6%
+-commutative86.6%
sqr-neg86.6%
fma-define86.6%
Simplified86.6%
Taylor expanded in z around inf 89.2%
*-commutative89.2%
Simplified89.2%
inv-pow89.2%
*-commutative89.2%
associate-*l*85.0%
unpow285.0%
*-commutative85.0%
add-sqr-sqrt43.0%
swap-sqr47.3%
pow-prod-down47.3%
pow-sqr47.4%
*-commutative47.4%
metadata-eval47.4%
unpow-prod-down43.5%
sqrt-pow285.5%
metadata-eval85.5%
inv-pow85.5%
*-commutative85.5%
associate-/r*85.5%
Applied egg-rr85.5%
associate-*l/89.5%
associate-/l*87.4%
Simplified87.4%
sqr-pow87.4%
associate-/l*94.1%
metadata-eval94.1%
unpow-194.1%
metadata-eval94.1%
unpow-194.1%
Applied egg-rr94.1%
Final simplification97.3%
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(*
y_s
(*
x_s
(if (<= z_m 1.0)
(/ (/ 1.0 x_m) y_m)
(* (/ 1.0 z_m) (/ (/ 1.0 z_m) (* y_m x_m)))))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
}
return y_s * (x_s * tmp);
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
real(8) :: tmp
if (z_m <= 1.0d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = (1.0d0 / z_m) * ((1.0d0 / z_m) / (y_m * x_m))
end if
code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
}
return y_s * (x_s * tmp);
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): tmp = 0 if z_m <= 1.0: tmp = (1.0 / x_m) / y_m else: tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m)) return y_s * (x_s * tmp)
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (z_m <= 1.0) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(Float64(1.0 / z_m) * Float64(Float64(1.0 / z_m) / Float64(y_m * x_m))); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
tmp = 0.0;
if (z_m <= 1.0)
tmp = (1.0 / x_m) / y_m;
else
tmp = (1.0 / z_m) * ((1.0 / z_m) / (y_m * x_m));
end
tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / z$95$m), $MachinePrecision] * N[(N[(1.0 / z$95$m), $MachinePrecision] / N[(y$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z\_m} \cdot \frac{\frac{1}{z\_m}}{y\_m \cdot x\_m}\\
\end{array}\right)
\end{array}
if z < 1Initial program 96.4%
Taylor expanded in z around 0 77.4%
if 1 < z Initial program 91.5%
associate-/l/91.5%
remove-double-neg91.5%
distribute-rgt-neg-out91.5%
distribute-rgt-neg-out91.5%
remove-double-neg91.5%
associate-*l*88.1%
*-commutative88.1%
sqr-neg88.1%
+-commutative88.1%
sqr-neg88.1%
fma-define88.1%
Simplified88.1%
Taylor expanded in z around inf 87.1%
add-sqr-sqrt66.2%
sqrt-div43.4%
metadata-eval43.4%
associate-*r*43.2%
*-commutative43.2%
sqrt-prod43.3%
*-commutative43.3%
sqrt-pow143.3%
metadata-eval43.3%
pow143.3%
sqrt-div43.3%
metadata-eval43.3%
associate-*r*46.6%
*-commutative46.6%
sqrt-prod46.6%
*-commutative46.6%
sqrt-pow151.5%
metadata-eval51.5%
pow151.5%
Applied egg-rr51.5%
unpow-151.5%
unpow-151.5%
pow-sqr51.5%
*-commutative51.5%
*-commutative51.5%
metadata-eval51.5%
Simplified51.5%
metadata-eval51.5%
pow-prod-up51.5%
pow-prod-down51.5%
swap-sqr46.5%
unpow246.5%
add-sqr-sqrt88.7%
*-commutative88.7%
associate-*l*90.5%
*-commutative90.5%
inv-pow90.5%
associate-*r*87.1%
associate-/r*87.2%
Applied egg-rr87.2%
inv-pow87.2%
unpow-prod-down87.2%
inv-pow87.2%
unpow287.2%
pow-prod-down88.6%
pow-sqr88.5%
metadata-eval88.5%
*-commutative88.5%
div-inv88.6%
associate-/l/90.1%
sqr-pow90.0%
associate-/l*95.3%
metadata-eval95.3%
unpow-195.3%
metadata-eval95.3%
unpow-195.3%
*-commutative95.3%
Applied egg-rr95.3%
Final simplification81.4%
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(*
y_s
(*
x_s
(if (<= z_m 1.0)
(/ (/ 1.0 x_m) y_m)
(* (/ 1.0 (* y_m z_m)) (/ 1.0 (* z_m x_m)))))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m));
}
return y_s * (x_s * tmp);
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
real(8) :: tmp
if (z_m <= 1.0d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = (1.0d0 / (y_m * z_m)) * (1.0d0 / (z_m * x_m))
end if
code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m));
}
return y_s * (x_s * tmp);
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): tmp = 0 if z_m <= 1.0: tmp = (1.0 / x_m) / y_m else: tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m)) return y_s * (x_s * tmp)
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (z_m <= 1.0) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(Float64(1.0 / Float64(y_m * z_m)) * Float64(1.0 / Float64(z_m * x_m))); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
tmp = 0.0;
if (z_m <= 1.0)
tmp = (1.0 / x_m) / y_m;
else
tmp = (1.0 / (y_m * z_m)) * (1.0 / (z_m * x_m));
end
tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(z$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m \cdot z\_m} \cdot \frac{1}{z\_m \cdot x\_m}\\
\end{array}\right)
\end{array}
if z < 1Initial program 96.4%
Taylor expanded in z around 0 77.4%
if 1 < z Initial program 91.5%
associate-/l/91.5%
remove-double-neg91.5%
distribute-rgt-neg-out91.5%
distribute-rgt-neg-out91.5%
remove-double-neg91.5%
associate-*l*88.1%
*-commutative88.1%
sqr-neg88.1%
+-commutative88.1%
sqr-neg88.1%
fma-define88.1%
Simplified88.1%
add-sqr-sqrt38.7%
pow238.7%
*-commutative38.7%
sqrt-prod38.7%
fma-undefine38.7%
+-commutative38.7%
hypot-1-def38.7%
Applied egg-rr38.7%
Applied egg-rr94.8%
Taylor expanded in z around inf 93.9%
Taylor expanded in z around inf 93.8%
Final simplification81.1%
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(*
y_s
(*
x_s
(if (<= z_m 1.0)
(/ (/ 1.0 x_m) y_m)
(* (/ 1.0 (* y_m z_m)) (/ (/ 1.0 x_m) z_m))))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m);
}
return y_s * (x_s * tmp);
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
real(8) :: tmp
if (z_m <= 1.0d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = (1.0d0 / (y_m * z_m)) * ((1.0d0 / x_m) / z_m)
end if
code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m);
}
return y_s * (x_s * tmp);
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): tmp = 0 if z_m <= 1.0: tmp = (1.0 / x_m) / y_m else: tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m) return y_s * (x_s * tmp)
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (z_m <= 1.0) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(Float64(1.0 / Float64(y_m * z_m)) * Float64(Float64(1.0 / x_m) / z_m)); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
tmp = 0.0;
if (z_m <= 1.0)
tmp = (1.0 / x_m) / y_m;
else
tmp = (1.0 / (y_m * z_m)) * ((1.0 / x_m) / z_m);
end
tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m \cdot z\_m} \cdot \frac{\frac{1}{x\_m}}{z\_m}\\
\end{array}\right)
\end{array}
if z < 1Initial program 96.4%
Taylor expanded in z around 0 77.4%
if 1 < z Initial program 91.5%
associate-/l/91.5%
remove-double-neg91.5%
distribute-rgt-neg-out91.5%
distribute-rgt-neg-out91.5%
remove-double-neg91.5%
associate-*l*88.1%
*-commutative88.1%
sqr-neg88.1%
+-commutative88.1%
sqr-neg88.1%
fma-define88.1%
Simplified88.1%
add-sqr-sqrt38.7%
pow238.7%
*-commutative38.7%
sqrt-prod38.7%
fma-undefine38.7%
+-commutative38.7%
hypot-1-def38.7%
Applied egg-rr38.7%
Applied egg-rr94.8%
Taylor expanded in z around inf 93.9%
Taylor expanded in z around inf 93.8%
associate-/r*93.7%
Simplified93.7%
Final simplification81.1%
z_m = (fabs.f64 z)
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_m should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z_m)
:precision binary64
(*
y_s
(*
x_s
(if (<= z_m 1.0)
(/ (/ 1.0 x_m) y_m)
(* (/ (/ 1.0 z_m) x_m) (/ 1.0 (* y_m z_m)))))))z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m));
}
return y_s * (x_s * tmp);
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
real(8) :: tmp
if (z_m <= 1.0d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = ((1.0d0 / z_m) / x_m) * (1.0d0 / (y_m * z_m))
end if
code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m));
}
return y_s * (x_s * tmp);
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): tmp = 0 if z_m <= 1.0: tmp = (1.0 / x_m) / y_m else: tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m)) return y_s * (x_s * tmp)
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (z_m <= 1.0) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(Float64(Float64(1.0 / z_m) / x_m) * Float64(1.0 / Float64(y_m * z_m))); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
tmp = 0.0;
if (z_m <= 1.0)
tmp = (1.0 / x_m) / y_m;
else
tmp = ((1.0 / z_m) / x_m) * (1.0 / (y_m * z_m));
end
tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(N[(1.0 / z$95$m), $MachinePrecision] / x$95$m), $MachinePrecision] * N[(1.0 / N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z\_m}}{x\_m} \cdot \frac{1}{y\_m \cdot z\_m}\\
\end{array}\right)
\end{array}
if z < 1Initial program 96.4%
Taylor expanded in z around 0 77.4%
if 1 < z Initial program 91.5%
associate-/l/91.5%
remove-double-neg91.5%
distribute-rgt-neg-out91.5%
distribute-rgt-neg-out91.5%
remove-double-neg91.5%
associate-*l*88.1%
*-commutative88.1%
sqr-neg88.1%
+-commutative88.1%
sqr-neg88.1%
fma-define88.1%
Simplified88.1%
add-sqr-sqrt38.7%
pow238.7%
*-commutative38.7%
sqrt-prod38.7%
fma-undefine38.7%
+-commutative38.7%
hypot-1-def38.7%
Applied egg-rr38.7%
Applied egg-rr94.8%
Taylor expanded in z around inf 93.9%
Taylor expanded in z around inf 93.8%
Final simplification81.1%
z_m = (fabs.f64 z) 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_m should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z_m) :precision binary64 (* y_s (* x_s (if (<= z_m 1.0) (/ (/ 1.0 x_m) y_m) (/ 1.0 (* x_m (* y_m z_m)))))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = 1.0 / (x_m * (y_m * z_m));
}
return y_s * (x_s * tmp);
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
real(8) :: tmp
if (z_m <= 1.0d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = 1.0d0 / (x_m * (y_m * z_m))
end if
code = y_s * (x_s * tmp)
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = 1.0 / (x_m * (y_m * z_m));
}
return y_s * (x_s * tmp);
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): tmp = 0 if z_m <= 1.0: tmp = (1.0 / x_m) / y_m else: tmp = 1.0 / (x_m * (y_m * z_m)) return y_s * (x_s * tmp)
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) tmp = 0.0 if (z_m <= 1.0) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(1.0 / Float64(x_m * Float64(y_m * z_m))); end return Float64(y_s * Float64(x_s * tmp)) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z_m)
tmp = 0.0;
if (z_m <= 1.0)
tmp = (1.0 / x_m) / y_m;
else
tmp = 1.0 / (x_m * (y_m * z_m));
end
tmp_2 = y_s * (x_s * tmp);
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(1.0 / N[(x$95$m * N[(y$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x\_m \cdot \left(y\_m \cdot z\_m\right)}\\
\end{array}\right)
\end{array}
if z < 1Initial program 96.4%
Taylor expanded in z around 0 77.4%
if 1 < z Initial program 91.5%
associate-/l/91.5%
remove-double-neg91.5%
distribute-rgt-neg-out91.5%
distribute-rgt-neg-out91.5%
remove-double-neg91.5%
associate-*l*88.1%
*-commutative88.1%
sqr-neg88.1%
+-commutative88.1%
sqr-neg88.1%
fma-define88.1%
Simplified88.1%
add-sqr-sqrt38.7%
pow238.7%
*-commutative38.7%
sqrt-prod38.7%
fma-undefine38.7%
+-commutative38.7%
hypot-1-def38.7%
Applied egg-rr38.7%
Applied egg-rr94.8%
Taylor expanded in z around inf 93.9%
Taylor expanded in z around 0 42.9%
Final simplification69.8%
z_m = (fabs.f64 z) 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_m should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z_m) :precision binary64 (* y_s (* x_s (/ 1.0 (* y_m x_m)))))
z_m = fabs(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_m);
double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
return y_s * (x_s * (1.0 / (y_m * x_m)));
}
z_m = abs(z)
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_m should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z_m)
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_m
code = y_s * (x_s * (1.0d0 / (y_m * x_m)))
end function
z_m = Math.abs(z);
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_m;
public static double code(double y_s, double x_s, double x_m, double y_m, double z_m) {
return y_s * (x_s * (1.0 / (y_m * x_m)));
}
z_m = math.fabs(z) 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_m] = sort([x_m, y_m, z_m]) def code(y_s, x_s, x_m, y_m, z_m): return y_s * (x_s * (1.0 / (y_m * x_m)))
z_m = abs(z) 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_m = sort([x_m, y_m, z_m]) function code(y_s, x_s, x_m, y_m, z_m) return Float64(y_s * Float64(x_s * Float64(1.0 / Float64(y_m * x_m)))) end
z_m = abs(z);
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_m = num2cell(sort([x_m, y_m, z_m])){:}
function tmp = code(y_s, x_s, x_m, y_m, z_m)
tmp = y_s * (x_s * (1.0 / (y_m * x_m)));
end
z_m = N[Abs[z], $MachinePrecision]
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_m should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z$95$m_] := N[(y$95$s * N[(x$95$s * N[(1.0 / N[(y$95$m * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
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_m] = \mathsf{sort}([x_m, y_m, z_m])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{1}{y\_m \cdot x\_m}\right)
\end{array}
Initial program 95.3%
associate-/l/95.0%
remove-double-neg95.0%
distribute-rgt-neg-out95.0%
distribute-rgt-neg-out95.0%
remove-double-neg95.0%
associate-*l*93.9%
*-commutative93.9%
sqr-neg93.9%
+-commutative93.9%
sqr-neg93.9%
fma-define93.9%
Simplified93.9%
Taylor expanded in z around 0 65.1%
Final simplification65.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 2024089
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:alt
(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)))))