
(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 7 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 (* (* 2.0 (PI)) n) (fma -0.5 k 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.2%
lift-pow.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
sub-negN/A
+-commutativeN/A
unpow-prod-upN/A
lower-*.f64N/A
Applied rewrites98.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6498.9
Applied rewrites99.3%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (/ (sqrt (* n (PI))) (sqrt (* k 0.5))) (/ (pow (* (* 2.0 (PI)) n) (* -0.5 k)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\frac{\sqrt{n \cdot \mathsf{PI}\left(\right)}}{\sqrt{k \cdot 0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(-0.5 \cdot k\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1Initial program 98.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6467.8
Applied rewrites67.8%
Applied rewrites67.8%
Applied rewrites67.9%
Applied rewrites98.7%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
lower-*.f6498.6
Applied rewrites98.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6498.6
Applied rewrites98.6%
(FPCore (k n) :precision binary64 (/ (sqrt (* n (PI))) (sqrt (* k 0.5))))
\begin{array}{l}
\\
\frac{\sqrt{n \cdot \mathsf{PI}\left(\right)}}{\sqrt{k \cdot 0.5}}
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6433.4
Applied rewrites33.4%
Applied rewrites33.5%
Applied rewrites33.5%
Applied rewrites48.1%
(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.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6433.4
Applied rewrites33.4%
Applied rewrites33.5%
Applied rewrites47.8%
(FPCore (k n) :precision binary64 (* (sqrt (* (/ 2.0 k) (PI))) (sqrt n)))
\begin{array}{l}
\\
\sqrt{\frac{2}{k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6433.4
Applied rewrites33.4%
Applied rewrites33.5%
Applied rewrites33.5%
Applied rewrites47.8%
(FPCore (k n) :precision binary64 (* (sqrt (* n (PI))) (sqrt (/ 2.0 k))))
\begin{array}{l}
\\
\sqrt{n \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{\frac{2}{k}}
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6433.4
Applied rewrites33.4%
Applied rewrites33.5%
Applied rewrites47.7%
(FPCore (k n) :precision binary64 (sqrt (* (* n (PI)) (/ 2.0 k))))
\begin{array}{l}
\\
\sqrt{\left(n \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{2}{k}}
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6433.4
Applied rewrites33.4%
Applied rewrites33.5%
Applied rewrites33.5%
herbie shell --seed 2024305
(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))))