
(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 (let* ((t_0 (* (PI) 2.0))) (* (sqrt n) (sqrt (/ t_0 (* (pow (* t_0 n) k) k))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot 2\\
\sqrt{n} \cdot \sqrt{\frac{t\_0}{{\left(t\_0 \cdot n\right)}^{k} \cdot k}}
\end{array}
\end{array}
Initial program 99.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Applied rewrites99.8%
(FPCore (k n)
:precision binary64
(let* ((t_0 (sqrt (* (* (PI) 2.0) n))))
(if (<=
(* (pow (sqrt k) -1.0) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
4e-107)
(/ t_0 (pow (* k k) 0.25))
(/ t_0 (sqrt k)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n}\\
\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 4 \cdot 10^{-107}:\\
\;\;\;\;\frac{t\_0}{{\left(k \cdot k\right)}^{0.25}}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{\sqrt{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)))) < 4e-107Initial program 99.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.f643.6
Applied rewrites3.6%
Applied rewrites3.6%
Applied rewrites50.0%
if 4e-107 < (*.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.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.f6440.2
Applied rewrites40.2%
Applied rewrites59.1%
Final simplification56.2%
(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.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Applied rewrites99.7%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* (PI) 2.0) n)) (sqrt k)))
\begin{array}{l}
\\
\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n}}{\sqrt{k}}
\end{array}
Initial program 99.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.f6428.6
Applied rewrites28.6%
Applied rewrites41.5%
(FPCore (k n) :precision binary64 (* (sqrt n) (sqrt (/ (* (PI) 2.0) k))))
\begin{array}{l}
\\
\sqrt{n} \cdot \sqrt{\frac{\mathsf{PI}\left(\right) \cdot 2}{k}}
\end{array}
Initial program 99.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.f6428.6
Applied rewrites28.6%
Applied rewrites41.5%
(FPCore (k n) :precision binary64 (sqrt (* (* n (/ 2.0 k)) (PI))))
\begin{array}{l}
\\
\sqrt{\left(n \cdot \frac{2}{k}\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 99.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.f6428.6
Applied rewrites28.6%
Applied rewrites28.7%
Applied rewrites28.7%
Applied rewrites28.7%
(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.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.f6428.6
Applied rewrites28.6%
Applied rewrites28.7%
Applied rewrites28.7%
herbie shell --seed 2024320
(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))))