
(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 9 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 (* n (* (PI) 2.0)))) (* (sqrt (pow 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)\\
\sqrt{{k}^{-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%
Taylor expanded in k around 0
lower-sqrt.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
Final simplification99.7%
(FPCore (k n) :precision binary64 (pow (* (pow (* n (* (PI) 2.0)) (fma 0.5 k -0.5)) (sqrt k)) -1.0))
\begin{array}{l}
\\
{\left({\left(n \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\right)}^{\left(\mathsf{fma}\left(0.5, k, -0.5\right)\right)} \cdot \sqrt{k}\right)}^{-1}
\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
lift-/.f64N/A
associate-*l/N/A
clear-numN/A
lower-/.f64N/A
*-lft-identityN/A
lower-/.f6499.6
lift-*.f64N/A
lift-pow.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
Applied rewrites99.6%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites99.6%
Final simplification99.6%
(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.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.6%
Final simplification99.6%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (/ (sqrt (* 2.0 n)) (sqrt (/ k (PI)))) (/ (pow (* (* 2.0 (PI)) n) (* -0.5 k)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\mathsf{PI}\left(\right)}}}\\
\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.f6476.6
Applied rewrites76.6%
Applied rewrites76.8%
Applied rewrites76.8%
Applied rewrites98.3%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
lower-*.f64100.0
Applied rewrites100.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f64100.0
Applied rewrites100.0%
(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.6
Applied rewrites99.5%
(FPCore (k n) :precision binary64 (/ (sqrt (* 2.0 n)) (sqrt (/ k (PI)))))
\begin{array}{l}
\\
\frac{\sqrt{2 \cdot n}}{\sqrt{\frac{k}{\mathsf{PI}\left(\right)}}}
\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.f6439.0
Applied rewrites39.0%
Applied rewrites39.1%
Applied rewrites39.1%
Applied rewrites49.7%
(FPCore (k n) :precision binary64 (* (sqrt (* (/ (PI) k) 2.0)) (sqrt n)))
\begin{array}{l}
\\
\sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot 2} \cdot \sqrt{n}
\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.f6439.0
Applied rewrites39.0%
Applied rewrites39.1%
Applied rewrites49.7%
(FPCore (k n) :precision binary64 (sqrt (* (/ n k) (* 2.0 (PI)))))
\begin{array}{l}
\\
\sqrt{\frac{n}{k} \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)}
\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.f6439.0
Applied rewrites39.0%
Applied rewrites39.1%
Applied rewrites39.1%
(FPCore (k n) :precision binary64 (sqrt (* (* (/ 2.0 k) (PI)) n)))
\begin{array}{l}
\\
\sqrt{\left(\frac{2}{k} \cdot \mathsf{PI}\left(\right)\right) \cdot n}
\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.f6439.0
Applied rewrites39.0%
Applied rewrites39.1%
Applied rewrites39.1%
herbie shell --seed 2024324
(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))))