
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* y (+ 1.0 (* z z))) 1e+259)
(/ (/ 1.0 x_m) (fma (* y z) z y))
(/ (/ (pow y -0.5) (* x_m (* (hypot 1.0 z) (sqrt y)))) (hypot 1.0 z)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 1e+259) {
tmp = (1.0 / x_m) / fma((y * z), z, y);
} else {
tmp = (pow(y, -0.5) / (x_m * (hypot(1.0, z) * sqrt(y)))) / hypot(1.0, z);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 1e+259) tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64((y ^ -0.5) / Float64(x_m * Float64(hypot(1.0, z) * sqrt(y)))) / hypot(1.0, z)); end return 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+259], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[y, -0.5], $MachinePrecision] / N[(x$95$m * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 10^{+259}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{y}^{-0.5}}{x\_m \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}\right)}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 9.999999999999999e258Initial program 94.7%
+-commutative94.7%
distribute-lft-in94.7%
associate-*r*96.1%
*-rgt-identity96.1%
fma-define96.1%
Applied egg-rr96.1%
if 9.999999999999999e258 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 66.2%
associate-/l/66.3%
remove-double-neg66.3%
distribute-rgt-neg-out66.3%
distribute-rgt-neg-out66.3%
remove-double-neg66.3%
associate-*l*75.1%
*-commutative75.1%
sqr-neg75.1%
+-commutative75.1%
sqr-neg75.1%
fma-define75.1%
Simplified75.1%
associate-*r*74.5%
*-commutative74.5%
associate-/r*74.4%
*-commutative74.4%
associate-/l/74.4%
fma-undefine74.4%
+-commutative74.4%
associate-/r*66.2%
add-sqr-sqrt34.1%
associate-/l*34.1%
inv-pow34.1%
sqrt-pow134.2%
metadata-eval34.2%
inv-pow34.2%
sqrt-pow134.2%
metadata-eval34.2%
+-commutative34.2%
fma-undefine34.2%
*-commutative34.2%
Applied egg-rr34.2%
div-inv34.2%
associate-*r*34.2%
pow-prod-up66.2%
metadata-eval66.2%
inv-pow66.2%
*-commutative66.2%
associate-/r*66.2%
add-sqr-sqrt66.2%
associate-/r*66.2%
un-div-inv66.2%
fma-undefine66.2%
+-commutative66.2%
metadata-eval66.2%
rem-square-sqrt66.2%
hypot-undefine66.2%
hypot-undefine66.2%
frac-times75.3%
associate-/l/75.3%
un-div-inv75.3%
Applied egg-rr99.7%
Final simplification96.7%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (/ (/ (pow y -0.5) (* x_m (hypot 1.0 z))) (* (hypot 1.0 z) (sqrt y)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
return x_s * ((pow(y, -0.5) / (x_m * hypot(1.0, z))) / (hypot(1.0, z) * sqrt(y)));
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
return x_s * ((Math.pow(y, -0.5) / (x_m * Math.hypot(1.0, z))) / (Math.hypot(1.0, z) * Math.sqrt(y)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): return x_s * ((math.pow(y, -0.5) / (x_m * math.hypot(1.0, z))) / (math.hypot(1.0, z) * math.sqrt(y)))
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) return Float64(x_s * Float64(Float64((y ^ -0.5) / Float64(x_m * hypot(1.0, z))) / Float64(hypot(1.0, z) * sqrt(y)))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp = code(x_s, x_m, y, z)
tmp = x_s * (((y ^ -0.5) / (x_m * hypot(1.0, z))) / (hypot(1.0, z) * sqrt(y)));
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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(N[(N[Power[y, -0.5], $MachinePrecision] / N[(x$95$m * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \frac{\frac{{y}^{-0.5}}{x\_m \cdot \mathsf{hypot}\left(1, z\right)}}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y}}
\end{array}
Initial program 90.1%
associate-/l/90.0%
remove-double-neg90.0%
distribute-rgt-neg-out90.0%
distribute-rgt-neg-out90.0%
remove-double-neg90.0%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
associate-*r*90.4%
*-commutative90.4%
associate-/r*90.2%
*-commutative90.2%
associate-/l/90.3%
fma-undefine90.3%
+-commutative90.3%
associate-/r*90.1%
add-sqr-sqrt39.8%
associate-/l*39.9%
inv-pow39.9%
sqrt-pow139.9%
metadata-eval39.9%
inv-pow39.9%
sqrt-pow139.9%
metadata-eval39.9%
+-commutative39.9%
fma-undefine39.9%
*-commutative39.9%
Applied egg-rr39.9%
div-inv39.8%
associate-*r*39.8%
pow-prod-up89.9%
metadata-eval89.9%
inv-pow89.9%
*-commutative89.9%
associate-/r*90.6%
add-sqr-sqrt48.8%
associate-/r*48.8%
un-div-inv48.8%
fma-undefine48.8%
+-commutative48.8%
metadata-eval48.8%
rem-square-sqrt48.8%
hypot-undefine48.8%
hypot-undefine48.8%
frac-times50.3%
associate-/l/50.3%
un-div-inv50.4%
Applied egg-rr54.4%
Final simplification54.4%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* y (+ 1.0 (* z z))) 5e+301)
(/ (/ 1.0 x_m) (fma (* y z) z y))
(/ (/ (pow y -0.5) (* x_m (hypot 1.0 z))) (* z (sqrt y))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+301) {
tmp = (1.0 / x_m) / fma((y * z), z, y);
} else {
tmp = (pow(y, -0.5) / (x_m * hypot(1.0, z))) / (z * sqrt(y));
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+301) tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64((y ^ -0.5) / Float64(x_m * hypot(1.0, z))) / Float64(z * sqrt(y))); end return 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+301], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[y, -0.5], $MachinePrecision] / N[(x$95$m * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{y}^{-0.5}}{x\_m \cdot \mathsf{hypot}\left(1, z\right)}}{z \cdot \sqrt{y}}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 5.0000000000000004e301Initial program 94.8%
+-commutative94.8%
distribute-lft-in94.8%
associate-*r*96.1%
*-rgt-identity96.1%
fma-define96.1%
Applied egg-rr96.1%
if 5.0000000000000004e301 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 64.6%
associate-/l/64.6%
remove-double-neg64.6%
distribute-rgt-neg-out64.6%
distribute-rgt-neg-out64.6%
remove-double-neg64.6%
associate-*l*73.9%
*-commutative73.9%
sqr-neg73.9%
+-commutative73.9%
sqr-neg73.9%
fma-define73.9%
Simplified73.9%
associate-*r*73.3%
*-commutative73.3%
associate-/r*73.1%
*-commutative73.1%
associate-/l/73.1%
fma-undefine73.1%
+-commutative73.1%
associate-/r*64.6%
add-sqr-sqrt30.9%
associate-/l*30.9%
inv-pow30.9%
sqrt-pow130.9%
metadata-eval30.9%
inv-pow30.9%
sqrt-pow130.9%
metadata-eval30.9%
+-commutative30.9%
fma-undefine30.9%
*-commutative30.9%
Applied egg-rr30.9%
div-inv30.9%
associate-*r*30.9%
pow-prod-up64.6%
metadata-eval64.6%
inv-pow64.6%
*-commutative64.6%
associate-/r*64.6%
add-sqr-sqrt64.6%
associate-/r*64.6%
un-div-inv64.6%
fma-undefine64.6%
+-commutative64.6%
metadata-eval64.6%
rem-square-sqrt64.6%
hypot-undefine64.6%
hypot-undefine64.6%
frac-times74.1%
associate-/l/74.1%
un-div-inv74.1%
Applied egg-rr99.6%
Taylor expanded in z around inf 82.9%
Final simplification94.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(let* ((t_0 (/ (pow x_m -0.5) z)))
(*
x_s
(if (<= (* y (+ 1.0 (* z z))) 5e+301)
(/ (/ 1.0 x_m) (fma (* y z) z y))
(* t_0 (/ t_0 y))))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double t_0 = pow(x_m, -0.5) / z;
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+301) {
tmp = (1.0 / x_m) / fma((y * z), z, y);
} else {
tmp = t_0 * (t_0 / y);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) t_0 = Float64((x_m ^ -0.5) / z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+301) tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y * z), z, y)); else tmp = Float64(t_0 * Float64(t_0 / y)); end return 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := Block[{t$95$0 = N[(N[Power[x$95$m, -0.5], $MachinePrecision] / z), $MachinePrecision]}, N[(x$95$s * If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+301], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$0 / y), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
\begin{array}{l}
t_0 := \frac{{x\_m}^{-0.5}}{z}\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{t\_0}{y}\\
\end{array}
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 5.0000000000000004e301Initial program 94.8%
+-commutative94.8%
distribute-lft-in94.8%
associate-*r*96.1%
*-rgt-identity96.1%
fma-define96.1%
Applied egg-rr96.1%
if 5.0000000000000004e301 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 64.6%
associate-/l/64.6%
remove-double-neg64.6%
distribute-rgt-neg-out64.6%
distribute-rgt-neg-out64.6%
remove-double-neg64.6%
associate-*l*73.9%
*-commutative73.9%
sqr-neg73.9%
+-commutative73.9%
sqr-neg73.9%
fma-define73.9%
Simplified73.9%
associate-*r*73.3%
*-commutative73.3%
associate-/r*73.1%
*-commutative73.1%
associate-/l/73.1%
fma-undefine73.1%
+-commutative73.1%
associate-/r*64.6%
add-sqr-sqrt30.9%
associate-/l*30.9%
inv-pow30.9%
sqrt-pow130.9%
metadata-eval30.9%
inv-pow30.9%
sqrt-pow130.9%
metadata-eval30.9%
+-commutative30.9%
fma-undefine30.9%
*-commutative30.9%
Applied egg-rr30.9%
div-inv30.9%
associate-*r*30.9%
pow-prod-up64.6%
metadata-eval64.6%
inv-pow64.6%
*-commutative64.6%
associate-/r*64.6%
add-sqr-sqrt64.6%
associate-/r*64.6%
un-div-inv64.6%
fma-undefine64.6%
+-commutative64.6%
metadata-eval64.6%
rem-square-sqrt64.6%
hypot-undefine64.6%
hypot-undefine64.6%
frac-times74.1%
associate-/l/74.1%
un-div-inv74.1%
Applied egg-rr99.6%
Taylor expanded in z around inf 64.6%
associate-/r*64.6%
*-commutative64.6%
associate-/r*73.8%
Simplified73.8%
add-sqr-sqrt68.9%
associate-/l*68.8%
sqrt-div35.6%
inv-pow35.6%
sqrt-pow135.6%
metadata-eval35.6%
sqrt-pow133.2%
metadata-eval33.2%
pow133.2%
sqrt-div33.2%
inv-pow33.2%
sqrt-pow133.2%
metadata-eval33.2%
sqrt-pow147.2%
metadata-eval47.2%
pow147.2%
Applied egg-rr47.2%
Final simplification88.5%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (* (/ 1.0 (* x_m (hypot 1.0 z))) (/ (/ 1.0 y) (hypot 1.0 z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
return x_s * ((1.0 / (x_m * hypot(1.0, z))) * ((1.0 / y) / hypot(1.0, z)));
}
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
return x_s * ((1.0 / (x_m * Math.hypot(1.0, z))) * ((1.0 / y) / Math.hypot(1.0, z)));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): return x_s * ((1.0 / (x_m * math.hypot(1.0, z))) * ((1.0 / y) / math.hypot(1.0, z)))
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) return Float64(x_s * Float64(Float64(1.0 / Float64(x_m * hypot(1.0, z))) * Float64(Float64(1.0 / y) / hypot(1.0, z)))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp = code(x_s, x_m, y, z)
tmp = x_s * ((1.0 / (x_m * hypot(1.0, z))) * ((1.0 / y) / hypot(1.0, z)));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(N[(1.0 / N[(x$95$m * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / y), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \left(\frac{1}{x\_m \cdot \mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{y}}{\mathsf{hypot}\left(1, z\right)}\right)
\end{array}
Initial program 90.1%
associate-/l/90.0%
remove-double-neg90.0%
distribute-rgt-neg-out90.0%
distribute-rgt-neg-out90.0%
remove-double-neg90.0%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
Taylor expanded in y around 0 90.0%
associate-*r*90.4%
+-commutative90.4%
unpow290.4%
fma-undefine90.4%
associate-/r*90.2%
Simplified90.2%
associate-/r*90.3%
div-inv90.2%
add-sqr-sqrt90.2%
times-frac91.8%
fma-undefine91.8%
+-commutative91.8%
hypot-1-def91.8%
associate-/r*91.8%
fma-undefine91.8%
+-commutative91.8%
hypot-1-def98.1%
Applied egg-rr98.1%
Final simplification98.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* y (+ 1.0 (* z z))) 5e+301)
(/ (/ 1.0 x_m) (fma (* y z) z y))
(/ (* (/ 1.0 z) (/ (/ 1.0 x_m) z)) y))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((y * (1.0 + (z * z))) <= 5e+301) {
tmp = (1.0 / x_m) / fma((y * z), z, y);
} else {
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(y * Float64(1.0 + Float64(z * z))) <= 5e+301) tmp = Float64(Float64(1.0 / x_m) / fma(Float64(y * z), z, y)); else tmp = Float64(Float64(Float64(1.0 / z) * Float64(Float64(1.0 / x_m) / z)) / y); end return 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+301], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / z), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \leq 5 \cdot 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{\mathsf{fma}\left(y \cdot z, z, y\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z} \cdot \frac{\frac{1}{x\_m}}{z}}{y}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 5.0000000000000004e301Initial program 94.8%
+-commutative94.8%
distribute-lft-in94.8%
associate-*r*96.1%
*-rgt-identity96.1%
fma-define96.1%
Applied egg-rr96.1%
if 5.0000000000000004e301 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 64.6%
associate-/l/64.6%
remove-double-neg64.6%
distribute-rgt-neg-out64.6%
distribute-rgt-neg-out64.6%
remove-double-neg64.6%
associate-*l*73.9%
*-commutative73.9%
sqr-neg73.9%
+-commutative73.9%
sqr-neg73.9%
fma-define73.9%
Simplified73.9%
associate-*r*73.3%
*-commutative73.3%
associate-/r*73.1%
*-commutative73.1%
associate-/l/73.1%
fma-undefine73.1%
+-commutative73.1%
associate-/r*64.6%
add-sqr-sqrt30.9%
associate-/l*30.9%
inv-pow30.9%
sqrt-pow130.9%
metadata-eval30.9%
inv-pow30.9%
sqrt-pow130.9%
metadata-eval30.9%
+-commutative30.9%
fma-undefine30.9%
*-commutative30.9%
Applied egg-rr30.9%
div-inv30.9%
associate-*r*30.9%
pow-prod-up64.6%
metadata-eval64.6%
inv-pow64.6%
*-commutative64.6%
associate-/r*64.6%
add-sqr-sqrt64.6%
associate-/r*64.6%
un-div-inv64.6%
fma-undefine64.6%
+-commutative64.6%
metadata-eval64.6%
rem-square-sqrt64.6%
hypot-undefine64.6%
hypot-undefine64.6%
frac-times74.1%
associate-/l/74.1%
un-div-inv74.1%
Applied egg-rr99.6%
Taylor expanded in z around inf 64.6%
associate-/r*64.6%
*-commutative64.6%
associate-/r*73.8%
Simplified73.8%
*-un-lft-identity73.8%
unpow273.8%
times-frac89.6%
Applied egg-rr89.6%
Final simplification95.1%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* z z) 1e+300)
(/ 1.0 (* y (* x_m (fma z z 1.0))))
(/ (/ 1.0 (* x_m (* y z))) (hypot 1.0 z)))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * z) <= 1e+300) {
tmp = 1.0 / (y * (x_m * fma(z, z, 1.0)));
} else {
tmp = (1.0 / (x_m * (y * z))) / hypot(1.0, z);
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+300) tmp = Float64(1.0 / Float64(y * Float64(x_m * fma(z, z, 1.0)))); else tmp = Float64(Float64(1.0 / Float64(x_m * Float64(y * z))) / hypot(1.0, z)); end return 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 1e+300], N[(1.0 / N[(y * N[(x$95$m * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(x$95$m * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+300}:\\
\;\;\;\;\frac{1}{y \cdot \left(x\_m \cdot \mathsf{fma}\left(z, z, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x\_m \cdot \left(y \cdot z\right)}}{\mathsf{hypot}\left(1, z\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.0000000000000001e300Initial program 95.8%
associate-/l/95.7%
remove-double-neg95.7%
distribute-rgt-neg-out95.7%
distribute-rgt-neg-out95.7%
remove-double-neg95.7%
associate-*l*97.2%
*-commutative97.2%
sqr-neg97.2%
+-commutative97.2%
sqr-neg97.2%
fma-define97.2%
Simplified97.2%
if 1.0000000000000001e300 < (*.f64 z z) Initial program 71.3%
associate-/l/71.3%
remove-double-neg71.3%
distribute-rgt-neg-out71.3%
distribute-rgt-neg-out71.3%
remove-double-neg71.3%
associate-*l*72.9%
*-commutative72.9%
sqr-neg72.9%
+-commutative72.9%
sqr-neg72.9%
fma-define72.9%
Simplified72.9%
associate-*r*72.3%
*-commutative72.3%
associate-/r*72.3%
*-commutative72.3%
associate-/l/72.3%
fma-undefine72.3%
+-commutative72.3%
associate-/r*71.3%
add-sqr-sqrt30.8%
associate-/l*30.8%
inv-pow30.8%
sqrt-pow130.8%
metadata-eval30.8%
inv-pow30.8%
sqrt-pow130.8%
metadata-eval30.8%
+-commutative30.8%
fma-undefine30.8%
*-commutative30.8%
Applied egg-rr30.8%
div-inv30.8%
associate-*r*30.8%
pow-prod-up71.3%
metadata-eval71.3%
inv-pow71.3%
*-commutative71.3%
associate-/r*72.7%
add-sqr-sqrt35.9%
associate-/r*35.9%
un-div-inv35.9%
fma-undefine35.9%
+-commutative35.9%
metadata-eval35.9%
rem-square-sqrt35.9%
hypot-undefine35.9%
hypot-undefine35.9%
frac-times42.3%
associate-/l/42.3%
un-div-inv42.3%
Applied egg-rr53.1%
Taylor expanded in z around inf 80.4%
Final simplification93.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* z z) 4e+34)
(/ (/ 1.0 (* y (fma z z 1.0))) x_m)
(/ (* (/ 1.0 z) (/ (/ 1.0 x_m) z)) y))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * z) <= 4e+34) {
tmp = (1.0 / (y * fma(z, z, 1.0))) / x_m;
} else {
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
}
return x_s * tmp;
}
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+34) tmp = Float64(Float64(1.0 / Float64(y * fma(z, z, 1.0))) / x_m); else tmp = Float64(Float64(Float64(1.0 / z) * Float64(Float64(1.0 / x_m) / z)) / y); end return 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 4e+34], N[(N[(1.0 / N[(y * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision], N[(N[(N[(1.0 / z), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+34}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \mathsf{fma}\left(z, z, 1\right)}}{x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z} \cdot \frac{\frac{1}{x\_m}}{z}}{y}\\
\end{array}
\end{array}
if (*.f64 z z) < 3.99999999999999978e34Initial 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%
associate-*r*99.4%
*-commutative99.4%
associate-/r*99.5%
*-commutative99.5%
associate-/l/99.7%
fma-undefine99.7%
+-commutative99.7%
associate-/r*99.7%
add-sqr-sqrt42.9%
associate-/l*42.9%
inv-pow42.9%
sqrt-pow143.0%
metadata-eval43.0%
inv-pow43.0%
sqrt-pow142.9%
metadata-eval42.9%
+-commutative42.9%
fma-undefine42.9%
*-commutative42.9%
Applied egg-rr42.9%
associate-*r/42.9%
*-commutative42.9%
pow-prod-up99.7%
metadata-eval99.7%
inv-pow99.7%
fma-undefine99.7%
distribute-lft-in99.7%
associate-*l*99.7%
*-commutative99.7%
*-un-lft-identity99.7%
fma-undefine99.7%
associate-/l/99.5%
associate-/r*99.7%
fma-undefine99.7%
associate-*l*99.7%
*-un-lft-identity99.7%
*-commutative99.7%
distribute-lft-in99.7%
fma-undefine99.7%
Applied egg-rr99.7%
if 3.99999999999999978e34 < (*.f64 z z) Initial program 79.8%
associate-/l/79.8%
remove-double-neg79.8%
distribute-rgt-neg-out79.8%
distribute-rgt-neg-out79.8%
remove-double-neg79.8%
associate-*l*83.0%
*-commutative83.0%
sqr-neg83.0%
+-commutative83.0%
sqr-neg83.0%
fma-define83.0%
Simplified83.0%
associate-*r*80.8%
*-commutative80.8%
associate-/r*80.3%
*-commutative80.3%
associate-/l/80.3%
fma-undefine80.3%
+-commutative80.3%
associate-/r*79.8%
add-sqr-sqrt36.5%
associate-/l*36.6%
inv-pow36.6%
sqrt-pow136.6%
metadata-eval36.6%
inv-pow36.6%
sqrt-pow136.6%
metadata-eval36.6%
+-commutative36.6%
fma-undefine36.6%
*-commutative36.6%
Applied egg-rr36.6%
div-inv36.5%
associate-*r*36.5%
pow-prod-up79.7%
metadata-eval79.7%
inv-pow79.7%
*-commutative79.7%
associate-/r*81.0%
add-sqr-sqrt38.4%
associate-/r*38.4%
un-div-inv38.4%
fma-undefine38.4%
+-commutative38.4%
metadata-eval38.4%
rem-square-sqrt38.4%
hypot-undefine38.4%
hypot-undefine38.4%
frac-times41.5%
associate-/l/41.5%
un-div-inv41.5%
Applied egg-rr49.7%
Taylor expanded in z around inf 79.8%
associate-/r*79.8%
*-commutative79.8%
associate-/r*83.2%
Simplified83.2%
*-un-lft-identity83.2%
unpow283.2%
times-frac90.4%
Applied egg-rr90.4%
Final simplification95.2%
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 #s(literal 1 binary64) x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
(FPCore (x_s x_m y z)
:precision binary64
(*
x_s
(if (<= (* z z) 4e+34)
(/ (/ 1.0 x_m) (* y (+ 1.0 (* z z))))
(/ (* (/ 1.0 z) (/ (/ 1.0 x_m) z)) y))))x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * z) <= 4e+34) {
tmp = (1.0 / x_m) / (y * (1.0 + (z * z)));
} else {
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z * z) <= 4d+34) then
tmp = (1.0d0 / x_m) / (y * (1.0d0 + (z * z)))
else
tmp = ((1.0d0 / z) * ((1.0d0 / x_m) / z)) / y
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if ((z * z) <= 4e+34) {
tmp = (1.0 / x_m) / (y * (1.0 + (z * z)));
} else {
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if (z * z) <= 4e+34: tmp = (1.0 / x_m) / (y * (1.0 + (z * z))) else: tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (Float64(z * z) <= 4e+34) tmp = Float64(Float64(1.0 / x_m) / Float64(y * Float64(1.0 + Float64(z * z)))); else tmp = Float64(Float64(Float64(1.0 / z) * Float64(Float64(1.0 / x_m) / z)) / y); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if ((z * z) <= 4e+34)
tmp = (1.0 / x_m) / (y * (1.0 + (z * z)));
else
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
end
tmp_2 = 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 4e+34], N[(N[(1.0 / x$95$m), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / z), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+34}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y \cdot \left(1 + z \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z} \cdot \frac{\frac{1}{x\_m}}{z}}{y}\\
\end{array}
\end{array}
if (*.f64 z z) < 3.99999999999999978e34Initial program 99.7%
if 3.99999999999999978e34 < (*.f64 z z) Initial program 79.8%
associate-/l/79.8%
remove-double-neg79.8%
distribute-rgt-neg-out79.8%
distribute-rgt-neg-out79.8%
remove-double-neg79.8%
associate-*l*83.0%
*-commutative83.0%
sqr-neg83.0%
+-commutative83.0%
sqr-neg83.0%
fma-define83.0%
Simplified83.0%
associate-*r*80.8%
*-commutative80.8%
associate-/r*80.3%
*-commutative80.3%
associate-/l/80.3%
fma-undefine80.3%
+-commutative80.3%
associate-/r*79.8%
add-sqr-sqrt36.5%
associate-/l*36.6%
inv-pow36.6%
sqrt-pow136.6%
metadata-eval36.6%
inv-pow36.6%
sqrt-pow136.6%
metadata-eval36.6%
+-commutative36.6%
fma-undefine36.6%
*-commutative36.6%
Applied egg-rr36.6%
div-inv36.5%
associate-*r*36.5%
pow-prod-up79.7%
metadata-eval79.7%
inv-pow79.7%
*-commutative79.7%
associate-/r*81.0%
add-sqr-sqrt38.4%
associate-/r*38.4%
un-div-inv38.4%
fma-undefine38.4%
+-commutative38.4%
metadata-eval38.4%
rem-square-sqrt38.4%
hypot-undefine38.4%
hypot-undefine38.4%
frac-times41.5%
associate-/l/41.5%
un-div-inv41.5%
Applied egg-rr49.7%
Taylor expanded in z around inf 79.8%
associate-/r*79.8%
*-commutative79.8%
associate-/r*83.2%
Simplified83.2%
*-un-lft-identity83.2%
unpow283.2%
times-frac90.4%
Applied egg-rr90.4%
Final simplification95.2%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (if (<= z 0.7) (/ (/ 1.0 x_m) y) (/ (* (/ 1.0 z) (/ (/ 1.0 x_m) z)) y))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= 0.7) {
tmp = (1.0 / x_m) / y;
} else {
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
}
return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 0.7d0) then
tmp = (1.0d0 / x_m) / y
else
tmp = ((1.0d0 / z) * ((1.0d0 / x_m) / z)) / y
end if
code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
double tmp;
if (z <= 0.7) {
tmp = (1.0 / x_m) / y;
} else {
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
}
return x_s * tmp;
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): tmp = 0 if z <= 0.7: tmp = (1.0 / x_m) / y else: tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y return x_s * tmp
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) tmp = 0.0 if (z <= 0.7) tmp = Float64(Float64(1.0 / x_m) / y); else tmp = Float64(Float64(Float64(1.0 / z) * Float64(Float64(1.0 / x_m) / z)) / y); end return Float64(x_s * tmp) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp_2 = code(x_s, x_m, y, z)
tmp = 0.0;
if (z <= 0.7)
tmp = (1.0 / x_m) / y;
else
tmp = ((1.0 / z) * ((1.0 / x_m) / z)) / y;
end
tmp_2 = 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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[z, 0.7], N[(N[(1.0 / x$95$m), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(1.0 / z), $MachinePrecision] * N[(N[(1.0 / x$95$m), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 0.7:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z} \cdot \frac{\frac{1}{x\_m}}{z}}{y}\\
\end{array}
\end{array}
if z < 0.69999999999999996Initial program 92.0%
Taylor expanded in z around 0 67.5%
if 0.69999999999999996 < z Initial program 83.6%
associate-/l/83.6%
remove-double-neg83.6%
distribute-rgt-neg-out83.6%
distribute-rgt-neg-out83.6%
remove-double-neg83.6%
associate-*l*86.7%
*-commutative86.7%
sqr-neg86.7%
+-commutative86.7%
sqr-neg86.7%
fma-define86.7%
Simplified86.7%
associate-*r*84.3%
*-commutative84.3%
associate-/r*83.3%
*-commutative83.3%
associate-/l/83.2%
fma-undefine83.2%
+-commutative83.2%
associate-/r*83.6%
add-sqr-sqrt43.2%
associate-/l*43.3%
inv-pow43.3%
sqrt-pow143.3%
metadata-eval43.3%
inv-pow43.3%
sqrt-pow143.3%
metadata-eval43.3%
+-commutative43.3%
fma-undefine43.3%
*-commutative43.3%
Applied egg-rr43.3%
div-inv43.2%
associate-*r*43.2%
pow-prod-up83.5%
metadata-eval83.5%
inv-pow83.5%
*-commutative83.5%
associate-/r*83.5%
add-sqr-sqrt40.3%
associate-/r*40.3%
un-div-inv40.2%
fma-undefine40.2%
+-commutative40.2%
metadata-eval40.2%
rem-square-sqrt40.2%
hypot-undefine40.2%
hypot-undefine40.3%
frac-times41.9%
associate-/l/41.9%
un-div-inv42.0%
Applied egg-rr53.0%
Taylor expanded in z around inf 82.9%
associate-/r*82.9%
*-commutative82.9%
associate-/r*86.0%
Simplified86.0%
*-un-lft-identity86.0%
unpow286.0%
times-frac90.8%
Applied egg-rr90.8%
Final simplification72.8%
x\_m = (fabs.f64 x) x\_s = (copysign.f64 #s(literal 1 binary64) x) NOTE: x_m, y, and z should be sorted in increasing order before calling this function. (FPCore (x_s x_m y z) :precision binary64 (* x_s (/ 1.0 (* y x_m))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
assert(x_m < y && y < z);
double code(double x_s, double x_m, double y, double z) {
return x_s * (1.0 / (y * x_m));
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x_s, x_m, y, z)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x_s * (1.0d0 / (y * x_m))
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
assert x_m < y && y < z;
public static double code(double x_s, double x_m, double y, double z) {
return x_s * (1.0 / (y * x_m));
}
x\_m = math.fabs(x) x\_s = math.copysign(1.0, x) [x_m, y, z] = sort([x_m, y, z]) def code(x_s, x_m, y, z): return x_s * (1.0 / (y * x_m))
x\_m = abs(x) x\_s = copysign(1.0, x) x_m, y, z = sort([x_m, y, z]) function code(x_s, x_m, y, z) return Float64(x_s * Float64(1.0 / Float64(y * x_m))) end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
x_m, y, z = num2cell(sort([x_m, y, z])){:}
function tmp = code(x_s, x_m, y, z)
tmp = x_s * (1.0 / (y * x_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]
NOTE: x_m, y, and z should be sorted in increasing order before calling this function.
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * N[(1.0 / N[(y * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \frac{1}{y \cdot x\_m}
\end{array}
Initial program 90.1%
associate-/l/90.0%
remove-double-neg90.0%
distribute-rgt-neg-out90.0%
distribute-rgt-neg-out90.0%
remove-double-neg90.0%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
Taylor expanded in z around 0 55.6%
Final simplification55.6%
(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 2024131
(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)))))