
(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 7 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))) 5e+301)
(/ (/ 1.0 x_m) (fma (* y z) z y))
(/ (/ 1.0 z) (* y (* z 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) {
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) / (y * (z * x_m));
}
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(1.0 / z) / Float64(y * Float64(z * x_m))); 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[(1.0 / z), $MachinePrecision] / N[(y * N[(z * x$95$m), $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{1}{z}}{y \cdot \left(z \cdot x\_m\right)}\\
\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%
remove-double-neg64.6%
distribute-lft-neg-out64.6%
distribute-rgt-neg-in64.6%
associate-/r*73.1%
associate-/l/73.1%
associate-/l/73.3%
distribute-lft-neg-out73.3%
distribute-rgt-neg-in73.3%
distribute-lft-neg-in73.3%
remove-double-neg73.3%
sqr-neg73.3%
+-commutative73.3%
sqr-neg73.3%
fma-define73.3%
*-commutative73.3%
Simplified73.3%
Taylor expanded in z around inf 73.3%
*-un-lft-identity73.3%
associate-/r*73.4%
pow-flip73.3%
metadata-eval73.3%
Applied egg-rr73.3%
*-lft-identity73.3%
associate-/r*73.9%
Simplified73.9%
associate-/l/73.3%
sqr-pow73.3%
times-frac94.9%
metadata-eval94.9%
unpow-194.9%
metadata-eval94.9%
unpow-194.9%
Applied egg-rr94.9%
*-commutative94.9%
associate-/l/95.0%
frac-times99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
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 (/ (/ (/ 1.0 (sqrt y)) (hypot 1.0 z)) (* x_m (* (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) {
return x_s * (((1.0 / sqrt(y)) / hypot(1.0, z)) / (x_m * (sqrt(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 / Math.sqrt(y)) / Math.hypot(1.0, z)) / (x_m * (Math.sqrt(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 / math.sqrt(y)) / math.hypot(1.0, z)) / (x_m * (math.sqrt(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(Float64(1.0 / sqrt(y)) / hypot(1.0, z)) / Float64(x_m * Float64(sqrt(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 / sqrt(y)) / hypot(1.0, z)) / (x_m * (sqrt(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[(N[(1.0 / N[Sqrt[y], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[(x$95$m * N[(N[Sqrt[y], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $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{\frac{1}{\sqrt{y}}}{\mathsf{hypot}\left(1, z\right)}}{x\_m \cdot \left(\sqrt{y} \cdot \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%
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%
*-un-lft-identity90.1%
add-sqr-sqrt48.9%
times-frac48.8%
+-commutative48.8%
fma-undefine48.8%
*-commutative48.8%
sqrt-prod48.8%
fma-undefine48.8%
+-commutative48.8%
hypot-1-def48.8%
+-commutative48.8%
Applied egg-rr54.3%
associate-/l/54.3%
associate-*r/54.4%
*-rgt-identity54.4%
*-commutative54.4%
associate-/r*54.4%
*-commutative54.4%
Simplified54.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 (let* ((t_0 (* (sqrt y) (hypot 1.0 z)))) (* x_s (/ (/ 1.0 t_0) (* x_m t_0)))))
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 = sqrt(y) * hypot(1.0, z);
return x_s * ((1.0 / t_0) / (x_m * t_0));
}
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 t_0 = Math.sqrt(y) * Math.hypot(1.0, z);
return x_s * ((1.0 / t_0) / (x_m * t_0));
}
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): t_0 = math.sqrt(y) * math.hypot(1.0, z) return x_s * ((1.0 / t_0) / (x_m * t_0))
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(sqrt(y) * hypot(1.0, z)) return Float64(x_s * Float64(Float64(1.0 / t_0) / Float64(x_m * t_0))) 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)
t_0 = sqrt(y) * hypot(1.0, z);
tmp = x_s * ((1.0 / t_0) / (x_m * t_0));
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
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[Sqrt[y], $MachinePrecision] * N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * N[(N[(1.0 / t$95$0), $MachinePrecision] / N[(x$95$m * t$95$0), $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 := \sqrt{y} \cdot \mathsf{hypot}\left(1, z\right)\\
x\_s \cdot \frac{\frac{1}{t\_0}}{x\_m \cdot t\_0}
\end{array}
\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%
*-un-lft-identity90.1%
add-sqr-sqrt48.9%
times-frac48.8%
+-commutative48.8%
fma-undefine48.8%
*-commutative48.8%
sqrt-prod48.8%
fma-undefine48.8%
+-commutative48.8%
hypot-1-def48.8%
+-commutative48.8%
Applied egg-rr54.3%
associate-/l/54.3%
associate-*r/54.4%
*-rgt-identity54.4%
*-commutative54.4%
associate-/r*54.4%
*-commutative54.4%
Simplified54.4%
add-sqr-sqrt54.2%
associate-/l*54.2%
inv-pow54.2%
sqrt-pow154.3%
metadata-eval54.3%
inv-pow54.3%
sqrt-pow154.2%
metadata-eval54.2%
Applied egg-rr54.2%
associate-*r/54.3%
pow-sqr54.4%
metadata-eval54.4%
unpow-154.4%
associate-/r*54.4%
Simplified54.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
(let* ((t_0 (* y (+ 1.0 (* z z)))))
(*
x_s
(if (<= t_0 5e+301) (/ (/ 1.0 x_m) t_0) (/ (/ 1.0 z) (* y (* z 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) {
double t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 5e+301) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / z) / (y * (z * x_m));
}
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) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 + (z * z))
if (t_0 <= 5d+301) then
tmp = (1.0d0 / x_m) / t_0
else
tmp = (1.0d0 / z) / (y * (z * x_m))
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 t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 5e+301) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / z) / (y * (z * x_m));
}
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): t_0 = y * (1.0 + (z * z)) tmp = 0 if t_0 <= 5e+301: tmp = (1.0 / x_m) / t_0 else: tmp = (1.0 / z) / (y * (z * x_m)) 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(y * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 5e+301) tmp = Float64(Float64(1.0 / x_m) / t_0); else tmp = Float64(Float64(1.0 / z) / Float64(y * Float64(z * x_m))); 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)
t_0 = y * (1.0 + (z * z));
tmp = 0.0;
if (t_0 <= 5e+301)
tmp = (1.0 / x_m) / t_0;
else
tmp = (1.0 / z) / (y * (z * x_m));
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_] := Block[{t$95$0 = N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, 5e+301], N[(N[(1.0 / x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(y * N[(z * x$95$m), $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])\\
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + z \cdot z\right)\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y \cdot \left(z \cdot x\_m\right)}\\
\end{array}
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 5.0000000000000004e301Initial program 94.8%
if 5.0000000000000004e301 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 64.6%
remove-double-neg64.6%
distribute-lft-neg-out64.6%
distribute-rgt-neg-in64.6%
associate-/r*73.1%
associate-/l/73.1%
associate-/l/73.3%
distribute-lft-neg-out73.3%
distribute-rgt-neg-in73.3%
distribute-lft-neg-in73.3%
remove-double-neg73.3%
sqr-neg73.3%
+-commutative73.3%
sqr-neg73.3%
fma-define73.3%
*-commutative73.3%
Simplified73.3%
Taylor expanded in z around inf 73.3%
*-un-lft-identity73.3%
associate-/r*73.4%
pow-flip73.3%
metadata-eval73.3%
Applied egg-rr73.3%
*-lft-identity73.3%
associate-/r*73.9%
Simplified73.9%
associate-/l/73.3%
sqr-pow73.3%
times-frac94.9%
metadata-eval94.9%
unpow-194.9%
metadata-eval94.9%
unpow-194.9%
Applied egg-rr94.9%
*-commutative94.9%
associate-/l/95.0%
frac-times99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
Final simplification95.6%
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-22) (/ (/ 1.0 x_m) y) (/ (/ 1.0 z) (* y (* z 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) {
double tmp;
if ((z * z) <= 1e-22) {
tmp = (1.0 / x_m) / y;
} else {
tmp = (1.0 / z) / (y * (z * x_m));
}
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) <= 1d-22) then
tmp = (1.0d0 / x_m) / y
else
tmp = (1.0d0 / z) / (y * (z * x_m))
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) <= 1e-22) {
tmp = (1.0 / x_m) / y;
} else {
tmp = (1.0 / z) / (y * (z * x_m));
}
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) <= 1e-22: tmp = (1.0 / x_m) / y else: tmp = (1.0 / z) / (y * (z * x_m)) 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-22) tmp = Float64(Float64(1.0 / x_m) / y); else tmp = Float64(Float64(1.0 / z) / Float64(y * Float64(z * x_m))); 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) <= 1e-22)
tmp = (1.0 / x_m) / y;
else
tmp = (1.0 / z) / (y * (z * x_m));
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], 1e-22], N[(N[(1.0 / x$95$m), $MachinePrecision] / y), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(y * N[(z * x$95$m), $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}\;z \cdot z \leq 10^{-22}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y \cdot \left(z \cdot x\_m\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 1e-22Initial program 99.7%
Taylor expanded in z around 0 99.7%
if 1e-22 < (*.f64 z z) Initial program 81.1%
remove-double-neg81.1%
distribute-lft-neg-out81.1%
distribute-rgt-neg-in81.1%
associate-/r*81.6%
associate-/l/81.6%
associate-/l/82.1%
distribute-lft-neg-out82.1%
distribute-rgt-neg-in82.1%
distribute-lft-neg-in82.1%
remove-double-neg82.1%
sqr-neg82.1%
+-commutative82.1%
sqr-neg82.1%
fma-define82.1%
*-commutative82.1%
Simplified82.1%
Taylor expanded in z around inf 81.3%
*-un-lft-identity81.3%
associate-/r*81.4%
pow-flip81.4%
metadata-eval81.4%
Applied egg-rr81.4%
*-lft-identity81.4%
associate-/r*83.6%
Simplified83.6%
associate-/l/81.4%
sqr-pow81.4%
times-frac95.8%
metadata-eval95.8%
unpow-195.8%
metadata-eval95.8%
unpow-195.8%
Applied egg-rr95.8%
*-commutative95.8%
associate-/l/96.0%
frac-times95.4%
*-un-lft-identity95.4%
Applied egg-rr95.4%
Final simplification97.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 (if (<= (* z z) 0.5) (/ (/ 1.0 x_m) y) (/ 1.0 (* (* z z) (* 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) {
double tmp;
if ((z * z) <= 0.5) {
tmp = (1.0 / x_m) / y;
} else {
tmp = 1.0 / ((z * z) * (y * x_m));
}
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) <= 0.5d0) then
tmp = (1.0d0 / x_m) / y
else
tmp = 1.0d0 / ((z * z) * (y * x_m))
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) <= 0.5) {
tmp = (1.0 / x_m) / y;
} else {
tmp = 1.0 / ((z * z) * (y * x_m));
}
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) <= 0.5: tmp = (1.0 / x_m) / y else: tmp = 1.0 / ((z * z) * (y * x_m)) 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) <= 0.5) tmp = Float64(Float64(1.0 / x_m) / y); else tmp = Float64(1.0 / Float64(Float64(z * z) * Float64(y * x_m))); 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) <= 0.5)
tmp = (1.0 / x_m) / y;
else
tmp = 1.0 / ((z * z) * (y * x_m));
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], 0.5], N[(N[(1.0 / x$95$m), $MachinePrecision] / y), $MachinePrecision], N[(1.0 / N[(N[(z * z), $MachinePrecision] * N[(y * x$95$m), $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}\;z \cdot z \leq 0.5:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(z \cdot z\right) \cdot \left(y \cdot x\_m\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.5Initial program 99.7%
Taylor expanded in z around 0 99.7%
if 0.5 < (*.f64 z z) Initial program 81.1%
remove-double-neg81.1%
distribute-lft-neg-out81.1%
distribute-rgt-neg-in81.1%
associate-/r*81.6%
associate-/l/81.6%
associate-/l/82.1%
distribute-lft-neg-out82.1%
distribute-rgt-neg-in82.1%
distribute-lft-neg-in82.1%
remove-double-neg82.1%
sqr-neg82.1%
+-commutative82.1%
sqr-neg82.1%
fma-define82.1%
*-commutative82.1%
Simplified82.1%
Taylor expanded in z around inf 81.3%
unpow281.3%
Applied egg-rr81.3%
Final simplification90.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 (/ 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%
(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
(! :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)))))