
(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 10 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 t_0) (pow t_0 (* 0.5 k))) (sqrt (/ 1.0 k)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot \left(\mathsf{PI}\left(\right) \cdot 2\right)\\
\frac{\sqrt{t\_0}}{{t\_0}^{\left(0.5 \cdot k\right)}} \cdot \sqrt{\frac{1}{k}}
\end{array}
\end{array}
Initial program 99.5%
Taylor expanded in k around inf
Applied rewrites99.6%
Applied rewrites99.7%
(FPCore (k n) :precision binary64 (if (<= (* (/ 1.0 (sqrt k)) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0))) 1e-70) (sqrt (* n (/ (fma (PI) k (* k (PI))) (* k k)))) (* (sqrt (* (PI) n)) (sqrt (/ 2.0 k)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{k}} \cdot {\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \leq 10^{-70}:\\
\;\;\;\;\sqrt{n \cdot \frac{\mathsf{fma}\left(\mathsf{PI}\left(\right), k, k \cdot \mathsf{PI}\left(\right)\right)}{k \cdot k}}\\
\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)))) < 9.99999999999999996e-71Initial program 99.7%
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.f6414.2
Applied rewrites14.2%
Applied rewrites14.2%
Applied rewrites14.2%
Applied rewrites58.9%
if 9.99999999999999996e-71 < (*.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.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.f6449.2
Applied rewrites49.2%
Applied rewrites49.3%
Applied rewrites64.2%
(FPCore (k n) :precision binary64 (if (<= k 1.0) (* (sqrt (* (PI) n)) (sqrt (/ 2.0 k))) (/ (pow (* (* (PI) 2.0) n) (* -0.5 k)) (sqrt k))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 1:\\
\;\;\;\;\sqrt{\mathsf{PI}\left(\right) \cdot n} \cdot \sqrt{\frac{2}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot 2\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.1
Applied rewrites76.1%
Applied rewrites76.3%
Applied rewrites97.4%
if 1 < k Initial program 100.0%
Taylor expanded in k around inf
Applied rewrites100.0%
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in k around inf
Applied rewrites100.0%
(FPCore (k n) :precision binary64 (* (pow (* (* 2.0 n) (PI)) (fma -0.5 k 0.5)) (sqrt (/ 1.0 k))))
\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{\frac{1}{k}}
\end{array}
Initial program 99.5%
Taylor expanded in k around inf
Applied rewrites99.6%
(FPCore (k n) :precision binary64 (/ (pow (* (* (PI) 2.0) n) (fma k -0.5 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\sqrt{k}}
\end{array}
Initial program 99.5%
Taylor expanded in k around inf
Applied rewrites99.6%
Applied rewrites99.7%
Applied rewrites99.6%
Applied rewrites99.6%
(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.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.f6438.2
Applied rewrites38.2%
Applied rewrites38.4%
Applied rewrites48.6%
(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.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.f6438.2
Applied rewrites38.2%
Applied rewrites38.4%
(FPCore (k n) :precision binary64 (sqrt (* (/ (PI) k) (* n 2.0))))
\begin{array}{l}
\\
\sqrt{\frac{\mathsf{PI}\left(\right)}{k} \cdot \left(n \cdot 2\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.f6438.2
Applied rewrites38.2%
Applied rewrites38.4%
Applied rewrites38.4%
(FPCore (k n) :precision binary64 (sqrt (* (* (PI) n) (/ 2.0 k))))
\begin{array}{l}
\\
\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot \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.f6438.2
Applied rewrites38.2%
Applied rewrites38.4%
Applied rewrites38.3%
(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.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.f6438.2
Applied rewrites38.2%
Applied rewrites38.4%
Applied rewrites38.0%
herbie shell --seed 2024366
(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))))