
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (* y_m (+ 1.0 (* z z))) 1e+301)
(/ (/ 1.0 x) (fma (* y_m z) z y_m))
(/ (/ 1.0 z) (* y_m (* z x))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((y_m * (1.0 + (z * z))) <= 1e+301) {
tmp = (1.0 / x) / fma((y_m * z), z, y_m);
} else {
tmp = (1.0 / z) / (y_m * (z * x));
}
return y_s * tmp;
}
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (Float64(y_m * Float64(1.0 + Float64(z * z))) <= 1e+301) tmp = Float64(Float64(1.0 / x) / fma(Float64(y_m * z), z, y_m)); else tmp = Float64(Float64(1.0 / z) / Float64(y_m * Float64(z * x))); end return Float64(y_s * tmp) end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+301], N[(N[(1.0 / x), $MachinePrecision] / N[(N[(y$95$m * z), $MachinePrecision] * z + y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(y$95$m * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \cdot \left(1 + z \cdot z\right) \leq 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x}}{\mathsf{fma}\left(y\_m \cdot z, z, y\_m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y\_m \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.00000000000000005e301Initial program 95.8%
+-commutative95.8%
distribute-lft-in95.8%
associate-*r*97.1%
*-rgt-identity97.1%
fma-def97.1%
Applied egg-rr97.1%
if 1.00000000000000005e301 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 76.9%
associate-/l/76.9%
metadata-eval76.9%
associate-*r/76.9%
associate-/l/76.9%
associate-*r/76.9%
associate-/l*76.9%
associate-/r/76.9%
/-rgt-identity76.9%
associate-*l*84.6%
*-commutative84.6%
sqr-neg84.6%
+-commutative84.6%
sqr-neg84.6%
fma-def84.6%
Simplified84.6%
Taylor expanded in z around inf 76.9%
associate-*r*84.3%
*-commutative84.3%
Simplified84.3%
expm1-log1p-u84.3%
expm1-udef76.8%
associate-/r*76.8%
pow-flip76.8%
metadata-eval76.8%
Applied egg-rr76.8%
expm1-def86.4%
expm1-log1p86.4%
Simplified86.4%
add-sqr-sqrt86.4%
*-un-lft-identity86.4%
times-frac86.4%
sqrt-pow179.2%
metadata-eval79.2%
unpow-179.2%
sqrt-pow192.4%
metadata-eval92.4%
unpow-192.4%
Applied egg-rr92.4%
/-rgt-identity92.4%
associate-/l/92.3%
un-div-inv92.4%
*-commutative92.4%
associate-*l*100.0%
Applied egg-rr100.0%
Final simplification97.5%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (* (/ (pow y_m -0.5) (hypot 1.0 z)) (/ (/ (pow x -1.0) (hypot 1.0 z)) (sqrt y_m)))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * ((pow(y_m, -0.5) / hypot(1.0, z)) * ((pow(x, -1.0) / hypot(1.0, z)) / sqrt(y_m)));
}
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * ((Math.pow(y_m, -0.5) / Math.hypot(1.0, z)) * ((Math.pow(x, -1.0) / Math.hypot(1.0, z)) / Math.sqrt(y_m)));
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * ((math.pow(y_m, -0.5) / math.hypot(1.0, z)) * ((math.pow(x, -1.0) / math.hypot(1.0, z)) / math.sqrt(y_m)))
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(Float64((y_m ^ -0.5) / hypot(1.0, z)) * Float64(Float64((x ^ -1.0) / hypot(1.0, z)) / sqrt(y_m)))) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (((y_m ^ -0.5) / hypot(1.0, z)) * (((x ^ -1.0) / hypot(1.0, z)) / sqrt(y_m))); end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(N[(N[Power[y$95$m, -0.5], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[x, -1.0], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(\frac{{y\_m}^{-0.5}}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{\frac{{x}^{-1}}{\mathsf{hypot}\left(1, z\right)}}{\sqrt{y\_m}}\right)
\end{array}
Initial program 93.2%
associate-/l/92.9%
metadata-eval92.9%
associate-*r/92.9%
associate-/l/93.2%
associate-*r/93.2%
associate-/l*92.9%
associate-/r/92.9%
/-rgt-identity92.9%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-def91.5%
Simplified91.5%
fma-udef91.5%
+-commutative91.5%
*-commutative91.5%
associate-*l*92.9%
associate-/l/93.2%
add-sqr-sqrt62.7%
sqrt-div22.8%
inv-pow22.8%
sqrt-pow122.7%
metadata-eval22.7%
*-commutative22.7%
sqrt-prod22.8%
hypot-1-def22.8%
sqrt-div22.7%
inv-pow22.7%
sqrt-pow122.7%
metadata-eval22.7%
*-commutative22.7%
Applied egg-rr25.2%
unpow225.2%
Simplified25.2%
unpow225.2%
div-inv25.2%
associate-*l*24.1%
*-commutative24.1%
associate-/r*24.1%
metadata-eval24.1%
sqrt-div24.1%
inv-pow24.1%
sqrt-pow124.1%
metadata-eval24.1%
Applied egg-rr24.1%
associate-*r/24.1%
*-commutative24.1%
associate-*r/25.2%
associate-*l/25.2%
associate-*l*25.2%
*-commutative25.2%
associate-*l/25.2%
associate-/r*24.9%
pow-sqr46.7%
metadata-eval46.7%
Simplified46.7%
Final simplification46.7%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (pow (/ (/ (pow x -0.5) (hypot 1.0 z)) (sqrt y_m)) 2.0)))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * pow(((pow(x, -0.5) / hypot(1.0, z)) / sqrt(y_m)), 2.0);
}
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * Math.pow(((Math.pow(x, -0.5) / Math.hypot(1.0, z)) / Math.sqrt(y_m)), 2.0);
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * math.pow(((math.pow(x, -0.5) / math.hypot(1.0, z)) / math.sqrt(y_m)), 2.0)
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * (Float64(Float64((x ^ -0.5) / hypot(1.0, z)) / sqrt(y_m)) ^ 2.0)) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * ((((x ^ -0.5) / hypot(1.0, z)) / sqrt(y_m)) ^ 2.0); end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[Power[N[(N[(N[Power[x, -0.5], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot {\left(\frac{\frac{{x}^{-0.5}}{\mathsf{hypot}\left(1, z\right)}}{\sqrt{y\_m}}\right)}^{2}
\end{array}
Initial program 93.2%
associate-/l/92.9%
metadata-eval92.9%
associate-*r/92.9%
associate-/l/93.2%
associate-*r/93.2%
associate-/l*92.9%
associate-/r/92.9%
/-rgt-identity92.9%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-def91.5%
Simplified91.5%
fma-udef91.5%
+-commutative91.5%
*-commutative91.5%
associate-*l*92.9%
associate-/l/93.2%
add-sqr-sqrt62.7%
sqrt-div22.8%
inv-pow22.8%
sqrt-pow122.7%
metadata-eval22.7%
*-commutative22.7%
sqrt-prod22.8%
hypot-1-def22.8%
sqrt-div22.7%
inv-pow22.7%
sqrt-pow122.7%
metadata-eval22.7%
*-commutative22.7%
Applied egg-rr25.2%
unpow225.2%
Simplified25.2%
expm1-log1p-u24.8%
expm1-udef14.4%
Applied egg-rr14.4%
expm1-def24.8%
expm1-log1p25.2%
associate-/r*25.2%
Simplified25.2%
Final simplification25.2%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (* (/ 1.0 y_m) (/ 1.0 (pow (* (hypot 1.0 z) (sqrt x)) 2.0)))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * ((1.0 / y_m) * (1.0 / pow((hypot(1.0, z) * sqrt(x)), 2.0)));
}
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * ((1.0 / y_m) * (1.0 / Math.pow((Math.hypot(1.0, z) * Math.sqrt(x)), 2.0)));
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * ((1.0 / y_m) * (1.0 / math.pow((math.hypot(1.0, z) * math.sqrt(x)), 2.0)))
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(Float64(1.0 / y_m) * Float64(1.0 / (Float64(hypot(1.0, z) * sqrt(x)) ^ 2.0)))) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * ((1.0 / y_m) * (1.0 / ((hypot(1.0, z) * sqrt(x)) ^ 2.0))); end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(N[(1.0 / y$95$m), $MachinePrecision] * N[(1.0 / N[Power[N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(\frac{1}{y\_m} \cdot \frac{1}{{\left(\mathsf{hypot}\left(1, z\right) \cdot \sqrt{x}\right)}^{2}}\right)
\end{array}
Initial program 93.2%
associate-/l/92.9%
metadata-eval92.9%
associate-*r/92.9%
associate-/l/93.2%
associate-*r/93.2%
associate-/l*92.9%
associate-/r/92.9%
/-rgt-identity92.9%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-def91.5%
Simplified91.5%
associate-/r*91.9%
div-inv91.8%
Applied egg-rr91.8%
add-sqr-sqrt51.1%
pow251.1%
fma-udef51.1%
+-commutative51.1%
*-commutative51.1%
sqrt-prod51.1%
hypot-1-def51.8%
Applied egg-rr51.8%
Final simplification51.8%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* y_m (+ 1.0 (* z z)))))
(*
y_s
(if (<= t_0 1e+301) (/ 1.0 (* x t_0)) (/ (/ 1.0 z) (* y_m (* z x)))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+301) {
tmp = 1.0 / (x * t_0);
} else {
tmp = (1.0 / z) / (y_m * (z * x));
}
return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y_m * (1.0d0 + (z * z))
if (t_0 <= 1d+301) then
tmp = 1.0d0 / (x * t_0)
else
tmp = (1.0d0 / z) / (y_m * (z * x))
end if
code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+301) {
tmp = 1.0 / (x * t_0);
} else {
tmp = (1.0 / z) / (y_m * (z * x));
}
return y_s * tmp;
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = y_m * (1.0 + (z * z)) tmp = 0 if t_0 <= 1e+301: tmp = 1.0 / (x * t_0) else: tmp = (1.0 / z) / (y_m * (z * x)) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(y_m * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 1e+301) tmp = Float64(1.0 / Float64(x * t_0)); else tmp = Float64(Float64(1.0 / z) / Float64(y_m * Float64(z * x))); end return Float64(y_s * tmp) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) t_0 = y_m * (1.0 + (z * z)); tmp = 0.0; if (t_0 <= 1e+301) tmp = 1.0 / (x * t_0); else tmp = (1.0 / z) / (y_m * (z * x)); end tmp_2 = y_s * tmp; end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, 1e+301], N[(1.0 / N[(x * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(y$95$m * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(1 + z \cdot z\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 10^{+301}:\\
\;\;\;\;\frac{1}{x \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y\_m \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.00000000000000005e301Initial program 95.8%
associate-/l/95.5%
Simplified95.5%
if 1.00000000000000005e301 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 76.9%
associate-/l/76.9%
metadata-eval76.9%
associate-*r/76.9%
associate-/l/76.9%
associate-*r/76.9%
associate-/l*76.9%
associate-/r/76.9%
/-rgt-identity76.9%
associate-*l*84.6%
*-commutative84.6%
sqr-neg84.6%
+-commutative84.6%
sqr-neg84.6%
fma-def84.6%
Simplified84.6%
Taylor expanded in z around inf 76.9%
associate-*r*84.3%
*-commutative84.3%
Simplified84.3%
expm1-log1p-u84.3%
expm1-udef76.8%
associate-/r*76.8%
pow-flip76.8%
metadata-eval76.8%
Applied egg-rr76.8%
expm1-def86.4%
expm1-log1p86.4%
Simplified86.4%
add-sqr-sqrt86.4%
*-un-lft-identity86.4%
times-frac86.4%
sqrt-pow179.2%
metadata-eval79.2%
unpow-179.2%
sqrt-pow192.4%
metadata-eval92.4%
unpow-192.4%
Applied egg-rr92.4%
/-rgt-identity92.4%
associate-/l/92.3%
un-div-inv92.4%
*-commutative92.4%
associate-*l*100.0%
Applied egg-rr100.0%
Final simplification96.2%
y_m = (fabs.f64 y)
y_s = (copysign.f64 1 y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* y_m (+ 1.0 (* z z)))))
(*
y_s
(if (<= t_0 1e+301) (/ (/ 1.0 x) t_0) (/ (/ 1.0 z) (* y_m (* z x)))))))y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / z) / (y_m * (z * x));
}
return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y_m * (1.0d0 + (z * z))
if (t_0 <= 1d+301) then
tmp = (1.0d0 / x) / t_0
else
tmp = (1.0d0 / z) / (y_m * (z * x))
end if
code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = y_m * (1.0 + (z * z));
double tmp;
if (t_0 <= 1e+301) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / z) / (y_m * (z * x));
}
return y_s * tmp;
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = y_m * (1.0 + (z * z)) tmp = 0 if t_0 <= 1e+301: tmp = (1.0 / x) / t_0 else: tmp = (1.0 / z) / (y_m * (z * x)) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(y_m * Float64(1.0 + Float64(z * z))) tmp = 0.0 if (t_0 <= 1e+301) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(1.0 / z) / Float64(y_m * Float64(z * x))); end return Float64(y_s * tmp) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) t_0 = y_m * (1.0 + (z * z)); tmp = 0.0; if (t_0 <= 1e+301) tmp = (1.0 / x) / t_0; else tmp = (1.0 / z) / (y_m * (z * x)); end tmp_2 = y_s * tmp; end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(y$95$m * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, 1e+301], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(y$95$m * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := y\_m \cdot \left(1 + z \cdot z\right)\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 10^{+301}:\\
\;\;\;\;\frac{\frac{1}{x}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y\_m \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
\end{array}
if (*.f64 y (+.f64 1 (*.f64 z z))) < 1.00000000000000005e301Initial program 95.8%
if 1.00000000000000005e301 < (*.f64 y (+.f64 1 (*.f64 z z))) Initial program 76.9%
associate-/l/76.9%
metadata-eval76.9%
associate-*r/76.9%
associate-/l/76.9%
associate-*r/76.9%
associate-/l*76.9%
associate-/r/76.9%
/-rgt-identity76.9%
associate-*l*84.6%
*-commutative84.6%
sqr-neg84.6%
+-commutative84.6%
sqr-neg84.6%
fma-def84.6%
Simplified84.6%
Taylor expanded in z around inf 76.9%
associate-*r*84.3%
*-commutative84.3%
Simplified84.3%
expm1-log1p-u84.3%
expm1-udef76.8%
associate-/r*76.8%
pow-flip76.8%
metadata-eval76.8%
Applied egg-rr76.8%
expm1-def86.4%
expm1-log1p86.4%
Simplified86.4%
add-sqr-sqrt86.4%
*-un-lft-identity86.4%
times-frac86.4%
sqrt-pow179.2%
metadata-eval79.2%
unpow-179.2%
sqrt-pow192.4%
metadata-eval92.4%
unpow-192.4%
Applied egg-rr92.4%
/-rgt-identity92.4%
associate-/l/92.3%
un-div-inv92.4%
*-commutative92.4%
associate-*l*100.0%
Applied egg-rr100.0%
Final simplification96.4%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 0.019) (/ (/ -1.0 y_m) (- x)) (/ 1.0 (* z (* y_m (* z x)))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.019) {
tmp = (-1.0 / y_m) / -x;
} else {
tmp = 1.0 / (z * (y_m * (z * x)));
}
return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 0.019d0) then
tmp = ((-1.0d0) / y_m) / -x
else
tmp = 1.0d0 / (z * (y_m * (z * x)))
end if
code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.019) {
tmp = (-1.0 / y_m) / -x;
} else {
tmp = 1.0 / (z * (y_m * (z * x)));
}
return y_s * tmp;
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if z <= 0.019: tmp = (-1.0 / y_m) / -x else: tmp = 1.0 / (z * (y_m * (z * x))) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 0.019) tmp = Float64(Float64(-1.0 / y_m) / Float64(-x)); else tmp = Float64(1.0 / Float64(z * Float64(y_m * Float64(z * x)))); end return Float64(y_s * tmp) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (z <= 0.019) tmp = (-1.0 / y_m) / -x; else tmp = 1.0 / (z * (y_m * (z * x))); end tmp_2 = y_s * tmp; end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 0.019], N[(N[(-1.0 / y$95$m), $MachinePrecision] / (-x)), $MachinePrecision], N[(1.0 / N[(z * N[(y$95$m * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 0.019:\\
\;\;\;\;\frac{\frac{-1}{y\_m}}{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(y\_m \cdot \left(z \cdot x\right)\right)}\\
\end{array}
\end{array}
if z < 0.0189999999999999995Initial program 94.0%
associate-/l/93.7%
metadata-eval93.7%
associate-*r/93.7%
associate-/l/94.0%
associate-*r/94.0%
associate-/l*93.7%
associate-/r/93.7%
/-rgt-identity93.7%
associate-*l*93.3%
*-commutative93.3%
sqr-neg93.3%
+-commutative93.3%
sqr-neg93.3%
fma-def93.3%
Simplified93.3%
associate-/r*93.8%
div-inv93.8%
Applied egg-rr93.8%
Taylor expanded in z around 0 67.4%
un-div-inv67.5%
frac-2neg67.5%
neg-mul-167.5%
un-div-inv67.5%
Applied egg-rr67.5%
if 0.0189999999999999995 < z Initial program 90.4%
associate-/l/90.3%
metadata-eval90.3%
associate-*r/90.3%
associate-/l/90.4%
associate-*r/90.4%
associate-/l*90.3%
associate-/r/90.3%
/-rgt-identity90.3%
associate-*l*85.7%
*-commutative85.7%
sqr-neg85.7%
+-commutative85.7%
sqr-neg85.7%
fma-def85.7%
Simplified85.7%
Taylor expanded in z around inf 88.6%
associate-*r*88.3%
*-commutative88.3%
Simplified88.3%
expm1-log1p-u81.9%
expm1-udef55.0%
associate-/r*55.0%
pow-flip55.0%
metadata-eval55.0%
Applied egg-rr55.0%
expm1-def81.9%
expm1-log1p88.3%
Simplified88.3%
add-sqr-sqrt88.0%
*-un-lft-identity88.0%
times-frac88.2%
sqrt-pow188.2%
metadata-eval88.2%
unpow-188.2%
sqrt-pow188.4%
metadata-eval88.4%
unpow-188.4%
Applied egg-rr88.4%
/-rgt-identity88.4%
*-commutative88.4%
clear-num88.3%
frac-times88.4%
metadata-eval88.4%
div-inv88.4%
remove-double-div88.5%
*-commutative88.5%
associate-*l*95.4%
Applied egg-rr95.4%
Final simplification74.1%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 0.019) (/ (/ -1.0 y_m) (- x)) (/ (/ 1.0 z) (* y_m (* z x))))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.019) {
tmp = (-1.0 / y_m) / -x;
} else {
tmp = (1.0 / z) / (y_m * (z * x));
}
return y_s * tmp;
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 0.019d0) then
tmp = ((-1.0d0) / y_m) / -x
else
tmp = (1.0d0 / z) / (y_m * (z * x))
end if
code = y_s * tmp
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (z <= 0.019) {
tmp = (-1.0 / y_m) / -x;
} else {
tmp = (1.0 / z) / (y_m * (z * x));
}
return y_s * tmp;
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if z <= 0.019: tmp = (-1.0 / y_m) / -x else: tmp = (1.0 / z) / (y_m * (z * x)) return y_s * tmp
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (z <= 0.019) tmp = Float64(Float64(-1.0 / y_m) / Float64(-x)); else tmp = Float64(Float64(1.0 / z) / Float64(y_m * Float64(z * x))); end return Float64(y_s * tmp) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (z <= 0.019) tmp = (-1.0 / y_m) / -x; else tmp = (1.0 / z) / (y_m * (z * x)); end tmp_2 = y_s * tmp; end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 0.019], N[(N[(-1.0 / y$95$m), $MachinePrecision] / (-x)), $MachinePrecision], N[(N[(1.0 / z), $MachinePrecision] / N[(y$95$m * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 0.019:\\
\;\;\;\;\frac{\frac{-1}{y\_m}}{-x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z}}{y\_m \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if z < 0.0189999999999999995Initial program 94.0%
associate-/l/93.7%
metadata-eval93.7%
associate-*r/93.7%
associate-/l/94.0%
associate-*r/94.0%
associate-/l*93.7%
associate-/r/93.7%
/-rgt-identity93.7%
associate-*l*93.3%
*-commutative93.3%
sqr-neg93.3%
+-commutative93.3%
sqr-neg93.3%
fma-def93.3%
Simplified93.3%
associate-/r*93.8%
div-inv93.8%
Applied egg-rr93.8%
Taylor expanded in z around 0 67.4%
un-div-inv67.5%
frac-2neg67.5%
neg-mul-167.5%
un-div-inv67.5%
Applied egg-rr67.5%
if 0.0189999999999999995 < z Initial program 90.4%
associate-/l/90.3%
metadata-eval90.3%
associate-*r/90.3%
associate-/l/90.4%
associate-*r/90.4%
associate-/l*90.3%
associate-/r/90.3%
/-rgt-identity90.3%
associate-*l*85.7%
*-commutative85.7%
sqr-neg85.7%
+-commutative85.7%
sqr-neg85.7%
fma-def85.7%
Simplified85.7%
Taylor expanded in z around inf 88.6%
associate-*r*88.3%
*-commutative88.3%
Simplified88.3%
expm1-log1p-u81.9%
expm1-udef55.0%
associate-/r*55.0%
pow-flip55.0%
metadata-eval55.0%
Applied egg-rr55.0%
expm1-def81.9%
expm1-log1p88.3%
Simplified88.3%
add-sqr-sqrt88.0%
*-un-lft-identity88.0%
times-frac88.2%
sqrt-pow188.2%
metadata-eval88.2%
unpow-188.2%
sqrt-pow188.4%
metadata-eval88.4%
unpow-188.4%
Applied egg-rr88.4%
/-rgt-identity88.4%
associate-/l/88.4%
un-div-inv88.5%
*-commutative88.5%
associate-*l*95.5%
Applied egg-rr95.5%
Final simplification74.1%
y_m = (fabs.f64 y) y_s = (copysign.f64 1 y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (/ 1.0 (* y_m x))))
y_m = fabs(y);
y_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * (1.0 / (y_m * x));
}
y_m = abs(y)
y_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (1.0d0 / (y_m * x))
end function
y_m = Math.abs(y);
y_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (1.0 / (y_m * x));
}
y_m = math.fabs(y) y_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * (1.0 / (y_m * x))
y_m = abs(y) y_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(1.0 / Float64(y_m * x))) end
y_m = abs(y); y_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (1.0 / (y_m * x)); end
y_m = N[Abs[y], $MachinePrecision]
y_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(1.0 / N[(y$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
y_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \frac{1}{y\_m \cdot x}
\end{array}
Initial program 93.2%
associate-/l/92.9%
metadata-eval92.9%
associate-*r/92.9%
associate-/l/93.2%
associate-*r/93.2%
associate-/l*92.9%
associate-/r/92.9%
/-rgt-identity92.9%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-def91.5%
Simplified91.5%
Taylor expanded in z around 0 55.1%
Final simplification55.1%
(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 2024026
(FPCore (x y z)
:name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(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)))))