
(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 13 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 (/ (/ (/ (PI) (* b 2.0)) a) (+ b a)))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\frac{\mathsf{PI}\left(\right)}{b \cdot 2}}{a}}{b + a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
associate-/r/N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6499.7
Applied rewrites99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1.4e+152) (* (PI) (/ 0.5 (* a (* b a)))) (/ (* (PI) 0.5) (* b (* a (+ b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.4 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\
\end{array}
\end{array}
if a < -1.4000000000000001e152Initial program 54.6%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6498.5
Applied rewrites98.5%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6498.5
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6478.9
Applied rewrites78.9%
associate-*r*N/A
lift-*.f64N/A
lower-*.f6498.5
Applied rewrites98.5%
if -1.4000000000000001e152 < a Initial program 84.3%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-inN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6496.8
Applied rewrites96.8%
Final simplification97.0%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (let* ((t_0 (* (PI) 0.5))) (if (<= b 9.5e+81) (/ t_0 (* a (* b (+ b a)))) (/ t_0 (* b (* b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot 0.5\\
\mathbf{if}\;b \leq 9.5 \cdot 10^{+81}:\\
\;\;\;\;\frac{t\_0}{a \cdot \left(b \cdot \left(b + a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 9.50000000000000083e81Initial program 81.8%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
associate-/r/N/A
lower-/.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-+.f64N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-/.f64N/A
div-invN/A
metadata-evalN/A
lift-/.f64N/A
associate-*l/N/A
associate-/r*N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites93.7%
if 9.50000000000000083e81 < b Initial program 72.7%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites88.9%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f64100.0
Applied rewrites100.0%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
metadata-evalN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= a -1e+116) (/ (* (PI) 0.5) (* a (* b a))) (* (PI) (/ 0.5 (* b (* a (+ b a)))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1 \cdot 10^{+116}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(a \cdot \left(b + a\right)\right)}\\
\end{array}
\end{array}
if a < -1.00000000000000002e116Initial program 62.5%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6498.7
Applied rewrites98.7%
if -1.00000000000000002e116 < a Initial program 83.8%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-+.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-inN/A
+-commutativeN/A
lift-+.f64N/A
lower-*.f6496.6
Applied rewrites96.6%
Final simplification96.9%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (/ (* (PI) 0.5) (* b a)) (+ b a)))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\frac{\mathsf{PI}\left(\right) \cdot 0.5}{b \cdot a}}{b + a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ (PI) (+ b a)) (/ 0.5 (* b a))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\mathsf{PI}\left(\right)}{b + a} \cdot \frac{0.5}{b \cdot a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
Applied rewrites99.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (/ (PI) (* b a)) (/ 0.5 (+ b a))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\mathsf{PI}\left(\right)}{b \cdot a} \cdot \frac{0.5}{b + a}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
div-invN/A
associate-*r*N/A
div-invN/A
lower-/.f64N/A
Applied rewrites99.7%
lift-PI.f64N/A
lift-*.f64N/A
associate-/l/N/A
lift-/.f64N/A
lift-+.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
associate-*l/N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6499.6
Applied rewrites99.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (let* ((t_0 (* (PI) 0.5))) (if (<= b 1.1e-95) (/ t_0 (* a (* b a))) (/ t_0 (* b (* b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot 0.5\\
\mathbf{if}\;b \leq 1.1 \cdot 10^{-95}:\\
\;\;\;\;\frac{t\_0}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 1.0999999999999999e-95Initial program 78.3%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
if 1.0999999999999999e-95 < b Initial program 85.9%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites94.1%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f6478.3
Applied rewrites78.3%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
div-invN/A
metadata-evalN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6477.8
Applied rewrites77.8%
Final simplification70.7%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.1e-95) (/ (* (PI) 0.5) (* a (* b a))) (* (PI) (/ 0.5 (* b (* b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{-95}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot 0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 1.0999999999999999e-95Initial program 78.3%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
if 1.0999999999999999e-95 < b Initial program 85.9%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites94.1%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f6478.3
Applied rewrites78.3%
lift-PI.f64N/A
frac-2negN/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
div-invN/A
associate-/l*N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
associate-/l/N/A
associate-/r*N/A
metadata-evalN/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.7
Applied rewrites77.7%
Final simplification70.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (if (<= b 1.1e-95) (* (PI) (/ 0.5 (* a (* b a)))) (* (PI) (/ 0.5 (* b (* b a))))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.1 \cdot 10^{-95}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \frac{0.5}{b \cdot \left(b \cdot a\right)}\\
\end{array}
\end{array}
if b < 1.0999999999999999e-95Initial program 78.3%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6467.8
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6461.2
Applied rewrites61.2%
associate-*r*N/A
lift-*.f64N/A
lower-*.f6467.8
Applied rewrites67.8%
if 1.0999999999999999e-95 < b Initial program 85.9%
lift-PI.f64N/A
lift-/.f64N/A
*-rgt-identityN/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
*-rgt-identityN/A
lift-/.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-subN/A
frac-timesN/A
lower-/.f64N/A
Applied rewrites94.1%
Taylor expanded in b around inf
lower-/.f64N/A
lower-PI.f6478.3
Applied rewrites78.3%
lift-PI.f64N/A
frac-2negN/A
lift-*.f64N/A
lift-*.f64N/A
frac-2negN/A
div-invN/A
associate-/l*N/A
div-invN/A
*-commutativeN/A
lower-*.f64N/A
div-invN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l/N/A
associate-/l/N/A
associate-/r*N/A
metadata-evalN/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6477.7
Applied rewrites77.7%
Final simplification70.6%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (/ (* (PI) 0.5) (* (+ b a) (* b a))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\frac{\mathsf{PI}\left(\right) \cdot 0.5}{\left(b + a\right) \cdot \left(b \cdot a\right)}
\end{array}
Initial program 80.5%
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-PI.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
frac-timesN/A
*-rgt-identityN/A
Applied rewrites99.2%
NOTE: a and b should be sorted in increasing order before calling this function. (FPCore (a b) :precision binary64 (* (PI) (/ 0.5 (* a (* b a)))))
\begin{array}{l}
[a, b] = \mathsf{sort}([a, b])\\
\\
\mathsf{PI}\left(\right) \cdot \frac{0.5}{a \cdot \left(b \cdot a\right)}
\end{array}
Initial program 80.5%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6464.0
Applied rewrites64.0%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6463.9
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6459.2
Applied rewrites59.2%
associate-*r*N/A
lift-*.f64N/A
lower-*.f6463.9
Applied rewrites63.9%
Final simplification63.9%
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}{b \cdot \left(a \cdot a\right)}
\end{array}
Initial program 80.5%
Taylor expanded in b around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6464.0
Applied rewrites64.0%
lift-PI.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6463.9
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f6459.2
Applied rewrites59.2%
herbie shell --seed 2024216
(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))))