
(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 12 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 (let* ((t_0 (* (PI) (* n 2.0)))) (* (/ (sqrt t_0) (pow t_0 (* 0.5 k))) (sqrt (pow k -1.0)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(n \cdot 2\right)\\
\frac{\sqrt{t\_0}}{{t\_0}^{\left(0.5 \cdot k\right)}} \cdot \sqrt{{k}^{-1}}
\end{array}
\end{array}
Initial program 99.4%
Taylor expanded in k around inf
Applied rewrites99.5%
Applied rewrites99.7%
Final simplification99.7%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (sqrt k) -1.0) (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}\;{\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:\\
\;\;\;\;\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.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.f6453.6
Applied rewrites53.6%
Applied rewrites53.7%
Applied rewrites67.9%
Final simplification76.0%
(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.4%
Taylor expanded in k around inf
Applied rewrites99.5%
Final simplification99.5%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* (PI) n) 2.0)) (* (pow (sqrt (* (* n 2.0) (PI))) k) (sqrt k))))
\begin{array}{l}
\\
\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{{\left(\sqrt{\left(n \cdot 2\right) \cdot \mathsf{PI}\left(\right)}\right)}^{k} \cdot \sqrt{k}}
\end{array}
Initial program 99.4%
Taylor expanded in k around inf
Applied rewrites99.5%
Applied rewrites99.7%
Applied rewrites99.7%
Applied rewrites99.7%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (PI) n)))
(if (<= k 5.1e-107)
(* (sqrt t_0) (sqrt (/ 2.0 k)))
(sqrt (/ (pow (* t_0 2.0) (- 1.0 k)) k)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot n\\
\mathbf{if}\;k \leq 5.1 \cdot 10^{-107}:\\
\;\;\;\;\sqrt{t\_0} \cdot \sqrt{\frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{\left(t\_0 \cdot 2\right)}^{\left(1 - k\right)}}{k}}\\
\end{array}
\end{array}
if k < 5.1000000000000002e-107Initial 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.f6465.4
Applied rewrites65.4%
Applied rewrites65.7%
Applied rewrites99.5%
if 5.1000000000000002e-107 < k Initial program 99.5%
Taylor expanded in k around inf
Applied rewrites99.6%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.7%
(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.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites51.7%
Taylor expanded in k around inf
*-commutativeN/A
exp-prodN/A
unpow1/2N/A
lower-sqrt.f64N/A
exp-to-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
lower--.f6499.4
Applied rewrites99.4%
Applied rewrites99.5%
(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.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.f6440.8
Applied rewrites40.8%
Applied rewrites40.9%
Applied rewrites51.4%
(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.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.f6440.8
Applied rewrites40.8%
Applied rewrites40.9%
Applied rewrites51.4%
(FPCore (k n) :precision binary64 (sqrt (* (/ (* (PI) n) k) 2.0)))
\begin{array}{l}
\\
\sqrt{\frac{\mathsf{PI}\left(\right) \cdot n}{k} \cdot 2}
\end{array}
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.f6440.8
Applied rewrites40.8%
Applied rewrites40.9%
(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.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.f6440.8
Applied rewrites40.8%
Applied rewrites40.9%
Applied rewrites40.9%
(FPCore (k n) :precision binary64 (sqrt (* (PI) (* n (/ 2.0 k)))))
\begin{array}{l}
\\
\sqrt{\mathsf{PI}\left(\right) \cdot \left(n \cdot \frac{2}{k}\right)}
\end{array}
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.f6440.8
Applied rewrites40.8%
Applied rewrites40.9%
Applied rewrites40.9%
Applied rewrites40.9%
(FPCore (k n) :precision binary64 (sqrt (* n (* (PI) (/ 2.0 k)))))
\begin{array}{l}
\\
\sqrt{n \cdot \left(\mathsf{PI}\left(\right) \cdot \frac{2}{k}\right)}
\end{array}
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.f6440.8
Applied rewrites40.8%
Applied rewrites40.9%
Applied rewrites40.9%
Applied rewrites40.8%
herbie shell --seed 2024350
(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))))