
(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 6 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) (* 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 98.9%
Taylor expanded in k around inf
sinh-+-cosh-revN/A
+-commutativeN/A
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
mul-1-negN/A
distribute-rgt-inN/A
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
Applied rewrites98.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6499.0
Applied rewrites99.0%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (sqrt k) -1.0) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
0.0)
(/ (pow (* (PI) (* (PI) 2.0)) (fma -0.5 k 0.5)) (sqrt k))
(* (sqrt (* (/ 2.0 k) (PI))) (sqrt n))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\sqrt{k}\right)}^{-1} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \leq 0:\\
\;\;\;\;\frac{{\left(\mathsf{PI}\left(\right) \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{2}{k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\\
\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)))) < 0.0Initial program 100.0%
Taylor expanded in k around inf
Applied rewrites100.0%
Applied rewrites100.0%
if 0.0 < (*.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 98.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.f6449.2
Applied rewrites49.2%
Applied rewrites49.3%
Applied rewrites49.4%
Applied rewrites69.3%
Final simplification76.0%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (PI) n)))
(if (<= k 1.6e+174)
(* (sqrt (* (/ 2.0 k) (PI))) (sqrt n))
(sqrt (/ (fma t_0 k (* k t_0)) (* k k))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot n\\
\mathbf{if}\;k \leq 1.6 \cdot 10^{+174}:\\
\;\;\;\;\sqrt{\frac{2}{k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\mathsf{fma}\left(t\_0, k, k \cdot t\_0\right)}{k \cdot k}}\\
\end{array}
\end{array}
if k < 1.6e174Initial program 98.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.f6447.5
Applied rewrites47.5%
Applied rewrites47.7%
Applied rewrites47.7%
Applied rewrites66.8%
if 1.6e174 < k Initial program 100.0%
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.f642.5
Applied rewrites2.5%
Applied rewrites2.5%
Applied rewrites13.4%
(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 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.f6439.1
Applied rewrites39.1%
Applied rewrites39.2%
Applied rewrites39.2%
Applied rewrites54.8%
(FPCore (k n) :precision binary64 (* (sqrt (* (PI) n)) (sqrt (/ 2.0 k))))
\begin{array}{l}
\\
\sqrt{\mathsf{PI}\left(\right) \cdot n} \cdot \sqrt{\frac{2}{k}}
\end{array}
Initial 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.f6439.1
Applied rewrites39.1%
Applied rewrites39.2%
Applied rewrites54.5%
(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 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.f6439.1
Applied rewrites39.1%
Applied rewrites39.2%
Applied rewrites39.2%
herbie shell --seed 2024354
(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))))