
(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 10 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 (pow k -1.0)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))
\begin{array}{l}
\\
\sqrt{{k}^{-1}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.6%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.6
Applied rewrites99.6%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (* (sqrt (pow k -1.0)) (sqrt (* (* 2.0 n) (PI)))) (/ (pow (* (* (PI) n) 2.0) (* -0.5 k)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{{k}^{-1}} \cdot \sqrt{\left(2 \cdot n\right) \cdot \mathsf{PI}\left(\right)}\\
\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.2%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.3
Applied rewrites99.3%
Taylor expanded in k around 0
unpow-prod-downN/A
*-commutativeN/A
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lower-sqrt.f6497.6
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f6497.6
Applied rewrites97.6%
if 1 < k Initial program 100.0%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-sqrt.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-lft-identity100.0
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64100.0
Applied rewrites100.0%
Taylor expanded in k around inf
lift-*.f64100.0
Applied rewrites100.0%
(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%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-sqrt.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-lft-identity99.6
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
(FPCore (k n) :precision binary64 (* (sqrt (pow k -1.0)) (sqrt (* (* 2.0 n) (PI)))))
\begin{array}{l}
\\
\sqrt{{k}^{-1}} \cdot \sqrt{\left(2 \cdot n\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 99.6%
lift-/.f64N/A
metadata-evalN/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f6499.6
Applied rewrites99.6%
Taylor expanded in k around 0
unpow-prod-downN/A
*-commutativeN/A
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lower-sqrt.f6450.8
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f6450.8
Applied rewrites50.8%
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (sqrt (* (+ (PI) (PI)) n))))
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot \sqrt{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot n}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6450.8
Applied rewrites50.8%
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6450.8
Applied rewrites50.8%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* (PI) n) 2.0)) (sqrt k)))
\begin{array}{l}
\\
\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}
\end{array}
Initial program 99.6%
Taylor expanded in k around 0
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6450.8
Applied rewrites50.8%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites50.8%
Final simplification50.8%
(FPCore (k n) :precision binary64 (sqrt (/ (* (* 2.0 n) (PI)) k)))
\begin{array}{l}
\\
\sqrt{\frac{\left(2 \cdot n\right) \cdot \mathsf{PI}\left(\right)}{k}}
\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.f6437.9
Applied rewrites37.9%
lift-*.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l/N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lower-/.f6437.9
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f6437.9
Applied rewrites37.9%
(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.f6437.9
Applied rewrites37.9%
(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.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.f6437.9
Applied rewrites37.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.f6437.9
Applied rewrites37.9%
(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.f6437.9
Applied rewrites37.9%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-/.f6437.8
Applied rewrites37.8%
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-*.f6437.8
Applied rewrites37.8%
herbie shell --seed 2025054
(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))))