
(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 9 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}
(FPCore (a b) :precision binary64 (if (or (<= a -1.2e+57) (not (<= a 5e+15))) (* (/ (PI) (* 2.0 (+ a b))) (* (pow (- b a) -1.0) (/ (/ (- b a) a) b))) (/ (* (/ (PI) (* (+ a b) 2.0)) (/ (/ (- b a) b) a)) (- b a))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.2 \cdot 10^{+57} \lor \neg \left(a \leq 5 \cdot 10^{+15}\right):\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{2 \cdot \left(a + b\right)} \cdot \left({\left(b - a\right)}^{-1} \cdot \frac{\frac{b - a}{a}}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{\left(a + b\right) \cdot 2} \cdot \frac{\frac{b - a}{b}}{a}}{b - a}\\
\end{array}
\end{array}
if a < -1.20000000000000002e57 or 5e15 < a Initial program 78.1%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6492.2
Applied rewrites92.2%
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
lift-/.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.8%
if -1.20000000000000002e57 < a < 5e15Initial program 85.4%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6491.2
Applied rewrites91.2%
Applied rewrites90.7%
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
lift-*.f64N/A
associate-/l*N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites91.1%
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
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.6%
Final simplification99.7%
(FPCore (a b) :precision binary64 (if (or (<= b -3000000000000.0) (not (<= b 2e-42))) (/ (* (/ (PI) (* (+ a b) 2.0)) (/ (/ (- b a) b) a)) (- b a)) (/ (/ (* (- b a) (PI)) a) (* (* b (* (+ b a) 2.0)) (- b a)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3000000000000 \lor \neg \left(b \leq 2 \cdot 10^{-42}\right):\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{\left(a + b\right) \cdot 2} \cdot \frac{\frac{b - a}{b}}{a}}{b - a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(b - a\right) \cdot \mathsf{PI}\left(\right)}{a}}{\left(b \cdot \left(\left(b + a\right) \cdot 2\right)\right) \cdot \left(b - a\right)}\\
\end{array}
\end{array}
if b < -3e12 or 2.00000000000000008e-42 < b Initial program 79.1%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6490.5
Applied rewrites90.5%
Applied rewrites90.0%
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
lift-*.f64N/A
associate-/l*N/A
*-lft-identityN/A
*-rgt-identityN/A
Applied rewrites90.5%
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
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites99.7%
if -3e12 < b < 2.00000000000000008e-42Initial program 86.1%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6492.9
Applied rewrites92.9%
Applied rewrites93.0%
Applied rewrites99.3%
Final simplification99.5%
(FPCore (a b) :precision binary64 (if (or (<= b -1e+123) (not (<= b 2e+107))) (/ (* (/ (PI) b) 0.5) (* a b)) (/ (* (/ (PI) (* (* 2.0 (+ a b)) (- b a))) (- b a)) (* a b))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{+123} \lor \neg \left(b \leq 2 \cdot 10^{+107}\right):\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{b} \cdot 0.5}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{\left(2 \cdot \left(a + b\right)\right) \cdot \left(b - a\right)} \cdot \left(b - a\right)}{a \cdot b}\\
\end{array}
\end{array}
if b < -9.99999999999999978e122 or 1.9999999999999999e107 < b Initial program 61.0%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6482.6
Applied rewrites82.6%
Applied rewrites81.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6499.8
Applied rewrites99.8%
if -9.99999999999999978e122 < b < 1.9999999999999999e107Initial program 90.9%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6495.2
Applied rewrites95.2%
Applied rewrites95.3%
Final simplification96.6%
(FPCore (a b)
:precision binary64
(if (<= b -9.8e+76)
(/ (* (/ (PI) b) 0.5) (* a b))
(if (<= b 3.1e+62)
(/ (/ (* (- b a) (PI)) a) (* (* b (* (+ b a) 2.0)) (- b a)))
(* (/ (PI) (* b (* a b))) 0.5))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9.8 \cdot 10^{+76}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{b} \cdot 0.5}{a \cdot b}\\
\mathbf{elif}\;b \leq 3.1 \cdot 10^{+62}:\\
\;\;\;\;\frac{\frac{\left(b - a\right) \cdot \mathsf{PI}\left(\right)}{a}}{\left(b \cdot \left(\left(b + a\right) \cdot 2\right)\right) \cdot \left(b - a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{b \cdot \left(a \cdot b\right)} \cdot 0.5\\
\end{array}
\end{array}
if b < -9.80000000000000053e76Initial program 71.5%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6486.3
Applied rewrites86.3%
Applied rewrites84.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6499.9
Applied rewrites99.9%
if -9.80000000000000053e76 < b < 3.10000000000000014e62Initial program 89.6%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6494.6
Applied rewrites94.6%
Applied rewrites94.7%
Applied rewrites99.1%
if 3.10000000000000014e62 < b Initial program 68.6%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6486.6
Applied rewrites86.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6486.7
Applied rewrites86.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6499.7
Applied rewrites99.7%
Final simplification99.3%
(FPCore (a b) :precision binary64 (if (or (<= b -3.7e+85) (not (<= b 1.55e+118))) (/ (* (/ (PI) b) 0.5) (* a b)) (/ (* (PI) b) (* (* a b) (* 2.0 (* (+ b a) b))))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.7 \cdot 10^{+85} \lor \neg \left(b \leq 1.55 \cdot 10^{+118}\right):\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{b} \cdot 0.5}{a \cdot b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right) \cdot b}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot b\right)\right)}\\
\end{array}
\end{array}
if b < -3.7000000000000002e85 or 1.54999999999999993e118 < b Initial program 64.9%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Applied rewrites83.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6499.8
Applied rewrites99.8%
if -3.7000000000000002e85 < b < 1.54999999999999993e118Initial program 90.4%
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-/.f64N/A
*-commutativeN/A
frac-subN/A
frac-timesN/A
frac-timesN/A
Applied rewrites88.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6465.1
Applied rewrites65.1%
Taylor expanded in a around 0
Applied rewrites93.1%
Final simplification95.2%
(FPCore (a b) :precision binary64 (if (or (<= b -1.8e-38) (not (<= b 1.02e-41))) (* (/ (PI) (* b (* a b))) 0.5) (/ (* (/ (PI) a) 0.5) (* a b))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8 \cdot 10^{-38} \lor \neg \left(b \leq 1.02 \cdot 10^{-41}\right):\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{b \cdot \left(a \cdot b\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a} \cdot 0.5}{a \cdot b}\\
\end{array}
\end{array}
if b < -1.8e-38 or 1.02e-41 < b Initial program 81.2%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6491.4
Applied rewrites91.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.0
Applied rewrites77.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6485.4
Applied rewrites85.4%
if -1.8e-38 < b < 1.02e-41Initial program 84.1%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6491.9
Applied rewrites91.9%
Applied rewrites91.9%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6489.2
Applied rewrites89.2%
Final simplification86.9%
(FPCore (a b) :precision binary64 (if (or (<= b -1.8e-38) (not (<= b 1.02e-41))) (* (/ (PI) (* b (* a b))) 0.5) (* (/ (PI) (* a (* a b))) 0.5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8 \cdot 10^{-38} \lor \neg \left(b \leq 1.02 \cdot 10^{-41}\right):\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{b \cdot \left(a \cdot b\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\end{array}
\end{array}
if b < -1.8e-38 or 1.02e-41 < b Initial program 81.2%
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r/N/A
difference-of-squaresN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f6491.4
Applied rewrites91.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.0
Applied rewrites77.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f6485.4
Applied rewrites85.4%
if -1.8e-38 < b < 1.02e-41Initial program 84.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6481.4
Applied rewrites81.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6488.7
Applied rewrites88.7%
Final simplification86.7%
(FPCore (a b) :precision binary64 (if (or (<= b -1.8e-38) (not (<= b 1.02e-41))) (* (/ (PI) (* (* b b) a)) 0.5) (* (/ (PI) (* a (* a b))) 0.5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.8 \cdot 10^{-38} \lor \neg \left(b \leq 1.02 \cdot 10^{-41}\right):\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{\left(b \cdot b\right) \cdot a} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\end{array}
\end{array}
if b < -1.8e-38 or 1.02e-41 < b Initial program 81.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.0
Applied rewrites77.0%
if -1.8e-38 < b < 1.02e-41Initial program 84.1%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6481.4
Applied rewrites81.4%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6488.7
Applied rewrites88.7%
Final simplification81.7%
(FPCore (a b) :precision binary64 (* (/ (PI) (* a (* a b))) 0.5))
\begin{array}{l}
\\
\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5
\end{array}
Initial program 82.3%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6458.5
Applied rewrites58.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6461.4
Applied rewrites61.4%
herbie shell --seed 2025051
(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))))