
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
(FPCore (k n) :precision binary64 (* (sqrt (/ 1.0 k)) (pow (* (+ (PI) (PI)) n) (fma -0.5 k 0.5))))
\begin{array}{l}
\\
\sqrt{\frac{1}{k}} \cdot {\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}
\end{array}
Initial program 99.7%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
inv-powN/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f6499.8
Applied rewrites99.8%
lift-PI.f64N/A
lift-*.f64N/A
count-2-revN/A
lift-+.f64N/A
lift-PI.f64N/A
lift-PI.f6499.8
Applied rewrites99.8%
(FPCore (k n)
:precision binary64
(if (<=
(* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
2e+147)
(sqrt (* (* n (/ (PI) k)) 2.0))
(/ (sqrt (* (* 2.0 k) (* (PI) n))) k)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \leq 2 \cdot 10^{+147}:\\
\;\;\;\;\sqrt{\left(n \cdot \frac{\mathsf{PI}\left(\right)}{k}\right) \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot k\right) \cdot \left(\mathsf{PI}\left(\right) \cdot n\right)}}{k}\\
\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)))) < 2e147Initial program 99.6%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6455.9
Applied rewrites55.9%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6455.9
Applied rewrites55.9%
if 2e147 < (*.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.8%
Taylor expanded in k around 0
lower-/.f64N/A
Applied rewrites76.1%
Taylor expanded in k around 0
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
sqrt-prodN/A
lift-*.f64N/A
lift-sqrt.f6435.4
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites36.4%
(FPCore (k n) :precision binary64 (if (<= k 0.98) (* (sqrt (/ 1.0 k)) (sqrt (* (* (PI) 2.0) n))) (* (/ 1.0 (sqrt k)) (pow (* (+ (PI) (PI)) n) (* -0.5 k)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.98:\\
\;\;\;\;\sqrt{\frac{1}{k}} \cdot \sqrt{\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{k}} \cdot {\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(-0.5 \cdot k\right)}\\
\end{array}
\end{array}
if k < 0.97999999999999998Initial program 99.3%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.5
Applied rewrites99.5%
lift-pow.f64N/A
inv-powN/A
lower-/.f6499.5
Applied rewrites99.5%
Taylor expanded in k around 0
*-commutativeN/A
Applied rewrites98.4%
if 0.97999999999999998 < k Initial program 100.0%
Taylor expanded in k around inf
lower-*.f6499.3
Applied rewrites99.3%
lift-PI.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6499.3
Applied rewrites99.3%
(FPCore (k n) :precision binary64 (* (sqrt (/ 1.0 k)) (sqrt (* (* (PI) 2.0) n))))
\begin{array}{l}
\\
\sqrt{\frac{1}{k}} \cdot \sqrt{\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n}
\end{array}
Initial program 99.7%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
inv-powN/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in k around 0
*-commutativeN/A
Applied rewrites48.3%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* (PI) 2.0) n)) (sqrt k)))
\begin{array}{l}
\\
\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n}}{\sqrt{k}}
\end{array}
Initial program 99.7%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6437.0
Applied rewrites37.0%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-/.f6437.0
Applied rewrites37.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqrt-prodN/A
associate-*r/N/A
sqrt-undivN/A
associate-*l/N/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites48.3%
(FPCore (k n) :precision binary64 (sqrt (* (* n (/ (PI) k)) 2.0)))
\begin{array}{l}
\\
\sqrt{\left(n \cdot \frac{\mathsf{PI}\left(\right)}{k}\right) \cdot 2}
\end{array}
Initial program 99.7%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6437.0
Applied rewrites37.0%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6437.0
Applied rewrites37.0%
herbie shell --seed 2025051
(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))))