
(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 12 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 50000000.0) (+ (/ (* (tan t_0) (/ -1.0 F)) 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 50000000:\\
\;\;\;\;\frac{\tan t\_0 \cdot \frac{-1}{F}}{F} + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 5e7Initial program 73.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6484.8
Applied rewrites84.8%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification88.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 (* (tan t_0) (/ 1.0 (* F F)))) -1e-165)
(* (/ (- (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 - \tan t\_0 \cdot \frac{1}{F \cdot F} \leq -1 \cdot 10^{-165}:\\
\;\;\;\;\frac{-\mathsf{PI}\left(\right)}{F} \cdot \frac{l\_m}{F}\\
\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)))) < -1e-165Initial program 68.2%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6476.6
Applied rewrites76.6%
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-*.f6459.1
Applied rewrites59.1%
Taylor expanded in F around 0
Applied rewrites21.8%
if -1e-165 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) Initial program 76.5%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6476.7
Applied rewrites76.7%
Final simplification52.7%
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 50000000.0) (- 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 50000000:\\
\;\;\;\;t\_0 - \frac{\frac{\tan t\_0}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 5e7Initial program 73.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6484.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.8
Applied rewrites84.8%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification88.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 2000.0)
(-
t_0
(/
(/ -1.0 F)
(/
(* (fma (* 0.3333333333333333 (PI)) (* l_m l_m) (/ -1.0 (PI))) 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 2000:\\
\;\;\;\;t\_0 - \frac{\frac{-1}{F}}{\frac{\mathsf{fma}\left(0.3333333333333333 \cdot \mathsf{PI}\left(\right), l\_m \cdot l\_m, \frac{-1}{\mathsf{PI}\left(\right)}\right) \cdot F}{l\_m}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 2e3Initial program 73.7%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-tan.f64N/A
tan-quotN/A
frac-2negN/A
clear-numN/A
frac-timesN/A
distribute-rgt-neg-inN/A
div-invN/A
lower-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites84.8%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites90.5%
Taylor expanded in F around 0
Applied rewrites90.4%
if 2e3 < (*.f64 (PI.f64) l) Initial program 70.3%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6498.3
Applied rewrites98.3%
Final simplification92.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 50000000.0)
(- t_0 (/ (/ -1.0 F) (/ (/ (- F) (PI)) 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 50000000:\\
\;\;\;\;t\_0 - \frac{\frac{-1}{F}}{\frac{\frac{-F}{\mathsf{PI}\left(\right)}}{l\_m}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 5e7Initial program 73.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lift-tan.f64N/A
tan-quotN/A
frac-2negN/A
clear-numN/A
frac-timesN/A
distribute-rgt-neg-inN/A
div-invN/A
lower-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
Applied rewrites84.7%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites90.1%
Taylor expanded in l around 0
Applied rewrites79.1%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification84.0%
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 50000000.0)
(fma (* (/ 1.0 (/ F (PI))) 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 50000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{F}{\mathsf{PI}\left(\right)}} \cdot l\_m, \frac{-1}{F}, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 5e7Initial program 73.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 rewrites84.8%
lift-PI.f64N/A
add-sqr-sqrtN/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6484.6
Applied rewrites84.6%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6479.1
Applied rewrites79.1%
Applied rewrites79.1%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification84.0%
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 50000000.0) (fma (/ l_m (/ F (PI))) (/ -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 50000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{l\_m}{\frac{F}{\mathsf{PI}\left(\right)}}, \frac{-1}{F}, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 5e7Initial program 73.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 rewrites84.8%
lift-PI.f64N/A
add-sqr-sqrtN/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6484.6
Applied rewrites84.6%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6479.1
Applied rewrites79.1%
Applied rewrites79.1%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification84.0%
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 50000000.0) (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 50000000:\\
\;\;\;\;\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) < 5e7Initial program 73.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 rewrites84.8%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6479.1
Applied rewrites79.1%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification84.0%
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 50000000.0) (+ (/ (/ (* (- (PI)) l_m) F) 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 50000000:\\
\;\;\;\;\frac{\frac{\left(-\mathsf{PI}\left(\right)\right) \cdot l\_m}{F}}{F} + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (*.f64 (PI.f64) l) < 5e7Initial program 73.8%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
frac-2negN/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-neg.f6484.8
Applied rewrites84.8%
Taylor expanded in l around 0
mul-1-negN/A
distribute-neg-fracN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-/.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-PI.f6479.1
Applied rewrites79.1%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification84.0%
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 50000000.0) (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 50000000:\\
\;\;\;\;\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) < 5e7Initial program 73.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 rewrites84.8%
lift-PI.f64N/A
add-sqr-sqrtN/A
lower-*.f64N/A
lift-PI.f64N/A
lower-sqrt.f64N/A
lift-PI.f64N/A
lower-sqrt.f6484.6
Applied rewrites84.6%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6479.1
Applied rewrites79.1%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-neg.f64N/A
un-div-invN/A
lower-/.f6479.0
Applied rewrites79.0%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification84.0%
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 50000000.0) (* (- (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 50000000:\\
\;\;\;\;\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) < 5e7Initial program 73.8%
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-*.f6468.1
Applied rewrites68.1%
if 5e7 < (*.f64 (PI.f64) l) Initial program 69.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.9
Applied rewrites99.9%
Final simplification75.7%
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 72.9%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6476.8
Applied rewrites76.8%
Final simplification76.8%
herbie shell --seed 2024331
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* (PI) l) (* (/ 1.0 (* F F)) (tan (* (PI) l)))))