
(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 1 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 1e+308) (/ (/ 1.0 x_m) t_0) (/ (/ 1.0 (* y (* z x_m))) 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 t_0 = y * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+308) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / (y * (z * x_m))) / z;
}
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 <= 1d+308) then
tmp = (1.0d0 / x_m) / t_0
else
tmp = (1.0d0 / (y * (z * x_m))) / z
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 <= 1e+308) {
tmp = (1.0 / x_m) / t_0;
} else {
tmp = (1.0 / (y * (z * x_m))) / z;
}
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 <= 1e+308: tmp = (1.0 / x_m) / t_0 else: tmp = (1.0 / (y * (z * x_m))) / 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) t_0 = Float64(y * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 1e+308) tmp = Float64(Float64(1.0 / x_m) / t_0); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x_m))) / z); 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 <= 1e+308)
tmp = (1.0 / x_m) / t_0;
else
tmp = (1.0 / (y * (z * x_m))) / z;
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, 1e+308], N[(N[(1.0 / x$95$m), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $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 10^{+308}:\\
\;\;\;\;\frac{\frac{1}{x\_m}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\_m\right)}}{z}\\
\end{array}
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1e308Initial program 95.4%
if 1e308 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 79.9%
associate-/l/79.9%
associate-*l*82.1%
*-commutative82.1%
sqr-neg82.1%
+-commutative82.1%
sqr-neg82.1%
fma-define82.1%
Simplified82.1%
add-sqr-sqrt30.4%
pow230.4%
*-commutative30.4%
sqrt-prod30.4%
fma-undefine30.4%
+-commutative30.4%
hypot-1-def39.7%
Applied egg-rr39.7%
Taylor expanded in z around inf 79.9%
associate-*r*81.9%
Simplified81.9%
associate-/r*81.9%
metadata-eval81.9%
frac-times81.9%
unpow281.9%
times-frac98.4%
Applied egg-rr98.4%
associate-*r/99.9%
associate-/r*99.8%
frac-times99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification96.1%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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) (* (/ 1.0 (hypot 1.0 z)) (/ (/ 1.0 x_m) (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 / y) * ((1.0 / hypot(1.0, z)) * ((1.0 / x_m) / 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 / y) * ((1.0 / Math.hypot(1.0, z)) * ((1.0 / x_m) / 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 / y) * ((1.0 / math.hypot(1.0, z)) * ((1.0 / x_m) / 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 / y) * Float64(Float64(1.0 / hypot(1.0, z)) * Float64(Float64(1.0 / x_m) / 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 / y) * ((1.0 / hypot(1.0, z)) * ((1.0 / x_m) / 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 / y), $MachinePrecision] * N[(N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / x$95$m), $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 \left(\frac{1}{y} \cdot \left(\frac{1}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{1}{x\_m}}{\mathsf{hypot}\left(1, z\right)}\right)\right)
\end{array}
Initial program 92.9%
associate-/l/92.9%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
associate-*r*90.8%
*-commutative90.8%
associate-/r*90.9%
*-commutative90.9%
associate-/l/90.9%
associate-/r*92.9%
*-un-lft-identity92.9%
times-frac91.8%
Applied egg-rr91.8%
*-un-lft-identity91.8%
add-sqr-sqrt91.8%
times-frac91.7%
fma-undefine91.7%
unpow291.7%
+-commutative91.7%
metadata-eval91.7%
unpow291.7%
hypot-undefine91.8%
fma-undefine91.8%
unpow291.8%
+-commutative91.8%
metadata-eval91.8%
unpow291.8%
hypot-undefine95.8%
Applied egg-rr95.8%
Final simplification95.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 (* (hypot 1.0 z) (* (hypot 1.0 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) {
return x_s * (1.0 / (y * (hypot(1.0, z) * (hypot(1.0, z) * x_m))));
}
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 * (Math.hypot(1.0, z) * (Math.hypot(1.0, z) * 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 * (math.hypot(1.0, z) * (math.hypot(1.0, z) * 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 * Float64(hypot(1.0, z) * Float64(hypot(1.0, z) * 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 * (hypot(1.0, z) * (hypot(1.0, z) * 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 * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * x$95$m), $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{1}{y \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot \left(\mathsf{hypot}\left(1, z\right) \cdot x\_m\right)\right)}
\end{array}
Initial program 92.9%
associate-/l/92.9%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
add-sqr-sqrt43.6%
pow243.6%
*-commutative43.6%
sqrt-prod43.6%
fma-undefine43.6%
+-commutative43.6%
hypot-1-def45.8%
Applied egg-rr45.8%
unpow245.8%
swap-sqr43.6%
hypot-undefine43.6%
metadata-eval43.6%
unpow243.6%
hypot-undefine43.6%
metadata-eval43.6%
unpow243.6%
add-sqr-sqrt43.6%
+-commutative43.6%
unpow243.6%
fma-undefine43.6%
add-sqr-sqrt43.6%
add-sqr-sqrt91.5%
associate-*l*91.5%
fma-undefine91.5%
unpow291.5%
+-commutative91.5%
metadata-eval91.5%
unpow291.5%
hypot-undefine91.5%
Applied egg-rr95.1%
Final simplification95.1%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 1.0) (/ 1.0 (* y x_m)) (/ (/ -1.0 y) (* z (* 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 <= 1.0) {
tmp = 1.0 / (y * x_m);
} else {
tmp = (-1.0 / y) / (z * (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 <= 1.0d0) then
tmp = 1.0d0 / (y * x_m)
else
tmp = ((-1.0d0) / y) / (z * (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 <= 1.0) {
tmp = 1.0 / (y * x_m);
} else {
tmp = (-1.0 / y) / (z * (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 <= 1.0: tmp = 1.0 / (y * x_m) else: tmp = (-1.0 / y) / (z * (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 (z <= 1.0) tmp = Float64(1.0 / Float64(y * x_m)); else tmp = Float64(Float64(-1.0 / y) / Float64(z * Float64(z * Float64(-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 <= 1.0)
tmp = 1.0 / (y * x_m);
else
tmp = (-1.0 / y) / (z * (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[z, 1.0], N[(1.0 / N[(y * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / y), $MachinePrecision] / N[(z * 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 \leq 1:\\
\;\;\;\;\frac{1}{y \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{y}}{z \cdot \left(z \cdot \left(-x\_m\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 93.8%
associate-/l/93.8%
associate-*l*92.8%
*-commutative92.8%
sqr-neg92.8%
+-commutative92.8%
sqr-neg92.8%
fma-define92.8%
Simplified92.8%
Taylor expanded in z around 0 73.5%
if 1 < z Initial program 90.5%
associate-/l/90.5%
associate-*l*87.9%
*-commutative87.9%
sqr-neg87.9%
+-commutative87.9%
sqr-neg87.9%
fma-define87.9%
Simplified87.9%
add-sqr-sqrt37.7%
pow237.7%
*-commutative37.7%
sqrt-prod37.7%
fma-undefine37.7%
+-commutative37.7%
hypot-1-def40.4%
Applied egg-rr40.4%
Taylor expanded in z around inf 89.5%
associate-*r*86.0%
Simplified86.0%
associate-/r*85.4%
metadata-eval85.4%
frac-times85.5%
unpow285.5%
times-frac94.8%
Applied egg-rr94.8%
associate-/r*94.7%
frac-2neg94.7%
frac-times90.9%
*-un-lft-identity90.9%
distribute-neg-frac90.9%
metadata-eval90.9%
*-commutative90.9%
Applied egg-rr90.9%
Final simplification78.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 1.0) (/ 1.0 (* y x_m)) (/ 1.0 (* y (* z (* 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 <= 1.0) {
tmp = 1.0 / (y * x_m);
} else {
tmp = 1.0 / (y * (z * (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 <= 1.0d0) then
tmp = 1.0d0 / (y * x_m)
else
tmp = 1.0d0 / (y * (z * (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 <= 1.0) {
tmp = 1.0 / (y * x_m);
} else {
tmp = 1.0 / (y * (z * (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 <= 1.0: tmp = 1.0 / (y * x_m) else: tmp = 1.0 / (y * (z * (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 (z <= 1.0) tmp = Float64(1.0 / Float64(y * x_m)); else tmp = Float64(1.0 / Float64(y * Float64(z * 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 <= 1.0)
tmp = 1.0 / (y * x_m);
else
tmp = 1.0 / (y * (z * (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[z, 1.0], N[(1.0 / N[(y * x$95$m), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(y * N[(z * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
[x_m, y, z] = \mathsf{sort}([x_m, y, z])\\
\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 1:\\
\;\;\;\;\frac{1}{y \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y \cdot \left(z \cdot \left(z \cdot x\_m\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 93.8%
associate-/l/93.8%
associate-*l*92.8%
*-commutative92.8%
sqr-neg92.8%
+-commutative92.8%
sqr-neg92.8%
fma-define92.8%
Simplified92.8%
Taylor expanded in z around 0 73.5%
if 1 < z Initial program 90.5%
associate-/l/90.5%
associate-*l*87.9%
*-commutative87.9%
sqr-neg87.9%
+-commutative87.9%
sqr-neg87.9%
fma-define87.9%
Simplified87.9%
add-sqr-sqrt37.7%
pow237.7%
*-commutative37.7%
sqrt-prod37.7%
fma-undefine37.7%
+-commutative37.7%
hypot-1-def40.4%
Applied egg-rr40.4%
Taylor expanded in z around inf 40.4%
unpow240.4%
swap-sqr37.6%
add-sqr-sqrt86.9%
associate-*r*91.0%
Applied egg-rr91.0%
Final simplification78.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 1.0) (/ 1.0 (* y x_m)) (/ (/ 1.0 (* y (* z x_m))) 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 <= 1.0) {
tmp = 1.0 / (y * x_m);
} else {
tmp = (1.0 / (y * (z * x_m))) / z;
}
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 <= 1.0d0) then
tmp = 1.0d0 / (y * x_m)
else
tmp = (1.0d0 / (y * (z * x_m))) / z
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 <= 1.0) {
tmp = 1.0 / (y * x_m);
} else {
tmp = (1.0 / (y * (z * x_m))) / z;
}
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 <= 1.0: tmp = 1.0 / (y * x_m) else: tmp = (1.0 / (y * (z * x_m))) / 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 (z <= 1.0) tmp = Float64(1.0 / Float64(y * x_m)); else tmp = Float64(Float64(1.0 / Float64(y * Float64(z * x_m))) / z); 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 <= 1.0)
tmp = 1.0 / (y * x_m);
else
tmp = (1.0 / (y * (z * x_m))) / z;
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, 1.0], N[(1.0 / N[(y * x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(y * N[(z * x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $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 1:\\
\;\;\;\;\frac{1}{y \cdot x\_m}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y \cdot \left(z \cdot x\_m\right)}}{z}\\
\end{array}
\end{array}
if z < 1Initial program 93.8%
associate-/l/93.8%
associate-*l*92.8%
*-commutative92.8%
sqr-neg92.8%
+-commutative92.8%
sqr-neg92.8%
fma-define92.8%
Simplified92.8%
Taylor expanded in z around 0 73.5%
if 1 < z Initial program 90.5%
associate-/l/90.5%
associate-*l*87.9%
*-commutative87.9%
sqr-neg87.9%
+-commutative87.9%
sqr-neg87.9%
fma-define87.9%
Simplified87.9%
add-sqr-sqrt37.7%
pow237.7%
*-commutative37.7%
sqrt-prod37.7%
fma-undefine37.7%
+-commutative37.7%
hypot-1-def40.4%
Applied egg-rr40.4%
Taylor expanded in z around inf 89.5%
associate-*r*86.0%
Simplified86.0%
associate-/r*85.4%
metadata-eval85.4%
frac-times85.5%
unpow285.5%
times-frac94.8%
Applied egg-rr94.8%
associate-*r/92.2%
associate-/r*92.0%
frac-times92.1%
metadata-eval92.1%
*-commutative92.1%
*-commutative92.1%
Applied egg-rr92.1%
Final simplification78.6%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 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 92.9%
associate-/l/92.9%
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 58.4%
Final simplification58.4%
(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 2024050
(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)))))