
(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 (/ (pow (* (* (PI) n) 2.0) (fma -0.5 k 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
lift-*.f64N/A
lift-/.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
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in k around inf
lower-*.f6455.8
Applied rewrites55.8%
lift-*.f64N/A
*-lft-identity55.8
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6455.8
Applied rewrites55.8%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (PI) n)))
(if (<=
(* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
5e+148)
(sqrt (* (/ t_0 k) 2.0))
(/ (sqrt (* (* 2.0 k) t_0)) k))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot n\\
\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 5 \cdot 10^{+148}:\\
\;\;\;\;\sqrt{\frac{t\_0}{k} \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot k\right) \cdot t\_0}}{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)))) < 5.00000000000000024e148Initial 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.f6455.7
Applied rewrites55.7%
if 5.00000000000000024e148 < (*.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 rewrites67.9%
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.f6432.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites32.2%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (/ (sqrt (* (* 2.0 n) (PI))) (sqrt k)) (/ (pow (* (* (PI) n) 2.0) (* -0.5 k)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\frac{\sqrt{\left(2 \cdot n\right) \cdot \mathsf{PI}\left(\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(-0.5 \cdot k\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1Initial program 99.1%
lift-*.f64N/A
lift-/.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
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.2%
Taylor expanded in k around 0
*-lft-identityN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
sqr-powN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites97.5%
if 1 < k Initial program 100.0%
lift-*.f64N/A
lift-/.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
associate-*l/N/A
lower-/.f64N/A
Applied rewrites100.0%
Taylor expanded in k around inf
lower-*.f6499.3
Applied rewrites99.3%
lift-*.f64N/A
*-lft-identity99.3
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6499.3
Applied rewrites99.3%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* 2.0 n) (PI))) (sqrt k)))
\begin{array}{l}
\\
\frac{\sqrt{\left(2 \cdot n\right) \cdot \mathsf{PI}\left(\right)}}{\sqrt{k}}
\end{array}
Initial program 99.6%
lift-*.f64N/A
lift-/.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
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.6%
Taylor expanded in k around 0
*-lft-identityN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
sqr-powN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites47.5%
(FPCore (k n) :precision binary64 (sqrt (* (/ (* (PI) n) k) 2.0)))
\begin{array}{l}
\\
\sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k} \cdot 2}
\end{array}
Initial 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.f6438.1
Applied rewrites38.1%
(FPCore (k n) :precision binary64 (sqrt (* (PI) (* (/ n k) 2.0))))
\begin{array}{l}
\\
\sqrt{\mathsf{PI}\left(\right) \cdot \left(\frac{n}{k} \cdot 2\right)}
\end{array}
Initial 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.f6438.1
Applied rewrites38.1%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-/.f6438.1
Applied rewrites38.1%
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f6438.1
Applied rewrites38.1%
herbie shell --seed 2025050
(FPCore (k n)
:name "Migdal et al, Equation (51)"
:precision binary64
:pre (TRUE)
(* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))