
(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 (* (sqrt (* PI n)) (sqrt (/ 2.0 (* k (pow (* PI (* n 2.0)) k))))))
double code(double k, double n) {
return sqrt((((double) M_PI) * n)) * sqrt((2.0 / (k * pow((((double) M_PI) * (n * 2.0)), k))));
}
public static double code(double k, double n) {
return Math.sqrt((Math.PI * n)) * Math.sqrt((2.0 / (k * Math.pow((Math.PI * (n * 2.0)), k))));
}
def code(k, n): return math.sqrt((math.pi * n)) * math.sqrt((2.0 / (k * math.pow((math.pi * (n * 2.0)), k))))
function code(k, n) return Float64(sqrt(Float64(pi * n)) * sqrt(Float64(2.0 / Float64(k * (Float64(pi * Float64(n * 2.0)) ^ k))))) end
function tmp = code(k, n) tmp = sqrt((pi * n)) * sqrt((2.0 / (k * ((pi * (n * 2.0)) ^ k)))); end
code[k_, n_] := N[(N[Sqrt[N[(Pi * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 / N[(k * N[Power[N[(Pi * N[(n * 2.0), $MachinePrecision]), $MachinePrecision], k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\pi \cdot n} \cdot \sqrt{\frac{2}{k \cdot {\left(\pi \cdot \left(n \cdot 2\right)\right)}^{k}}}
\end{array}
Initial program 99.6%
*-commutativeN/A
un-div-invN/A
div-subN/A
metadata-evalN/A
pow-subN/A
associate-/l/N/A
/-lowering-/.f64N/A
unpow1/2N/A
sqrt-lowering-sqrt.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
pow-lowering-pow.f64N/A
Applied egg-rr99.7%
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
pow-unpowN/A
unpow1/2N/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f6499.7
Applied egg-rr99.7%
sqrt-undivN/A
*-commutativeN/A
associate-/l*N/A
sqrt-prodN/A
pow1/2N/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
pow-lowering-pow.f64N/A
Applied egg-rr99.7%
(FPCore (k n) :precision binary64 (if (<= (* (/ 1.0 (sqrt k)) (pow (* n (* PI 2.0)) (/ (- 1.0 k) 2.0))) 0.0) (pow (* (* k k) (* k k)) -0.125) (* (sqrt (/ (* PI 2.0) k)) (sqrt n))))
double code(double k, double n) {
double tmp;
if (((1.0 / sqrt(k)) * pow((n * (((double) M_PI) * 2.0)), ((1.0 - k) / 2.0))) <= 0.0) {
tmp = pow(((k * k) * (k * k)), -0.125);
} else {
tmp = sqrt(((((double) M_PI) * 2.0) / k)) * sqrt(n);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (((1.0 / Math.sqrt(k)) * Math.pow((n * (Math.PI * 2.0)), ((1.0 - k) / 2.0))) <= 0.0) {
tmp = Math.pow(((k * k) * (k * k)), -0.125);
} else {
tmp = Math.sqrt(((Math.PI * 2.0) / k)) * Math.sqrt(n);
}
return tmp;
}
def code(k, n): tmp = 0 if ((1.0 / math.sqrt(k)) * math.pow((n * (math.pi * 2.0)), ((1.0 - k) / 2.0))) <= 0.0: tmp = math.pow(((k * k) * (k * k)), -0.125) else: tmp = math.sqrt(((math.pi * 2.0) / k)) * math.sqrt(n) return tmp
function code(k, n) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(k)) * (Float64(n * Float64(pi * 2.0)) ^ Float64(Float64(1.0 - k) / 2.0))) <= 0.0) tmp = Float64(Float64(k * k) * Float64(k * k)) ^ -0.125; else tmp = Float64(sqrt(Float64(Float64(pi * 2.0) / k)) * sqrt(n)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (((1.0 / sqrt(k)) * ((n * (pi * 2.0)) ^ ((1.0 - k) / 2.0))) <= 0.0) tmp = ((k * k) * (k * k)) ^ -0.125; else tmp = sqrt(((pi * 2.0) / k)) * sqrt(n); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] * N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0], N[Power[N[(N[(k * k), $MachinePrecision] * N[(k * k), $MachinePrecision]), $MachinePrecision], -0.125], $MachinePrecision], N[(N[Sqrt[N[(N[(Pi * 2.0), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{k}} \cdot {\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)} \leq 0:\\
\;\;\;\;{\left(\left(k \cdot k\right) \cdot \left(k \cdot k\right)\right)}^{-0.125}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\pi \cdot 2}{k}} \cdot \sqrt{n}\\
\end{array}
\end{array}
if (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) < 0.0Initial program 100.0%
Taylor expanded in k around inf
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in k around 0
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f643.8
Simplified3.8%
sqrt-divN/A
metadata-evalN/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f643.8
Applied egg-rr3.8%
pow1/2N/A
pow-flipN/A
metadata-evalN/A
sqr-powN/A
unpow-prod-downN/A
sqr-powN/A
pow-prod-downN/A
pow-lowering-pow.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
metadata-evalN/A
metadata-eval75.8
Applied egg-rr75.8%
if 0.0 < (*.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 k)) (pow.f64 (*.f64 (*.f64 #s(literal 2 binary64) (PI.f64)) n) (/.f64 (-.f64 #s(literal 1 binary64) k) #s(literal 2 binary64)))) Initial program 99.4%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6447.8
Simplified47.8%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f6447.8
Applied egg-rr47.8%
sqrt-unprodN/A
pow1/2N/A
associate-*l*N/A
unpow-prod-downN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
pow-prod-downN/A
pow1/2N/A
pow1/2N/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6464.8
Applied egg-rr64.8%
*-commutativeN/A
pow1/2N/A
unpow-prod-downN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-unprodN/A
*-commutativeN/A
sqrt-lowering-sqrt.f64N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f6464.8
Applied egg-rr64.8%
Final simplification67.9%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (* (sqrt (/ (* PI 2.0) k)) (sqrt n)) (/ (pow (* (* PI n) 2.0) (* k -0.5)) (sqrt k))))
double code(double k, double n) {
double tmp;
if (k <= 1.0) {
tmp = sqrt(((((double) M_PI) * 2.0) / k)) * sqrt(n);
} else {
tmp = pow(((((double) M_PI) * n) * 2.0), (k * -0.5)) / sqrt(k);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.0) {
tmp = Math.sqrt(((Math.PI * 2.0) / k)) * Math.sqrt(n);
} else {
tmp = Math.pow(((Math.PI * n) * 2.0), (k * -0.5)) / Math.sqrt(k);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.0: tmp = math.sqrt(((math.pi * 2.0) / k)) * math.sqrt(n) else: tmp = math.pow(((math.pi * n) * 2.0), (k * -0.5)) / math.sqrt(k) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.0) tmp = Float64(sqrt(Float64(Float64(pi * 2.0) / k)) * sqrt(n)); else tmp = Float64((Float64(Float64(pi * n) * 2.0) ^ Float64(k * -0.5)) / sqrt(k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.0) tmp = sqrt(((pi * 2.0) / k)) * sqrt(n); else tmp = (((pi * n) * 2.0) ^ (k * -0.5)) / sqrt(k); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.0], N[(N[Sqrt[N[(N[(Pi * 2.0), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(N[(Pi * n), $MachinePrecision] * 2.0), $MachinePrecision], N[(k * -0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{\frac{\pi \cdot 2}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(\pi \cdot n\right) \cdot 2\right)}^{\left(k \cdot -0.5\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1Initial program 99.1%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6471.1
Simplified71.1%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f6471.1
Applied egg-rr71.1%
sqrt-unprodN/A
pow1/2N/A
associate-*l*N/A
unpow-prod-downN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
pow-prod-downN/A
pow1/2N/A
pow1/2N/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6496.5
Applied egg-rr96.5%
*-commutativeN/A
pow1/2N/A
unpow-prod-downN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-unprodN/A
*-commutativeN/A
sqrt-lowering-sqrt.f64N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f6496.6
Applied egg-rr96.6%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
*-lowering-*.f64100.0
Simplified100.0%
*-commutativeN/A
un-div-invN/A
/-lowering-/.f64N/A
associate-*r*N/A
pow-lowering-pow.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64100.0
Applied egg-rr100.0%
Final simplification98.4%
(FPCore (k n) :precision binary64 (* (sqrt (/ 1.0 k)) (pow (* n (* PI 2.0)) (fma -0.5 k 0.5))))
double code(double k, double n) {
return sqrt((1.0 / k)) * pow((n * (((double) M_PI) * 2.0)), fma(-0.5, k, 0.5));
}
function code(k, n) return Float64(sqrt(Float64(1.0 / k)) * (Float64(n * Float64(pi * 2.0)) ^ fma(-0.5, k, 0.5))) end
code[k_, n_] := N[(N[Sqrt[N[(1.0 / k), $MachinePrecision]], $MachinePrecision] * N[Power[N[(n * N[(Pi * 2.0), $MachinePrecision]), $MachinePrecision], N[(-0.5 * k + 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{k}} \cdot {\left(n \cdot \left(\pi \cdot 2\right)\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}
\end{array}
Initial program 99.6%
Taylor expanded in k around inf
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-*l*N/A
exp-prodN/A
*-commutativeN/A
pow-lowering-pow.f64N/A
rem-exp-logN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
rem-exp-logN/A
*-lowering-*.f64N/A
rem-exp-logN/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sub-negN/A
mul-1-negN/A
Simplified99.6%
(FPCore (k n) :precision binary64 (/ (pow (* (* PI n) 2.0) (fma k -0.5 0.5)) (sqrt k)))
double code(double k, double n) {
return pow(((((double) M_PI) * n) * 2.0), fma(k, -0.5, 0.5)) / sqrt(k);
}
function code(k, n) return Float64((Float64(Float64(pi * n) * 2.0) ^ fma(k, -0.5, 0.5)) / sqrt(k)) end
code[k_, n_] := N[(N[Power[N[(N[(Pi * n), $MachinePrecision] * 2.0), $MachinePrecision], N[(k * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(\left(\pi \cdot n\right) \cdot 2\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
*-commutativeN/A
un-div-invN/A
div-subN/A
metadata-evalN/A
pow-subN/A
associate-/l/N/A
/-lowering-/.f64N/A
unpow1/2N/A
sqrt-lowering-sqrt.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
pow-lowering-pow.f64N/A
Applied egg-rr99.7%
*-commutativeN/A
associate-/r*N/A
pow1/2N/A
metadata-evalN/A
pow-flipN/A
associate-/r*N/A
unpow-prod-upN/A
/-lowering-/.f64N/A
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 0.5) (* (sqrt (/ (* PI 2.0) k)) (sqrt n)) (sqrt (pow (* k k) -0.5))))
double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = sqrt(((((double) M_PI) * 2.0) / k)) * sqrt(n);
} else {
tmp = sqrt(pow((k * k), -0.5));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = Math.sqrt(((Math.PI * 2.0) / k)) * Math.sqrt(n);
} else {
tmp = Math.sqrt(Math.pow((k * k), -0.5));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 0.5: tmp = math.sqrt(((math.pi * 2.0) / k)) * math.sqrt(n) else: tmp = math.sqrt(math.pow((k * k), -0.5)) return tmp
function code(k, n) tmp = 0.0 if (k <= 0.5) tmp = Float64(sqrt(Float64(Float64(pi * 2.0) / k)) * sqrt(n)); else tmp = sqrt((Float64(k * k) ^ -0.5)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 0.5) tmp = sqrt(((pi * 2.0) / k)) * sqrt(n); else tmp = sqrt(((k * k) ^ -0.5)); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 0.5], N[(N[Sqrt[N[(N[(Pi * 2.0), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[Power[N[(k * k), $MachinePrecision], -0.5], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.5:\\
\;\;\;\;\sqrt{\frac{\pi \cdot 2}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(k \cdot k\right)}^{-0.5}}\\
\end{array}
\end{array}
if k < 0.5Initial program 99.1%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6471.1
Simplified71.1%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f6471.1
Applied egg-rr71.1%
sqrt-unprodN/A
pow1/2N/A
associate-*l*N/A
unpow-prod-downN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
pow-prod-downN/A
pow1/2N/A
pow1/2N/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6496.5
Applied egg-rr96.5%
*-commutativeN/A
pow1/2N/A
unpow-prod-downN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-unprodN/A
*-commutativeN/A
sqrt-lowering-sqrt.f64N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f6496.6
Applied egg-rr96.6%
if 0.5 < k Initial program 100.0%
Taylor expanded in k around inf
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in k around 0
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f643.3
Simplified3.3%
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
pow-lowering-pow.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
(FPCore (k n) :precision binary64 (if (<= k 0.5) (* (sqrt (/ (* PI 2.0) k)) (sqrt n)) (sqrt (sqrt (/ 1.0 (* k k))))))
double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = sqrt(((((double) M_PI) * 2.0) / k)) * sqrt(n);
} else {
tmp = sqrt(sqrt((1.0 / (k * k))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = Math.sqrt(((Math.PI * 2.0) / k)) * Math.sqrt(n);
} else {
tmp = Math.sqrt(Math.sqrt((1.0 / (k * k))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 0.5: tmp = math.sqrt(((math.pi * 2.0) / k)) * math.sqrt(n) else: tmp = math.sqrt(math.sqrt((1.0 / (k * k)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 0.5) tmp = Float64(sqrt(Float64(Float64(pi * 2.0) / k)) * sqrt(n)); else tmp = sqrt(sqrt(Float64(1.0 / Float64(k * k)))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 0.5) tmp = sqrt(((pi * 2.0) / k)) * sqrt(n); else tmp = sqrt(sqrt((1.0 / (k * k)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 0.5], N[(N[Sqrt[N[(N[(Pi * 2.0), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision] * N[Sqrt[n], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[Sqrt[N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.5:\\
\;\;\;\;\sqrt{\frac{\pi \cdot 2}{k}} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt{\frac{1}{k \cdot k}}}\\
\end{array}
\end{array}
if k < 0.5Initial program 99.1%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6471.1
Simplified71.1%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f6471.1
Applied egg-rr71.1%
sqrt-unprodN/A
pow1/2N/A
associate-*l*N/A
unpow-prod-downN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
PI-lowering-PI.f64N/A
pow-prod-downN/A
pow1/2N/A
pow1/2N/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
*-lowering-*.f6496.5
Applied egg-rr96.5%
*-commutativeN/A
pow1/2N/A
unpow-prod-downN/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
pow1/2N/A
sqrt-unprodN/A
*-commutativeN/A
sqrt-lowering-sqrt.f64N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
pow1/2N/A
sqrt-lowering-sqrt.f6496.6
Applied egg-rr96.6%
if 0.5 < k Initial program 100.0%
Taylor expanded in k around inf
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in k around 0
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f643.3
Simplified3.3%
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
pow-lowering-pow.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
pow2N/A
pow-powN/A
metadata-evalN/A
inv-powN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
(FPCore (k n) :precision binary64 (if (<= k 0.5) (* (sqrt (* PI n)) (sqrt (/ 2.0 k))) (sqrt (sqrt (/ 1.0 (* k k))))))
double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = sqrt((((double) M_PI) * n)) * sqrt((2.0 / k));
} else {
tmp = sqrt(sqrt((1.0 / (k * k))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = Math.sqrt((Math.PI * n)) * Math.sqrt((2.0 / k));
} else {
tmp = Math.sqrt(Math.sqrt((1.0 / (k * k))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 0.5: tmp = math.sqrt((math.pi * n)) * math.sqrt((2.0 / k)) else: tmp = math.sqrt(math.sqrt((1.0 / (k * k)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 0.5) tmp = Float64(sqrt(Float64(pi * n)) * sqrt(Float64(2.0 / k))); else tmp = sqrt(sqrt(Float64(1.0 / Float64(k * k)))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 0.5) tmp = sqrt((pi * n)) * sqrt((2.0 / k)); else tmp = sqrt(sqrt((1.0 / (k * k)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 0.5], N[(N[Sqrt[N[(Pi * n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(2.0 / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[Sqrt[N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.5:\\
\;\;\;\;\sqrt{\pi \cdot n} \cdot \sqrt{\frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt{\frac{1}{k \cdot k}}}\\
\end{array}
\end{array}
if k < 0.5Initial program 99.1%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6471.1
Simplified71.1%
sqrt-unprodN/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
sqrt-undivN/A
div-invN/A
*-commutativeN/A
sqrt-prodN/A
*-commutativeN/A
pow1/2N/A
associate-*r*N/A
*-lowering-*.f64N/A
Applied egg-rr96.6%
if 0.5 < k Initial program 100.0%
Taylor expanded in k around inf
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in k around 0
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f643.3
Simplified3.3%
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
pow-lowering-pow.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
pow2N/A
pow-powN/A
metadata-evalN/A
inv-powN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
Final simplification60.4%
(FPCore (k n) :precision binary64 (if (<= k 0.5) (* (sqrt n) (sqrt (* PI (/ 2.0 k)))) (sqrt (sqrt (/ 1.0 (* k k))))))
double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = sqrt(n) * sqrt((((double) M_PI) * (2.0 / k)));
} else {
tmp = sqrt(sqrt((1.0 / (k * k))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = Math.sqrt(n) * Math.sqrt((Math.PI * (2.0 / k)));
} else {
tmp = Math.sqrt(Math.sqrt((1.0 / (k * k))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 0.5: tmp = math.sqrt(n) * math.sqrt((math.pi * (2.0 / k))) else: tmp = math.sqrt(math.sqrt((1.0 / (k * k)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 0.5) tmp = Float64(sqrt(n) * sqrt(Float64(pi * Float64(2.0 / k)))); else tmp = sqrt(sqrt(Float64(1.0 / Float64(k * k)))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 0.5) tmp = sqrt(n) * sqrt((pi * (2.0 / k))); else tmp = sqrt(sqrt((1.0 / (k * k)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 0.5], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(Pi * N[(2.0 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[Sqrt[N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.5:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\pi \cdot \frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt{\frac{1}{k \cdot k}}}\\
\end{array}
\end{array}
if k < 0.5Initial program 99.1%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6471.1
Simplified71.1%
sqrt-unprodN/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
sqrt-undivN/A
div-invN/A
associate-*r*N/A
unpow1/2N/A
*-commutativeN/A
unpow-prod-downN/A
associate-*r*N/A
*-lowering-*.f64N/A
Applied egg-rr96.6%
if 0.5 < k Initial program 100.0%
Taylor expanded in k around inf
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in k around 0
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f643.3
Simplified3.3%
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
pow-lowering-pow.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
pow2N/A
pow-powN/A
metadata-evalN/A
inv-powN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
Final simplification60.4%
(FPCore (k n) :precision binary64 (if (<= k 0.5) (sqrt (* 2.0 (/ (* PI n) k))) (sqrt (sqrt (/ 1.0 (* k k))))))
double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = sqrt((2.0 * ((((double) M_PI) * n) / k)));
} else {
tmp = sqrt(sqrt((1.0 / (k * k))));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 0.5) {
tmp = Math.sqrt((2.0 * ((Math.PI * n) / k)));
} else {
tmp = Math.sqrt(Math.sqrt((1.0 / (k * k))));
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 0.5: tmp = math.sqrt((2.0 * ((math.pi * n) / k))) else: tmp = math.sqrt(math.sqrt((1.0 / (k * k)))) return tmp
function code(k, n) tmp = 0.0 if (k <= 0.5) tmp = sqrt(Float64(2.0 * Float64(Float64(pi * n) / k))); else tmp = sqrt(sqrt(Float64(1.0 / Float64(k * k)))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 0.5) tmp = sqrt((2.0 * ((pi * n) / k))); else tmp = sqrt(sqrt((1.0 / (k * k)))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 0.5], N[Sqrt[N[(2.0 * N[(N[(Pi * n), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[Sqrt[N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.5:\\
\;\;\;\;\sqrt{2 \cdot \frac{\pi \cdot n}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\sqrt{\frac{1}{k \cdot k}}}\\
\end{array}
\end{array}
if k < 0.5Initial program 99.1%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6471.1
Simplified71.1%
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f6471.4
Applied egg-rr71.4%
if 0.5 < k Initial program 100.0%
Taylor expanded in k around inf
*-lowering-*.f64100.0
Simplified100.0%
Taylor expanded in k around 0
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f643.3
Simplified3.3%
inv-powN/A
metadata-evalN/A
pow-prod-upN/A
pow-prod-downN/A
pow-lowering-pow.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
pow2N/A
pow-powN/A
metadata-evalN/A
inv-powN/A
rem-square-sqrtN/A
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
frac-timesN/A
metadata-evalN/A
/-lowering-/.f64N/A
*-lowering-*.f6427.4
Applied egg-rr27.4%
(FPCore (k n) :precision binary64 (sqrt (* 2.0 (/ (* PI n) k))))
double code(double k, double n) {
return sqrt((2.0 * ((((double) M_PI) * n) / k)));
}
public static double code(double k, double n) {
return Math.sqrt((2.0 * ((Math.PI * n) / k)));
}
def code(k, n): return math.sqrt((2.0 * ((math.pi * n) / k)))
function code(k, n) return sqrt(Float64(2.0 * Float64(Float64(pi * n) / k))) end
function tmp = code(k, n) tmp = sqrt((2.0 * ((pi * n) / k))); end
code[k_, n_] := N[Sqrt[N[(2.0 * N[(N[(Pi * n), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot \frac{\pi \cdot n}{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
PI-lowering-PI.f64N/A
sqrt-lowering-sqrt.f6435.3
Simplified35.3%
sqrt-unprodN/A
sqrt-lowering-sqrt.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
PI-lowering-PI.f6435.4
Applied egg-rr35.4%
(FPCore (k n) :precision binary64 (sqrt (/ 1.0 k)))
double code(double k, double n) {
return sqrt((1.0 / k));
}
real(8) function code(k, n)
real(8), intent (in) :: k
real(8), intent (in) :: n
code = sqrt((1.0d0 / k))
end function
public static double code(double k, double n) {
return Math.sqrt((1.0 / k));
}
def code(k, n): return math.sqrt((1.0 / k))
function code(k, n) return sqrt(Float64(1.0 / k)) end
function tmp = code(k, n) tmp = sqrt((1.0 / k)); end
code[k_, n_] := N[Sqrt[N[(1.0 / k), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around inf
*-lowering-*.f6455.8
Simplified55.8%
Taylor expanded in k around 0
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f645.2
Simplified5.2%
herbie shell --seed 2024205
(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))))