
(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 12 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 (/ 1.0 k)) (* (sqrt t_0) (pow t_0 (* -0.5 k))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\\
\sqrt{\frac{1}{k}} \cdot \left(\sqrt{t\_0} \cdot {t\_0}^{\left(-0.5 \cdot k\right)}\right)
\end{array}
\end{array}
Initial program 99.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
exp-prodN/A
lower-pow.f64N/A
*-commutativeN/A
exp-to-powN/A
unpow1/2N/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
Applied rewrites99.7%
Final simplification99.7%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k)))))
(if (<= t_0 4e-100)
(* (* (sqrt (/ k (* (/ k (PI)) k))) (sqrt n)) (sqrt 2.0))
(if (<= t_0 1e+274)
(/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))
(/ (pow (* 0.0 n) (fma k -0.5 0.5)) (sqrt k))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}}\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
\mathbf{elif}\;t\_0 \leq 10^{+274}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(0 \cdot n\right)}^{\left(\mathsf{fma}\left(k, -0.5, 0.5\right)\right)}}{\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)))) < 4.0000000000000001e-100Initial program 99.8%
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.f647.1
Applied rewrites7.1%
Applied rewrites7.1%
Applied rewrites48.9%
Applied rewrites48.9%
if 4.0000000000000001e-100 < (*.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.99999999999999921e273Initial 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.f6478.0
Applied rewrites78.0%
Applied rewrites97.6%
if 9.99999999999999921e273 < (*.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 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f64100.0
Applied rewrites100.0%
Final simplification86.8%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k)))
4e-100)
(* (* (sqrt (/ k (* (/ k (PI)) k))) (sqrt n)) (sqrt 2.0))
(/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\left(\sqrt{\frac{k}{\frac{k}{\mathsf{PI}\left(\right)} \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
\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)))) < 4.0000000000000001e-100Initial program 99.8%
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.f647.1
Applied rewrites7.1%
Applied rewrites7.1%
Applied rewrites48.9%
Applied rewrites48.9%
if 4.0000000000000001e-100 < (*.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.f6454.0
Applied rewrites54.0%
Applied rewrites67.5%
Final simplification63.1%
(FPCore (k n)
:precision binary64
(if (<=
(* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k)))
4e-100)
(* (* (sqrt (* (/ k (* k k)) (PI))) (sqrt n)) (sqrt 2.0))
(/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 4 \cdot 10^{-100}:\\
\;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
\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)))) < 4.0000000000000001e-100Initial program 99.8%
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.f647.1
Applied rewrites7.1%
Applied rewrites7.1%
Applied rewrites48.9%
Applied rewrites48.9%
if 4.0000000000000001e-100 < (*.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.f6454.0
Applied rewrites54.0%
Applied rewrites67.5%
Final simplification63.1%
(FPCore (k n)
:precision binary64
(let* ((t_0 (* (PI) n)))
(if (<= (* (pow (* (* (PI) 2.0) n) (/ (- 1.0 k) 2.0)) (/ 1.0 (sqrt k))) 0.0)
(sqrt (/ (fma t_0 k (* t_0 k)) (* k k)))
(/ (sqrt (* t_0 2.0)) (sqrt k)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot n\\
\mathbf{if}\;{\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot n\right)}^{\left(\frac{1 - k}{2}\right)} \cdot \frac{1}{\sqrt{k}} \leq 0:\\
\;\;\;\;\sqrt{\frac{\mathsf{fma}\left(t\_0, k, t\_0 \cdot k\right)}{k \cdot k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{t\_0 \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.2
Applied rewrites3.2%
Applied rewrites3.2%
Applied rewrites3.2%
Applied rewrites10.2%
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.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.f6454.4
Applied rewrites54.4%
Applied rewrites67.7%
Final simplification54.9%
(FPCore (k n) :precision binary64 (/ (pow (* (* (PI) n) 2.0) (fma k -0.5 0.5)) (sqrt k)))
\begin{array}{l}
\\
\frac{{\left(\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2\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
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
exp-prodN/A
lower-pow.f64N/A
*-commutativeN/A
exp-to-powN/A
unpow1/2N/A
lower-sqrt.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f64N/A
lower--.f64N/A
lower-sqrt.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
Applied rewrites99.7%
Applied rewrites99.6%
Final simplification99.6%
(FPCore (k n)
:precision binary64
(if (<= k 8.5e+104)
(/ (sqrt (* (* (PI) n) 2.0)) (sqrt k))
(if (<= k 1.32e+154)
(* (* (sqrt (/ (* k k) (* (* (/ k (PI)) k) k))) (sqrt n)) (sqrt 2.0))
(* (* (sqrt (* (/ k (* k k)) (PI))) (sqrt n)) (sqrt 2.0)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 8.5 \cdot 10^{+104}:\\
\;\;\;\;\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{k}}\\
\mathbf{elif}\;k \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\left(\sqrt{\frac{k \cdot k}{\left(\frac{k}{\mathsf{PI}\left(\right)} \cdot k\right) \cdot k}} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{k}{k \cdot k} \cdot \mathsf{PI}\left(\right)} \cdot \sqrt{n}\right) \cdot \sqrt{2}\\
\end{array}
\end{array}
if k < 8.4999999999999999e104Initial 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.f6457.9
Applied rewrites57.9%
Applied rewrites72.0%
if 8.4999999999999999e104 < k < 1.31999999999999998e154Initial 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.f642.9
Applied rewrites2.9%
Applied rewrites2.9%
Applied rewrites2.9%
Applied rewrites64.2%
if 1.31999999999999998e154 < k Initial 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.f642.6
Applied rewrites2.6%
Applied rewrites2.7%
Applied rewrites45.7%
Applied rewrites45.7%
Final simplification65.7%
(FPCore (k n) :precision binary64 (/ (sqrt (* (* (PI) n) 2.0)) (sqrt k)))
\begin{array}{l}
\\
\frac{\sqrt{\left(\mathsf{PI}\left(\right) \cdot n\right) \cdot 2}}{\sqrt{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.f6443.0
Applied rewrites43.0%
Applied rewrites53.3%
Final simplification53.3%
(FPCore (k n) :precision binary64 (* (sqrt (/ 2.0 k)) (sqrt (* (PI) n))))
\begin{array}{l}
\\
\sqrt{\frac{2}{k}} \cdot \sqrt{\mathsf{PI}\left(\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.f6443.0
Applied rewrites43.0%
Applied rewrites43.0%
Applied rewrites53.3%
Final simplification53.3%
(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.f6443.0
Applied rewrites43.0%
Applied rewrites43.0%
Applied rewrites53.2%
Final simplification53.2%
(FPCore (k n) :precision binary64 (sqrt (* (* n 2.0) (/ (PI) k))))
\begin{array}{l}
\\
\sqrt{\left(n \cdot 2\right) \cdot \frac{\mathsf{PI}\left(\right)}{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.f6443.0
Applied rewrites43.0%
Applied rewrites43.0%
Applied rewrites43.1%
Final simplification43.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.f6443.0
Applied rewrites43.0%
Applied rewrites43.0%
Applied rewrites43.1%
Applied rewrites43.1%
Final simplification43.1%
herbie shell --seed 2024312
(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))))