
(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 8 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)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z_m)
:precision binary64
(*
x_s
(if (<= (* y (+ 1.0 (* z_m z_m))) 2e+304)
(/ (/ 1.0 x_m) (fma (* y z_m) z_m y))
(/ (/ (/ 1.0 (sqrt y)) (hypot 1.0 z_m)) (* (sqrt y) (* z_m x_m))))))z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if ((y * (1.0 + (z_m * z_m))) <= 2e+304) {
tmp = (1.0 / x_m) / fma((y * z_m), z_m, y);
} else {
tmp = ((1.0 / sqrt(y)) / hypot(1.0, z_m)) / (sqrt(y) * (z_m * x_m));
}
return x_s * tmp;
}
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z_m * z_m))) <= 2e+304) tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y * z_m), z_m, y)); else tmp = Float64(Float64(Float64(1.0 / sqrt(y)) / hypot(1.0, z_m)) / Float64(sqrt(y) * Float64(z_m * x_m))); end return 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * If[LessEqual[N[(y * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+304], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y * z$95$m), $MachinePrecision] * z$95$m + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[y], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[y], $MachinePrecision] * N[(z$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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z\_m \cdot z\_m\right) \leq 2 \cdot 10^{+304}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y \cdot z\_m, z\_m, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\_m\right)}}{\sqrt{y} \cdot \left(z\_m \cdot x\_m\right)}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 1.9999999999999999e304Initial program 94.5%
+-commutative94.5%
distribute-lft-in94.5%
associate-*r*96.2%
*-rgt-identity96.2%
fma-define96.2%
Applied egg-rr96.2%
if 1.9999999999999999e304 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 69.9%
associate-/l/69.9%
associate-*l*72.5%
*-commutative72.5%
sqr-neg72.5%
+-commutative72.5%
sqr-neg72.5%
fma-define72.5%
Simplified72.5%
associate-*r*72.3%
*-commutative72.3%
associate-/r*72.3%
*-commutative72.3%
associate-/l/72.3%
fma-undefine72.3%
+-commutative72.3%
associate-/r*69.9%
*-un-lft-identity69.9%
add-sqr-sqrt69.9%
times-frac69.9%
+-commutative69.9%
fma-undefine69.9%
*-commutative69.9%
sqrt-prod69.9%
fma-undefine69.9%
+-commutative69.9%
hypot-1-def69.9%
+-commutative69.9%
Applied egg-rr99.7%
associate-/l/99.6%
associate-*r/99.7%
*-rgt-identity99.7%
*-commutative99.7%
associate-/r*99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in z around inf 85.2%
Final simplification94.7%
z_m = (fabs.f64 z) x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z_m) :precision binary64 (* x_s (/ (/ (/ 1.0 (sqrt y)) (hypot 1.0 z_m)) (* x_m (* (sqrt y) (hypot 1.0 z_m))))))
z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
return x_s * (((1.0 / sqrt(y)) / hypot(1.0, z_m)) / (x_m * (sqrt(y) * hypot(1.0, z_m))));
}
z_m = Math.abs(z);
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z_m;
public static double code(double x_s, double x_m, double y, double z_m) {
return x_s * (((1.0 / Math.sqrt(y)) / Math.hypot(1.0, z_m)) / (x_m * (Math.sqrt(y) * Math.hypot(1.0, z_m))));
}
z_m = math.fabs(z) x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z_m] = sort([x_m, y, z_m]) def code(x_s, x_m, y, z_m): return x_s * (((1.0 / math.sqrt(y)) / math.hypot(1.0, z_m)) / (x_m * (math.sqrt(y) * math.hypot(1.0, z_m))))
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) return Float64(x_s * Float64(Float64(Float64(1.0 / sqrt(y)) / hypot(1.0, z_m)) / Float64(x_m * Float64(sqrt(y) * hypot(1.0, z_m))))) end
z_m = abs(z);
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z_m = num2cell(sort([x_m, y, z_m])){:}
function tmp = code(x_s, x_m, y, z_m)
tmp = x_s * (((1.0 / sqrt(y)) / hypot(1.0, z_m)) / (x_m * (sqrt(y) * hypot(1.0, z_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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * N[(N[(N[(1.0 / N[Sqrt[y], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $MachinePrecision]), $MachinePrecision] / N[(x$95$m * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + z$95$m ^ 2], $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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \frac{\frac{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\_m\right)}}{x\_m \cdot \left(\sqrt{y} \cdot \mathsf{hypot}\left(1, z\_m\right)\right)}
\end{array}
Initial program 91.1%
associate-/l/91.1%
associate-*l*88.5%
*-commutative88.5%
sqr-neg88.5%
+-commutative88.5%
sqr-neg88.5%
fma-define88.5%
Simplified88.5%
associate-*r*89.2%
*-commutative89.2%
associate-/r*89.2%
*-commutative89.2%
associate-/l/89.3%
fma-undefine89.3%
+-commutative89.3%
associate-/r*91.1%
*-un-lft-identity91.1%
add-sqr-sqrt42.8%
times-frac42.9%
+-commutative42.9%
fma-undefine42.9%
*-commutative42.9%
sqrt-prod42.9%
fma-undefine42.9%
+-commutative42.9%
hypot-1-def42.9%
+-commutative42.9%
Applied egg-rr46.9%
associate-/l/46.9%
associate-*r/46.9%
*-rgt-identity46.9%
*-commutative46.9%
associate-/r*47.0%
*-commutative47.0%
Simplified47.0%
Final simplification47.0%
z_m = (fabs.f64 z)
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z_m)
:precision binary64
(*
x_s
(if (<= (* z_m z_m) 5e+306)
(* (/ 1.0 y) (/ (/ 1.0 x_m) (fma z_m z_m 1.0)))
(* (/ (/ 1.0 y) z_m) (/ (/ 1.0 x_m) z_m)))))z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if ((z_m * z_m) <= 5e+306) {
tmp = (1.0 / y) * ((1.0 / x_m) / fma(z_m, z_m, 1.0));
} else {
tmp = ((1.0 / y) / z_m) * ((1.0 / x_m) / z_m);
}
return x_s * tmp;
}
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) tmp = 0.0 if (Float64(z_m * z_m) <= 5e+306) tmp = Float64(Float64(1.0 / y) * Float64(Float64(1.0 / x_m) / fma(z_m, z_m, 1.0))); else tmp = Float64(Float64(Float64(1.0 / y) / z_m) * Float64(Float64(1.0 / x_m) / z_m)); end return 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e+306], N[(N[(1.0 / y), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(z$95$m * z$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z$95$m), $MachinePrecision] * N[(N[(1.0 / x$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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\frac{1}{y} \cdot \frac{\frac{1}{x\_m}}{\mathsf{fma}\left(z\_m, z\_m, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z\_m} \cdot \frac{\frac{1}{x\_m}}{z\_m}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999993e306Initial program 98.6%
associate-/l/98.6%
associate-*l*95.3%
*-commutative95.3%
sqr-neg95.3%
+-commutative95.3%
sqr-neg95.3%
fma-define95.3%
Simplified95.3%
associate-*r*96.2%
*-commutative96.2%
associate-/r*96.3%
*-commutative96.3%
associate-/l/96.3%
associate-/r*98.6%
*-un-lft-identity98.6%
times-frac95.3%
Applied egg-rr95.3%
if 4.99999999999999993e306 < (*.f64 z z) Initial program 65.0%
associate-/l/65.0%
associate-*l*65.0%
*-commutative65.0%
sqr-neg65.0%
+-commutative65.0%
sqr-neg65.0%
fma-define65.0%
Simplified65.0%
add-sqr-sqrt32.9%
pow232.9%
*-commutative32.9%
sqrt-prod32.9%
fma-undefine32.9%
+-commutative32.9%
hypot-1-def37.7%
Applied egg-rr37.7%
Taylor expanded in z around inf 37.7%
unpow237.7%
swap-sqr32.9%
add-sqr-sqrt65.0%
associate-*r*81.5%
Applied egg-rr81.5%
associate-/r*82.7%
associate-*l*65.0%
unpow265.0%
associate-/r*64.6%
div-inv64.6%
unpow264.6%
times-frac99.8%
Applied egg-rr99.8%
z_m = (fabs.f64 z)
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z_m)
:precision binary64
(*
x_s
(if (<= (* z_m z_m) 5e+306)
(/ 1.0 (* y (* x_m (fma z_m z_m 1.0))))
(* (/ (/ 1.0 y) z_m) (/ (/ 1.0 x_m) z_m)))))z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if ((z_m * z_m) <= 5e+306) {
tmp = 1.0 / (y * (x_m * fma(z_m, z_m, 1.0)));
} else {
tmp = ((1.0 / y) / z_m) * ((1.0 / x_m) / z_m);
}
return x_s * tmp;
}
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) tmp = 0.0 if (Float64(z_m * z_m) <= 5e+306) tmp = Float64(1.0 / Float64(y * Float64(x_m * fma(z_m, z_m, 1.0)))); else tmp = Float64(Float64(Float64(1.0 / y) / z_m) * Float64(Float64(1.0 / x_m) / z_m)); end return 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 5e+306], N[(1.0 / N[(y * N[(x$95$m * N[(z$95$m * z$95$m + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z$95$m), $MachinePrecision] * N[(N[(1.0 / x$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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 5 \cdot 10^{+306}:\\
\;\;\;\;\frac{1}{y \cdot \left(x\_m \cdot \mathsf{fma}\left(z\_m, z\_m, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z\_m} \cdot \frac{\frac{1}{x\_m}}{z\_m}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999993e306Initial program 98.6%
associate-/l/98.6%
associate-*l*95.3%
*-commutative95.3%
sqr-neg95.3%
+-commutative95.3%
sqr-neg95.3%
fma-define95.3%
Simplified95.3%
if 4.99999999999999993e306 < (*.f64 z z) Initial program 65.0%
associate-/l/65.0%
associate-*l*65.0%
*-commutative65.0%
sqr-neg65.0%
+-commutative65.0%
sqr-neg65.0%
fma-define65.0%
Simplified65.0%
add-sqr-sqrt32.9%
pow232.9%
*-commutative32.9%
sqrt-prod32.9%
fma-undefine32.9%
+-commutative32.9%
hypot-1-def37.7%
Applied egg-rr37.7%
Taylor expanded in z around inf 37.7%
unpow237.7%
swap-sqr32.9%
add-sqr-sqrt65.0%
associate-*r*81.5%
Applied egg-rr81.5%
associate-/r*82.7%
associate-*l*65.0%
unpow265.0%
associate-/r*64.6%
div-inv64.6%
unpow264.6%
times-frac99.8%
Applied egg-rr99.8%
z_m = (fabs.f64 z)
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z_m)
:precision binary64
(*
x_s
(if (<= (* z_m z_m) 3e+48)
(/ (/ 1.0 x_m) (* y (+ 1.0 (* z_m z_m))))
(* (/ (/ 1.0 y) z_m) (/ 1.0 (* z_m x_m))))))z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if ((z_m * z_m) <= 3e+48) {
tmp = (1.0 / x_m) / (y * (1.0 + (z_m * z_m)));
} else {
tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m));
}
return x_s * tmp;
}
z_m = abs(z)
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if ((z_m * z_m) <= 3d+48) then
tmp = (1.0d0 / x_m) / (y * (1.0d0 + (z_m * z_m)))
else
tmp = ((1.0d0 / y) / z_m) * (1.0d0 / (z_m * x_m))
end if
code = x_s * tmp
end function
z_m = Math.abs(z);
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z_m;
public static double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if ((z_m * z_m) <= 3e+48) {
tmp = (1.0 / x_m) / (y * (1.0 + (z_m * z_m)));
} else {
tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m));
}
return x_s * tmp;
}
z_m = math.fabs(z) x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z_m] = sort([x_m, y, z_m]) def code(x_s, x_m, y, z_m): tmp = 0 if (z_m * z_m) <= 3e+48: tmp = (1.0 / x_m) / (y * (1.0 + (z_m * z_m))) else: tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m)) return x_s * tmp
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) tmp = 0.0 if (Float64(z_m * z_m) <= 3e+48) tmp = Float64(Float64(1.0 / x_m) / Float64(y * Float64(1.0 + Float64(z_m * z_m)))); else tmp = Float64(Float64(Float64(1.0 / y) / z_m) * Float64(1.0 / Float64(z_m * x_m))); end return Float64(x_s * tmp) end
z_m = abs(z);
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z_m = num2cell(sort([x_m, y, z_m])){:}
function tmp_2 = code(x_s, x_m, y, z_m)
tmp = 0.0;
if ((z_m * z_m) <= 3e+48)
tmp = (1.0 / x_m) / (y * (1.0 + (z_m * z_m)));
else
tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m));
end
tmp_2 = 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * If[LessEqual[N[(z$95$m * z$95$m), $MachinePrecision], 3e+48], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y * N[(1.0 + N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z$95$m), $MachinePrecision] * N[(1.0 / N[(z$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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \cdot z\_m \leq 3 \cdot 10^{+48}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y \cdot \left(1 + z\_m \cdot z\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z\_m} \cdot \frac{1}{z\_m \cdot x\_m}\\
\end{array}
\end{array}
if (*.f64 z z) < 3e48Initial program 99.6%
if 3e48 < (*.f64 z z) Initial program 81.4%
associate-/l/81.4%
associate-*l*75.9%
*-commutative75.9%
sqr-neg75.9%
+-commutative75.9%
sqr-neg75.9%
fma-define75.9%
Simplified75.9%
add-sqr-sqrt32.6%
pow232.6%
*-commutative32.6%
sqrt-prod32.6%
fma-undefine32.6%
+-commutative32.6%
hypot-1-def34.9%
Applied egg-rr34.9%
Taylor expanded in z around inf 34.9%
unpow234.9%
swap-sqr32.6%
add-sqr-sqrt75.9%
associate-*r*83.8%
Applied egg-rr83.8%
associate-/r*84.4%
*-un-lft-identity84.4%
times-frac97.3%
Applied egg-rr97.3%
Final simplification98.5%
z_m = (fabs.f64 z)
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z_m)
:precision binary64
(*
x_s
(if (<= z_m 1.0)
(/ (/ 1.0 y) x_m)
(* (/ (/ 1.0 y) z_m) (/ 1.0 (* z_m x_m))))))z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / y) / x_m;
} else {
tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m));
}
return x_s * tmp;
}
z_m = abs(z)
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 1.0d0) then
tmp = (1.0d0 / y) / x_m
else
tmp = ((1.0d0 / y) / z_m) * (1.0d0 / (z_m * x_m))
end if
code = x_s * tmp
end function
z_m = Math.abs(z);
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z_m;
public static double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / y) / x_m;
} else {
tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m));
}
return x_s * tmp;
}
z_m = math.fabs(z) x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z_m] = sort([x_m, y, z_m]) def code(x_s, x_m, y, z_m): tmp = 0 if z_m <= 1.0: tmp = (1.0 / y) / x_m else: tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m)) return x_s * tmp
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) tmp = 0.0 if (z_m <= 1.0) tmp = Float64(Float64(1.0 / y) / x_m); else tmp = Float64(Float64(Float64(1.0 / y) / z_m) * Float64(1.0 / Float64(z_m * x_m))); end return Float64(x_s * tmp) end
z_m = abs(z);
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z_m = num2cell(sort([x_m, y, z_m])){:}
function tmp_2 = code(x_s, x_m, y, z_m)
tmp = 0.0;
if (z_m <= 1.0)
tmp = (1.0 / y) / x_m;
else
tmp = ((1.0 / y) / z_m) * (1.0 / (z_m * x_m));
end
tmp_2 = 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / y), $MachinePrecision] / x$95$m), $MachinePrecision], N[(N[(N[(1.0 / y), $MachinePrecision] / z$95$m), $MachinePrecision] * N[(1.0 / N[(z$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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y}}{z\_m} \cdot \frac{1}{z\_m \cdot x\_m}\\
\end{array}
\end{array}
if z < 1Initial program 94.6%
associate-/l/94.5%
associate-*l*92.1%
*-commutative92.1%
sqr-neg92.1%
+-commutative92.1%
sqr-neg92.1%
fma-define92.1%
Simplified92.1%
add-sqr-sqrt41.5%
pow241.5%
*-commutative41.5%
sqrt-prod41.5%
fma-undefine41.5%
+-commutative41.5%
hypot-1-def41.9%
Applied egg-rr41.9%
unpow241.9%
associate-*l*41.9%
*-commutative41.9%
associate-*l*41.9%
add-sqr-sqrt94.5%
Applied egg-rr94.5%
Taylor expanded in z around 0 72.0%
associate-/l/72.1%
Simplified72.1%
if 1 < z Initial program 81.1%
associate-/l/81.0%
associate-*l*77.9%
*-commutative77.9%
sqr-neg77.9%
+-commutative77.9%
sqr-neg77.9%
fma-define77.9%
Simplified77.9%
add-sqr-sqrt43.0%
pow243.0%
*-commutative43.0%
sqrt-prod43.1%
fma-undefine43.1%
+-commutative43.1%
hypot-1-def46.0%
Applied egg-rr46.0%
Taylor expanded in z around inf 46.0%
unpow246.0%
swap-sqr43.1%
add-sqr-sqrt77.4%
associate-*r*84.8%
Applied egg-rr84.8%
associate-/r*85.1%
*-un-lft-identity85.1%
times-frac96.2%
Applied egg-rr96.2%
Final simplification78.2%
z_m = (fabs.f64 z) x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z_m) :precision binary64 (* x_s (if (<= z_m 1.0) (/ (/ 1.0 y) x_m) (/ 1.0 (* y (* z_m (* z_m x_m)))))))
z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / y) / x_m;
} else {
tmp = 1.0 / (y * (z_m * (z_m * x_m)));
}
return x_s * tmp;
}
z_m = abs(z)
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8) :: tmp
if (z_m <= 1.0d0) then
tmp = (1.0d0 / y) / x_m
else
tmp = 1.0d0 / (y * (z_m * (z_m * x_m)))
end if
code = x_s * tmp
end function
z_m = Math.abs(z);
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z_m;
public static double code(double x_s, double x_m, double y, double z_m) {
double tmp;
if (z_m <= 1.0) {
tmp = (1.0 / y) / x_m;
} else {
tmp = 1.0 / (y * (z_m * (z_m * x_m)));
}
return x_s * tmp;
}
z_m = math.fabs(z) x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z_m] = sort([x_m, y, z_m]) def code(x_s, x_m, y, z_m): tmp = 0 if z_m <= 1.0: tmp = (1.0 / y) / x_m else: tmp = 1.0 / (y * (z_m * (z_m * x_m))) return x_s * tmp
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) tmp = 0.0 if (z_m <= 1.0) tmp = Float64(Float64(1.0 / y) / x_m); else tmp = Float64(1.0 / Float64(y * Float64(z_m * Float64(z_m * x_m)))); end return Float64(x_s * tmp) end
z_m = abs(z);
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z_m = num2cell(sort([x_m, y, z_m])){:}
function tmp_2 = code(x_s, x_m, y, z_m)
tmp = 0.0;
if (z_m <= 1.0)
tmp = (1.0 / y) / x_m;
else
tmp = 1.0 / (y * (z_m * (z_m * x_m)));
end
tmp_2 = 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * If[LessEqual[z$95$m, 1.0], N[(N[(1.0 / y), $MachinePrecision] / x$95$m), $MachinePrecision], N[(1.0 / N[(y * N[(z$95$m * 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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1:\\
\;\;\;\;\frac{\frac{1}{y}}{x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z\_m \cdot \left(z\_m \cdot x\_m\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 94.6%
associate-/l/94.5%
associate-*l*92.1%
*-commutative92.1%
sqr-neg92.1%
+-commutative92.1%
sqr-neg92.1%
fma-define92.1%
Simplified92.1%
add-sqr-sqrt41.5%
pow241.5%
*-commutative41.5%
sqrt-prod41.5%
fma-undefine41.5%
+-commutative41.5%
hypot-1-def41.9%
Applied egg-rr41.9%
unpow241.9%
associate-*l*41.9%
*-commutative41.9%
associate-*l*41.9%
add-sqr-sqrt94.5%
Applied egg-rr94.5%
Taylor expanded in z around 0 72.0%
associate-/l/72.1%
Simplified72.1%
if 1 < z Initial program 81.1%
associate-/l/81.0%
associate-*l*77.9%
*-commutative77.9%
sqr-neg77.9%
+-commutative77.9%
sqr-neg77.9%
fma-define77.9%
Simplified77.9%
add-sqr-sqrt43.0%
pow243.0%
*-commutative43.0%
sqrt-prod43.1%
fma-undefine43.1%
+-commutative43.1%
hypot-1-def46.0%
Applied egg-rr46.0%
Taylor expanded in z around inf 46.0%
unpow246.0%
swap-sqr43.1%
add-sqr-sqrt77.4%
associate-*r*84.8%
Applied egg-rr84.8%
Final simplification75.3%
z_m = (fabs.f64 z) x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z_m) :precision binary64 (* x_s (/ 1.0 (* y x_m))))
z_m = fabs(z);
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z_m);
double code(double x_s, double x_m, double y, double z_m) {
return x_s * (1.0 / (y * x_m));
}
z_m = abs(z)
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z_m)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z_m
code = x_s * (1.0d0 / (y * x_m))
end function
z_m = Math.abs(z);
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z_m;
public static double code(double x_s, double x_m, double y, double z_m) {
return x_s * (1.0 / (y * x_m));
}
z_m = math.fabs(z) x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z_m] = sort([x_m, y, z_m]) def code(x_s, x_m, y, z_m): return x_s * (1.0 / (y * x_m))
z_m = abs(z) x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z_m = sort([x_m, y, z_m]) function code(x_s, x_m, y, z_m) return Float64(x_s * Float64(1.0 / Float64(y * x_m))) end
z_m = abs(z);
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z_m = num2cell(sort([x_m, y, z_m])){:}
function tmp = code(x_s, x_m, y, z_m)
tmp = x_s * (1.0 / (y * 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]
NOTE: x_m, y, and z_m should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z$95$m_] := N[(x$95$s * N[(1.0 / N[(y * x$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)
\\
[x_m, y, z_m] = \mathsf{sort}([x_m, y, z_m])\\
\\
x\_s \cdot \frac{1}{y \cdot x\_m}
\end{array}
Initial program 91.1%
associate-/l/91.1%
associate-*l*88.5%
*-commutative88.5%
sqr-neg88.5%
+-commutative88.5%
sqr-neg88.5%
fma-define88.5%
Simplified88.5%
Taylor expanded in z around 0 59.3%
(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 2024086
(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)))))