
(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 12 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 (* 2.0 (* PI n)))) (/ (* (pow k -0.5) (sqrt t_0)) (pow t_0 (* k 0.5)))))
double code(double k, double n) {
double t_0 = 2.0 * (((double) M_PI) * n);
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 = 2.0 * (Math.PI * n);
return (Math.pow(k, -0.5) * Math.sqrt(t_0)) / Math.pow(t_0, (k * 0.5));
}
def code(k, n): t_0 = 2.0 * (math.pi * n) return (math.pow(k, -0.5) * math.sqrt(t_0)) / math.pow(t_0, (k * 0.5))
function code(k, n) t_0 = Float64(2.0 * Float64(pi * n)) return Float64(Float64((k ^ -0.5) * sqrt(t_0)) / (t_0 ^ Float64(k * 0.5))) end
function tmp = code(k, n) t_0 = 2.0 * (pi * n); tmp = ((k ^ -0.5) * sqrt(t_0)) / (t_0 ^ (k * 0.5)); end
code[k_, n_] := Block[{t$95$0 = N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Power[k, -0.5], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(\pi \cdot n\right)\\
\frac{{k}^{-0.5} \cdot \sqrt{t\_0}}{{t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.4%
associate-*r*99.4%
div-sub99.4%
metadata-eval99.4%
pow-div99.6%
pow1/299.6%
associate-*r/99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* n (* 2.0 PI)))) (* (sqrt t_0) (/ (pow k -0.5) (pow t_0 (* k 0.5))))))
double code(double k, double n) {
double t_0 = n * (2.0 * ((double) M_PI));
return sqrt(t_0) * (pow(k, -0.5) / pow(t_0, (k * 0.5)));
}
public static double code(double k, double n) {
double t_0 = n * (2.0 * Math.PI);
return Math.sqrt(t_0) * (Math.pow(k, -0.5) / Math.pow(t_0, (k * 0.5)));
}
def code(k, n): t_0 = n * (2.0 * math.pi) return math.sqrt(t_0) * (math.pow(k, -0.5) / math.pow(t_0, (k * 0.5)))
function code(k, n) t_0 = Float64(n * Float64(2.0 * pi)) return Float64(sqrt(t_0) * Float64((k ^ -0.5) / (t_0 ^ Float64(k * 0.5)))) end
function tmp = code(k, n) t_0 = n * (2.0 * pi); tmp = sqrt(t_0) * ((k ^ -0.5) / (t_0 ^ (k * 0.5))); end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] * N[(N[Power[k, -0.5], $MachinePrecision] / N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(2 \cdot \pi\right)\\
\sqrt{t\_0} \cdot \frac{{k}^{-0.5}}{{t\_0}^{\left(k \cdot 0.5\right)}}
\end{array}
\end{array}
Initial program 99.4%
associate-*r*99.4%
div-sub99.4%
metadata-eval99.4%
pow-div99.6%
pow1/299.6%
associate-*r/99.6%
pow1/299.6%
pow-flip99.7%
metadata-eval99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
*-commutative99.7%
associate-/l*99.7%
associate-*r*99.7%
*-commutative99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* n (* 2.0 PI)))) (/ (sqrt t_0) (* (pow t_0 (* k 0.5)) (sqrt k)))))
double code(double k, double n) {
double t_0 = n * (2.0 * ((double) M_PI));
return sqrt(t_0) / (pow(t_0, (k * 0.5)) * sqrt(k));
}
public static double code(double k, double n) {
double t_0 = n * (2.0 * Math.PI);
return Math.sqrt(t_0) / (Math.pow(t_0, (k * 0.5)) * Math.sqrt(k));
}
def code(k, n): t_0 = n * (2.0 * math.pi) return math.sqrt(t_0) / (math.pow(t_0, (k * 0.5)) * math.sqrt(k))
function code(k, n) t_0 = Float64(n * Float64(2.0 * pi)) return Float64(sqrt(t_0) / Float64((t_0 ^ Float64(k * 0.5)) * sqrt(k))) end
function tmp = code(k, n) t_0 = n * (2.0 * pi); tmp = sqrt(t_0) / ((t_0 ^ (k * 0.5)) * sqrt(k)); end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[t$95$0], $MachinePrecision] / N[(N[Power[t$95$0, N[(k * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(2 \cdot \pi\right)\\
\frac{\sqrt{t\_0}}{{t\_0}^{\left(k \cdot 0.5\right)} \cdot \sqrt{k}}
\end{array}
\end{array}
Initial program 99.4%
associate-*l/99.4%
*-un-lft-identity99.4%
associate-*r*99.4%
div-sub99.4%
metadata-eval99.4%
pow-div99.7%
pow1/299.7%
associate-/l/99.7%
div-inv99.7%
metadata-eval99.7%
Applied egg-rr99.7%
associate-/l/99.7%
rem-square-sqrt99.7%
rem-sqrt-square99.7%
fabs-neg99.7%
neg-mul-199.7%
rem-square-sqrt0.0%
unpow1/20.0%
metadata-eval0.0%
pow-sqr0.0%
unswap-sqr0.0%
fabs-sqr0.0%
unswap-sqr0.0%
rem-square-sqrt26.8%
pow-sqr26.8%
metadata-eval26.8%
unpow1/226.8%
neg-mul-126.8%
associate-/r*26.8%
Simplified99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (if (<= k 2.5e-46) (/ (sqrt (* n (* 2.0 PI))) (sqrt k)) (sqrt (/ (pow (* 2.0 (* PI n)) (- 1.0 k)) k))))
double code(double k, double n) {
double tmp;
if (k <= 2.5e-46) {
tmp = sqrt((n * (2.0 * ((double) M_PI)))) / sqrt(k);
} else {
tmp = sqrt((pow((2.0 * (((double) M_PI) * n)), (1.0 - k)) / k));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 2.5e-46) {
tmp = Math.sqrt((n * (2.0 * Math.PI))) / Math.sqrt(k);
} else {
tmp = Math.sqrt((Math.pow((2.0 * (Math.PI * n)), (1.0 - k)) / k));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 2.5e-46: tmp = math.sqrt((n * (2.0 * math.pi))) / math.sqrt(k) else: tmp = math.sqrt((math.pow((2.0 * (math.pi * n)), (1.0 - k)) / k)) return tmp
function code(k, n) tmp = 0.0 if (k <= 2.5e-46) tmp = Float64(sqrt(Float64(n * Float64(2.0 * pi))) / sqrt(k)); else tmp = sqrt(Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(1.0 - k)) / k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 2.5e-46) tmp = sqrt((n * (2.0 * pi))) / sqrt(k); else tmp = sqrt((((2.0 * (pi * n)) ^ (1.0 - k)) / k)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 2.5e-46], N[(N[Sqrt[N[(n * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[Power[N[(2.0 * N[(Pi * n), $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^{-46}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(2 \cdot \pi\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 2.49999999999999996e-46Initial program 99.3%
Taylor expanded in k around 0 71.2%
*-commutative71.2%
associate-/l*71.2%
Simplified71.2%
pow171.2%
sqrt-unprod71.5%
clear-num71.4%
un-div-inv71.4%
Applied egg-rr71.4%
unpow171.4%
associate-/r/71.4%
associate-*l/71.4%
associate-/l*71.5%
Simplified71.5%
associate-*r/71.4%
*-commutative71.4%
Applied egg-rr71.4%
associate-*r/71.4%
*-commutative71.4%
sqrt-div99.4%
*-commutative99.4%
associate-*l*99.4%
Applied egg-rr99.4%
if 2.49999999999999996e-46 < k Initial program 99.4%
associate-*l/99.4%
*-lft-identity99.4%
associate-*l*99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
div-inv99.4%
div-inv99.4%
metadata-eval99.4%
pow1/299.4%
pow-flip99.4%
metadata-eval99.4%
Applied egg-rr99.4%
add-sqr-sqrt99.4%
sqrt-unprod99.4%
swap-sqr99.4%
Applied egg-rr99.4%
associate-*r/99.4%
*-rgt-identity99.4%
associate-*r*99.4%
*-commutative99.4%
associate-*r*99.4%
distribute-lft-in99.4%
*-commutative99.4%
metadata-eval99.4%
associate-*r*99.4%
metadata-eval99.4%
neg-mul-199.4%
Simplified99.4%
Final simplification99.4%
(FPCore (k n) :precision binary64 (if (<= k 2e+92) (* (sqrt (* 2.0 n)) (sqrt (/ PI k))) (sqrt (* 2.0 (+ -1.0 (fma n (/ PI k) 1.0))))))
double code(double k, double n) {
double tmp;
if (k <= 2e+92) {
tmp = sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
} else {
tmp = sqrt((2.0 * (-1.0 + fma(n, (((double) M_PI) / k), 1.0))));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 2e+92) tmp = Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))); else tmp = sqrt(Float64(2.0 * Float64(-1.0 + fma(n, Float64(pi / k), 1.0)))); end return tmp end
code[k_, n_] := If[LessEqual[k, 2e+92], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(2.0 * N[(-1.0 + N[(n * N[(Pi / k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2 \cdot 10^{+92}:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot \left(-1 + \mathsf{fma}\left(n, \frac{\pi}{k}, 1\right)\right)}\\
\end{array}
\end{array}
if k < 2.0000000000000001e92Initial program 99.0%
Taylor expanded in k around 0 55.3%
*-commutative55.3%
associate-/l*55.3%
Simplified55.3%
pow155.3%
sqrt-unprod55.5%
clear-num55.4%
un-div-inv55.4%
Applied egg-rr55.4%
unpow155.4%
associate-/r/55.4%
associate-*l/55.4%
associate-/l*55.5%
Simplified55.5%
pow1/255.5%
associate-*r*55.5%
unpow-prod-down72.8%
pow1/272.8%
Applied egg-rr72.8%
unpow1/272.8%
Simplified72.8%
if 2.0000000000000001e92 < k Initial program 100.0%
Taylor expanded in k around 0 2.7%
*-commutative2.7%
associate-/l*2.7%
Simplified2.7%
pow12.7%
sqrt-unprod2.7%
clear-num2.7%
un-div-inv2.7%
Applied egg-rr2.7%
unpow12.7%
associate-/r/2.7%
associate-*l/2.7%
associate-/l*2.7%
Simplified2.7%
expm1-log1p-u2.7%
expm1-undefine32.4%
clear-num32.4%
un-div-inv32.4%
Applied egg-rr32.4%
sub-neg32.4%
metadata-eval32.4%
+-commutative32.4%
log1p-undefine32.4%
rem-exp-log32.4%
+-commutative32.4%
associate-/r/32.4%
associate-*l/32.4%
associate-/l*32.4%
fma-define32.4%
Simplified32.4%
(FPCore (k n) :precision binary64 (if (<= k 3.5e+239) (* (sqrt (* 2.0 n)) (sqrt (/ PI k))) (cbrt (pow (* n (* 2.0 (/ PI k))) 1.5))))
double code(double k, double n) {
double tmp;
if (k <= 3.5e+239) {
tmp = sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
} else {
tmp = cbrt(pow((n * (2.0 * (((double) M_PI) / k))), 1.5));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 3.5e+239) {
tmp = Math.sqrt((2.0 * n)) * Math.sqrt((Math.PI / k));
} else {
tmp = Math.cbrt(Math.pow((n * (2.0 * (Math.PI / k))), 1.5));
}
return tmp;
}
function code(k, n) tmp = 0.0 if (k <= 3.5e+239) tmp = Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))); else tmp = cbrt((Float64(n * Float64(2.0 * Float64(pi / k))) ^ 1.5)); end return tmp end
code[k_, n_] := If[LessEqual[k, 3.5e+239], N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Power[N[Power[N[(n * N[(2.0 * N[(Pi / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 3.5 \cdot 10^{+239}:\\
\;\;\;\;\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(n \cdot \left(2 \cdot \frac{\pi}{k}\right)\right)}^{1.5}}\\
\end{array}
\end{array}
if k < 3.5000000000000001e239Initial program 99.3%
Taylor expanded in k around 0 43.4%
*-commutative43.4%
associate-/l*43.4%
Simplified43.4%
pow143.4%
sqrt-unprod43.5%
clear-num43.5%
un-div-inv43.5%
Applied egg-rr43.5%
unpow143.5%
associate-/r/43.5%
associate-*l/43.5%
associate-/l*43.5%
Simplified43.5%
pow1/243.5%
associate-*r*43.5%
unpow-prod-down57.0%
pow1/257.0%
Applied egg-rr57.0%
unpow1/257.0%
Simplified57.0%
if 3.5000000000000001e239 < k Initial program 100.0%
Taylor expanded in k around 0 2.9%
*-commutative2.9%
associate-/l*2.9%
Simplified2.9%
pow12.9%
sqrt-unprod2.9%
clear-num2.9%
un-div-inv2.9%
Applied egg-rr2.9%
unpow12.9%
associate-/r/2.9%
associate-*l/2.9%
associate-/l*2.9%
Simplified2.9%
add-cbrt-cube16.9%
pow1/316.9%
add-sqr-sqrt16.9%
pow116.9%
pow1/216.9%
pow-prod-up16.9%
metadata-eval16.9%
Applied egg-rr16.9%
unpow1/316.9%
*-commutative16.9%
associate-*l*16.9%
Simplified16.9%
Final simplification51.7%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* 2.0 (* PI n)) (- 0.5 (* k 0.5)))))
double code(double k, double n) {
return pow(k, -0.5) * pow((2.0 * (((double) M_PI) * n)), (0.5 - (k * 0.5)));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow((2.0 * (Math.PI * n)), (0.5 - (k * 0.5)));
}
def code(k, n): return math.pow(k, -0.5) * math.pow((2.0 * (math.pi * n)), (0.5 - (k * 0.5)))
function code(k, n) return Float64((k ^ -0.5) * (Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 - Float64(k * 0.5)))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * ((2.0 * (pi * n)) ^ (0.5 - (k * 0.5))); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 - k \cdot 0.5\right)}
\end{array}
Initial program 99.4%
associate-*l/99.4%
*-lft-identity99.4%
associate-*l*99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
div-inv99.4%
div-inv99.4%
metadata-eval99.4%
pow1/299.4%
pow-flip99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ (pow (* 2.0 (* PI n)) (- 0.5 (/ k 2.0))) (sqrt k)))
double code(double k, double n) {
return pow((2.0 * (((double) M_PI) * n)), (0.5 - (k / 2.0))) / sqrt(k);
}
public static double code(double k, double n) {
return Math.pow((2.0 * (Math.PI * n)), (0.5 - (k / 2.0))) / Math.sqrt(k);
}
def code(k, n): return math.pow((2.0 * (math.pi * n)), (0.5 - (k / 2.0))) / math.sqrt(k)
function code(k, n) return Float64((Float64(2.0 * Float64(pi * n)) ^ Float64(0.5 - Float64(k / 2.0))) / sqrt(k)) end
function tmp = code(k, n) tmp = ((2.0 * (pi * n)) ^ (0.5 - (k / 2.0))) / sqrt(k); end
code[k_, n_] := N[(N[Power[N[(2.0 * N[(Pi * n), $MachinePrecision]), $MachinePrecision], N[(0.5 - N[(k / 2.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(2 \cdot \left(\pi \cdot n\right)\right)}^{\left(0.5 - \frac{k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.4%
associate-*l/99.4%
*-lft-identity99.4%
associate-*l*99.4%
div-sub99.4%
metadata-eval99.4%
Simplified99.4%
(FPCore (k n) :precision binary64 (* (sqrt (* 2.0 n)) (sqrt (/ PI k))))
double code(double k, double n) {
return sqrt((2.0 * n)) * sqrt((((double) M_PI) / k));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * n)) * Math.sqrt((Math.PI / k));
}
def code(k, n): return math.sqrt((2.0 * n)) * math.sqrt((math.pi / k))
function code(k, n) return Float64(sqrt(Float64(2.0 * n)) * sqrt(Float64(pi / k))) end
function tmp = code(k, n) tmp = sqrt((2.0 * n)) * sqrt((pi / k)); end
code[k_, n_] := N[(N[Sqrt[N[(2.0 * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot n} \cdot \sqrt{\frac{\pi}{k}}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 38.0%
*-commutative38.0%
associate-/l*38.0%
Simplified38.0%
pow138.0%
sqrt-unprod38.1%
clear-num38.1%
un-div-inv38.1%
Applied egg-rr38.1%
unpow138.1%
associate-/r/38.1%
associate-*l/38.1%
associate-/l*38.1%
Simplified38.1%
pow1/238.1%
associate-*r*38.1%
unpow-prod-down49.8%
pow1/249.8%
Applied egg-rr49.8%
unpow1/249.8%
Simplified49.8%
(FPCore (k n) :precision binary64 (pow (* (/ 0.5 n) (/ k PI)) -0.5))
double code(double k, double n) {
return pow(((0.5 / n) * (k / ((double) M_PI))), -0.5);
}
public static double code(double k, double n) {
return Math.pow(((0.5 / n) * (k / Math.PI)), -0.5);
}
def code(k, n): return math.pow(((0.5 / n) * (k / math.pi)), -0.5)
function code(k, n) return Float64(Float64(0.5 / n) * Float64(k / pi)) ^ -0.5 end
function tmp = code(k, n) tmp = ((0.5 / n) * (k / pi)) ^ -0.5; end
code[k_, n_] := N[Power[N[(N[(0.5 / n), $MachinePrecision] * N[(k / Pi), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{0.5}{n} \cdot \frac{k}{\pi}\right)}^{-0.5}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 38.0%
*-commutative38.0%
associate-/l*38.0%
Simplified38.0%
pow138.0%
sqrt-unprod38.1%
clear-num38.1%
un-div-inv38.1%
Applied egg-rr38.1%
unpow138.1%
associate-/r/38.1%
associate-*l/38.1%
associate-/l*38.1%
Simplified38.1%
associate-*r/38.1%
clear-num38.1%
un-div-inv38.1%
sqrt-undiv39.8%
clear-num39.7%
sqrt-undiv39.8%
div-inv39.8%
metadata-eval39.8%
Applied egg-rr39.8%
inv-pow39.8%
sqrt-pow239.9%
*-commutative39.9%
associate-/r*39.8%
metadata-eval39.8%
Applied egg-rr39.8%
associate-/r*39.9%
associate-*r/39.9%
times-frac39.9%
Simplified39.9%
(FPCore (k n) :precision binary64 (pow (* k (/ 0.5 (* PI n))) -0.5))
double code(double k, double n) {
return pow((k * (0.5 / (((double) M_PI) * n))), -0.5);
}
public static double code(double k, double n) {
return Math.pow((k * (0.5 / (Math.PI * n))), -0.5);
}
def code(k, n): return math.pow((k * (0.5 / (math.pi * n))), -0.5)
function code(k, n) return Float64(k * Float64(0.5 / Float64(pi * n))) ^ -0.5 end
function tmp = code(k, n) tmp = (k * (0.5 / (pi * n))) ^ -0.5; end
code[k_, n_] := N[Power[N[(k * N[(0.5 / N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]
\begin{array}{l}
\\
{\left(k \cdot \frac{0.5}{\pi \cdot n}\right)}^{-0.5}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 38.0%
*-commutative38.0%
associate-/l*38.0%
Simplified38.0%
pow138.0%
sqrt-unprod38.1%
clear-num38.1%
un-div-inv38.1%
Applied egg-rr38.1%
unpow138.1%
associate-/r/38.1%
associate-*l/38.1%
associate-/l*38.1%
Simplified38.1%
associate-*r/38.1%
clear-num38.1%
un-div-inv38.1%
sqrt-undiv39.8%
clear-num39.7%
sqrt-undiv39.8%
div-inv39.8%
metadata-eval39.8%
Applied egg-rr39.8%
inv-pow39.8%
sqrt-pow239.9%
*-commutative39.9%
associate-/r*39.8%
metadata-eval39.8%
Applied egg-rr39.8%
*-commutative39.8%
associate-/r*39.9%
associate-*l/39.9%
associate-/l*39.9%
Simplified39.9%
Final simplification39.9%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (* n (/ PI k)))))
double code(double k, double n) {
return sqrt((2.0 * (n * (((double) M_PI) / k))));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * (n * (Math.PI / k))));
}
def code(k, n): return math.sqrt((2.0 * (n * (math.pi / k))))
function code(k, n) return sqrt(Float64(2.0 * Float64(n * Float64(pi / k)))) end
function tmp = code(k, n) tmp = sqrt((2.0 * (n * (pi / k)))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(n * N[(Pi / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \left(n \cdot \frac{\pi}{k}\right)}
\end{array}
Initial program 99.4%
Taylor expanded in k around 0 38.0%
*-commutative38.0%
associate-/l*38.0%
Simplified38.0%
pow138.0%
sqrt-unprod38.1%
clear-num38.1%
un-div-inv38.1%
Applied egg-rr38.1%
unpow138.1%
associate-/r/38.1%
associate-*l/38.1%
associate-/l*38.1%
Simplified38.1%
herbie shell --seed 2024135
(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))))