
(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 (* (* 2.0 n) (PI)) (fma -0.5 k 0.5)) (sqrt (pow k -1.0))))
\begin{array}{l}
\\
{\left(\left(2 \cdot n\right) \cdot \mathsf{PI}\left(\right)\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)} \cdot \sqrt{{k}^{-1}}
\end{array}
Initial program 99.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Final simplification99.7%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (PI) (* n 2.0))))
(if (<= k 1.0)
(* (sqrt t_0) (pow k -0.5))
(/ (pow t_0 (* -0.5 k)) (sqrt k)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(n \cdot 2\right)\\
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{t\_0} \cdot {k}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{{t\_0}^{\left(-0.5 \cdot k\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1Initial program 99.1%
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.f6476.4
Applied rewrites76.4%
Applied rewrites97.0%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
lower-*.f6499.4
Applied rewrites99.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.4
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6499.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites99.4%
(FPCore (k n) :precision binary64 (/ (pow (* (PI) (* n 2.0)) (fma -0.5 k 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\mathsf{PI}\left(\right) \cdot \left(n \cdot 2\right)\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 inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.7%
Applied rewrites99.6%
(FPCore (k n) :precision binary64 (* (sqrt (* (PI) (* n 2.0))) (pow k -0.5)))
\begin{array}{l}
\\
\sqrt{\mathsf{PI}\left(\right) \cdot \left(n \cdot 2\right)} \cdot {k}^{-0.5}
\end{array}
Initial program 99.6%
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.f6435.8
Applied rewrites35.8%
Applied rewrites45.1%
(FPCore (k n) :precision binary64 (* (sqrt (/ (PI) k)) (sqrt (* n 2.0))))
\begin{array}{l}
\\
\sqrt{\frac{\mathsf{PI}\left(\right)}{k}} \cdot \sqrt{n \cdot 2}
\end{array}
Initial program 99.6%
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.f6435.8
Applied rewrites35.8%
Applied rewrites35.9%
Applied rewrites45.0%
(FPCore (k n) :precision binary64 (* (sqrt n) (sqrt (* (/ 2.0 k) (PI)))))
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{\frac{2}{k} \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 99.6%
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.f6435.8
Applied rewrites35.8%
Applied rewrites35.9%
Applied rewrites36.0%
Applied rewrites45.0%
(FPCore (k n) :precision binary64 (sqrt (* (* (PI) 2.0) (/ n k))))
\begin{array}{l}
\\
\sqrt{\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot \frac{n}{k}}
\end{array}
Initial program 99.6%
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.f6435.8
Applied rewrites35.8%
Applied rewrites35.9%
Applied rewrites36.0%
(FPCore (k n) :precision binary64 (sqrt (* n (* (/ 2.0 k) (PI)))))
\begin{array}{l}
\\
\sqrt{n \cdot \left(\frac{2}{k} \cdot \mathsf{PI}\left(\right)\right)}
\end{array}
Initial program 99.6%
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.f6435.8
Applied rewrites35.8%
Applied rewrites35.9%
Applied rewrites36.0%
Applied rewrites35.9%
herbie shell --seed 2024322
(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))))