
(FPCore (a b) :precision binary64 (* (* (/ (PI) 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
\begin{array}{l}
\\
\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (* (* (/ (PI) 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))
\begin{array}{l}
\\
\left(\frac{\mathsf{PI}\left(\right)}{2} \cdot \frac{1}{b \cdot b - a \cdot a}\right) \cdot \left(\frac{1}{a} - \frac{1}{b}\right)
\end{array}
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -2e+110) (* (* (/ -1.0 b) (/ (PI) (+ a b))) (/ 0.5 (- b a))) (* (/ (/ (- b a) (+ a b)) (* (* (- b a) a) b)) (* 0.5 (PI)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2 \cdot 10^{+110}:\\
\;\;\;\;\left(\frac{-1}{b} \cdot \frac{\mathsf{PI}\left(\right)}{a + b}\right) \cdot \frac{0.5}{b - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b - a}{a + b}}{\left(\left(b - a\right) \cdot a\right) \cdot b} \cdot \left(0.5 \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if a < -2e110Initial program 60.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
div-invN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.9%
Taylor expanded in a around inf
Applied rewrites99.9%
if -2e110 < a Initial program 79.4%
Applied rewrites91.5%
Applied rewrites98.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6498.7
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
lift-/.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
times-fracN/A
lift-PI.f64N/A
lower-*.f64N/A
Applied rewrites94.3%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.1e-109) (/ (/ (* 0.5 (PI)) (* a b)) a) (* (* (pow a -1.0) (/ (PI) (+ a b))) (/ 0.5 (- b a)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{0.5 \cdot \mathsf{PI}\left(\right)}{a \cdot b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\left({a}^{-1} \cdot \frac{\mathsf{PI}\left(\right)}{a + b}\right) \cdot \frac{0.5}{b - a}\\
\end{array}
\end{array}
if b < 2.09999999999999996e-109Initial program 74.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Applied rewrites57.1%
Applied rewrites69.0%
Applied rewrites69.4%
if 2.09999999999999996e-109 < b Initial program 79.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
div-invN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.7%
Taylor expanded in a around 0
lower-/.f6490.1
Applied rewrites90.1%
Final simplification75.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (* (/ (PI) (+ a b)) (- b a)) (* (- b a) (* (* a b) 2.0))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\mathsf{PI}\left(\right)}{a + b} \cdot \left(b - a\right)}{\left(b - a\right) \cdot \left(\left(a \cdot b\right) \cdot 2\right)}
\end{array}
Initial program 75.9%
Applied rewrites88.3%
Applied rewrites98.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.1e-109) (/ (/ (* 0.5 (PI)) (* a b)) a) (* (/ (/ (PI) b) a) (/ 0.5 (- b a)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{0.5 \cdot \mathsf{PI}\left(\right)}{a \cdot b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{b}}{a} \cdot \frac{0.5}{b - a}\\
\end{array}
\end{array}
if b < 2.09999999999999996e-109Initial program 74.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Applied rewrites57.1%
Applied rewrites69.0%
Applied rewrites69.4%
if 2.09999999999999996e-109 < b Initial program 79.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
div-invN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.7%
Taylor expanded in a around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-PI.f64N/A
lower-*.f6453.4
Applied rewrites53.4%
Taylor expanded in a around 0
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-PI.f6489.9
Applied rewrites89.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.1e-109) (/ (/ (* 0.5 (PI)) (* a b)) a) (* (/ (/ (PI) a) b) (/ 0.5 (- b a)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{0.5 \cdot \mathsf{PI}\left(\right)}{a \cdot b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b} \cdot \frac{0.5}{b - a}\\
\end{array}
\end{array}
if b < 2.09999999999999996e-109Initial program 74.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Applied rewrites57.1%
Applied rewrites69.0%
Applied rewrites69.4%
if 2.09999999999999996e-109 < b Initial program 79.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
un-div-invN/A
lift-/.f64N/A
div-invN/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
difference-of-squaresN/A
times-fracN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites75.7%
Taylor expanded in a around 0
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-PI.f6489.7
Applied rewrites89.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.1e-109) (/ (/ (* 0.5 (PI)) (* a b)) a) (/ (PI) (* (- b a) (* (* a b) 2.0)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{0.5 \cdot \mathsf{PI}\left(\right)}{a \cdot b}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b - a\right) \cdot \left(\left(a \cdot b\right) \cdot 2\right)}\\
\end{array}
\end{array}
if b < 2.09999999999999996e-109Initial program 74.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Applied rewrites57.1%
Applied rewrites69.0%
Applied rewrites69.4%
if 2.09999999999999996e-109 < b Initial program 79.0%
Applied rewrites98.4%
Applied rewrites98.8%
Taylor expanded in a around 0
lower-PI.f6489.1
Applied rewrites89.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.1e-109) (* (/ (PI) a) (/ 0.5 (* a b))) (/ (PI) (* (- b a) (* (* a b) 2.0)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-109}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a} \cdot \frac{0.5}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b - a\right) \cdot \left(\left(a \cdot b\right) \cdot 2\right)}\\
\end{array}
\end{array}
if b < 2.09999999999999996e-109Initial program 74.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Applied rewrites69.4%
if 2.09999999999999996e-109 < b Initial program 79.0%
Applied rewrites98.4%
Applied rewrites98.8%
Taylor expanded in a around 0
lower-PI.f6489.1
Applied rewrites89.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 2.1e-109) (* (/ (PI) (* (* a b) a)) 0.5) (/ (PI) (* (- b a) (* (* a b) 2.0)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.1 \cdot 10^{-109}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b - a\right) \cdot \left(\left(a \cdot b\right) \cdot 2\right)}\\
\end{array}
\end{array}
if b < 2.09999999999999996e-109Initial program 74.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Applied rewrites69.0%
if 2.09999999999999996e-109 < b Initial program 79.0%
Applied rewrites98.4%
Applied rewrites98.8%
Taylor expanded in a around 0
lower-PI.f6489.1
Applied rewrites89.1%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 4e-93) (* (/ (PI) (* (* a b) a)) 0.5) (* (/ (PI) (* (* b b) a)) 0.5)))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 4 \cdot 10^{-93}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
\end{array}
\end{array}
if b < 3.9999999999999996e-93Initial program 75.0%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6458.0
Applied rewrites58.0%
Applied rewrites69.7%
if 3.9999999999999996e-93 < b Initial program 77.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6473.3
Applied rewrites73.3%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ (PI) (* (* a b) a)) 0.5))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\mathsf{PI}\left(\right)}{\left(a \cdot b\right) \cdot a} \cdot 0.5
\end{array}
Initial program 75.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.6
Applied rewrites52.6%
Applied rewrites61.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (PI) (/ 0.5 (* (* b a) a))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{PI}\left(\right) \cdot \frac{0.5}{\left(b \cdot a\right) \cdot a}
\end{array}
Initial program 75.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.6
Applied rewrites52.6%
Applied rewrites52.6%
Applied rewrites61.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (PI) (/ 0.5 (* (* a a) b))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{PI}\left(\right) \cdot \frac{0.5}{\left(a \cdot a\right) \cdot b}
\end{array}
Initial program 75.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6452.6
Applied rewrites52.6%
Applied rewrites52.6%
herbie shell --seed 2024317
(FPCore (a b)
:name "NMSE Section 6.1 mentioned, B"
:precision binary64
(* (* (/ (PI) 2.0) (/ 1.0 (- (* b b) (* a a)))) (- (/ 1.0 a) (/ 1.0 b))))