
(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 8 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 (* n (* (PI) 2.0)) (/ (- 1.0 k) 2.0)) (pow k -0.5)))
\begin{array}{l}
\\
{\left(n \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)} \cdot {k}^{-0.5}
\end{array}
Initial program 99.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-/.f64N/A
inv-powN/A
lift-sqrt.f64N/A
pow1/2N/A
pow-powN/A
lower-pow.f64N/A
metadata-eval99.6
Applied rewrites99.6%
(FPCore (k n) :precision binary64 (/ (pow (* n (* (PI) 2.0)) (/ (- 1.0 k) 2.0)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(n \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right)}^{\left(\frac{1 - k}{2}\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (pow (* (* (PI) n) 2.0) (fma -0.5 k 0.5))))
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot {\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}
\end{array}
Initial program 99.5%
lift-pow.f64N/A
lift-*.f64N/A
unpow-prod-downN/A
lower-*.f64N/A
lower-pow.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6476.7
Applied rewrites76.7%
Taylor expanded in k around inf
Applied rewrites99.5%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (* (PI) n) 2.0)))
(if (<= k 1.35e-29)
(/ (sqrt t_0) (sqrt k))
(sqrt (/ (pow t_0 (- 1.0 k)) k)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\\
\mathbf{if}\;k \leq 1.35 \cdot 10^{-29}:\\
\;\;\;\;\frac{\sqrt{t\_0}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{t\_0}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 1.35000000000000011e-29Initial program 99.4%
Taylor expanded in k around 0
Applied rewrites70.7%
Applied rewrites99.5%
if 1.35000000000000011e-29 < k Initial program 99.7%
Taylor expanded in k around inf
Applied rewrites98.9%
Taylor expanded in k around inf
Applied rewrites98.9%
(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.5%
Taylor expanded in k around 0
Applied rewrites39.5%
Applied rewrites53.5%
(FPCore (k n) :precision binary64 (* (sqrt (/ (* (PI) 2.0) k)) (sqrt n)))
\begin{array}{l}
\\
\sqrt{\frac{\mathsf{PI}\left(\right) \cdot 2}{k}} \cdot \sqrt{n}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0
Applied rewrites39.5%
Applied rewrites39.6%
Applied rewrites39.7%
Applied rewrites53.2%
(FPCore (k n) :precision binary64 (sqrt (* n (/ (* 2.0 (PI)) k))))
\begin{array}{l}
\\
\sqrt{n \cdot \frac{2 \cdot \mathsf{PI}\left(\right)}{k}}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0
Applied rewrites39.5%
Applied rewrites39.6%
Applied rewrites39.7%
(FPCore (k n) :precision binary64 (sqrt (* n (* (PI) (/ 2.0 k)))))
\begin{array}{l}
\\
\sqrt{n \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{2}{k}\right)}
\end{array}
Initial program 99.5%
Taylor expanded in k around 0
Applied rewrites39.5%
Applied rewrites39.6%
Applied rewrites39.7%
Applied rewrites39.6%
herbie shell --seed 2025019
(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))))