
(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 (sqrt (* (* 2.0 (PI)) n)))) (/ t_0 (* (sqrt k) (pow t_0 k)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n}\\
\frac{t\_0}{\sqrt{k} \cdot {t\_0}^{k}}
\end{array}
\end{array}
Initial program 99.5%
lift-pow.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
sub-negN/A
+-commutativeN/A
unpow-prod-upN/A
lower-*.f64N/A
Applied rewrites99.6%
lift-PI.f64N/A
add-sqr-sqrtN/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6499.5
Applied rewrites99.5%
Applied rewrites99.7%
(FPCore (k n) :precision binary64 (let* ((t_0 (* n (* (PI) 2.0)))) (* (pow (sqrt k) -1.0) (* (pow t_0 (* k -0.5)) (sqrt t_0)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\\
{\left(\sqrt{k}\right)}^{-1} \cdot \left({t\_0}^{\left(k \cdot -0.5\right)} \cdot \sqrt{t\_0}\right)
\end{array}
\end{array}
Initial program 99.5%
lift-pow.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
sub-negN/A
+-commutativeN/A
unpow-prod-upN/A
lower-*.f64N/A
Applied rewrites99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (* (sqrt (* n (PI))) (sqrt (/ 2.0 k))) (/ (pow (* (* 2.0 (PI)) n) (* -0.5 k)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{n \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{\frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(-0.5 \cdot k\right)}}{\sqrt{k}}\\
\end{array}
\end{array}
if k < 1Initial program 99.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.f6469.0
Applied rewrites69.0%
Applied rewrites69.3%
Applied rewrites97.3%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
lower-*.f6499.2
Applied rewrites99.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.2
Applied rewrites99.2%
(FPCore (k n) :precision binary64 (/ (pow (* (* 2.0 (PI)) n) (fma -0.5 k 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\mathsf{fma}\left(-0.5, k, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
lift-pow.f64N/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
sub-negN/A
+-commutativeN/A
unpow-prod-upN/A
lower-*.f64N/A
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.7
Applied rewrites99.5%
(FPCore (k n) :precision binary64 (* (sqrt (* n (PI))) (sqrt (/ 2.0 k))))
\begin{array}{l}
\\
\sqrt{n \cdot \mathsf{PI}\left(\right)} \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.f6437.1
Applied rewrites37.1%
Applied rewrites37.3%
Applied rewrites51.8%
(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.f6437.1
Applied rewrites37.1%
Applied rewrites37.3%
Applied rewrites37.3%
(FPCore (k n) :precision binary64 (sqrt (* (* (/ n k) (PI)) 2.0)))
\begin{array}{l}
\\
\sqrt{\left(\frac{n}{k} \cdot \mathsf{PI}\left(\right)\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.f6437.1
Applied rewrites37.1%
Applied rewrites37.3%
Applied rewrites37.3%
herbie shell --seed 2024313
(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))))