
(FPCore (F l) :precision binary64 (let* ((t_0 (* (PI) l))) (- t_0 (* (/ 1.0 (* F F)) (tan t_0)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \ell\\
t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (F l) :precision binary64 (let* ((t_0 (* (PI) l))) (- t_0 (* (/ 1.0 (* F F)) (tan t_0)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \ell\\
t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0
\end{array}
\end{array}
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (let* ((t_0 (* l_m (PI)))) (* l_s (if (<= t_0 4e+15) (fma (/ (tan t_0) F) (/ -1.0 F) t_0) t_0))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\tan t\_0}{F}, \frac{-1}{F}, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 4e15Initial program 80.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
distribute-neg-frac2N/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
times-fracN/A
distribute-neg-frac2N/A
lower-fma.f64N/A
Applied rewrites88.5%
if 4e15 < (*.f64 (PI.f64) l) Initial program 59.0%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6498.0
Applied rewrites98.0%
Final simplification90.8%
l\_m = (fabs.f64 l)
l\_s = (copysign.f64 #s(literal 1 binary64) l)
(FPCore (l_s F l_m)
:precision binary64
(let* ((t_0 (* l_m (PI))) (t_1 (- t_0 (* (tan t_0) (/ 1.0 (* F F))))))
(*
l_s
(if (<= t_1 -5e+252)
t_0
(if (<= t_1 -2e-181) (* (/ l_m (* F F)) (- (PI))) t_0)))))\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
t_1 := t\_0 - \tan t\_0 \cdot \frac{1}{F \cdot F}\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+252}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq -2 \cdot 10^{-181}:\\
\;\;\;\;\frac{l\_m}{F \cdot F} \cdot \left(-\mathsf{PI}\left(\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -4.9999999999999997e252 or -2.00000000000000009e-181 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) Initial program 68.5%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6470.2
Applied rewrites70.2%
if -4.9999999999999997e252 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -2.00000000000000009e-181Initial program 95.0%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lift-*.f64N/A
associate-/r*N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6495.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6495.1
Applied rewrites95.1%
Taylor expanded in l around 0
*-commutativeN/A
sub-negN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
sub-negN/A
lower--.f64N/A
lower-PI.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6485.5
Applied rewrites85.5%
Taylor expanded in F around 0
Applied rewrites13.0%
Applied rewrites13.0%
Final simplification55.2%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (let* ((t_0 (* l_m (PI)))) (* l_s (if (<= t_0 4e+15) (- t_0 (/ (/ (tan t_0) F) F)) t_0))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+15}:\\
\;\;\;\;t\_0 - \frac{\frac{\tan t\_0}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 4e15Initial program 80.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6488.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.4
Applied rewrites88.4%
if 4e15 < (*.f64 (PI.f64) l) Initial program 59.0%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6498.0
Applied rewrites98.0%
Final simplification90.8%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (let* ((t_0 (* l_m (PI)))) (* l_s (if (<= t_0 0.04) (fma (/ t_0 F) (/ -1.0 F) t_0) t_0))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0.04:\\
\;\;\;\;\mathsf{fma}\left(\frac{t\_0}{F}, \frac{-1}{F}, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 0.0400000000000000008Initial program 81.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
distribute-neg-frac2N/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
times-fracN/A
distribute-neg-frac2N/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6484.3
Applied rewrites84.3%
if 0.0400000000000000008 < (*.f64 (PI.f64) l) Initial program 58.4%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6496.5
Applied rewrites96.5%
Final simplification87.4%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (let* ((t_0 (* l_m (PI)))) (* l_s (if (<= t_0 0.04) (fma (* (/ (PI) F) l_m) (/ -1.0 F) t_0) t_0))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0.04:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{PI}\left(\right)}{F} \cdot l\_m, \frac{-1}{F}, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 0.0400000000000000008Initial program 81.1%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
distribute-neg-frac2N/A
*-rgt-identityN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
times-fracN/A
distribute-neg-frac2N/A
lower-fma.f64N/A
Applied rewrites88.8%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6484.3
Applied rewrites84.3%
if 0.0400000000000000008 < (*.f64 (PI.f64) l) Initial program 58.4%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6496.5
Applied rewrites96.5%
Final simplification87.4%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (let* ((t_0 (* l_m (PI)))) (* l_s (if (<= t_0 0.04) (fma (PI) l_m (/ (* (/ (PI) F) l_m) (- F))) t_0))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0.04:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{PI}\left(\right), l\_m, \frac{\frac{\mathsf{PI}\left(\right)}{F} \cdot l\_m}{-F}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 0.0400000000000000008Initial program 81.1%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lift-*.f64N/A
associate-/r*N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-/.f6488.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6488.8
Applied rewrites88.8%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6484.3
Applied rewrites84.3%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6484.3
lift-/.f64N/A
lift-/.f64N/A
clear-numN/A
lower-/.f6484.3
Applied rewrites84.3%
if 0.0400000000000000008 < (*.f64 (PI.f64) l) Initial program 58.4%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6496.5
Applied rewrites96.5%
Final simplification87.4%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (let* ((t_0 (* l_m (PI)))) (* l_s (if (<= t_0 0.04) (* (- (PI) (/ (PI) (* F F))) l_m) t_0))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := l\_m \cdot \mathsf{PI}\left(\right)\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0.04:\\
\;\;\;\;\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F \cdot F}\right) \cdot l\_m\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 0.0400000000000000008Initial program 81.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-PI.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
unpow2N/A
lower-*.f6476.6
Applied rewrites76.6%
if 0.0400000000000000008 < (*.f64 (PI.f64) l) Initial program 58.4%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6496.5
Applied rewrites96.5%
Final simplification81.6%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (* l_s (* l_m (PI))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
l\_s \cdot \left(l\_m \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 75.4%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6474.2
Applied rewrites74.2%
Final simplification74.2%
herbie shell --seed 2024255
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* (PI) l) (* (/ 1.0 (* F F)) (tan (* (PI) l)))))