
(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}
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (let* ((t_0 (* (hypot 1.0 z) (sqrt y_m)))) (* y_s (* (/ 1.0 t_0) (/ (/ 1.0 x) t_0)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double t_0 = hypot(1.0, z) * sqrt(y_m);
return y_s * ((1.0 / t_0) * ((1.0 / x) / t_0));
}
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = Math.hypot(1.0, z) * Math.sqrt(y_m);
return y_s * ((1.0 / t_0) * ((1.0 / x) / t_0));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): t_0 = math.hypot(1.0, z) * math.sqrt(y_m) return y_s * ((1.0 / t_0) * ((1.0 / x) / t_0))
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) t_0 = Float64(hypot(1.0, z) * sqrt(y_m)) return Float64(y_s * Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / x) / t_0))) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp = code(y_s, x, y_m, z)
t_0 = hypot(1.0, z) * sqrt(y_m);
tmp = y_s * ((1.0 / t_0) * ((1.0 / x) / t_0));
end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(1, z\right) \cdot \sqrt{y\_m}\\
y\_s \cdot \left(\frac{1}{t\_0} \cdot \frac{\frac{1}{x}}{t\_0}\right)
\end{array}
\end{array}
Initial program 92.2%
associate-/l/91.6%
remove-double-neg91.6%
distribute-rgt-neg-out91.6%
distribute-rgt-neg-out91.6%
remove-double-neg91.6%
associate-*l*91.6%
*-commutative91.6%
sqr-neg91.6%
+-commutative91.6%
sqr-neg91.6%
fma-define91.6%
Simplified91.6%
*-commutative91.6%
associate-*r*91.6%
fma-undefine91.6%
+-commutative91.6%
associate-/l/92.2%
add-sqr-sqrt43.1%
*-un-lft-identity43.1%
times-frac43.1%
+-commutative43.1%
fma-undefine43.1%
*-commutative43.1%
sqrt-prod43.1%
fma-undefine43.1%
+-commutative43.1%
hypot-1-def43.1%
+-commutative43.1%
Applied egg-rr47.0%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (/ (* (/ 1.0 (hypot 1.0 z)) (/ 1.0 (* (hypot 1.0 z) x))) y_m)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
return y_s * (((1.0 / hypot(1.0, z)) * (1.0 / (hypot(1.0, z) * x))) / y_m);
}
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (((1.0 / Math.hypot(1.0, z)) * (1.0 / (Math.hypot(1.0, z) * x))) / y_m);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): return y_s * (((1.0 / math.hypot(1.0, z)) * (1.0 / (math.hypot(1.0, z) * x))) / y_m)
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) return Float64(y_s * Float64(Float64(Float64(1.0 / hypot(1.0, z)) * Float64(1.0 / Float64(hypot(1.0, z) * x))) / y_m)) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp = code(y_s, x, y_m, z)
tmp = y_s * (((1.0 / hypot(1.0, z)) * (1.0 / (hypot(1.0, z) * x))) / y_m);
end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(N[(N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \frac{\frac{1}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{1}{\mathsf{hypot}\left(1, z\right) \cdot x}}{y\_m}
\end{array}
Initial program 92.2%
associate-/l/91.6%
remove-double-neg91.6%
distribute-rgt-neg-out91.6%
distribute-rgt-neg-out91.6%
remove-double-neg91.6%
associate-*l*91.6%
*-commutative91.6%
sqr-neg91.6%
+-commutative91.6%
sqr-neg91.6%
fma-define91.6%
Simplified91.6%
*-commutative91.6%
associate-*r*91.6%
fma-undefine91.6%
+-commutative91.6%
associate-/l/92.2%
add-sqr-sqrt43.1%
*-un-lft-identity43.1%
times-frac43.1%
+-commutative43.1%
fma-undefine43.1%
*-commutative43.1%
sqrt-prod43.1%
fma-undefine43.1%
+-commutative43.1%
hypot-1-def43.1%
+-commutative43.1%
Applied egg-rr47.0%
associate-/r*47.0%
associate-/r*45.9%
frac-times43.8%
associate-/l/43.8%
add-sqr-sqrt95.7%
Applied egg-rr95.7%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (* y_m (+ 1.0 (* z z))) 1e+306)
(/ (/ 1.0 x) (fma (* z y_m) z y_m))
(/ (/ 1.0 y_m) (* z (* z x))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((y_m * (1.0 + (z * z))) <= 1e+306) {
tmp = (1.0 / x) / fma((z * y_m), z, y_m);
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(y_m * Float64(1.0 + Float64(z * z))) <= 1e+306) tmp = Float64(Float64(1.0 / x) / fma(Float64(z * y_m), z, y_m)); else tmp = Float64(Float64(1.0 / y_m) / Float64(z * Float64(z * x))); end return Float64(y_s * tmp) end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+306], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(z * y$95$m), $MachinePrecision] * z + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \cdot \left(1 + z \cdot z\right) \leq 10^{+306}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(z \cdot y\_m, z, y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 1.00000000000000002e306Initial program 95.5%
+-commutative95.5%
distribute-lft-in95.6%
associate-*r*97.2%
*-rgt-identity97.2%
fma-define97.2%
Applied egg-rr97.2%
if 1.00000000000000002e306 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 70.1%
associate-/l/70.1%
remove-double-neg70.1%
distribute-rgt-neg-out70.1%
distribute-rgt-neg-out70.1%
remove-double-neg70.1%
associate-*l*78.5%
*-commutative78.5%
sqr-neg78.5%
+-commutative78.5%
sqr-neg78.5%
fma-define78.5%
Simplified78.5%
Taylor expanded in z around inf 70.1%
associate-/r*70.1%
associate-/r*78.2%
Simplified78.2%
div-inv78.2%
pow278.2%
times-frac96.9%
Applied egg-rr96.9%
associate-/l/95.1%
frac-times89.6%
*-un-lft-identity89.6%
Applied egg-rr89.6%
Final simplification96.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (* z z) 5e+162)
(/ (/ (/ 1.0 x) (fma z z 1.0)) y_m)
(/ (/ 1.0 y_m) (* z (* z x))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z * z) <= 5e+162) {
tmp = ((1.0 / x) / fma(z, z, 1.0)) / y_m;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(z * z) <= 5e+162) tmp = Float64(Float64(Float64(1.0 / x) / fma(z, z, 1.0)) / y_m); else tmp = Float64(Float64(1.0 / y_m) / Float64(z * Float64(z * x))); end return Float64(y_s * tmp) end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 5e+162], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+162}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{\mathsf{fma}\left(z, z, 1\right)}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.9999999999999997e162Initial program 99.1%
associate-/l/98.3%
remove-double-neg98.3%
distribute-rgt-neg-out98.3%
distribute-rgt-neg-out98.3%
remove-double-neg98.3%
associate-*l*98.8%
*-commutative98.8%
sqr-neg98.8%
+-commutative98.8%
sqr-neg98.8%
fma-define98.8%
Simplified98.8%
*-commutative98.8%
associate-*r*98.3%
fma-undefine98.3%
+-commutative98.3%
associate-/l/99.1%
add-sqr-sqrt46.6%
*-un-lft-identity46.6%
times-frac46.6%
+-commutative46.6%
fma-undefine46.6%
*-commutative46.6%
sqrt-prod46.6%
fma-undefine46.6%
+-commutative46.6%
hypot-1-def46.6%
+-commutative46.6%
Applied egg-rr47.1%
*-commutative47.1%
div-inv47.1%
associate-/r*46.6%
swap-sqr46.6%
add-sqr-sqrt99.1%
hypot-1-def99.1%
hypot-1-def99.1%
add-sqr-sqrt99.1%
associate-/r*99.6%
+-commutative99.6%
fma-define99.6%
Applied egg-rr99.6%
if 4.9999999999999997e162 < (*.f64 z z) Initial program 77.3%
associate-/l/77.1%
remove-double-neg77.1%
distribute-rgt-neg-out77.1%
distribute-rgt-neg-out77.1%
remove-double-neg77.1%
associate-*l*76.0%
*-commutative76.0%
sqr-neg76.0%
+-commutative76.0%
sqr-neg76.0%
fma-define76.0%
Simplified76.0%
Taylor expanded in z around inf 77.1%
associate-/r*77.3%
associate-/r*80.1%
Simplified80.1%
div-inv80.1%
pow280.1%
times-frac94.2%
Applied egg-rr94.2%
associate-/l/92.4%
frac-times87.4%
*-un-lft-identity87.4%
Applied egg-rr87.4%
Final simplification95.7%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (* z z) 2e+153)
(/ (/ 1.0 (* x (fma z z 1.0))) y_m)
(/ (/ 1.0 y_m) (* z (* z x))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z * z) <= 2e+153) {
tmp = (1.0 / (x * fma(z, z, 1.0))) / y_m;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(z * z) <= 2e+153) tmp = Float64(Float64(1.0 / Float64(x * fma(z, z, 1.0))) / y_m); else tmp = Float64(Float64(1.0 / y_m) / Float64(z * Float64(z * x))); end return Float64(y_s * tmp) end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 2e+153], N[(N[(1.0 / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+153}:\\
\;\;\;\;\frac{\frac{1}{x \cdot \mathsf{fma}\left(z, z, 1\right)}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2e153Initial program 99.1%
associate-/l/98.3%
remove-double-neg98.3%
distribute-rgt-neg-out98.3%
distribute-rgt-neg-out98.3%
remove-double-neg98.3%
associate-*l*98.8%
*-commutative98.8%
sqr-neg98.8%
+-commutative98.8%
sqr-neg98.8%
fma-define98.8%
Simplified98.8%
*-commutative98.8%
associate-*r*98.3%
fma-undefine98.3%
+-commutative98.3%
associate-/l/99.1%
add-sqr-sqrt46.5%
*-un-lft-identity46.5%
times-frac46.6%
+-commutative46.6%
fma-undefine46.6%
*-commutative46.6%
sqrt-prod46.6%
fma-undefine46.6%
+-commutative46.6%
hypot-1-def46.6%
+-commutative46.6%
Applied egg-rr47.1%
associate-/r*47.1%
associate-/r*47.1%
frac-times47.1%
associate-/l/47.1%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
associate-/r*99.5%
associate-*r/99.6%
frac-times99.6%
metadata-eval99.6%
hypot-undefine99.6%
hypot-undefine99.6%
rem-square-sqrt99.6%
metadata-eval99.6%
+-commutative99.6%
fma-undefine99.6%
associate-/r*99.6%
*-commutative99.6%
Applied egg-rr99.6%
if 2e153 < (*.f64 z z) Initial program 77.8%
associate-/l/77.6%
remove-double-neg77.6%
distribute-rgt-neg-out77.6%
distribute-rgt-neg-out77.6%
remove-double-neg77.6%
associate-*l*76.5%
*-commutative76.5%
sqr-neg76.5%
+-commutative76.5%
sqr-neg76.5%
fma-define76.5%
Simplified76.5%
Taylor expanded in z around inf 77.6%
associate-/r*77.8%
associate-/r*80.6%
Simplified80.6%
div-inv80.5%
pow280.5%
times-frac94.3%
Applied egg-rr94.3%
associate-/l/92.6%
frac-times87.7%
*-un-lft-identity87.7%
Applied egg-rr87.7%
Final simplification95.7%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* y_m (+ 1.0 (* z z)))))
(*
y_s
(if (<= t_0 1e+306) (/ (/ 1.0 x) t_0) (/ (/ 1.0 y_m) (* z (* z x)))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+306) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
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 <= 1d+306) then
tmp = (1.0d0 / x) / t_0
else
tmp = (1.0d0 / y_m) / (z * (z * x))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+306) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): t_0 = y_m * (1.0 + (z * z)) tmp = 0 if t_0 <= 1e+306: tmp = (1.0 / x) / t_0 else: tmp = (1.0 / y_m) / (z * (z * x)) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) t_0 = Float64(y_m * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 1e+306) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(1.0 / y_m) / Float64(z * Float64(z * x))); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
t_0 = y_m * (1.0 + (z * z));
tmp = 0.0;
if (t_0 <= 1e+306)
tmp = (1.0 / x) / t_0;
else
tmp = (1.0 / y_m) / (z * (z * x));
end
tmp_2 = y_s * tmp;
end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, 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 * If[LessEqual[t$95$0, 1e+306], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(1 + z \cdot z\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 10^{+306}:\\
\;\;\;\;\frac{\frac{1}{x}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 1.00000000000000002e306Initial program 95.5%
if 1.00000000000000002e306 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 70.1%
associate-/l/70.1%
remove-double-neg70.1%
distribute-rgt-neg-out70.1%
distribute-rgt-neg-out70.1%
remove-double-neg70.1%
associate-*l*78.5%
*-commutative78.5%
sqr-neg78.5%
+-commutative78.5%
sqr-neg78.5%
fma-define78.5%
Simplified78.5%
Taylor expanded in z around inf 70.1%
associate-/r*70.1%
associate-/r*78.2%
Simplified78.2%
div-inv78.2%
pow278.2%
times-frac96.9%
Applied egg-rr96.9%
associate-/l/95.1%
frac-times89.6%
*-un-lft-identity89.6%
Applied egg-rr89.6%
Final simplification94.8%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= (* z z) 2e-15) (/ (/ 1.0 x) y_m) (/ (/ 1.0 y_m) (* z (* z x))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z * z) <= 2e-15) {
tmp = (1.0 / x) / y_m;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 2d-15) then
tmp = (1.0d0 / x) / y_m
else
tmp = (1.0d0 / y_m) / (z * (z * x))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z * z) <= 2e-15) {
tmp = (1.0 / x) / y_m;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if (z * z) <= 2e-15: tmp = (1.0 / x) / y_m else: tmp = (1.0 / y_m) / (z * (z * x)) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(z * z) <= 2e-15) tmp = Float64(Float64(1.0 / x) / y_m); else tmp = Float64(Float64(1.0 / y_m) / Float64(z * Float64(z * x))); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if ((z * z) <= 2e-15)
tmp = (1.0 / x) / y_m;
else
tmp = (1.0 / y_m) / (z * (z * x));
end
tmp_2 = y_s * tmp;
end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 2e-15], N[(N[(1.0 / x), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{-15}:\\
\;\;\;\;\frac{\frac{1}{x}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 2.0000000000000002e-15Initial program 99.6%
associate-/l/99.2%
remove-double-neg99.2%
distribute-rgt-neg-out99.2%
distribute-rgt-neg-out99.2%
remove-double-neg99.2%
associate-*l*99.2%
*-commutative99.2%
sqr-neg99.2%
+-commutative99.2%
sqr-neg99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in z around 0 99.2%
associate-/r*99.6%
Simplified99.6%
if 2.0000000000000002e-15 < (*.f64 z z) Initial program 83.7%
associate-/l/83.0%
remove-double-neg83.0%
distribute-rgt-neg-out83.0%
distribute-rgt-neg-out83.0%
remove-double-neg83.0%
associate-*l*83.0%
*-commutative83.0%
sqr-neg83.0%
+-commutative83.0%
sqr-neg83.0%
fma-define83.0%
Simplified83.0%
Taylor expanded in z around inf 81.4%
associate-/r*82.0%
associate-/r*83.2%
Simplified83.2%
div-inv83.2%
pow283.2%
times-frac94.2%
Applied egg-rr94.2%
associate-/l/93.0%
frac-times89.6%
*-un-lft-identity89.6%
Applied egg-rr89.6%
Final simplification94.9%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 1.0) (/ (/ 1.0 x) y_m) (/ 1.0 (* (* z x) (* z y_m))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y_m;
} else {
tmp = 1.0 / ((z * x) * (z * y_m));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1.0d0) then
tmp = (1.0d0 / x) / y_m
else
tmp = 1.0d0 / ((z * x) * (z * y_m))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / x) / y_m;
} else {
tmp = 1.0 / ((z * x) * (z * y_m));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): tmp = 0 if z <= 1.0: tmp = (1.0 / x) / y_m else: tmp = 1.0 / ((z * x) * (z * y_m)) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 1.0) tmp = Float64(Float64(1.0 / x) / y_m); else tmp = Float64(1.0 / Float64(Float64(z * x) * Float64(z * y_m))); end return Float64(y_s * tmp) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp_2 = code(y_s, x, y_m, z)
tmp = 0.0;
if (z <= 1.0)
tmp = (1.0 / x) / y_m;
else
tmp = 1.0 / ((z * x) * (z * y_m));
end
tmp_2 = y_s * tmp;
end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 1.0], N[(N[(1.0 / x), $MachinePrecision] / y$95$m), $MachinePrecision], N[(1.0 / N[(N[(z * x), $MachinePrecision] * N[(z * y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{\frac{1}{x}}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(z \cdot x\right) \cdot \left(z \cdot y\_m\right)}\\
\end{array}
\end{array}
if z < 1Initial program 95.9%
associate-/l/95.1%
remove-double-neg95.1%
distribute-rgt-neg-out95.1%
distribute-rgt-neg-out95.1%
remove-double-neg95.1%
associate-*l*94.7%
*-commutative94.7%
sqr-neg94.7%
+-commutative94.7%
sqr-neg94.7%
fma-define94.7%
Simplified94.7%
Taylor expanded in z around 0 78.0%
associate-/r*77.9%
Simplified77.9%
if 1 < z Initial program 82.1%
associate-/l/82.0%
remove-double-neg82.0%
distribute-rgt-neg-out82.0%
distribute-rgt-neg-out82.0%
remove-double-neg82.0%
associate-*l*83.2%
*-commutative83.2%
sqr-neg83.2%
+-commutative83.2%
sqr-neg83.2%
fma-define83.2%
Simplified83.2%
Taylor expanded in z around inf 79.9%
associate-/r*80.0%
associate-/r*83.4%
Simplified83.4%
div-inv83.4%
pow283.4%
times-frac94.3%
Applied egg-rr94.3%
*-commutative94.3%
associate-/l/94.2%
associate-/l/92.2%
frac-times92.2%
metadata-eval92.2%
Applied egg-rr92.2%
Final simplification81.8%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) NOTE: x, y_m, and z should be sorted in increasing order before calling this function. (FPCore (y_s x y_m z) :precision binary64 (* y_s (/ 1.0 (* y_m x))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
assert(x < y_m && y_m < z);
double code(double y_s, double x, double y_m, double z) {
return y_s * (1.0 / (y_m * x));
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
NOTE: x, y_m, and z should be sorted in increasing order before calling this function.
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (1.0d0 / (y_m * x))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
assert x < y_m && y_m < z;
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (1.0 / (y_m * x));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) [x, y_m, z] = sort([x, y_m, z]) def code(y_s, x, y_m, z): return y_s * (1.0 / (y_m * x))
y\_m = abs(y) y\_s = copysign(1.0, y) x, y_m, z = sort([x, y_m, z]) function code(y_s, x, y_m, z) return Float64(y_s * Float64(1.0 / Float64(y_m * x))) end
y\_m = abs(y);
y\_s = sign(y) * abs(1.0);
x, y_m, z = num2cell(sort([x, y_m, z])){:}
function tmp = code(y_s, x, y_m, z)
tmp = y_s * (1.0 / (y_m * x));
end
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, y_m, and z should be sorted in increasing order before calling this function.
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(1.0 / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
[x, y_m, z] = \mathsf{sort}([x, y_m, z])\\
\\
y\_s \cdot \frac{1}{y\_m \cdot x}
\end{array}
Initial program 92.2%
associate-/l/91.6%
remove-double-neg91.6%
distribute-rgt-neg-out91.6%
distribute-rgt-neg-out91.6%
remove-double-neg91.6%
associate-*l*91.6%
*-commutative91.6%
sqr-neg91.6%
+-commutative91.6%
sqr-neg91.6%
fma-define91.6%
Simplified91.6%
Taylor expanded in z around 0 62.0%
(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 2024180
(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)))))