
(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 8 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 (* (/ (PI) (* 2.0 (+ a b))) (* (pow (- b a) -1.0) (- (pow a -1.0) (pow b -1.0)))))
\begin{array}{l}
\\
\frac{\mathsf{PI}\left(\right)}{2 \cdot \left(a + b\right)} \cdot \left({\left(b - a\right)}^{-1} \cdot \left({a}^{-1} - {b}^{-1}\right)\right)
\end{array}
Initial program 77.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--.f6487.2
Applied rewrites87.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.6%
(FPCore (a b) :precision binary64 (/ (* (PI) (pow (* b a) -1.0)) (* (+ b a) 2.0)))
\begin{array}{l}
\\
\frac{\mathsf{PI}\left(\right) \cdot {\left(b \cdot a\right)}^{-1}}{\left(b + a\right) \cdot 2}
\end{array}
Initial program 77.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--.f6487.2
Applied rewrites87.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.6%
Taylor expanded in a around 0
Applied rewrites99.6%
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6499.6
Applied rewrites99.6%
(FPCore (a b)
:precision binary64
(let* ((t_0 (/ (PI) a)))
(if (<= a -1.6e-23)
(* (/ t_0 (* b a)) 0.5)
(if (<= a 1.9e-33)
(/ (/ (* t_0 0.5) b) b)
(* (/ (PI) (* a (* a b))) 0.5)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{a}\\
\mathbf{if}\;a \leq -1.6 \cdot 10^{-23}:\\
\;\;\;\;\frac{t\_0}{b \cdot a} \cdot 0.5\\
\mathbf{elif}\;a \leq 1.9 \cdot 10^{-33}:\\
\;\;\;\;\frac{\frac{t\_0 \cdot 0.5}{b}}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\end{array}
\end{array}
if a < -1.59999999999999988e-23Initial program 67.5%
Taylor expanded in a around inf
Applied rewrites76.5%
Applied rewrites92.3%
Applied rewrites93.4%
if -1.59999999999999988e-23 < a < 1.89999999999999997e-33Initial program 81.3%
Taylor expanded in b around inf
Applied rewrites66.3%
Taylor expanded in a around 0
Applied rewrites74.0%
Applied rewrites86.8%
if 1.89999999999999997e-33 < a Initial program 79.2%
Taylor expanded in a around inf
Applied rewrites79.5%
Applied rewrites88.6%
(FPCore (a b) :precision binary64 (* (/ (PI) (* 2.0 (+ a b))) (/ 1.0 (* b a))))
\begin{array}{l}
\\
\frac{\mathsf{PI}\left(\right)}{2 \cdot \left(a + b\right)} \cdot \frac{1}{b \cdot a}
\end{array}
Initial program 77.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--.f6487.2
Applied rewrites87.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.6%
Taylor expanded in a around 0
Applied rewrites99.6%
Applied rewrites99.6%
(FPCore (a b) :precision binary64 (if (or (<= a -1.6e-23) (not (<= a 1.9e-33))) (* (/ (PI) (* a (* a b))) 0.5) (* (/ (PI) (* b (* b a))) 0.5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{-23} \lor \neg \left(a \leq 1.9 \cdot 10^{-33}\right):\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\end{array}
\end{array}
if a < -1.59999999999999988e-23 or 1.89999999999999997e-33 < a Initial program 73.9%
Taylor expanded in a around inf
Applied rewrites78.2%
Applied rewrites90.3%
if -1.59999999999999988e-23 < a < 1.89999999999999997e-33Initial program 81.3%
Taylor expanded in a around inf
Applied rewrites32.3%
Applied rewrites32.3%
Taylor expanded in a around 0
Applied rewrites74.0%
Applied rewrites85.8%
Final simplification88.1%
(FPCore (a b) :precision binary64 (if (or (<= a -1.6e-23) (not (<= a 2.15e-75))) (* (/ (PI) (* a (* a b))) 0.5) (* (/ (PI) (* (* b b) a)) 0.5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{-23} \lor \neg \left(a \leq 2.15 \cdot 10^{-75}\right):\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \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 a < -1.59999999999999988e-23 or 2.15e-75 < a Initial program 74.2%
Taylor expanded in a around inf
Applied rewrites76.8%
Applied rewrites88.4%
if -1.59999999999999988e-23 < a < 2.15e-75Initial program 81.3%
Taylor expanded in a around 0
Applied rewrites75.6%
Final simplification82.4%
(FPCore (a b)
:precision binary64
(if (<= a -1.6e-23)
(* (/ (/ (PI) a) (* b a)) 0.5)
(if (<= a 1.9e-33)
(* (/ (PI) (* b (* b a))) 0.5)
(* (/ (PI) (* a (* a b))) 0.5))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.6 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5\\
\mathbf{elif}\;a \leq 1.9 \cdot 10^{-33}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\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 a < -1.59999999999999988e-23Initial program 67.5%
Taylor expanded in a around inf
Applied rewrites76.5%
Applied rewrites92.3%
Applied rewrites93.4%
if -1.59999999999999988e-23 < a < 1.89999999999999997e-33Initial program 81.3%
Taylor expanded in a around inf
Applied rewrites32.3%
Applied rewrites32.3%
Taylor expanded in a around 0
Applied rewrites74.0%
Applied rewrites85.8%
if 1.89999999999999997e-33 < a Initial program 79.2%
Taylor expanded in a around inf
Applied rewrites79.5%
Applied rewrites88.6%
Final simplification88.3%
(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 77.5%
Taylor expanded in a around inf
Applied rewrites55.6%
Applied rewrites61.8%
herbie shell --seed 2025026
(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))))