
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (1.0d0 / x) / (y * (1.0d0 + (z * z)))
end function
public static double code(double x, double y, double z) {
return (1.0 / x) / (y * (1.0 + (z * z)));
}
def code(x, y, z): return (1.0 / x) / (y * (1.0 + (z * z)))
function code(x, y, z) return Float64(Float64(1.0 / x) / Float64(y * Float64(1.0 + Float64(z * z)))) end
function tmp = code(x, y, z) tmp = (1.0 / x) / (y * (1.0 + (z * z))); end
code[x_, y_, z_] := N[(N[(1.0 / x), $MachinePrecision] / N[(y * N[(1.0 + N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\end{array}
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (let* ((t_0 (* (hypot 1.0 z) (sqrt y_m)))) (* y_s (* (/ 1.0 t_0) (/ (/ 1.0 x) t_0)))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = hypot(1.0, z) * sqrt(y_m);
return y_s * ((1.0 / t_0) * ((1.0 / x) / t_0));
}
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = Math.hypot(1.0, z) * Math.sqrt(y_m);
return y_s * ((1.0 / t_0) * ((1.0 / x) / t_0));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = math.hypot(1.0, z) * math.sqrt(y_m) return y_s * ((1.0 / t_0) * ((1.0 / x) / t_0))
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(hypot(1.0, z) * sqrt(y_m)) return Float64(y_s * Float64(Float64(1.0 / t_0) * Float64(Float64(1.0 / x) / t_0))) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) t_0 = hypot(1.0, z) * sqrt(y_m); tmp = y_s * ((1.0 / t_0) * ((1.0 / x) / t_0)); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y$95$m], $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(1, z\right) \cdot \sqrt{y\_m}\\
y\_s \cdot \left(\frac{1}{t\_0} \cdot \frac{\frac{1}{x}}{t\_0}\right)
\end{array}
\end{array}
Initial program 90.4%
associate-/l/90.1%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
*-commutative91.5%
associate-*r*90.1%
fma-undefine90.1%
+-commutative90.1%
associate-/l/90.4%
add-sqr-sqrt45.7%
*-un-lft-identity45.7%
times-frac45.7%
+-commutative45.7%
fma-undefine45.7%
*-commutative45.7%
sqrt-prod45.7%
fma-undefine45.7%
+-commutative45.7%
hypot-1-def45.7%
+-commutative45.7%
Applied egg-rr49.4%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) 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((x ^ -0.5) / Float64(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[Power[x, -0.5], $MachinePrecision] / N[(N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision] * N[Sqrt[y$95$m], $MachinePrecision]), $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{{x}^{-0.5}}{\mathsf{hypot}\left(1, z\right) \cdot \sqrt{y\_m}}\right)}^{2}
\end{array}
Initial program 90.4%
associate-/l/90.1%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
*-commutative91.5%
associate-*r*90.1%
fma-undefine90.1%
+-commutative90.1%
associate-/l/90.4%
add-sqr-sqrt59.2%
sqrt-div23.0%
inv-pow23.0%
sqrt-pow123.0%
metadata-eval23.0%
+-commutative23.0%
fma-undefine23.0%
*-commutative23.0%
sqrt-prod23.0%
fma-undefine23.0%
+-commutative23.0%
hypot-1-def23.0%
sqrt-div23.0%
Applied egg-rr25.2%
unpow225.2%
Simplified25.2%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (/ (* (/ (/ 1.0 x) (hypot 1.0 z)) (/ 1.0 (hypot 1.0 z))) 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 * ((((1.0 / x) / hypot(1.0, z)) * (1.0 / hypot(1.0, z))) / 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 * ((((1.0 / x) / Math.hypot(1.0, z)) * (1.0 / Math.hypot(1.0, z))) / 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 * ((((1.0 / x) / math.hypot(1.0, z)) * (1.0 / math.hypot(1.0, z))) / 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(Float64(Float64(1.0 / x) / hypot(1.0, z)) * Float64(1.0 / hypot(1.0, z))) / 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 * ((((1.0 / x) / hypot(1.0, z)) * (1.0 / hypot(1.0, z))) / 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[(N[(1.0 / x), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[1.0 ^ 2 + z ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \frac{\frac{\frac{1}{x}}{\mathsf{hypot}\left(1, z\right)} \cdot \frac{1}{\mathsf{hypot}\left(1, z\right)}}{y\_m}
\end{array}
Initial program 90.4%
associate-/l/90.1%
associate-*l*91.5%
*-commutative91.5%
sqr-neg91.5%
+-commutative91.5%
sqr-neg91.5%
fma-define91.5%
Simplified91.5%
*-commutative91.5%
associate-*r*90.1%
fma-undefine90.1%
+-commutative90.1%
associate-/l/90.4%
add-sqr-sqrt45.7%
*-un-lft-identity45.7%
times-frac45.7%
+-commutative45.7%
fma-undefine45.7%
*-commutative45.7%
sqrt-prod45.7%
fma-undefine45.7%
+-commutative45.7%
hypot-1-def45.7%
+-commutative45.7%
Applied egg-rr49.4%
*-commutative49.4%
associate-/r*49.0%
associate-/r*49.0%
frac-times47.5%
add-sqr-sqrt94.3%
Applied egg-rr94.3%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= (* z z) 1e+237)
(/ (/ 1.0 y_m) (* x (fma z z 1.0)))
(/ (* (/ 1.0 y_m) (/ 1.0 z)) (* 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 * z) <= 1e+237) {
tmp = (1.0 / y_m) / (x * fma(z, z, 1.0));
} else {
tmp = ((1.0 / y_m) * (1.0 / z)) / (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(z * z) <= 1e+237) tmp = Float64(Float64(1.0 / y_m) / Float64(x * fma(z, z, 1.0))); else tmp = Float64(Float64(Float64(1.0 / y_m) * Float64(1.0 / z)) / Float64(z * x)); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 1e+237], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(x * N[(z * z + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / y$95$m), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision] / N[(z * x), $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 \cdot z \leq 10^{+237}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x \cdot \mathsf{fma}\left(z, z, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m} \cdot \frac{1}{z}}{z \cdot x}\\
\end{array}
\end{array}
if (*.f64 z z) < 9.9999999999999994e236Initial program 97.5%
associate-/l/97.0%
associate-*l*98.6%
*-commutative98.6%
sqr-neg98.6%
+-commutative98.6%
sqr-neg98.6%
fma-define98.6%
Simplified98.6%
*-commutative98.6%
associate-*r*97.0%
fma-undefine97.0%
+-commutative97.0%
associate-/l/97.5%
add-sqr-sqrt50.8%
*-un-lft-identity50.8%
times-frac50.9%
+-commutative50.9%
fma-undefine50.9%
*-commutative50.9%
sqrt-prod50.9%
fma-undefine50.9%
+-commutative50.9%
hypot-1-def50.9%
+-commutative50.9%
Applied egg-rr51.9%
Taylor expanded in y around 0 97.0%
associate-*r*95.4%
*-commutative95.4%
+-commutative95.4%
unpow295.4%
fma-undefine95.4%
associate-*r*98.6%
associate-/r*98.7%
Simplified98.7%
if 9.9999999999999994e236 < (*.f64 z z) Initial program 73.6%
associate-/l/73.7%
associate-*l*75.0%
*-commutative75.0%
sqr-neg75.0%
+-commutative75.0%
sqr-neg75.0%
fma-define75.0%
Simplified75.0%
Taylor expanded in z around inf 73.7%
associate-/r*73.6%
associate-/r*77.1%
Simplified77.1%
*-un-lft-identity77.1%
unpow277.1%
times-frac94.7%
associate-/l/94.7%
associate-/r*94.7%
Applied egg-rr94.7%
associate-/r*97.1%
associate-*r/96.9%
*-commutative96.9%
Applied egg-rr96.9%
Final simplification98.2%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(let* ((t_0 (* y_m (+ 1.0 (* z z)))))
(*
y_s
(if (<= t_0 5e+306) (/ (/ 1.0 x) t_0) (/ (/ 1.0 y_m) (* z (* 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 <= 5e+306) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
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 <= 5d+306) then
tmp = (1.0d0 / x) / t_0
else
tmp = (1.0d0 / y_m) / (z * (z * x))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
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 <= 5e+306) {
tmp = (1.0 / x) / t_0;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = y_m * (1.0 + (z * z)) tmp = 0 if t_0 <= 5e+306: tmp = (1.0 / x) / t_0 else: tmp = (1.0 / y_m) / (z * (z * x)) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) 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 <= 5e+306) tmp = Float64(Float64(1.0 / x) / t_0); else tmp = Float64(Float64(1.0 / y_m) / Float64(z * Float64(z * x))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) t_0 = y_m * (1.0 + (z * z)); tmp = 0.0; if (t_0 <= 5e+306) tmp = (1.0 / x) / t_0; else tmp = (1.0 / y_m) / (z * (z * x)); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
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, 5e+306], N[(N[(1.0 / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\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 5 \cdot 10^{+306}:\\
\;\;\;\;\frac{\frac{1}{x}}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
\end{array}
if (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) < 4.99999999999999993e306Initial program 93.1%
if 4.99999999999999993e306 < (*.f64 y (+.f64 #s(literal 1 binary64) (*.f64 z z))) Initial program 75.6%
associate-/l/75.6%
associate-*l*82.9%
*-commutative82.9%
sqr-neg82.9%
+-commutative82.9%
sqr-neg82.9%
fma-define82.9%
Simplified82.9%
Taylor expanded in z around inf 75.6%
associate-/r*75.6%
associate-/r*82.8%
Simplified82.8%
*-un-lft-identity82.8%
unpow282.8%
times-frac94.8%
associate-/l/94.9%
associate-/r*94.8%
Applied egg-rr94.8%
*-commutative94.8%
associate-/r*97.4%
frac-times90.4%
associate-/r/90.4%
clear-num90.4%
*-commutative90.4%
Applied egg-rr90.4%
Final simplification92.7%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= (* z z) 0.01) (/ (/ 1.0 y_m) x) (/ (/ 1.0 y_m) (* z (* 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 * z) <= 0.01) {
tmp = (1.0 / y_m) / x;
} else {
tmp = (1.0 / y_m) / (z * (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 * z) <= 0.01d0) then
tmp = (1.0d0 / y_m) / x
else
tmp = (1.0d0 / y_m) / (z * (z * x))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if ((z * z) <= 0.01) {
tmp = (1.0 / y_m) / x;
} else {
tmp = (1.0 / y_m) / (z * (z * x));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if (z * z) <= 0.01: tmp = (1.0 / y_m) / x else: tmp = (1.0 / y_m) / (z * (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(z * z) <= 0.01) tmp = Float64(Float64(1.0 / y_m) / x); else tmp = Float64(Float64(1.0 / y_m) / Float64(z * Float64(z * x))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if ((z * z) <= 0.01) tmp = (1.0 / y_m) / x; else tmp = (1.0 / y_m) / (z * (z * x)); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[N[(z * z), $MachinePrecision], 0.01], N[(N[(1.0 / y$95$m), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / y$95$m), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;z \cdot z \leq 0.01:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{z \cdot \left(z \cdot x\right)}\\
\end{array}
\end{array}
if (*.f64 z z) < 0.0100000000000000002Initial program 99.6%
associate-/l/99.4%
associate-*l*99.5%
*-commutative99.5%
sqr-neg99.5%
+-commutative99.5%
sqr-neg99.5%
fma-define99.5%
Simplified99.5%
Taylor expanded in z around 0 98.5%
inv-pow98.5%
add-sqr-sqrt42.8%
unpow-prod-down42.7%
Applied egg-rr42.7%
pow-sqr42.8%
*-commutative42.8%
metadata-eval42.8%
Simplified42.8%
sqrt-pow298.5%
metadata-eval98.5%
inv-pow98.5%
*-commutative98.5%
associate-/r*98.6%
Applied egg-rr98.6%
if 0.0100000000000000002 < (*.f64 z z) Initial program 82.4%
associate-/l/81.9%
associate-*l*84.7%
*-commutative84.7%
sqr-neg84.7%
+-commutative84.7%
sqr-neg84.7%
fma-define84.7%
Simplified84.7%
Taylor expanded in z around inf 81.2%
associate-/r*81.7%
associate-/r*81.6%
Simplified81.6%
*-un-lft-identity81.6%
unpow281.6%
times-frac91.3%
associate-/l/91.3%
associate-/r*91.3%
Applied egg-rr91.3%
*-commutative91.3%
associate-/r*94.3%
frac-times89.1%
associate-/r/89.1%
clear-num89.1%
*-commutative89.1%
Applied egg-rr89.1%
Final simplification93.5%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 1.0) (/ (/ 1.0 y_m) x) (/ 1.0 (* z (* z (* 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) {
double tmp;
if (z <= 1.0) {
tmp = (1.0 / y_m) / x;
} else {
tmp = 1.0 / (z * (z * (y_m * 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 <= 1.0d0) then
tmp = (1.0d0 / y_m) / x
else
tmp = 1.0d0 / (z * (z * (y_m * 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 <= 1.0) {
tmp = (1.0 / y_m) / x;
} else {
tmp = 1.0 / (z * (z * (y_m * 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 <= 1.0: tmp = (1.0 / y_m) / x else: tmp = 1.0 / (z * (z * (y_m * 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 <= 1.0) tmp = Float64(Float64(1.0 / y_m) / x); else tmp = Float64(1.0 / Float64(z * Float64(z * Float64(y_m * 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 <= 1.0) tmp = (1.0 / y_m) / x; else tmp = 1.0 / (z * (z * (y_m * 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, 1.0], N[(N[(1.0 / y$95$m), $MachinePrecision] / x), $MachinePrecision], N[(1.0 / N[(z * N[(z * N[(y$95$m * 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 1:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{z \cdot \left(z \cdot \left(y\_m \cdot x\right)\right)}\\
\end{array}
\end{array}
if z < 1Initial program 93.0%
associate-/l/92.5%
associate-*l*94.5%
*-commutative94.5%
sqr-neg94.5%
+-commutative94.5%
sqr-neg94.5%
fma-define94.5%
Simplified94.5%
Taylor expanded in z around 0 68.7%
inv-pow68.7%
add-sqr-sqrt29.0%
unpow-prod-down29.0%
Applied egg-rr29.0%
pow-sqr29.0%
*-commutative29.0%
metadata-eval29.0%
Simplified29.0%
sqrt-pow268.7%
metadata-eval68.7%
inv-pow68.7%
*-commutative68.7%
associate-/r*68.0%
Applied egg-rr68.0%
if 1 < z Initial program 82.9%
associate-/l/82.8%
associate-*l*82.8%
*-commutative82.8%
sqr-neg82.8%
+-commutative82.8%
sqr-neg82.8%
fma-define82.8%
Simplified82.8%
Taylor expanded in z around inf 82.4%
associate-/r*82.5%
associate-/r*80.9%
Simplified80.9%
*-un-lft-identity80.9%
unpow280.9%
times-frac93.4%
associate-/l/93.3%
associate-/r*93.3%
Applied egg-rr93.3%
*-commutative93.3%
clear-num93.4%
frac-times92.1%
metadata-eval92.1%
div-inv92.1%
associate-/r*92.1%
clear-num92.2%
/-rgt-identity92.2%
Applied egg-rr92.2%
Final simplification74.1%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (if (<= z 1.0) (/ (/ 1.0 y_m) x) (/ (/ 1.0 (* z x)) y_m))))
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 <= 1.0) {
tmp = (1.0 / y_m) / x;
} else {
tmp = (1.0 / (z * x)) / y_m;
}
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 <= 1.0d0) then
tmp = (1.0d0 / y_m) / x
else
tmp = (1.0d0 / (z * x)) / y_m
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 <= 1.0) {
tmp = (1.0 / y_m) / x;
} else {
tmp = (1.0 / (z * x)) / y_m;
}
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 <= 1.0: tmp = (1.0 / y_m) / x else: tmp = (1.0 / (z * x)) / y_m 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 <= 1.0) tmp = Float64(Float64(1.0 / y_m) / x); else tmp = Float64(Float64(1.0 / Float64(z * x)) / y_m); 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 <= 1.0) tmp = (1.0 / y_m) / x; else tmp = (1.0 / (z * x)) / y_m; end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[z, 1.0], N[(N[(1.0 / y$95$m), $MachinePrecision] / x), $MachinePrecision], N[(N[(1.0 / N[(z * x), $MachinePrecision]), $MachinePrecision] / y$95$m), $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 1:\\
\;\;\;\;\frac{\frac{1}{y\_m}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{z \cdot x}}{y\_m}\\
\end{array}
\end{array}
if z < 1Initial program 93.0%
associate-/l/92.5%
associate-*l*94.5%
*-commutative94.5%
sqr-neg94.5%
+-commutative94.5%
sqr-neg94.5%
fma-define94.5%
Simplified94.5%
Taylor expanded in z around 0 68.7%
inv-pow68.7%
add-sqr-sqrt29.0%
unpow-prod-down29.0%
Applied egg-rr29.0%
pow-sqr29.0%
*-commutative29.0%
metadata-eval29.0%
Simplified29.0%
sqrt-pow268.7%
metadata-eval68.7%
inv-pow68.7%
*-commutative68.7%
associate-/r*68.0%
Applied egg-rr68.0%
if 1 < z Initial program 82.9%
associate-/l/82.8%
associate-*l*82.8%
*-commutative82.8%
sqr-neg82.8%
+-commutative82.8%
sqr-neg82.8%
fma-define82.8%
Simplified82.8%
*-commutative82.8%
associate-*r*82.8%
fma-undefine82.8%
+-commutative82.8%
associate-/l/82.9%
add-sqr-sqrt44.7%
*-un-lft-identity44.7%
times-frac44.7%
+-commutative44.7%
fma-undefine44.7%
*-commutative44.7%
sqrt-prod44.6%
fma-undefine44.6%
+-commutative44.6%
hypot-1-def44.6%
+-commutative44.6%
Applied egg-rr50.6%
*-commutative50.6%
associate-/r*49.2%
associate-/r*49.1%
frac-times47.7%
add-sqr-sqrt88.5%
Applied egg-rr88.5%
Taylor expanded in z around inf 88.2%
Taylor expanded in z around 0 43.5%
Final simplification61.8%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) 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 90.4%
associate-/l/90.1%
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 57.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 2024129
(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)))))