
(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 (<= (* z z) 5e+111)
(/ (/ (/ 1.0 x_m) y_m) (fma z z 1.0))
(/ (/ 1.0 (* y_m (* z 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) <= 5e+111) {
tmp = ((1.0 / x_m) / y_m) / fma(z, z, 1.0);
} else {
tmp = (1.0 / (y_m * (z * 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) <= 5e+111) tmp = Float64(Float64(Float64(1.0 / x_m) / y_m) / fma(z, z, 1.0)); else tmp = Float64(Float64(1.0 / Float64(y_m * Float64(z * 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], 5e+111], N[(N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $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 5 \cdot 10^{+111}:\\
\;\;\;\;\frac{\frac{\frac{1}{x\_m}}{y\_m}}{\mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m \cdot \left(z \cdot x\_m\right)}}{z}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 4.9999999999999997e111Initial program 98.5%
associate-/l/98.1%
remove-double-neg98.1%
distribute-rgt-neg-out98.1%
distribute-rgt-neg-out98.1%
remove-double-neg98.1%
associate-*l*98.7%
*-commutative98.7%
sqr-neg98.7%
+-commutative98.7%
sqr-neg98.7%
fma-define98.7%
Simplified98.7%
*-commutative98.7%
associate-*r*98.1%
fma-undefine98.1%
+-commutative98.1%
associate-/l/98.5%
add-sqr-sqrt53.4%
*-un-lft-identity53.4%
times-frac53.4%
+-commutative53.4%
fma-undefine53.4%
*-commutative53.4%
sqrt-prod53.4%
fma-undefine53.4%
+-commutative53.4%
hypot-1-def53.4%
+-commutative53.4%
Applied egg-rr54.0%
frac-times53.4%
*-un-lft-identity53.4%
swap-sqr53.4%
hypot-undefine53.4%
hypot-undefine53.4%
rem-square-sqrt53.4%
metadata-eval53.4%
unpow253.4%
+-commutative53.4%
unpow253.4%
fma-undefine53.4%
add-sqr-sqrt98.5%
*-commutative98.5%
associate-/r*99.7%
Applied egg-rr99.7%
if 4.9999999999999997e111 < (*.f64 z z) Initial program 79.8%
remove-double-neg79.8%
distribute-lft-neg-out79.8%
distribute-rgt-neg-in79.8%
associate-/r*80.6%
associate-/l/80.6%
associate-/l/80.4%
distribute-lft-neg-out80.4%
distribute-rgt-neg-in80.4%
distribute-lft-neg-in80.4%
remove-double-neg80.4%
sqr-neg80.4%
+-commutative80.4%
sqr-neg80.4%
fma-define80.4%
*-commutative80.4%
Simplified80.4%
Taylor expanded in z around inf 80.4%
*-un-lft-identity80.4%
associate-/r*80.6%
*-commutative80.6%
associate-/r*80.7%
pow-flip81.2%
metadata-eval81.2%
Applied egg-rr81.2%
*-lft-identity81.2%
associate-/l/81.0%
Simplified81.0%
sqr-pow81.0%
associate-/l*90.8%
metadata-eval90.8%
unpow-190.8%
metadata-eval90.8%
unpow-190.8%
Applied egg-rr90.8%
associate-*l/90.9%
*-un-lft-identity90.9%
clear-num90.9%
*-commutative90.9%
associate-*r/98.1%
associate-/r/98.1%
/-rgt-identity98.1%
*-commutative98.1%
Applied egg-rr98.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 (* (hypot 1.0 z) (* (hypot 1.0 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) {
return y_s * (x_s * ((1.0 / (hypot(1.0, z) * (hypot(1.0, z) * x_m))) / y_m));
}
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 / (Math.hypot(1.0, z) * (Math.hypot(1.0, z) * 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 / (math.hypot(1.0, z) * (math.hypot(1.0, z) * 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(Float64(1.0 / Float64(hypot(1.0, z) * Float64(hypot(1.0, z) * 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 / (hypot(1.0, z) * (hypot(1.0, z) * 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[(N[(1.0 / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $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}{\mathsf{hypot}\left(1, z\right) \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot x\_m\right)}}{y\_m}\right)
\end{array}
Initial program 90.5%
associate-/l/90.3%
remove-double-neg90.3%
distribute-rgt-neg-out90.3%
distribute-rgt-neg-out90.3%
remove-double-neg90.3%
associate-*l*89.6%
*-commutative89.6%
sqr-neg89.6%
+-commutative89.6%
sqr-neg89.6%
fma-define89.6%
Simplified89.6%
*-commutative89.6%
associate-*r*90.3%
fma-undefine90.3%
+-commutative90.3%
associate-/l/90.5%
add-sqr-sqrt45.8%
*-un-lft-identity45.8%
times-frac45.8%
+-commutative45.8%
fma-undefine45.8%
*-commutative45.8%
sqrt-prod45.8%
fma-undefine45.8%
+-commutative45.8%
hypot-1-def45.8%
+-commutative45.8%
Applied egg-rr51.2%
*-commutative51.2%
associate-/r*51.2%
associate-/r*51.2%
frac-times49.4%
add-sqr-sqrt95.5%
Applied egg-rr95.5%
un-div-inv95.6%
clear-num95.5%
associate-/l/95.0%
associate-/r/95.0%
/-rgt-identity95.0%
*-commutative95.0%
Applied egg-rr95.0%
Final simplification95.0%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 1e+23)
(/ 1.0 (* (fma z z 1.0) (* x_m y_m)))
(/ (/ 1.0 (* y_m (* z 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) <= 1e+23) {
tmp = 1.0 / (fma(z, z, 1.0) * (x_m * y_m));
} else {
tmp = (1.0 / (y_m * (z * 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) <= 1e+23) tmp = Float64(1.0 / Float64(fma(z, z, 1.0) * Float64(x_m * y_m))); else tmp = Float64(Float64(1.0 / Float64(y_m * Float64(z * 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], 1e+23], N[(1.0 / N[(N[(z * z + 1.0), $MachinePrecision] * N[(x$95$m * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+23}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(z, z, 1\right) \cdot \left(x\_m \cdot y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m \cdot \left(z \cdot x\_m\right)}}{z}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 9.9999999999999992e22Initial program 99.1%
remove-double-neg99.1%
distribute-lft-neg-out99.1%
distribute-rgt-neg-in99.1%
associate-/r*99.7%
associate-/l/99.5%
associate-/l/99.5%
distribute-lft-neg-out99.5%
distribute-rgt-neg-in99.5%
distribute-lft-neg-in99.5%
remove-double-neg99.5%
sqr-neg99.5%
+-commutative99.5%
sqr-neg99.5%
fma-define99.5%
*-commutative99.5%
Simplified99.5%
if 9.9999999999999992e22 < (*.f64 z z) Initial program 80.4%
remove-double-neg80.4%
distribute-lft-neg-out80.4%
distribute-rgt-neg-in80.4%
associate-/r*81.9%
associate-/l/81.9%
associate-/l/81.5%
distribute-lft-neg-out81.5%
distribute-rgt-neg-in81.5%
distribute-lft-neg-in81.5%
remove-double-neg81.5%
sqr-neg81.5%
+-commutative81.5%
sqr-neg81.5%
fma-define81.5%
*-commutative81.5%
Simplified81.5%
Taylor expanded in z around inf 81.5%
*-un-lft-identity81.5%
associate-/r*81.9%
*-commutative81.9%
associate-/r*81.2%
pow-flip81.6%
metadata-eval81.6%
Applied egg-rr81.6%
*-lft-identity81.6%
associate-/l/82.3%
Simplified82.3%
sqr-pow82.3%
associate-/l*91.4%
metadata-eval91.4%
unpow-191.4%
metadata-eval91.4%
unpow-191.4%
Applied egg-rr91.4%
associate-*l/91.5%
*-un-lft-identity91.5%
clear-num91.5%
*-commutative91.5%
associate-*r/98.2%
associate-/r/98.2%
/-rgt-identity98.2%
*-commutative98.2%
Applied egg-rr98.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x_s x_m y_m z)
:precision binary64
(*
y_s
(*
x_s
(if (<= (* z z) 40000000.0)
(/ (/ 1.0 x_m) (* y_m (+ 1.0 (* z z))))
(/ (/ 1.0 (* y_m (* z 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) <= 40000000.0) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else {
tmp = (1.0 / (y_m * (z * 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 * z) <= 40000000.0d0) then
tmp = (1.0d0 / x_m) / (y_m * (1.0d0 + (z * z)))
else
tmp = (1.0d0 / (y_m * (z * 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 * z) <= 40000000.0) {
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
} else {
tmp = (1.0 / (y_m * (z * 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 * z) <= 40000000.0: tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z))) else: tmp = (1.0 / (y_m * (z * 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) <= 40000000.0) tmp = Float64(Float64(1.0 / x_m) / Float64(y_m * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(1.0 / Float64(y_m * Float64(z * 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 * z) <= 40000000.0)
tmp = (1.0 / x_m) / (y_m * (1.0 + (z * z)));
else
tmp = (1.0 / (y_m * (z * 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[N[(z * z), $MachinePrecision], 40000000.0], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $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 40000000:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m \cdot \left(z \cdot x\_m\right)}}{z}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 4e7Initial program 99.7%
if 4e7 < (*.f64 z z) Initial program 80.3%
remove-double-neg80.3%
distribute-lft-neg-out80.3%
distribute-rgt-neg-in80.3%
associate-/r*82.4%
associate-/l/82.5%
associate-/l/82.1%
distribute-lft-neg-out82.1%
distribute-rgt-neg-in82.1%
distribute-lft-neg-in82.1%
remove-double-neg82.1%
sqr-neg82.1%
+-commutative82.1%
sqr-neg82.1%
fma-define82.1%
*-commutative82.1%
Simplified82.1%
Taylor expanded in z around inf 81.9%
*-un-lft-identity81.9%
associate-/r*82.2%
*-commutative82.2%
associate-/r*81.6%
pow-flip82.0%
metadata-eval82.0%
Applied egg-rr82.0%
*-lft-identity82.0%
associate-/l/82.7%
Simplified82.7%
sqr-pow82.6%
associate-/l*91.4%
metadata-eval91.4%
unpow-191.4%
metadata-eval91.4%
unpow-191.4%
Applied egg-rr91.4%
associate-*l/91.5%
*-un-lft-identity91.5%
clear-num91.5%
*-commutative91.5%
associate-*r/98.0%
associate-/r/98.0%
/-rgt-identity98.0%
*-commutative98.0%
Applied egg-rr98.0%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (if (<= (* z z) 0.2) (/ (/ 1.0 x_m) y_m) (/ (/ 1.0 (* y_m (* z 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) <= 0.2) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / (y_m * (z * 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 * z) <= 0.2d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = (1.0d0 / (y_m * (z * 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 * z) <= 0.2) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / (y_m * (z * 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 * z) <= 0.2: tmp = (1.0 / x_m) / y_m else: tmp = (1.0 / (y_m * (z * 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) <= 0.2) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(Float64(1.0 / Float64(y_m * Float64(z * 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 * z) <= 0.2)
tmp = (1.0 / x_m) / y_m;
else
tmp = (1.0 / (y_m * (z * 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[N[(z * z), $MachinePrecision], 0.2], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / N[(y$95$m * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.2:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m \cdot \left(z \cdot x\_m\right)}}{z}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 0.20000000000000001Initial program 99.7%
associate-/l/99.5%
remove-double-neg99.5%
distribute-rgt-neg-out99.5%
distribute-rgt-neg-out99.5%
remove-double-neg99.5%
associate-*l*99.5%
*-commutative99.5%
sqr-neg99.5%
+-commutative99.5%
sqr-neg99.5%
fma-define99.5%
Simplified99.5%
Taylor expanded in z around 0 98.8%
associate-/r*99.1%
Simplified99.1%
if 0.20000000000000001 < (*.f64 z z) Initial program 80.6%
remove-double-neg80.6%
distribute-lft-neg-out80.6%
distribute-rgt-neg-in80.6%
associate-/r*82.7%
associate-/l/82.8%
associate-/l/82.4%
distribute-lft-neg-out82.4%
distribute-rgt-neg-in82.4%
distribute-lft-neg-in82.4%
remove-double-neg82.4%
sqr-neg82.4%
+-commutative82.4%
sqr-neg82.4%
fma-define82.4%
*-commutative82.4%
Simplified82.4%
Taylor expanded in z around inf 81.8%
*-un-lft-identity81.8%
associate-/r*82.2%
*-commutative82.2%
associate-/r*81.5%
pow-flip81.9%
metadata-eval81.9%
Applied egg-rr81.9%
*-lft-identity81.9%
associate-/l/82.6%
Simplified82.6%
sqr-pow82.5%
associate-/l*91.2%
metadata-eval91.2%
unpow-191.2%
metadata-eval91.2%
unpow-191.2%
Applied egg-rr91.2%
associate-*l/91.3%
*-un-lft-identity91.3%
clear-num91.3%
*-commutative91.3%
associate-*r/97.7%
associate-/r/97.7%
/-rgt-identity97.7%
*-commutative97.7%
Applied egg-rr97.7%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (if (<= (* z z) 0.2) (/ (/ 1.0 x_m) y_m) (/ (/ 1.0 z) (* y_m (* 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) <= 0.2) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / z) / (y_m * (z * x_m));
}
return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 0.2d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = (1.0d0 / z) / (y_m * (z * x_m))
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 0.2) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = (1.0 / z) / (y_m * (z * x_m));
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if (z * z) <= 0.2: tmp = (1.0 / x_m) / y_m else: tmp = (1.0 / z) / (y_m * (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) <= 0.2) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(Float64(1.0 / z) / Float64(y_m * Float64(z * x_m))); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if ((z * z) <= 0.2)
tmp = (1.0 / x_m) / y_m;
else
tmp = (1.0 / z) / (y_m * (z * x_m));
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 0.2], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(y$95$m * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.2:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y\_m \cdot \left(z \cdot x\_m\right)}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 0.20000000000000001Initial program 99.7%
associate-/l/99.5%
remove-double-neg99.5%
distribute-rgt-neg-out99.5%
distribute-rgt-neg-out99.5%
remove-double-neg99.5%
associate-*l*99.5%
*-commutative99.5%
sqr-neg99.5%
+-commutative99.5%
sqr-neg99.5%
fma-define99.5%
Simplified99.5%
Taylor expanded in z around 0 98.8%
associate-/r*99.1%
Simplified99.1%
if 0.20000000000000001 < (*.f64 z z) Initial program 80.6%
remove-double-neg80.6%
distribute-lft-neg-out80.6%
distribute-rgt-neg-in80.6%
associate-/r*82.7%
associate-/l/82.8%
associate-/l/82.4%
distribute-lft-neg-out82.4%
distribute-rgt-neg-in82.4%
distribute-lft-neg-in82.4%
remove-double-neg82.4%
sqr-neg82.4%
+-commutative82.4%
sqr-neg82.4%
fma-define82.4%
*-commutative82.4%
Simplified82.4%
Taylor expanded in z around inf 81.8%
*-un-lft-identity81.8%
associate-/r*82.2%
*-commutative82.2%
associate-/r*81.5%
pow-flip81.9%
metadata-eval81.9%
Applied egg-rr81.9%
*-lft-identity81.9%
associate-/l/82.6%
Simplified82.6%
sqr-pow82.5%
associate-/l*91.2%
metadata-eval91.2%
unpow-191.2%
metadata-eval91.2%
unpow-191.2%
Applied egg-rr91.2%
associate-/l/91.3%
un-div-inv91.2%
remove-double-div91.2%
div-inv91.2%
*-commutative91.2%
associate-*l/98.1%
associate-/r/98.2%
/-rgt-identity98.2%
associate-*l*97.6%
Applied egg-rr97.6%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (if (<= (* z z) 0.2) (/ (/ 1.0 x_m) y_m) (/ 1.0 (* y_m (* z (* 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) <= 0.2) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = 1.0 / (y_m * (z * (z * x_m)));
}
return y_s * (x_s * tmp);
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 0.2d0) then
tmp = (1.0d0 / x_m) / y_m
else
tmp = 1.0d0 / (y_m * (z * (z * x_m)))
end if
code = y_s * (x_s * tmp)
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
double tmp;
if ((z * z) <= 0.2) {
tmp = (1.0 / x_m) / y_m;
} else {
tmp = 1.0 / (y_m * (z * (z * x_m)));
}
return y_s * (x_s * tmp);
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): tmp = 0 if (z * z) <= 0.2: tmp = (1.0 / x_m) / y_m else: tmp = 1.0 / (y_m * (z * (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) <= 0.2) tmp = Float64(Float64(1.0 / x_m) / y_m); else tmp = Float64(1.0 / Float64(y_m * Float64(z * Float64(z * x_m)))); end return Float64(y_s * Float64(x_s * tmp)) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp_2 = code(y_s, x_s, x_m, y_m, z)
tmp = 0.0;
if ((z * z) <= 0.2)
tmp = (1.0 / x_m) / y_m;
else
tmp = 1.0 / (y_m * (z * (z * x_m)));
end
tmp_2 = y_s * (x_s * tmp);
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 0.2], N[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $MachinePrecision], N[(1.0 / N[(y$95$m * N[(z * N[(z * x$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 \cdot z \leq 0.2:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y\_m \cdot \left(z \cdot \left(z \cdot x\_m\right)\right)}\\
\end{array}\right)
\end{array}
if (*.f64 z z) < 0.20000000000000001Initial program 99.7%
associate-/l/99.5%
remove-double-neg99.5%
distribute-rgt-neg-out99.5%
distribute-rgt-neg-out99.5%
remove-double-neg99.5%
associate-*l*99.5%
*-commutative99.5%
sqr-neg99.5%
+-commutative99.5%
sqr-neg99.5%
fma-define99.5%
Simplified99.5%
Taylor expanded in z around 0 98.8%
associate-/r*99.1%
Simplified99.1%
if 0.20000000000000001 < (*.f64 z z) Initial program 80.6%
remove-double-neg80.6%
distribute-lft-neg-out80.6%
distribute-rgt-neg-in80.6%
associate-/r*82.7%
associate-/l/82.8%
associate-/l/82.4%
distribute-lft-neg-out82.4%
distribute-rgt-neg-in82.4%
distribute-lft-neg-in82.4%
remove-double-neg82.4%
sqr-neg82.4%
+-commutative82.4%
sqr-neg82.4%
fma-define82.4%
*-commutative82.4%
Simplified82.4%
Taylor expanded in z around inf 81.8%
add-sqr-sqrt38.4%
pow238.4%
*-commutative38.4%
sqrt-prod38.4%
sqrt-pow143.6%
metadata-eval43.6%
pow143.6%
Applied egg-rr43.6%
/-rgt-identity43.6%
clear-num43.6%
inv-pow43.6%
unpow243.6%
swap-sqr38.3%
pow238.3%
add-sqr-sqrt81.8%
*-commutative81.8%
unpow-prod-down81.8%
pow281.8%
pow-prod-down82.1%
pow-prod-up82.2%
metadata-eval82.2%
inv-pow82.2%
div-inv82.2%
clear-num82.3%
*-commutative82.3%
sqr-pow82.2%
times-frac96.5%
metadata-eval96.5%
unpow-196.5%
Applied egg-rr96.5%
clear-num96.4%
frac-times87.4%
*-un-lft-identity87.4%
associate-/l/87.4%
*-commutative87.4%
Applied egg-rr87.4%
associate-/r*98.0%
associate-/r/98.1%
/-rgt-identity98.1%
*-commutative98.1%
*-commutative98.1%
associate-*r*97.3%
associate-/l*88.9%
associate-/r/88.9%
/-rgt-identity88.9%
*-commutative88.9%
Simplified88.9%
Final simplification94.2%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (/ (/ 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(Float64(1.0 / 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[(N[(1.0 / x$95$m), $MachinePrecision] / y$95$m), $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}\right)
\end{array}
Initial program 90.5%
associate-/l/90.3%
remove-double-neg90.3%
distribute-rgt-neg-out90.3%
distribute-rgt-neg-out90.3%
remove-double-neg90.3%
associate-*l*89.6%
*-commutative89.6%
sqr-neg89.6%
+-commutative89.6%
sqr-neg89.6%
fma-define89.6%
Simplified89.6%
Taylor expanded in z around 0 60.2%
associate-/r*60.3%
Simplified60.3%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x_s x_m y_m z) :precision binary64 (* y_s (* x_s (/ 1.0 (* x_m y_m)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x_m < y_m && y_m < z);
double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * (1.0 / (x_m * y_m)));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x_s, x_m, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (x_s * (1.0d0 / (x_m * y_m)))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x_m < y_m && y_m < z;
public static double code(double y_s, double x_s, double x_m, double y_m, double z) {
return y_s * (x_s * (1.0 / (x_m * y_m)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x_m, y_m, z] = sort([x_m, y_m, z]) def code(y_s, x_s, x_m, y_m, z): return y_s * (x_s * (1.0 / (x_m * y_m)))
x\_m = abs(x) x\_s = copysign(1.0, x) y\_m = abs(y) y\_s = copysign(1.0, y) x_m, y_m, z = sort([x_m, y_m, z]) function code(y_s, x_s, x_m, y_m, z) return Float64(y_s * Float64(x_s * Float64(1.0 / Float64(x_m * y_m)))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x_m, y_m, z = num2cell(sort([x_m, y_m, z])){:}
function tmp = code(y_s, x_s, x_m, y_m, z)
tmp = y_s * (x_s * (1.0 / (x_m * y_m)));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x$95$s_, x$95$m_, y$95$m_, z_] := N[(y$95$s * N[(x$95$s * N[(1.0 / N[(x$95$m * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x_m, y_m, z] = \mathsf{sort}([x_m, y_m, z])\\
\\
y\_s \cdot \left(x\_s \cdot \frac{1}{x\_m \cdot y\_m}\right)
\end{array}
Initial program 90.5%
associate-/l/90.3%
remove-double-neg90.3%
distribute-rgt-neg-out90.3%
distribute-rgt-neg-out90.3%
remove-double-neg90.3%
associate-*l*89.6%
*-commutative89.6%
sqr-neg89.6%
+-commutative89.6%
sqr-neg89.6%
fma-define89.6%
Simplified89.6%
Taylor expanded in z around 0 60.2%
Final simplification60.2%
(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 2024185
(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)))))