
(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 (* (* (PI) n) 2.0) (fma -0.5 k 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f6499.2
Applied rewrites99.2%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-sqrt.f6499.2
Applied rewrites99.2%
lift-*.f64N/A
*-lft-identity99.2
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6499.2
Applied rewrites99.2%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (PI) n)))
(if (<= k 1.02)
(* (/ 1.0 (sqrt k)) (* (sqrt t_0) (sqrt 2.0)))
(/ (pow (* t_0 2.0) (* -0.5 k)) (sqrt k)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot n\\
\mathbf{if}\;k \leq 1.02:\\
\;\;\;\;\frac{1}{\sqrt{k}} \cdot \left(\sqrt{t\_0} \cdot \sqrt{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(t\_0 \cdot 2\right)}^{\left(-0.5 \cdot k\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1.02Initial program 98.3%
Taylor expanded in k around 0
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6495.9
Applied rewrites95.9%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
sqrt-unprodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f6496.5
Applied rewrites96.5%
if 1.02 < k Initial program 100.0%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-sqrt.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-lft-identity100.0
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64100.0
Applied rewrites100.0%
Taylor expanded in k around inf
lower-*.f6498.5
Applied rewrites98.5%
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (* (sqrt (* (PI) n)) (sqrt 2.0))))
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot \left(\sqrt{\mathsf{PI}\left(\right) \cdot n} \cdot \sqrt{2}\right)
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6447.8
Applied rewrites47.8%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
sqrt-unprodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f6448.1
Applied rewrites48.1%
(FPCore (k n) :precision binary64 (* (/ 1.0 (sqrt k)) (* (sqrt (+ (PI) (PI))) (sqrt n))))
\begin{array}{l}
\\
\frac{1}{\sqrt{k}} \cdot \left(\sqrt{\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right)
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6447.8
Applied rewrites47.8%
lift-sqrt.f64N/A
lift-*.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6448.0
Applied rewrites48.0%
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
count-2-revN/A
lower-+.f64N/A
lift-PI.f64N/A
lift-PI.f6448.0
Applied rewrites48.0%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* 2.0 n) (PI))) (sqrt k)))
\begin{array}{l}
\\
\frac{\sqrt{\left(2 \cdot n\right) \cdot \mathsf{PI}\left(\right)}}{\sqrt{k}}
\end{array}
Initial program 99.2%
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.2%
Taylor expanded in k around 0
*-lft-identityN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
sqr-powN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
sqrt-unprodN/A
*-commutativeN/A
*-commutativeN/A
Applied rewrites47.9%
Final simplification47.9%
(FPCore (k n) :precision binary64 (sqrt (* (* (PI) (/ n k)) 2.0)))
\begin{array}{l}
\\
\sqrt{\left(\mathsf{PI}\left(\right) \cdot \frac{n}{k}\right) \cdot 2}
\end{array}
Initial program 99.2%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6438.4
Applied rewrites38.4%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-/.f6438.4
Applied rewrites38.4%
(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 99.2%
Taylor expanded in k around 0
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6438.4
Applied rewrites38.4%
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6438.4
Applied rewrites38.4%
herbie shell --seed 2025056
(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))))