
(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 (* (* (PI) n) 2.0))) (/ (sqrt t_0) (* (pow t_0 (/ k 2.0)) (sqrt k)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\\
\frac{\sqrt{t\_0}}{{t\_0}^{\left(\frac{k}{2}\right)} \cdot \sqrt{k}}
\end{array}
\end{array}
Initial program 99.4%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-PI.f64N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6499.3
Applied rewrites99.3%
Applied rewrites99.6%
Final simplification99.6%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (sqrt k) -1.0) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
2e-62)
(sqrt (* (sqrt (/ (* (PI) (PI)) (* k k))) (* 2.0 n)))
(/ (sqrt (* (* (PI) n) 2.0)) (sqrt 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 2 \cdot 10^{-62}:\\
\;\;\;\;\sqrt{\sqrt{\frac{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)}{k \cdot k}} \cdot \left(2 \cdot n\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\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)))) < 2.0000000000000001e-62Initial 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.f6417.7
Applied rewrites17.7%
Applied rewrites17.6%
Applied rewrites17.7%
Applied rewrites59.1%
if 2.0000000000000001e-62 < (*.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.3%
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.f6455.8
Applied rewrites55.8%
Applied rewrites69.5%
Final simplification66.4%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (sqrt k) -1.0) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
0.0)
(sqrt (* (/ (* n (+ k k)) (* k k)) (PI)))
(/ (sqrt (* (* (PI) n) 2.0)) (sqrt 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{\frac{n \cdot \left(k + k\right)}{k \cdot k} \cdot \mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\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)))) < 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 rewrites13.8%
Applied rewrites13.8%
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.f6458.1
Applied rewrites58.1%
Applied rewrites70.8%
Final simplification56.6%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (sqrt k) -1.0) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
0.0)
(sqrt (* (/ (* n (+ k k)) (* k k)) (PI)))
(* (sqrt (/ (PI) k)) (sqrt (* 2.0 n)))))\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{\frac{n \cdot \left(k + k\right)}{k \cdot k} \cdot \mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\mathsf{PI}\left(\right)}{k}} \cdot \sqrt{2 \cdot n}\\
\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 rewrites13.8%
Applied rewrites13.8%
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.f6458.1
Applied rewrites58.1%
Applied rewrites58.2%
Applied rewrites70.8%
Final simplification56.5%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (sqrt k) -1.0) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
0.0)
(sqrt (* (/ (* n (+ k k)) (* k k)) (PI)))
(* (sqrt (* 2.0 (/ (PI) k))) (sqrt n))))\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{\frac{n \cdot \left(k + k\right)}{k \cdot k} \cdot \mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot \frac{\mathsf{PI}\left(\right)}{k}} \cdot \sqrt{n}\\
\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 rewrites13.8%
Applied rewrites13.8%
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.f6458.1
Applied rewrites58.1%
Applied rewrites58.2%
Applied rewrites70.8%
Final simplification56.5%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (sqrt k) -1.0) (pow (* (* 2.0 (PI)) n) (/ (- 1.0 k) 2.0)))
0.0)
(sqrt (* (/ (* n (+ k k)) (* k k)) (PI)))
(sqrt (* (* 2.0 (/ n k)) (PI)))))\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{\frac{n \cdot \left(k + k\right)}{k \cdot k} \cdot \mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(2 \cdot \frac{n}{k}\right) \cdot \mathsf{PI}\left(\right)}\\
\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 rewrites13.8%
Applied rewrites13.8%
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.f6458.1
Applied rewrites58.1%
Applied rewrites58.2%
Final simplification47.1%
(FPCore (k n) :precision binary64 (let* ((t_0 (* (* (PI) n) 2.0))) (* (pow (sqrt k) -1.0) (* (pow t_0 (* -0.5 k)) (sqrt t_0)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\\
{\left(\sqrt{k}\right)}^{-1} \cdot \left({t\_0}^{\left(-0.5 \cdot k\right)} \cdot \sqrt{t\_0}\right)
\end{array}
\end{array}
Initial program 99.4%
Taylor expanded in k around inf
sinh-+-cosh-revN/A
+-commutativeN/A
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
mul-1-negN/A
distribute-rgt-inN/A
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
Applied rewrites99.4%
Applied rewrites99.6%
Final simplification99.6%
(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 inf
sinh-+-cosh-revN/A
+-commutativeN/A
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
mul-1-negN/A
distribute-rgt-inN/A
distribute-rgt-out--N/A
fp-cancel-sub-signN/A
Applied rewrites99.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lower-/.f6499.4
Applied rewrites99.4%
(FPCore (k n) :precision binary64 (sqrt (* (* 2.0 (/ n k)) (PI))))
\begin{array}{l}
\\
\sqrt{\left(2 \cdot \frac{n}{k}\right) \cdot \mathsf{PI}\left(\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.f6444.4
Applied rewrites44.4%
Applied rewrites44.5%
herbie shell --seed 2024347
(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))))