
(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 10 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 (* (PI) l_m)))
(*
l_s
(if (<= l_m 5.6e-11)
(- t_0 (/ (* l_m (/ (PI) F)) F))
(if (<= l_m 3.35e+19) (/ (- (* (* F F) 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 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 5.6 \cdot 10^{-11}:\\
\;\;\;\;t\_0 - \frac{l\_m \cdot \frac{\mathsf{PI}\left(\right)}{F}}{F}\\
\mathbf{elif}\;l\_m \leq 3.35 \cdot 10^{+19}:\\
\;\;\;\;\frac{\left(F \cdot F\right) \cdot t\_0 - \tan t\_0}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 5.6e-11Initial program 74.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-tan.f64N/A
quot-tanN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6484.8
Applied rewrites84.8%
Taylor expanded in l around 0
Applied rewrites84.6%
Taylor expanded in l around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6480.0
Applied rewrites80.0%
if 5.6e-11 < l < 3.35e19Initial program 99.4%
Taylor expanded in F around 0
associate-*r/N/A
times-fracN/A
quot-tanN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-tan.f6463.7
Applied rewrites63.7%
Taylor expanded in l around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6437.6
Applied rewrites37.6%
Taylor expanded in F around 0
Applied rewrites99.6%
if 3.35e19 < l Initial program 60.9%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
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 (* (PI) l_m)))
(*
l_s
(if (<= l_m 3.2e+15)
(-
t_0
(/
(* (pow F -1.0) (sin t_0))
(* F (sin (+ (* (- (PI)) l_m) (/ (PI) 2.0))))))
t_0))))\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 3.2 \cdot 10^{+15}:\\
\;\;\;\;t\_0 - \frac{{F}^{-1} \cdot \sin t\_0}{F \cdot \sin \left(\left(-\mathsf{PI}\left(\right)\right) \cdot l\_m + \frac{\mathsf{PI}\left(\right)}{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 3.2e15Initial program 75.8%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-tan.f64N/A
quot-tanN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6485.4
Applied rewrites85.4%
lift-cos.f64N/A
cos-neg-revN/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift-PI.f6485.1
Applied rewrites85.1%
if 3.2e15 < l Initial program 61.5%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
Final simplification89.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 (* (PI) l_m)))
(*
l_s
(if (<= l_m 2.5e+15)
(- t_0 (/ (* (pow F -1.0) (sin t_0)) (* F (cos 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 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 2.5 \cdot 10^{+15}:\\
\;\;\;\;t\_0 - \frac{{F}^{-1} \cdot \sin t\_0}{F \cdot \cos t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 2.5e15Initial program 75.8%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-tan.f64N/A
quot-tanN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6485.4
Applied rewrites85.4%
if 2.5e15 < l Initial program 61.5%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
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 (* (PI) l_m)) (t_1 (- t_0 (* (/ 1.0 (* F F)) (tan t_0)))))
(*
l_s
(if (or (<= t_1 -2e+221) (not (<= t_1 -4e-213)))
t_0
(* (- l_m) (/ (PI) (* F F)))))))\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot l\_m\\
t_1 := t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+221} \lor \neg \left(t\_1 \leq -4 \cdot 10^{-213}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-l\_m\right) \cdot \frac{\mathsf{PI}\left(\right)}{F \cdot F}\\
\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)))) < -2.0000000000000001e221 or -3.9999999999999998e-213 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) Initial program 64.6%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6470.7
Applied rewrites70.7%
if -2.0000000000000001e221 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) < -3.9999999999999998e-213Initial program 93.8%
Taylor expanded in F around 0
associate-*r/N/A
times-fracN/A
quot-tanN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-tan.f6432.5
Applied rewrites32.5%
Taylor expanded in l around 0
mul-1-negN/A
lower-neg.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6431.9
Applied rewrites31.9%
Final simplification61.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 (* (PI) l_m)))
(*
l_s
(if (<= l_m 5.6e-11)
(- t_0 (/ (* l_m (/ (PI) F)) F))
(if (<= l_m 2.5e+15)
(/ (- (* (* (* F F) l_m) (PI)) (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 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 5.6 \cdot 10^{-11}:\\
\;\;\;\;t\_0 - \frac{l\_m \cdot \frac{\mathsf{PI}\left(\right)}{F}}{F}\\
\mathbf{elif}\;l\_m \leq 2.5 \cdot 10^{+15}:\\
\;\;\;\;\frac{\left(\left(F \cdot F\right) \cdot l\_m\right) \cdot \mathsf{PI}\left(\right) - \tan t\_0}{F \cdot F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 5.6e-11Initial program 74.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-tan.f64N/A
quot-tanN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6484.8
Applied rewrites84.8%
Taylor expanded in l around 0
Applied rewrites84.6%
Taylor expanded in l around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6480.0
Applied rewrites80.0%
if 5.6e-11 < l < 2.5e15Initial program 99.6%
Taylor expanded in F around 0
lower-/.f64N/A
Applied rewrites99.6%
if 2.5e15 < l Initial program 61.5%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
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 (* (PI) l_m))) (* l_s (if (<= l_m 2.5e+15) (+ t_0 (* (/ -1.0 F) (/ (tan t_0) F))) t_0))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 2.5 \cdot 10^{+15}:\\
\;\;\;\;t\_0 + \frac{-1}{F} \cdot \frac{\tan t\_0}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 2.5e15Initial program 75.8%
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
lower-/.f64N/A
lift-tan.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
associate-*l/N/A
pow2N/A
sqr-neg-revN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-tan.f64N/A
lower-neg.f6485.4
Applied rewrites85.4%
if 2.5e15 < l Initial program 61.5%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
Final simplification89.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 (* (PI) l_m)))
(*
l_s
(if (<= l_m 1.15e-28)
(- t_0 (/ (* l_m (/ (PI) F)) F))
(if (<= l_m 2.5e+15) (fma (/ -1.0 (* F F)) (tan t_0) 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 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 1.15 \cdot 10^{-28}:\\
\;\;\;\;t\_0 - \frac{l\_m \cdot \frac{\mathsf{PI}\left(\right)}{F}}{F}\\
\mathbf{elif}\;l\_m \leq 2.5 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{F \cdot F}, \tan t\_0, t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 1.14999999999999993e-28Initial program 74.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-tan.f64N/A
quot-tanN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6484.5
Applied rewrites84.5%
Taylor expanded in l around 0
Applied rewrites84.2%
Taylor expanded in l around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6479.5
Applied rewrites79.5%
if 1.14999999999999993e-28 < l < 2.5e15Initial program 99.6%
Taylor expanded in F around inf
associate-*r/N/A
times-fracN/A
quot-tanN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
lift-tan.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
if 2.5e15 < l Initial program 61.5%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6499.6
Applied rewrites99.6%
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 (* (PI) l_m))) (* l_s (if (<= l_m 2000000000.0) (- t_0 (/ (* l_m (/ (PI) 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 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 2000000000:\\
\;\;\;\;t\_0 - \frac{l\_m \cdot \frac{\mathsf{PI}\left(\right)}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 2e9Initial program 75.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-PI.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-tan.f64N/A
quot-tanN/A
frac-timesN/A
lower-/.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6485.3
Applied rewrites85.3%
Taylor expanded in l around 0
Applied rewrites85.0%
Taylor expanded in l around 0
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-PI.f6480.1
Applied rewrites80.1%
if 2e9 < l Initial program 62.0%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6498.2
Applied rewrites98.2%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (* l_s (if (<= l_m 2000000000.0) (* (- (PI) (/ (PI) (* F F))) l_m) (* (PI) l_m))))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 2000000000:\\
\;\;\;\;\left(\mathsf{PI}\left(\right) - \frac{\mathsf{PI}\left(\right)}{F \cdot F}\right) \cdot l\_m\\
\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot l\_m\\
\end{array}
\end{array}
if l < 2e9Initial program 75.7%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lift-PI.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
pow2N/A
lift-*.f6470.5
Applied rewrites70.5%
if 2e9 < l Initial program 62.0%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6498.2
Applied rewrites98.2%
l\_m = (fabs.f64 l) l\_s = (copysign.f64 #s(literal 1 binary64) l) (FPCore (l_s F l_m) :precision binary64 (* l_s (* (PI) l_m)))
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
l\_s \cdot \left(\mathsf{PI}\left(\right) \cdot l\_m\right)
\end{array}
Initial program 71.9%
Taylor expanded in F around inf
*-commutativeN/A
lift-*.f64N/A
lift-PI.f6470.3
Applied rewrites70.3%
herbie shell --seed 2025043
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* (PI) l) (* (/ 1.0 (* F F)) (tan (* (PI) l)))))