
(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 10 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 k -0.5) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))))
\begin{array}{l}
\\
{k}^{-0.5} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)}
\end{array}
Initial program 99.5%
lift-/.f64N/A
inv-powN/A
lift-sqrt.f64N/A
pow1/2N/A
pow-powN/A
lower-pow.f64N/A
metadata-eval99.7
Applied rewrites99.7%
(FPCore (k n) :precision binary64 (if (<= (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))) 0.0) (sqrt 0.0) (* (sqrt (* (PI) n)) (sqrt (/ 2.0 k)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \leq 0:\\
\;\;\;\;\sqrt{0}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{PI}\left(\right) \cdot n} \cdot \sqrt{\frac{2}{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)))) < 0.0Initial 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.f643.1
Applied rewrites3.1%
Applied rewrites3.1%
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 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.f6455.9
Applied rewrites55.9%
Applied rewrites56.1%
Applied rewrites73.5%
Final simplification78.9%
(FPCore (k n) :precision binary64 (if (<= k 0.78) (* (sqrt (* (PI) n)) (sqrt (/ 2.0 k))) (/ (pow (* (* n 2.0) n) (fma -0.5 k 0.5)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 0.78:\\
\;\;\;\;\sqrt{\mathsf{PI}\left(\right) \cdot n} \cdot \sqrt{\frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(n \cdot 2\right) \cdot n\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 0.78000000000000003Initial 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.f6475.2
Applied rewrites75.2%
Applied rewrites75.5%
Applied rewrites99.1%
if 0.78000000000000003 < k Initial program 100.0%
Taylor expanded in k around inf
Applied rewrites100.0%
Applied rewrites100.0%
(FPCore (k n) :precision binary64 (* (pow (* (* 2.0 n) (PI)) (fma -0.5 k 0.5)) (sqrt (/ 1.0 k))))
\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{\frac{1}{k}}
\end{array}
Initial program 99.5%
Taylor expanded in k around inf
Applied rewrites99.6%
(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 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.f6445.1
Applied rewrites45.1%
Applied rewrites45.3%
Applied rewrites59.2%
(FPCore (k n) :precision binary64 (* (sqrt (* n 2.0)) (sqrt (/ (PI) k))))
\begin{array}{l}
\\
\sqrt{n \cdot 2} \cdot \sqrt{\frac{\mathsf{PI}\left(\right)}{k}}
\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.f6445.1
Applied rewrites45.1%
Applied rewrites45.3%
Applied rewrites59.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.f6445.1
Applied rewrites45.1%
Applied rewrites45.3%
Applied rewrites59.1%
(FPCore (k n) :precision binary64 (sqrt (* (/ (* n (PI)) k) 2.0)))
\begin{array}{l}
\\
\sqrt{\frac{n \cdot \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.f6445.1
Applied rewrites45.1%
Applied rewrites45.3%
(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.f6445.1
Applied rewrites45.1%
Applied rewrites45.3%
Applied rewrites45.3%
(FPCore (k n) :precision binary64 (sqrt (* (+ (PI) (PI)) (/ n k))))
\begin{array}{l}
\\
\sqrt{\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot \frac{n}{k}}
\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.f6445.1
Applied rewrites45.1%
Applied rewrites45.3%
Applied rewrites45.3%
Applied rewrites45.3%
herbie shell --seed 2025003
(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))))