
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return (1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return (1.0 / Math.sqrt(k)) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
}
def code(k, n): return (1.0 / math.sqrt(k)) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
function code(k, n) return Float64(Float64(1.0 / sqrt(k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (1.0 / sqrt(k)) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return (1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return (1.0 / Math.sqrt(k)) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
}
def code(k, n): return (1.0 / math.sqrt(k)) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
function code(k, n) return Float64(Float64(1.0 / sqrt(k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (1.0 / sqrt(k)) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
(FPCore (k n) :precision binary64 (let* ((t_0 (* PI (* n 2.0)))) (* (pow k -0.5) (/ (sqrt t_0) (pow t_0 (* k 0.5))))))
double code(double k, double n) {
double t_0 = ((double) M_PI) * (n * 2.0);
return pow(k, -0.5) * (sqrt(t_0) / pow(t_0, (k * 0.5)));
}
public static double code(double k, double n) {
double t_0 = Math.PI * (n * 2.0);
return Math.pow(k, -0.5) * (Math.sqrt(t_0) / Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = math.pi * (n * 2.0) return math.pow(k, -0.5) * (math.sqrt(t_0) / math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(pi * Float64(n * 2.0)) return Float64((k ^ -0.5) * Float64(sqrt(t_0) / (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = pi * (n * 2.0); tmp = (k ^ -0.5) * (sqrt(t_0) / (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Power[k, -0.5], $MachinePrecision] * N[(N[Sqrt[t$95$0], $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(n \cdot 2\right)\\
{k}^{-0.5} \cdot \frac{\sqrt{t_0}}{{t_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.3%
div-sub99.3%
metadata-eval99.3%
pow-sub99.6%
pow1/299.6%
associate-*l*99.6%
associate-*l*99.6%
div-inv99.6%
metadata-eval99.6%
Applied egg-rr99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
*-commutative99.6%
Simplified99.6%
expm1-log1p-u96.4%
expm1-udef74.2%
inv-pow74.2%
sqrt-pow274.2%
metadata-eval74.2%
Applied egg-rr74.2%
expm1-def96.4%
expm1-log1p99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 2.4e-18) (/ (sqrt (* n (* 2.0 PI))) (sqrt k)) (/ 1.0 (sqrt (/ k (pow (* PI (* n 2.0)) (- 1.0 k)))))))
double code(double k, double n) {
double tmp;
if (k <= 2.4e-18) {
tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
} else {
tmp = 1.0 / sqrt((k / pow((((double) M_PI) * (n * 2.0)), (1.0 - k))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.4e-18) {
tmp = Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
} else {
tmp = 1.0 / Math.sqrt((k / Math.pow((Math.PI * (n * 2.0)), (1.0 - k))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.4e-18: tmp = math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k) else: tmp = 1.0 / math.sqrt((k / math.pow((math.pi * (n * 2.0)), (1.0 - k)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.4e-18) tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)); else tmp = Float64(1.0 / sqrt(Float64(k / (Float64(pi * Float64(n * 2.0)) ^ Float64(1.0 - k))))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.4e-18) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); else tmp = 1.0 / sqrt((k / ((pi * (n * 2.0)) ^ (1.0 - k)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.4e-18], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Sqrt[N[(k / N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.4 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{k}{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}}}\\
\end{array}
\end{array}
if k < 2.39999999999999994e-18Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.4%
expm1-log1p-u93.8%
expm1-udef73.3%
Applied egg-rr43.7%
expm1-def64.2%
expm1-log1p66.9%
*-commutative66.9%
associate-*r*66.9%
*-commutative66.9%
Simplified66.9%
add-cbrt-cube53.8%
add-sqr-sqrt53.8%
*-commutative53.8%
*-commutative53.8%
Applied egg-rr53.8%
Simplified53.7%
Taylor expanded in k around 0 49.8%
*-commutative49.8%
exp-prod50.0%
+-commutative50.0%
mul-1-neg50.0%
unsub-neg50.0%
exp-diff50.2%
associate-*r*50.2%
*-commutative50.2%
associate-*r*50.2%
rem-exp-log50.5%
associate-*r*50.5%
*-commutative50.5%
rem-exp-log53.7%
Simplified53.7%
pow1/350.5%
pow-pow66.9%
metadata-eval66.9%
pow1/266.9%
sqrt-div99.4%
*-commutative99.4%
associate-*l*99.4%
Applied egg-rr99.4%
if 2.39999999999999994e-18 < k Initial program 99.4%
*-commutative99.4%
associate-*r*99.4%
associate-/r/99.4%
add-sqr-sqrt99.3%
sqrt-unprod99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
pow-prod-up99.4%
Applied egg-rr99.4%
Taylor expanded in n around 0 99.2%
distribute-lft-in99.2%
remove-double-neg99.2%
log-rec99.2%
mul-1-neg99.2%
distribute-lft-in99.2%
*-commutative99.2%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (/ (pow k -0.5) (pow (* 2.0 (* n PI)) (* -0.5 (- 1.0 k)))))
double code(double k, double n) {
return pow(k, -0.5) / pow((2.0 * (n * ((double) M_PI))), (-0.5 * (1.0 - k)));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) / Math.pow((2.0 * (n * Math.PI)), (-0.5 * (1.0 - k)));
}
def code(k, n): return math.pow(k, -0.5) / math.pow((2.0 * (n * math.pi)), (-0.5 * (1.0 - k)))
function code(k, n) return Float64((k ^ -0.5) / (Float64(2.0 * Float64(n * pi)) ^ Float64(-0.5 * Float64(1.0 - k)))) end
function tmp = code(k, n) tmp = (k ^ -0.5) / ((2.0 * (n * pi)) ^ (-0.5 * (1.0 - k))); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[N[(2.0 * N[(n * Pi), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(1.0 - k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{k}^{-0.5}}{{\left(2 \cdot \left(n \cdot \pi\right)\right)}^{\left(-0.5 \cdot \left(1 - k\right)\right)}}
\end{array}
Initial program 99.3%
*-commutative99.3%
associate-*r*99.3%
associate-/r/99.3%
add-sqr-sqrt99.1%
sqrt-unprod99.3%
associate-*r*99.3%
*-commutative99.3%
associate-*r*99.3%
*-commutative99.3%
pow-prod-up99.3%
Applied egg-rr99.3%
div-inv99.3%
pow1/299.3%
associate-*r*99.3%
*-commutative99.3%
associate-*r*99.3%
pow-flip99.4%
associate-*r*99.4%
*-commutative99.4%
*-commutative99.4%
metadata-eval99.4%
Applied egg-rr99.4%
associate-*r*99.4%
Simplified99.4%
expm1-log1p-u96.8%
expm1-udef86.7%
associate-/r*86.7%
pow1/286.7%
pow-flip86.7%
metadata-eval86.7%
pow-pow86.7%
associate-*l*86.7%
Applied egg-rr86.7%
expm1-def96.8%
expm1-log1p99.4%
*-commutative99.4%
associate-*r*99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (if (<= k 2.5e-18) (/ (sqrt (* n (* 2.0 PI))) (sqrt k)) (sqrt (/ (pow (* PI (* n 2.0)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 2.5e-18) {
tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
} else {
tmp = sqrt((pow((((double) M_PI) * (n * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.5e-18) {
tmp = Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
} else {
tmp = Math.sqrt((Math.pow((Math.PI * (n * 2.0)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.5e-18: tmp = math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k) else: tmp = math.sqrt((math.pow((math.pi * (n * 2.0)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.5e-18) tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)); else tmp = sqrt(Float64((Float64(pi * Float64(n * 2.0)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.5e-18) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); else tmp = sqrt((((pi * (n * 2.0)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.5e-18], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 - k), $MachinePrecision]], $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 2.50000000000000018e-18Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.4%
expm1-log1p-u93.8%
expm1-udef73.3%
Applied egg-rr43.7%
expm1-def64.2%
expm1-log1p66.9%
*-commutative66.9%
associate-*r*66.9%
*-commutative66.9%
Simplified66.9%
add-cbrt-cube53.8%
add-sqr-sqrt53.8%
*-commutative53.8%
*-commutative53.8%
Applied egg-rr53.8%
Simplified53.7%
Taylor expanded in k around 0 49.8%
*-commutative49.8%
exp-prod50.0%
+-commutative50.0%
mul-1-neg50.0%
unsub-neg50.0%
exp-diff50.2%
associate-*r*50.2%
*-commutative50.2%
associate-*r*50.2%
rem-exp-log50.5%
associate-*r*50.5%
*-commutative50.5%
rem-exp-log53.7%
Simplified53.7%
pow1/350.5%
pow-pow66.9%
metadata-eval66.9%
pow1/266.9%
sqrt-div99.4%
*-commutative99.4%
associate-*l*99.4%
Applied egg-rr99.4%
if 2.50000000000000018e-18 < k Initial program 99.4%
*-commutative99.4%
*-commutative99.4%
associate-*r*99.4%
div-inv99.4%
expm1-log1p-u99.3%
expm1-udef97.6%
Applied egg-rr97.6%
expm1-def99.3%
expm1-log1p99.4%
*-commutative99.4%
associate-*r*99.4%
*-commutative99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (/ (pow (* PI (* n 2.0)) (/ (- 1.0 k) 2.0)) (sqrt k)))
double code(double k, double n) {
return pow((((double) M_PI) * (n * 2.0)), ((1.0 - k) / 2.0)) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((Math.PI * (n * 2.0)), ((1.0 - k) / 2.0)) / Math.sqrt(k);
}
def code(k, n): return math.pow((math.pi * (n * 2.0)), ((1.0 - k) / 2.0)) / math.sqrt(k)
function code(k, n) return Float64((Float64(pi * Float64(n * 2.0)) ^ Float64(Float64(1.0 - k) / 2.0)) / sqrt(k)) end
function tmp = code(k, n) tmp = ((pi * (n * 2.0)) ^ ((1.0 - k) / 2.0)) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\pi \cdot \left(n \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.3%
associate-*l/99.4%
*-lft-identity99.4%
*-commutative99.4%
associate-*l*99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (/ (sqrt PI) (sqrt (/ k (+ n n)))))
double code(double k, double n) {
return sqrt(((double) M_PI)) / sqrt((k / (n + n)));
}
public static double code(double k, double n) {
return Math.sqrt(Math.PI) / Math.sqrt((k / (n + n)));
}
def code(k, n): return math.sqrt(math.pi) / math.sqrt((k / (n + n)))
function code(k, n) return Float64(sqrt(pi) / sqrt(Float64(k / Float64(n + n)))) end
function tmp = code(k, n) tmp = sqrt(pi) / sqrt((k / (n + n))); end
code[k_, n_] := N[(N[Sqrt[Pi], $MachinePrecision] / N[Sqrt[N[(k / N[(n + n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{\pi}}{\sqrt{\frac{k}{n + n}}}
\end{array}
Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.4%
expm1-log1p-u96.8%
expm1-udef86.7%
Applied egg-rr73.3%
expm1-def83.5%
expm1-log1p84.8%
*-commutative84.8%
associate-*r*84.8%
*-commutative84.8%
Simplified84.8%
add-cbrt-cube78.6%
add-sqr-sqrt78.5%
*-commutative78.5%
*-commutative78.5%
Applied egg-rr78.5%
Simplified78.5%
Taylor expanded in k around 0 26.3%
*-commutative26.3%
exp-prod26.4%
+-commutative26.4%
mul-1-neg26.4%
unsub-neg26.4%
exp-diff26.5%
associate-*r*26.5%
*-commutative26.5%
associate-*r*26.5%
rem-exp-log26.6%
associate-*r*26.6%
*-commutative26.6%
rem-exp-log28.0%
Simplified28.0%
pow1/326.6%
pow-pow33.7%
metadata-eval33.7%
pow1/233.7%
associate-/l*33.7%
sqrt-div35.0%
Applied egg-rr35.0%
*-commutative35.0%
rem-log-exp4.3%
log-pow4.3%
unpow24.3%
log-prod4.3%
rem-log-exp7.9%
rem-log-exp35.0%
Simplified35.0%
Final simplification35.0%
(FPCore (k n) :precision binary64 (/ (sqrt (* n (* 2.0 PI))) (sqrt k)))
double code(double k, double n) {
return sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
}
def code(k, n): return math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k)
function code(k, n) return Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)) end
function tmp = code(k, n) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); end
code[k_, n_] := N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}
\end{array}
Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.4%
expm1-log1p-u96.8%
expm1-udef86.7%
Applied egg-rr73.3%
expm1-def83.5%
expm1-log1p84.8%
*-commutative84.8%
associate-*r*84.8%
*-commutative84.8%
Simplified84.8%
add-cbrt-cube78.6%
add-sqr-sqrt78.5%
*-commutative78.5%
*-commutative78.5%
Applied egg-rr78.5%
Simplified78.5%
Taylor expanded in k around 0 26.3%
*-commutative26.3%
exp-prod26.4%
+-commutative26.4%
mul-1-neg26.4%
unsub-neg26.4%
exp-diff26.5%
associate-*r*26.5%
*-commutative26.5%
associate-*r*26.5%
rem-exp-log26.6%
associate-*r*26.6%
*-commutative26.6%
rem-exp-log28.0%
Simplified28.0%
pow1/326.6%
pow-pow33.7%
metadata-eval33.7%
pow1/233.7%
sqrt-div48.3%
*-commutative48.3%
associate-*l*48.3%
Applied egg-rr48.3%
Final simplification48.3%
(FPCore (k n) :precision binary64 (/ 1.0 (sqrt (/ k (* n (* 2.0 PI))))))
double code(double k, double n) {
return 1.0 / sqrt((k / (n * (2.0 * ((double) M_PI)))));
}
public static double code(double k, double n) {
return 1.0 / Math.sqrt((k / (n * (2.0 * Math.PI))));
}
def code(k, n): return 1.0 / math.sqrt((k / (n * (2.0 * math.pi))))
function code(k, n) return Float64(1.0 / sqrt(Float64(k / Float64(n * Float64(2.0 * pi))))) end
function tmp = code(k, n) tmp = 1.0 / sqrt((k / (n * (2.0 * pi)))); end
code[k_, n_] := N[(1.0 / N[Sqrt[N[(k / N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{\frac{k}{n \cdot \left(2 \cdot \pi\right)}}}
\end{array}
Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.4%
expm1-log1p-u96.8%
expm1-udef86.7%
Applied egg-rr73.3%
expm1-def83.5%
expm1-log1p84.8%
*-commutative84.8%
associate-*r*84.8%
*-commutative84.8%
Simplified84.8%
add-cbrt-cube78.6%
add-sqr-sqrt78.5%
*-commutative78.5%
*-commutative78.5%
Applied egg-rr78.5%
Simplified78.5%
Taylor expanded in k around 0 26.3%
*-commutative26.3%
exp-prod26.4%
+-commutative26.4%
mul-1-neg26.4%
unsub-neg26.4%
exp-diff26.5%
associate-*r*26.5%
*-commutative26.5%
associate-*r*26.5%
rem-exp-log26.6%
associate-*r*26.6%
*-commutative26.6%
rem-exp-log28.0%
Simplified28.0%
pow1/326.6%
pow-pow33.7%
metadata-eval33.7%
pow1/233.7%
clear-num33.7%
sqrt-div35.0%
metadata-eval35.0%
*-commutative35.0%
associate-*l*35.0%
Applied egg-rr35.0%
Final simplification35.0%
(FPCore (k n) :precision binary64 (sqrt (* (+ n n) (/ PI k))))
double code(double k, double n) {
return sqrt(((n + n) * (((double) M_PI) / k)));
}
public static double code(double k, double n) {
return Math.sqrt(((n + n) * (Math.PI / k)));
}
def code(k, n): return math.sqrt(((n + n) * (math.pi / k)))
function code(k, n) return sqrt(Float64(Float64(n + n) * Float64(pi / k))) end
function tmp = code(k, n) tmp = sqrt(((n + n) * (pi / k))); end
code[k_, n_] := N[Sqrt[N[(N[(n + n), $MachinePrecision] * N[(Pi / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\left(n + n\right) \cdot \frac{\pi}{k}}
\end{array}
Initial program 99.3%
*-commutative99.3%
*-commutative99.3%
associate-*r*99.3%
div-inv99.4%
expm1-log1p-u96.8%
expm1-udef86.7%
Applied egg-rr73.3%
expm1-def83.5%
expm1-log1p84.8%
*-commutative84.8%
associate-*r*84.8%
*-commutative84.8%
Simplified84.8%
add-cbrt-cube78.6%
add-sqr-sqrt78.5%
*-commutative78.5%
*-commutative78.5%
Applied egg-rr78.5%
Simplified78.5%
Taylor expanded in k around 0 26.3%
*-commutative26.3%
exp-prod26.4%
+-commutative26.4%
mul-1-neg26.4%
unsub-neg26.4%
exp-diff26.5%
associate-*r*26.5%
*-commutative26.5%
associate-*r*26.5%
rem-exp-log26.6%
associate-*r*26.6%
*-commutative26.6%
rem-exp-log28.0%
Simplified28.0%
expm1-log1p-u27.4%
expm1-udef25.9%
pow1/325.8%
pow-pow30.7%
metadata-eval30.7%
pow1/230.7%
associate-/l*30.7%
Applied egg-rr30.7%
expm1-def32.5%
expm1-log1p33.7%
associate-/r/33.7%
*-commutative33.7%
rem-log-exp4.3%
log-pow4.3%
unpow24.3%
log-prod4.3%
rem-log-exp7.9%
rem-log-exp33.7%
Simplified33.7%
Final simplification33.7%
herbie shell --seed 2023207
(FPCore (k n)
:name "Migdal et al, Equation (51)"
:precision binary64
(* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))