
(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 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= y_m 5.8e+141)
(/ 1.0 (* (* (hypot 1.0 z) y_m) (* x_m (hypot 1.0 z))))
(/ (/ 1.0 y_m) (* x_m (fma z z 1.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 <= 5.8e+141) {
tmp = 1.0 / ((hypot(1.0, z) * y_m) * (x_m * hypot(1.0, z)));
} else {
tmp = (1.0 / y_m) / (x_m * fma(z, z, 1.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 (y_m <= 5.8e+141) tmp = Float64(1.0 / Float64(Float64(hypot(1.0, z) * y_m) * Float64(x_m * hypot(1.0, z)))); else tmp = Float64(Float64(1.0 / y_m) / Float64(x_m * fma(z, z, 1.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[y$95$m, 5.8e+141], N[(1.0 / N[(N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * y$95$m), $MachinePrecision] * N[(x$95$m * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(x$95$m * N[(z * z + 1.0), $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}\;y\_m \leq 5.8 \cdot 10^{+141}:\\
\;\;\;\;\frac{1}{\left(\mathsf{hypot}\left(1, z\right) \cdot y\_m\right) \cdot \left(x\_m \cdot \mathsf{hypot}\left(1, z\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x\_m \cdot \mathsf{fma}\left(z, z, 1\right)}\\
\end{array}\right)
\end{array}
if y < 5.80000000000000013e141Initial program 89.5%
associate-/l/89.2%
remove-double-neg89.2%
distribute-rgt-neg-out89.2%
distribute-rgt-neg-out89.2%
remove-double-neg89.2%
associate-*l*88.3%
*-commutative88.3%
sqr-neg88.3%
+-commutative88.3%
sqr-neg88.3%
fma-define88.3%
Simplified88.3%
*-commutative88.3%
associate-*r*89.2%
fma-undefine89.2%
+-commutative89.2%
associate-/l/89.5%
add-sqr-sqrt53.8%
sqrt-div15.6%
inv-pow15.6%
sqrt-pow115.6%
metadata-eval15.6%
+-commutative15.6%
fma-undefine15.6%
*-commutative15.6%
sqrt-prod15.6%
fma-undefine15.6%
+-commutative15.6%
hypot-1-def15.6%
sqrt-div15.6%
Applied egg-rr20.7%
unpow220.7%
Simplified20.7%
Applied egg-rr89.2%
add-sqr-sqrt89.2%
*-commutative89.2%
times-frac88.9%
clear-num88.9%
sqrt-div88.9%
metadata-eval88.9%
/-rgt-identity88.9%
fma-undefine88.9%
pow288.9%
+-commutative88.9%
metadata-eval88.9%
pow288.9%
hypot-undefine88.9%
Applied egg-rr97.3%
clear-num97.2%
clear-num97.0%
frac-times96.8%
metadata-eval96.8%
associate-/r/96.8%
/-rgt-identity96.8%
*-commutative96.8%
associate-/r/96.8%
/-rgt-identity96.8%
*-commutative96.8%
Applied egg-rr96.8%
if 5.80000000000000013e141 < y Initial program 91.8%
associate-/l/91.9%
remove-double-neg91.9%
distribute-rgt-neg-out91.9%
distribute-rgt-neg-out91.9%
remove-double-neg91.9%
associate-*l*100.0%
*-commutative100.0%
sqr-neg100.0%
+-commutative100.0%
sqr-neg100.0%
fma-define100.0%
Simplified100.0%
*-commutative100.0%
associate-*r*91.9%
fma-undefine91.9%
+-commutative91.9%
associate-/l/91.8%
add-sqr-sqrt80.4%
sqrt-div54.7%
inv-pow54.7%
sqrt-pow154.7%
metadata-eval54.7%
+-commutative54.7%
fma-undefine54.7%
*-commutative54.7%
sqrt-prod54.7%
fma-undefine54.7%
+-commutative54.7%
hypot-1-def54.7%
sqrt-div54.7%
Applied egg-rr62.5%
unpow262.5%
Simplified62.5%
Applied egg-rr99.9%
add-sqr-sqrt99.8%
*-commutative99.8%
times-frac96.9%
clear-num96.9%
sqrt-div97.0%
metadata-eval97.0%
/-rgt-identity97.0%
fma-undefine97.0%
pow297.0%
+-commutative97.0%
metadata-eval97.0%
pow297.0%
hypot-undefine97.0%
Applied egg-rr97.1%
associate-*r/91.9%
div-inv91.8%
associate-*l/91.8%
frac-times91.8%
metadata-eval91.8%
hypot-undefine91.8%
hypot-undefine91.8%
rem-square-sqrt91.8%
metadata-eval91.8%
+-commutative91.8%
fma-undefine91.8%
associate-/r*91.8%
associate-/l/91.8%
frac-times100.0%
*-rgt-identity100.0%
Applied egg-rr100.0%
Final simplification97.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (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 89.8%
associate-/l/89.5%
remove-double-neg89.5%
distribute-rgt-neg-out89.5%
distribute-rgt-neg-out89.5%
remove-double-neg89.5%
associate-*l*89.9%
*-commutative89.9%
sqr-neg89.9%
+-commutative89.9%
sqr-neg89.9%
fma-define89.9%
Simplified89.9%
*-commutative89.9%
associate-*r*89.5%
fma-undefine89.5%
+-commutative89.5%
associate-/l/89.8%
add-sqr-sqrt57.4%
sqrt-div21.0%
inv-pow21.0%
sqrt-pow121.0%
metadata-eval21.0%
+-commutative21.0%
fma-undefine21.0%
*-commutative21.0%
sqrt-prod21.0%
fma-undefine21.0%
+-commutative21.0%
hypot-1-def21.0%
sqrt-div21.0%
Applied egg-rr26.4%
unpow226.4%
Simplified26.4%
div-inv26.4%
*-commutative26.4%
associate-/r*26.4%
Applied egg-rr26.4%
associate-*r/26.3%
associate-*l/26.4%
associate-*r/26.4%
*-rgt-identity26.4%
Simplified26.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 2e+304)
(/ (/ 1.0 y_m) (* x_m (fma z z 1.0)))
(* (/ 1.0 (* z y_m)) (/ (/ 1.0 (hypot 1.0 z)) x_m))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 2e+304) {
tmp = (1.0 / y_m) / (x_m * fma(z, z, 1.0));
} else {
tmp = (1.0 / (z * y_m)) * ((1.0 / hypot(1.0, z)) / x_m);
}
return y_s * (x_s * tmp);
}
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) tmp = 0.0 if (Float64(z * z) <= 2e+304) tmp = Float64(Float64(1.0 / y_m) / Float64(x_m * fma(z, z, 1.0))); else tmp = Float64(Float64(1.0 / Float64(z * y_m)) * Float64(Float64(1.0 / hypot(1.0, z)) / x_m)); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 2e+304], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(x$95$m * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(z * y$95$m), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+304}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x\_m \cdot \mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot y\_m} \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)}}{x\_m}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 1.9999999999999999e304Initial program 96.4%
associate-/l/96.0%
remove-double-neg96.0%
distribute-rgt-neg-out96.0%
distribute-rgt-neg-out96.0%
remove-double-neg96.0%
associate-*l*96.6%
*-commutative96.6%
sqr-neg96.6%
+-commutative96.6%
sqr-neg96.6%
fma-define96.6%
Simplified96.6%
*-commutative96.6%
associate-*r*96.0%
fma-undefine96.0%
+-commutative96.0%
associate-/l/96.4%
add-sqr-sqrt55.1%
sqrt-div21.0%
inv-pow21.0%
sqrt-pow121.0%
metadata-eval21.0%
+-commutative21.0%
fma-undefine21.0%
*-commutative21.0%
sqrt-prod21.0%
fma-undefine21.0%
+-commutative21.0%
hypot-1-def21.0%
sqrt-div20.9%
Applied egg-rr23.2%
unpow223.2%
Simplified23.2%
Applied egg-rr97.8%
add-sqr-sqrt97.7%
*-commutative97.7%
times-frac96.6%
clear-num96.6%
sqrt-div96.6%
metadata-eval96.6%
/-rgt-identity96.6%
fma-undefine96.6%
pow296.6%
+-commutative96.6%
metadata-eval96.6%
pow296.6%
hypot-undefine96.6%
Applied egg-rr96.6%
associate-*r/96.3%
div-inv96.3%
associate-*l/96.3%
frac-times96.3%
metadata-eval96.3%
hypot-undefine96.3%
hypot-undefine96.3%
rem-square-sqrt96.3%
metadata-eval96.3%
+-commutative96.3%
fma-undefine96.3%
associate-/r*96.3%
associate-/l/96.3%
frac-times96.5%
*-rgt-identity96.5%
Applied egg-rr96.5%
if 1.9999999999999999e304 < (*.f64 z z) Initial program 65.7%
associate-/l/65.7%
remove-double-neg65.7%
distribute-rgt-neg-out65.7%
distribute-rgt-neg-out65.7%
remove-double-neg65.7%
associate-*l*65.7%
*-commutative65.7%
sqr-neg65.7%
+-commutative65.7%
sqr-neg65.7%
fma-define65.7%
Simplified65.7%
*-commutative65.7%
associate-*r*65.7%
fma-undefine65.7%
+-commutative65.7%
associate-/l/65.7%
add-sqr-sqrt65.7%
sqrt-div21.1%
inv-pow21.1%
sqrt-pow121.1%
metadata-eval21.1%
+-commutative21.1%
fma-undefine21.1%
*-commutative21.1%
sqrt-prod21.1%
fma-undefine21.1%
+-commutative21.1%
hypot-1-def21.1%
sqrt-div21.1%
Applied egg-rr37.9%
unpow237.9%
Simplified37.9%
Applied egg-rr64.9%
add-sqr-sqrt64.9%
*-commutative64.9%
times-frac65.7%
clear-num65.7%
sqrt-div65.7%
metadata-eval65.7%
/-rgt-identity65.7%
fma-undefine65.7%
pow265.7%
+-commutative65.7%
metadata-eval65.7%
pow265.7%
hypot-undefine65.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 75.6%
Final simplification92.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(let* ((t_0 (* y_m (+ 1.0 (* z z)))))
(*
y_s
(*
x_s
(if (<= t_0 5e+304)
(/ (/ 1.0 x_m) t_0)
(/ (/ 1.0 (pow z 2.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) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 5e+304) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / pow(z, 2.0)) / (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+304) then
tmp = (1.0d0 / x_m) / t_0
else
tmp = (1.0d0 / (z ** 2.0d0)) / (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+304) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / Math.pow(z, 2.0)) / (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+304: tmp = (1.0 / x_m) / t_0 else: tmp = (1.0 / math.pow(z, 2.0)) / (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+304) tmp = Float64(Float64(1.0 / x_m) / t_0); else tmp = Float64(Float64(1.0 / (z ^ 2.0)) / 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+304)
tmp = (1.0 / x_m) / t_0;
else
tmp = (1.0 / (z ^ 2.0)) / (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+304], N[(N[(1.0 / x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision] / 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])\\
\\
\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^{+304}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{{z}^{2}}}{x\_m \cdot y\_m}\\
\end{array}\right)
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 4.9999999999999997e304Initial program 95.3%
if 4.9999999999999997e304 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 58.0%
associate-/l/58.0%
remove-double-neg58.0%
distribute-rgt-neg-out58.0%
distribute-rgt-neg-out58.0%
remove-double-neg58.0%
associate-*l*70.2%
*-commutative70.2%
sqr-neg70.2%
+-commutative70.2%
sqr-neg70.2%
fma-define70.2%
Simplified70.2%
*-commutative70.2%
associate-*r*58.0%
fma-undefine58.0%
+-commutative58.0%
associate-/l/58.0%
add-sqr-sqrt58.0%
sqrt-div39.3%
inv-pow39.3%
sqrt-pow139.3%
metadata-eval39.3%
+-commutative39.3%
fma-undefine39.3%
*-commutative39.3%
sqrt-prod39.3%
fma-undefine39.3%
+-commutative39.3%
hypot-1-def39.3%
sqrt-div39.3%
Applied egg-rr75.7%
unpow275.7%
Simplified75.7%
Applied egg-rr69.4%
Taylor expanded in z around inf 69.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= z 1850000.0)
(/ (/ 1.0 x_m) (* y_m (+ 1.0 (* z z))))
(/ 1.0 (* y_m (* x_m (pow 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 (z <= 1850000.0) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else {
tmp = 1.0 / (y_m * (x_m * pow(z, 2.0)));
}
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 <= 1850000.0d0) then
tmp = (1.0d0 / x_m) / (y_m * (1.0d0 + (z * z)))
else
tmp = 1.0d0 / (y_m * (x_m * (z ** 2.0d0)))
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 <= 1850000.0) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else {
tmp = 1.0 / (y_m * (x_m * Math.pow(z, 2.0)));
}
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 <= 1850000.0: tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z))) else: tmp = 1.0 / (y_m * (x_m * math.pow(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 (z <= 1850000.0) tmp = Float64(Float64(1.0 / x_m) / Float64(y_m * Float64(1.0 + Float64(z * z)))); else tmp = Float64(1.0 / Float64(y_m * Float64(x_m * (z ^ 2.0)))); 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 <= 1850000.0)
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
else
tmp = 1.0 / (y_m * (x_m * (z ^ 2.0)));
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, 1850000.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y$95$m * N[(x$95$m * N[Power[z, 2.0], $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 1850000:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m \cdot \left(x\_m \cdot {z}^{2}\right)}\\
\end{array}\right)
\end{array}
if z < 1.85e6Initial program 92.4%
if 1.85e6 < z Initial program 78.7%
associate-/l/77.2%
remove-double-neg77.2%
distribute-rgt-neg-out77.2%
distribute-rgt-neg-out77.2%
remove-double-neg77.2%
associate-*l*79.1%
*-commutative79.1%
sqr-neg79.1%
+-commutative79.1%
sqr-neg79.1%
fma-define79.1%
Simplified79.1%
Taylor expanded in z around inf 77.2%
*-commutative77.2%
associate-*r*79.1%
*-commutative79.1%
Simplified79.1%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (/ (/ 1.0 y_m) (* x_m (fma z z 1.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 * ((1.0 / y_m) / (x_m * fma(z, z, 1.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(1.0 / y_m) / Float64(x_m * fma(z, z, 1.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[(N[(1.0 / y$95$m), $MachinePrecision] / N[(x$95$m * N[(z * z + 1.0), $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 \frac{\frac{1}{y\_m}}{x\_m \cdot \mathsf{fma}\left(z, z, 1\right)}\right)
\end{array}
Initial program 89.8%
associate-/l/89.5%
remove-double-neg89.5%
distribute-rgt-neg-out89.5%
distribute-rgt-neg-out89.5%
remove-double-neg89.5%
associate-*l*89.9%
*-commutative89.9%
sqr-neg89.9%
+-commutative89.9%
sqr-neg89.9%
fma-define89.9%
Simplified89.9%
*-commutative89.9%
associate-*r*89.5%
fma-undefine89.5%
+-commutative89.5%
associate-/l/89.8%
add-sqr-sqrt57.4%
sqrt-div21.0%
inv-pow21.0%
sqrt-pow121.0%
metadata-eval21.0%
+-commutative21.0%
fma-undefine21.0%
*-commutative21.0%
sqrt-prod21.0%
fma-undefine21.0%
+-commutative21.0%
hypot-1-def21.0%
sqrt-div21.0%
Applied egg-rr26.4%
unpow226.4%
Simplified26.4%
Applied egg-rr90.7%
add-sqr-sqrt90.6%
*-commutative90.6%
times-frac90.0%
clear-num90.0%
sqrt-div90.0%
metadata-eval90.0%
/-rgt-identity90.0%
fma-undefine90.0%
pow290.0%
+-commutative90.0%
metadata-eval90.0%
pow290.0%
hypot-undefine90.0%
Applied egg-rr97.3%
associate-*r/94.0%
div-inv93.9%
associate-*l/89.7%
frac-times89.7%
metadata-eval89.7%
hypot-undefine89.7%
hypot-undefine89.7%
rem-square-sqrt89.7%
metadata-eval89.7%
+-commutative89.7%
fma-undefine89.7%
associate-/r*89.7%
associate-/l/89.7%
frac-times89.9%
*-rgt-identity89.9%
Applied egg-rr89.9%
Final simplification89.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (/ 1.0 (* y_m (* x_m (fma z z 1.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 * (1.0 / (y_m * (x_m * fma(z, z, 1.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(1.0 / Float64(y_m * Float64(x_m * fma(z, z, 1.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[(1.0 / N[(y$95$m * N[(x$95$m * N[(z * z + 1.0), $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 \frac{1}{y\_m \cdot \left(x\_m \cdot \mathsf{fma}\left(z, z, 1\right)\right)}\right)
\end{array}
Initial program 89.8%
associate-/l/89.5%
remove-double-neg89.5%
distribute-rgt-neg-out89.5%
distribute-rgt-neg-out89.5%
remove-double-neg89.5%
associate-*l*89.9%
*-commutative89.9%
sqr-neg89.9%
+-commutative89.9%
sqr-neg89.9%
fma-define89.9%
Simplified89.9%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (/ (/ 1.0 x_m) (* y_m (+ 1.0 (* z z)))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * ((1.0 / x_m) / (y_m * (1.0 + (z * 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 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 * (1.0d0 + (z * z)))))
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 * (1.0 + (z * 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] = 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 * (1.0 + (z * 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 = 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(1.0 / x_m) / Float64(y_m * Float64(1.0 + Float64(z * z)))))) 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 * (1.0 + (z * z)))));
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[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z \cdot z\right)}\right)
\end{array}
Initial program 89.8%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (/ 1.0 (* x_m y_m)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * (1.0 / (x_m * y_m)));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (x_s * (1.0d0 / (x_m * y_m)))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * (1.0 / (x_m * y_m)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): return y_s * (x_s * (1.0 / (x_m * y_m)))
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) return Float64(y_s * Float64(x_s * Float64(1.0 / Float64(x_m * y_m)))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
tmp = y_s * (x_s * (1.0 / (x_m * y_m)));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(1.0 / N[(x$95$m * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{1}{x\_m \cdot y\_m}\right)
\end{array}
Initial program 89.8%
associate-/l/89.5%
remove-double-neg89.5%
distribute-rgt-neg-out89.5%
distribute-rgt-neg-out89.5%
remove-double-neg89.5%
associate-*l*89.9%
*-commutative89.9%
sqr-neg89.9%
+-commutative89.9%
sqr-neg89.9%
fma-define89.9%
Simplified89.9%
Taylor expanded in z around 0 68.8%
Final simplification68.8%
(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 2024170
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< (* y (+ 1 (* z z))) -inf.0) (/ (/ 1 y) (* (+ 1 (* z z)) x)) (if (< (* y (+ 1 (* z z))) 868074325056725200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (/ 1 x) (* (+ 1 (* z z)) y)) (/ (/ 1 y) (* (+ 1 (* z z)) x)))))
(/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))