
(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.5%
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
lower-fma.f6499.5
Applied rewrites99.5%
lift-PI.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6499.5
Applied rewrites99.5%
(FPCore (k n)
:precision binary64
(if (<=
(* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
2e+131)
(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^{+131}:\\
\;\;\;\;\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)))) < 1.9999999999999998e131Initial program 99.4%
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.8
Applied rewrites55.8%
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 1.9999999999999998e131 < (*.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.7%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.7
Applied rewrites99.7%
Taylor expanded in k around 0
Applied rewrites57.7%
Taylor expanded in k around 0
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lift-*.f64N/A
sqrt-prodN/A
lift-*.f64N/A
lift-sqrt.f6439.8
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites39.8%
Final simplification50.5%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (* (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 1:\\
\;\;\;\;\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 < 1Initial program 99.0%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.1
Applied rewrites99.1%
lift-pow.f64N/A
inv-powN/A
lower-/.f6499.1
Applied rewrites99.1%
Taylor expanded in k around 0
*-commutativeN/A
*-lft-identityN/A
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-sqrt.f6497.9
Applied rewrites97.9%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
lower-*.f6498.6
Applied rewrites98.6%
lift-PI.f64N/A
lift-*.f64N/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6498.6
Applied rewrites98.6%
(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.5%
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
*-lft-identityN/A
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-sqrt.f6450.4
Applied rewrites50.4%
(FPCore (k n) :precision binary64 (* (sqrt (* (/ (PI) k) 2.0)) (sqrt n)))
\begin{array}{l}
\\
\sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2} \cdot \sqrt{n}
\end{array}
Initial program 99.5%
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-*.f64N/A
lift-pow.f64N/A
lift-sqrt.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
inv-powN/A
unpow-prod-downN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites79.4%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-PI.f6498.1
Applied rewrites98.1%
Taylor expanded in k around 0
lower-sqrt.f6450.4
Applied rewrites50.4%
(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.5%
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.f6441.3
Applied rewrites41.3%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6441.3
Applied rewrites41.3%
herbie shell --seed 2025073
(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))))