
(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]
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
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]
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
(FPCore (k n) :precision binary64 (let* ((t_0 (* n (+ PI PI)))) (* (/ 1.0 (sqrt k)) (* (pow t_0 (* k -0.5)) (pow t_0 0.5)))))
double code(double k, double n) {
double t_0 = n * (((double) M_PI) + ((double) M_PI));
return (1.0 / sqrt(k)) * (pow(t_0, (k * -0.5)) * pow(t_0, 0.5));
}
public static double code(double k, double n) {
double t_0 = n * (Math.PI + Math.PI);
return (1.0 / Math.sqrt(k)) * (Math.pow(t_0, (k * -0.5)) * Math.pow(t_0, 0.5));
}
def code(k, n): t_0 = n * (math.pi + math.pi) return (1.0 / math.sqrt(k)) * (math.pow(t_0, (k * -0.5)) * math.pow(t_0, 0.5))
function code(k, n) t_0 = Float64(n * Float64(pi + pi)) return Float64(Float64(1.0 / sqrt(k)) * Float64((t_0 ^ Float64(k * -0.5)) * (t_0 ^ 0.5))) end
function tmp = code(k, n) t_0 = n * (pi + pi); tmp = (1.0 / sqrt(k)) * ((t_0 ^ (k * -0.5)) * (t_0 ^ 0.5)); end
code[k_, n_] := Block[{t$95$0 = N[(n * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / N[Sqrt[k], $MachinePrecision]), $MachinePrecision] * N[(N[Power[t$95$0, N[(k * -0.5), $MachinePrecision]], $MachinePrecision] * N[Power[t$95$0, 0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := n \cdot \left(\pi + \pi\right)\\
\frac{1}{\sqrt{k}} \cdot \left({t\_0}^{\left(k \cdot -0.5\right)} \cdot {t\_0}^{0.5}\right)
\end{array}
Initial program 99.4%
lift-pow.f64N/A
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
div-addN/A
metadata-evalN/A
pow-addN/A
lower-unsound-*.f64N/A
Applied rewrites99.5%
(FPCore (k n) :precision binary64 (* (pow k -0.5) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0))))
double code(double k, double n) {
return pow(k, -0.5) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
}
public static double code(double k, double n) {
return Math.pow(k, -0.5) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
}
def code(k, n): return math.pow(k, -0.5) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0))
function code(k, n) return Float64((k ^ -0.5) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0))) end
function tmp = code(k, n) tmp = (k ^ -0.5) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0)); end
code[k_, n_] := N[(N[Power[k, -0.5], $MachinePrecision] * N[Power[N[(N[(2.0 * Pi), $MachinePrecision] * n), $MachinePrecision], N[(N[(1.0 - k), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
{k}^{-0.5} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
Initial program 99.4%
lift-/.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
pow-flipN/A
lower-pow.f64N/A
metadata-eval99.5%
Applied rewrites99.5%
(FPCore (k n) :precision binary64 (/ (pow (* 6.283185307179586 n) (fma k -0.5 0.5)) (sqrt k)))
double code(double k, double n) {
return pow((6.283185307179586 * n), fma(k, -0.5, 0.5)) / sqrt(k);
}
function code(k, n) return Float64((Float64(6.283185307179586 * n) ^ fma(k, -0.5, 0.5)) / sqrt(k)) end
code[k_, n_] := N[(N[Power[N[(6.283185307179586 * n), $MachinePrecision], N[(k * -0.5 + 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]
\frac{{\left(6.283185307179586 \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}
Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
*-lft-identityN/A
lower-unsound-/.f6499.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
div-addN/A
Applied rewrites99.4%
Evaluated real constant99.4%
Applied rewrites99.5%
(FPCore (k n) :precision binary64 (if (<= k 1.2) (* (sqrt (+ n n)) (sqrt (/ PI k))) (/ (pow (* 6.283185307179586 n) (* -0.5 k)) (sqrt k))))
double code(double k, double n) {
double tmp;
if (k <= 1.2) {
tmp = sqrt((n + n)) * sqrt((((double) M_PI) / k));
} else {
tmp = pow((6.283185307179586 * n), (-0.5 * k)) / sqrt(k);
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (k <= 1.2) {
tmp = Math.sqrt((n + n)) * Math.sqrt((Math.PI / k));
} else {
tmp = Math.pow((6.283185307179586 * n), (-0.5 * k)) / Math.sqrt(k);
}
return tmp;
}
def code(k, n): tmp = 0 if k <= 1.2: tmp = math.sqrt((n + n)) * math.sqrt((math.pi / k)) else: tmp = math.pow((6.283185307179586 * n), (-0.5 * k)) / math.sqrt(k) return tmp
function code(k, n) tmp = 0.0 if (k <= 1.2) tmp = Float64(sqrt(Float64(n + n)) * sqrt(Float64(pi / k))); else tmp = Float64((Float64(6.283185307179586 * n) ^ Float64(-0.5 * k)) / sqrt(k)); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (k <= 1.2) tmp = sqrt((n + n)) * sqrt((pi / k)); else tmp = ((6.283185307179586 * n) ^ (-0.5 * k)) / sqrt(k); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[k, 1.2], N[(N[Sqrt[N[(n + n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(6.283185307179586 * n), $MachinePrecision], N[(-0.5 * k), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;k \leq 1.2:\\
\;\;\;\;\sqrt{n + n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(6.283185307179586 \cdot n\right)}^{\left(-0.5 \cdot k\right)}}{\sqrt{k}}\\
\end{array}
if k < 1.2Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
associate-*l*N/A
*-commutativeN/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f6449.9%
Applied rewrites49.9%
if 1.2 < k Initial program 99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
*-lft-identityN/A
lower-unsound-/.f6499.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4%
lift-*.f64N/A
count-2-revN/A
lower-+.f6499.4%
lift-/.f64N/A
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
div-addN/A
Applied rewrites99.4%
Evaluated real constant99.4%
Applied rewrites99.5%
Taylor expanded in k around inf
lower-*.f6453.0%
Applied rewrites53.0%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 PI) n) (/ (- 1.0 k) 2.0)))))
(if (<= t_0 4e-145)
(* n (sqrt (/ 6.283185307179586 (* k n))))
(if (<= t_0 1e+296)
(* (sqrt (+ n n)) (sqrt (/ PI k)))
(/ (sqrt (* n (+ PI PI))) (* (sqrt (sqrt (/ (/ 1.0 k) k))) k))))))double code(double k, double n) {
double t_0 = (1.0 / sqrt(k)) * pow(((2.0 * ((double) M_PI)) * n), ((1.0 - k) / 2.0));
double tmp;
if (t_0 <= 4e-145) {
tmp = n * sqrt((6.283185307179586 / (k * n)));
} else if (t_0 <= 1e+296) {
tmp = sqrt((n + n)) * sqrt((((double) M_PI) / k));
} else {
tmp = sqrt((n * (((double) M_PI) + ((double) M_PI)))) / (sqrt(sqrt(((1.0 / k) / k))) * k);
}
return tmp;
}
public static double code(double k, double n) {
double t_0 = (1.0 / Math.sqrt(k)) * Math.pow(((2.0 * Math.PI) * n), ((1.0 - k) / 2.0));
double tmp;
if (t_0 <= 4e-145) {
tmp = n * Math.sqrt((6.283185307179586 / (k * n)));
} else if (t_0 <= 1e+296) {
tmp = Math.sqrt((n + n)) * Math.sqrt((Math.PI / k));
} else {
tmp = Math.sqrt((n * (Math.PI + Math.PI))) / (Math.sqrt(Math.sqrt(((1.0 / k) / k))) * k);
}
return tmp;
}
def code(k, n): t_0 = (1.0 / math.sqrt(k)) * math.pow(((2.0 * math.pi) * n), ((1.0 - k) / 2.0)) tmp = 0 if t_0 <= 4e-145: tmp = n * math.sqrt((6.283185307179586 / (k * n))) elif t_0 <= 1e+296: tmp = math.sqrt((n + n)) * math.sqrt((math.pi / k)) else: tmp = math.sqrt((n * (math.pi + math.pi))) / (math.sqrt(math.sqrt(((1.0 / k) / k))) * k) return tmp
function code(k, n) t_0 = Float64(Float64(1.0 / sqrt(k)) * (Float64(Float64(2.0 * pi) * n) ^ Float64(Float64(1.0 - k) / 2.0))) tmp = 0.0 if (t_0 <= 4e-145) tmp = Float64(n * sqrt(Float64(6.283185307179586 / Float64(k * n)))); elseif (t_0 <= 1e+296) tmp = Float64(sqrt(Float64(n + n)) * sqrt(Float64(pi / k))); else tmp = Float64(sqrt(Float64(n * Float64(pi + pi))) / Float64(sqrt(sqrt(Float64(Float64(1.0 / k) / k))) * k)); end return tmp end
function tmp_2 = code(k, n) t_0 = (1.0 / sqrt(k)) * (((2.0 * pi) * n) ^ ((1.0 - k) / 2.0)); tmp = 0.0; if (t_0 <= 4e-145) tmp = n * sqrt((6.283185307179586 / (k * n))); elseif (t_0 <= 1e+296) tmp = sqrt((n + n)) * sqrt((pi / k)); else tmp = sqrt((n * (pi + pi))) / (sqrt(sqrt(((1.0 / k) / k))) * k); end tmp_2 = tmp; end
code[k_, n_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 4e-145], N[(n * N[Sqrt[N[(6.283185307179586 / N[(k * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+296], N[(N[Sqrt[N[(n + n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(n * N[(Pi + Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(N[Sqrt[N[Sqrt[N[(N[(1.0 / k), $MachinePrecision] / k), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \pi\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-145}:\\
\;\;\;\;n \cdot \sqrt{\frac{6.283185307179586}{k \cdot n}}\\
\mathbf{elif}\;t\_0 \leq 10^{+296}:\\
\;\;\;\;\sqrt{n + n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{n \cdot \left(\pi + \pi\right)}}{\sqrt{\sqrt{\frac{\frac{1}{k}}{k}}} \cdot k}\\
\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)))) < 3.9999999999999997e-145Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
Evaluated real constant38.0%
Taylor expanded in n around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.1%
Applied rewrites50.1%
if 3.9999999999999997e-145 < (*.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)))) < 9.9999999999999998e295Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
associate-*l*N/A
*-commutativeN/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f6449.9%
Applied rewrites49.9%
if 9.9999999999999998e295 < (*.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
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
Taylor expanded in k around inf
lower-/.f64N/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6449.8%
Applied rewrites49.8%
lift-*.f64N/A
count-2-revN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-outN/A
lift-+.f64N/A
lower-*.f6449.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6449.8%
Applied rewrites49.8%
lift-/.f64N/A
rem-square-sqrtN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
associate-/l/N/A
lift-sqrt.f64N/A
metadata-evalN/A
sqrt-fabs-revN/A
lift-sqrt.f64N/A
fabs-divN/A
lift-/.f64N/A
rem-sqrt-square-revN/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
metadata-evalN/A
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-undivN/A
lower-sqrt.f64N/A
Applied rewrites36.2%
(FPCore (k n) :precision binary64 (if (<= n 1e-11) (* (sqrt (+ n n)) (sqrt (/ PI k))) (* n (sqrt (/ 6.283185307179586 (* k n))))))
double code(double k, double n) {
double tmp;
if (n <= 1e-11) {
tmp = sqrt((n + n)) * sqrt((((double) M_PI) / k));
} else {
tmp = n * sqrt((6.283185307179586 / (k * n)));
}
return tmp;
}
public static double code(double k, double n) {
double tmp;
if (n <= 1e-11) {
tmp = Math.sqrt((n + n)) * Math.sqrt((Math.PI / k));
} else {
tmp = n * Math.sqrt((6.283185307179586 / (k * n)));
}
return tmp;
}
def code(k, n): tmp = 0 if n <= 1e-11: tmp = math.sqrt((n + n)) * math.sqrt((math.pi / k)) else: tmp = n * math.sqrt((6.283185307179586 / (k * n))) return tmp
function code(k, n) tmp = 0.0 if (n <= 1e-11) tmp = Float64(sqrt(Float64(n + n)) * sqrt(Float64(pi / k))); else tmp = Float64(n * sqrt(Float64(6.283185307179586 / Float64(k * n)))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (n <= 1e-11) tmp = sqrt((n + n)) * sqrt((pi / k)); else tmp = n * sqrt((6.283185307179586 / (k * n))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[n, 1e-11], N[(N[Sqrt[N[(n + n), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(Pi / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(n * N[Sqrt[N[(6.283185307179586 / N[(k * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;n \leq 10^{-11}:\\
\;\;\;\;\sqrt{n + n} \cdot \sqrt{\frac{\pi}{k}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \sqrt{\frac{6.283185307179586}{k \cdot n}}\\
\end{array}
if n < 9.9999999999999994e-12Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-+.f64N/A
count-2-revN/A
associate-/l*N/A
associate-*l*N/A
*-commutativeN/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
count-2-revN/A
lower-+.f64N/A
lower-unsound-sqrt.f64N/A
lower-/.f6449.9%
Applied rewrites49.9%
if 9.9999999999999994e-12 < n Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
Evaluated real constant38.0%
Taylor expanded in n around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.1%
Applied rewrites50.1%
(FPCore (k n) :precision binary64 (if (<= n 0.001) (* (sqrt n) (sqrt (/ 6.283185307179586 k))) (* n (sqrt (/ 6.283185307179586 (* k n))))))
double code(double k, double n) {
double tmp;
if (n <= 0.001) {
tmp = sqrt(n) * sqrt((6.283185307179586 / k));
} else {
tmp = n * sqrt((6.283185307179586 / (k * n)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(k, n)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: n
real(8) :: tmp
if (n <= 0.001d0) then
tmp = sqrt(n) * sqrt((6.283185307179586d0 / k))
else
tmp = n * sqrt((6.283185307179586d0 / (k * n)))
end if
code = tmp
end function
public static double code(double k, double n) {
double tmp;
if (n <= 0.001) {
tmp = Math.sqrt(n) * Math.sqrt((6.283185307179586 / k));
} else {
tmp = n * Math.sqrt((6.283185307179586 / (k * n)));
}
return tmp;
}
def code(k, n): tmp = 0 if n <= 0.001: tmp = math.sqrt(n) * math.sqrt((6.283185307179586 / k)) else: tmp = n * math.sqrt((6.283185307179586 / (k * n))) return tmp
function code(k, n) tmp = 0.0 if (n <= 0.001) tmp = Float64(sqrt(n) * sqrt(Float64(6.283185307179586 / k))); else tmp = Float64(n * sqrt(Float64(6.283185307179586 / Float64(k * n)))); end return tmp end
function tmp_2 = code(k, n) tmp = 0.0; if (n <= 0.001) tmp = sqrt(n) * sqrt((6.283185307179586 / k)); else tmp = n * sqrt((6.283185307179586 / (k * n))); end tmp_2 = tmp; end
code[k_, n_] := If[LessEqual[n, 0.001], N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(6.283185307179586 / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(n * N[Sqrt[N[(6.283185307179586 / N[(k * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;n \leq 0.001:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\frac{6.283185307179586}{k}}\\
\mathbf{else}:\\
\;\;\;\;n \cdot \sqrt{\frac{6.283185307179586}{k \cdot n}}\\
\end{array}
if n < 1e-3Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
Evaluated real constant38.0%
lift-sqrt.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l*N/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6449.8%
Applied rewrites49.8%
if 1e-3 < n Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
Evaluated real constant38.0%
Taylor expanded in n around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6450.1%
Applied rewrites50.1%
(FPCore (k n) :precision binary64 (* (sqrt n) (sqrt (/ 6.283185307179586 k))))
double code(double k, double n) {
return sqrt(n) * sqrt((6.283185307179586 / k));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(k, n)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: n
code = sqrt(n) * sqrt((6.283185307179586d0 / k))
end function
public static double code(double k, double n) {
return Math.sqrt(n) * Math.sqrt((6.283185307179586 / k));
}
def code(k, n): return math.sqrt(n) * math.sqrt((6.283185307179586 / k))
function code(k, n) return Float64(sqrt(n) * sqrt(Float64(6.283185307179586 / k))) end
function tmp = code(k, n) tmp = sqrt(n) * sqrt((6.283185307179586 / k)); end
code[k_, n_] := N[(N[Sqrt[n], $MachinePrecision] * N[Sqrt[N[(6.283185307179586 / k), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\sqrt{n} \cdot \sqrt{\frac{6.283185307179586}{k}}
Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
Evaluated real constant38.0%
lift-sqrt.f64N/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l*N/A
sqrt-prodN/A
lower-unsound-*.f64N/A
lower-unsound-sqrt.f64N/A
lower-unsound-sqrt.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6449.8%
Applied rewrites49.8%
(FPCore (k n) :precision binary64 (sqrt (* n (/ 6.283185307179586 k))))
double code(double k, double n) {
return sqrt((n * (6.283185307179586 / k)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(k, n)
use fmin_fmax_functions
real(8), intent (in) :: k
real(8), intent (in) :: n
code = sqrt((n * (6.283185307179586d0 / k)))
end function
public static double code(double k, double n) {
return Math.sqrt((n * (6.283185307179586 / k)));
}
def code(k, n): return math.sqrt((n * (6.283185307179586 / k)))
function code(k, n) return sqrt(Float64(n * Float64(6.283185307179586 / k))) end
function tmp = code(k, n) tmp = sqrt((n * (6.283185307179586 / k))); end
code[k_, n_] := N[Sqrt[N[(n * N[(6.283185307179586 / k), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\sqrt{n \cdot \frac{6.283185307179586}{k}}
Initial program 99.4%
Taylor expanded in k around 0
lower-/.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower-sqrt.f6449.9%
Applied rewrites49.9%
lift-/.f64N/A
Applied rewrites38.0%
Evaluated real constant38.0%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
mult-flip-revN/A
lower-/.f6438.0%
Applied rewrites38.0%
herbie shell --seed 2025187
(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))))