
(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 5 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) 2.0) n) (fma -0.5 k 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.5%
Applied rewrites99.5%
Applied rewrites99.6%
Final simplification99.6%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (* (PI) 2.0) n)))
(if (<= (* (pow t_0 (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k))) 2e-69)
(* (sqrt t_0) (pow (* k k) -0.25))
(* (sqrt (* n 2.0)) (sqrt (/ (PI) k))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\\
\mathbf{if}\;{t\_0}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 2 \cdot 10^{-69}:\\
\;\;\;\;\sqrt{t\_0} \cdot {\left(k \cdot k\right)}^{-0.25}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{n \cdot 2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right)}{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)))) < 1.9999999999999999e-69Initial program 99.7%
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.f6418.0
Applied rewrites18.0%
Applied rewrites17.9%
Applied rewrites51.8%
if 1.9999999999999999e-69 < (*.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.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.f6445.8
Applied rewrites45.8%
Applied rewrites45.9%
Applied rewrites45.9%
Applied rewrites63.3%
Final simplification60.0%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (* (sqrt n) (sqrt (* (/ (PI) k) 2.0))) (/ (pow (* (* (PI) 2.0) n) (* -0.5 k)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{n} \cdot \sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(-0.5 \cdot k\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1Initial program 98.9%
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.f6471.9
Applied rewrites71.9%
Applied rewrites72.0%
Applied rewrites72.0%
Applied rewrites96.3%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
lower-*.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f64100.0
lift-*.f64N/A
*-commutativeN/A
lift-*.f64100.0
Applied rewrites100.0%
Final simplification98.1%
(FPCore (k n) :precision binary64 (* (sqrt n) (sqrt (* (/ (PI) k) 2.0))))
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2}
\end{array}
Initial program 99.5%
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.f6437.8
Applied rewrites37.8%
Applied rewrites37.8%
Applied rewrites37.8%
Applied rewrites50.2%
Final simplification50.2%
(FPCore (k n) :precision binary64 (sqrt (* (* (/ (PI) k) n) 2.0)))
\begin{array}{l}
\\
\sqrt{\left(\frac{\mathsf{PI}\left(\right)}{k} \cdot n\right) \cdot 2}
\end{array}
Initial program 99.5%
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.f6437.8
Applied rewrites37.8%
Applied rewrites37.8%
Applied rewrites37.8%
Final simplification37.8%
herbie shell --seed 2024304
(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))))