
(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))) (/ 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.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--.f6488.6
Applied rewrites88.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
lift-/.f64N/A
lift-/.f64N/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in a around 0
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
*-commutativeN/A
lower-/.f64N/A
*-commutativeN/A
lift-*.f6499.7
Applied rewrites99.7%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (PI) b)) (t_1 (* (/ (PI) (* b (* b a))) 0.5)))
(if (<= b -3.1e+139)
t_1
(if (<= b -6.4e-157)
(/ t_0 (* (* (* (* a 2.0) b) b) (+ b a)))
(if (<= b 4e-220)
(* (/ (PI) (* a (* a b))) 0.5)
(if (<= b 2.2e+75) (/ t_0 (* (* a b) (* 2.0 (* (+ b a) b)))) t_1))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot b\\
t_1 := \frac{\mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{if}\;b \leq -3.1 \cdot 10^{+139}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -6.4 \cdot 10^{-157}:\\
\;\;\;\;\frac{t\_0}{\left(\left(\left(a \cdot 2\right) \cdot b\right) \cdot b\right) \cdot \left(b + a\right)}\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-220}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{+75}:\\
\;\;\;\;\frac{t\_0}{\left(a \cdot b\right) \cdot \left(2 \cdot \left(\left(b + a\right) \cdot b\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -3.1e139 or 2.20000000000000012e75 < b Initial program 58.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6448.8
Applied rewrites48.8%
Taylor expanded in a around 0
frac-timesN/A
*-rgt-identityN/A
difference-of-squares-revN/A
+-commutativeN/A
associate-*l*N/A
frac-subN/A
*-lft-identityN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6498.9
Applied rewrites98.9%
if -3.1e139 < b < -6.40000000000000041e-157Initial program 94.0%
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.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6469.2
Applied rewrites69.2%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-*r*N/A
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift--.f64N/A
+-commutativeN/A
lift-+.f6469.2
Applied rewrites69.2%
Taylor expanded in a around 0
Applied rewrites95.2%
if -6.40000000000000041e-157 < b < 3.99999999999999997e-220Initial program 64.9%
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.2
Applied rewrites81.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6499.6
Applied rewrites99.6%
if 3.99999999999999997e-220 < b < 2.20000000000000012e75Initial program 96.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 rewrites90.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6462.9
Applied rewrites62.9%
Taylor expanded in a around 0
Applied rewrites91.5%
Final simplification96.6%
(FPCore (a b)
:precision binary64
(let* ((t_0 (/ (* (PI) b) (* (* a b) (* 2.0 (* (+ b a) b)))))
(t_1 (* (/ (PI) (* b (* b a))) 0.5)))
(if (<= b -2.55e+73)
t_1
(if (<= b -6.4e-157)
t_0
(if (<= b 4e-220)
(* (/ (PI) (* a (* a b))) 0.5)
(if (<= b 2.2e+75) t_0 t_1))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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)}\\
t_1 := \frac{\mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{if}\;b \leq -2.55 \cdot 10^{+73}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq -6.4 \cdot 10^{-157}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-220}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{a \cdot \left(a \cdot b\right)} \cdot 0.5\\
\mathbf{elif}\;b \leq 2.2 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -2.55000000000000012e73 or 2.20000000000000012e75 < b Initial program 64.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-*.f6451.2
Applied rewrites51.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6451.3
Applied rewrites51.3%
Taylor expanded in a around 0
frac-timesN/A
*-rgt-identityN/A
difference-of-squares-revN/A
+-commutativeN/A
associate-*l*N/A
frac-subN/A
*-lft-identityN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6499.0
Applied rewrites99.0%
if -2.55000000000000012e73 < b < -6.40000000000000041e-157 or 3.99999999999999997e-220 < b < 2.20000000000000012e75Initial program 94.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.2%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lift-PI.f6463.1
Applied rewrites63.1%
Taylor expanded in a around 0
Applied rewrites93.1%
if -6.40000000000000041e-157 < b < 3.99999999999999997e-220Initial program 64.9%
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.2
Applied rewrites81.2%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6499.6
Applied rewrites99.6%
Final simplification96.6%
(FPCore (a b) :precision binary64 (if (or (<= a -6e-20) (not (<= a 8.8e-73))) (* (/ (/ (PI) a) (* b a)) 0.5) (* (/ (PI) (* b (* b a))) 0.5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{-20} \lor \neg \left(a \leq 8.8 \cdot 10^{-73}\right):\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \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 < -6.00000000000000057e-20 or 8.8000000000000001e-73 < a Initial program 77.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.5
Applied rewrites79.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6488.6
Applied rewrites88.6%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f6489.9
Applied rewrites89.9%
if -6.00000000000000057e-20 < a < 8.8000000000000001e-73Initial program 76.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6432.5
Applied rewrites32.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6432.6
Applied rewrites32.6%
Taylor expanded in a around 0
frac-timesN/A
*-rgt-identityN/A
difference-of-squares-revN/A
+-commutativeN/A
associate-*l*N/A
frac-subN/A
*-lft-identityN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6488.9
Applied rewrites88.9%
Final simplification89.5%
(FPCore (a b)
:precision binary64
(if (<= a -6e-20)
(/ (/ (* (/ (PI) b) 0.5) a) a)
(if (<= a 8.8e-73)
(* (/ (PI) (* b (* b a))) 0.5)
(* (/ (/ (PI) a) (* b a)) 0.5))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{-20}:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{PI}\left(\right)}{b} \cdot 0.5}{a}}{a}\\
\mathbf{elif}\;a \leq 8.8 \cdot 10^{-73}:\\
\;\;\;\;\frac{\mathsf{PI}\left(\right)}{b \cdot \left(b \cdot a\right)} \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{PI}\left(\right)}{a}}{b \cdot a} \cdot 0.5\\
\end{array}
\end{array}
if a < -6.00000000000000057e-20Initial program 81.9%
Taylor expanded in a around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6480.4
Applied rewrites80.4%
lift-*.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
Applied rewrites86.0%
Taylor expanded in a around inf
*-commutativeN/A
lift-/.f64N/A
lift-PI.f64N/A
lift-*.f6492.7
Applied rewrites92.7%
if -6.00000000000000057e-20 < a < 8.8000000000000001e-73Initial program 76.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6432.5
Applied rewrites32.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6432.6
Applied rewrites32.6%
Taylor expanded in a around 0
frac-timesN/A
*-rgt-identityN/A
difference-of-squares-revN/A
+-commutativeN/A
associate-*l*N/A
frac-subN/A
*-lft-identityN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6488.9
Applied rewrites88.9%
if 8.8000000000000001e-73 < a Initial program 74.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6473.6
Applied rewrites73.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6486.5
Applied rewrites86.5%
lift-PI.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
*-commutativeN/A
lower-*.f6487.8
Applied rewrites87.8%
Final simplification89.5%
(FPCore (a b) :precision binary64 (if (or (<= a -6e-20) (not (<= a 8.8e-73))) (* (/ (PI) (* a (* a b))) 0.5) (* (/ (PI) (* b (* b a))) 0.5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{-20} \lor \neg \left(a \leq 8.8 \cdot 10^{-73}\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 < -6.00000000000000057e-20 or 8.8000000000000001e-73 < a Initial program 77.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.5
Applied rewrites79.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6488.6
Applied rewrites88.6%
if -6.00000000000000057e-20 < a < 8.8000000000000001e-73Initial program 76.7%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6432.5
Applied rewrites32.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6432.6
Applied rewrites32.6%
Taylor expanded in a around 0
frac-timesN/A
*-rgt-identityN/A
difference-of-squares-revN/A
+-commutativeN/A
associate-*l*N/A
frac-subN/A
*-lft-identityN/A
*-rgt-identityN/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6488.9
Applied rewrites88.9%
Final simplification88.7%
(FPCore (a b) :precision binary64 (if (or (<= a -6e-20) (not (<= a 8.8e-73))) (* (/ (PI) (* a (* a b))) 0.5) (* (/ (PI) (* (* b b) a)) 0.5)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -6 \cdot 10^{-20} \lor \neg \left(a \leq 8.8 \cdot 10^{-73}\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 < -6.00000000000000057e-20 or 8.8000000000000001e-73 < a Initial program 77.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6479.5
Applied rewrites79.5%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6488.6
Applied rewrites88.6%
if -6.00000000000000057e-20 < a < 8.8000000000000001e-73Initial program 76.7%
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-*.f6475.3
Applied rewrites75.3%
Final simplification83.2%
(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.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6460.6
Applied rewrites60.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-*.f6466.0
Applied rewrites66.0%
Final simplification66.0%
herbie shell --seed 2025037
(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))))