
(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 (+ (pow (PI) -1.0) (PI))) (t_1 (* (PI) l_m)))
(*
l_s
(if (<= l_m 5.6e+14)
(+ t_1 (/ (/ (/ (sin t_1) (cos (fma (PI) l_m (PI)))) F) F))
(/
(fma t_0 l_m (/ (* (- (* (PI) (PI)) (pow (PI) -2.0)) l_m) t_0))
2.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)}^{-1} + \mathsf{PI}\left(\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 5.6 \cdot 10^{+14}:\\
\;\;\;\;t\_1 + \frac{\frac{\frac{\sin t\_1}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), l\_m, \mathsf{PI}\left(\right)\right)\right)}}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, l\_m, \frac{\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right) - {\mathsf{PI}\left(\right)}^{-2}\right) \cdot l\_m}{t\_0}\right)}{2}\\
\end{array}
\end{array}
\end{array}
if l < 5.6e14Initial program 84.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6490.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
*-lft-identityN/A
lift-tan.f64N/A
tan-+PI-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
tan-+PI-revN/A
lift-tan.f64N/A
lift-tan.f64N/A
tan-quotN/A
associate-*r/N/A
frac-2negN/A
lower-/.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
cos-+PI-revN/A
lower-cos.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
Applied rewrites90.1%
if 5.6e14 < l Initial program 71.2%
Taylor expanded in F around inf
Applied rewrites99.6%
Applied rewrites99.6%
Applied rewrites99.8%
Final simplification92.3%
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+14)
(+ t_0 (/ (/ (/ (sin t_0) (cos (fma (PI) 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 5.6 \cdot 10^{+14}:\\
\;\;\;\;t\_0 + \frac{\frac{\frac{\sin t\_0}{\cos \left(\mathsf{fma}\left(\mathsf{PI}\left(\right), l\_m, \mathsf{PI}\left(\right)\right)\right)}}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 5.6e14Initial program 84.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6490.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
*-lft-identityN/A
lift-tan.f64N/A
tan-+PI-revN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
tan-+PI-revN/A
lift-tan.f64N/A
lift-tan.f64N/A
tan-quotN/A
associate-*r/N/A
frac-2negN/A
lower-/.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
cos-+PI-revN/A
lower-cos.f64N/A
lift-*.f64N/A
lift-PI.f64N/A
Applied rewrites90.1%
if 5.6e14 < l Initial program 71.2%
Taylor expanded in F around inf
Applied rewrites99.6%
Final simplification92.3%
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+14)
(- t_0 (* (pow F -1.0) (/ (tan (* l_m (PI))) 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^{+14}:\\
\;\;\;\;t\_0 - {F}^{-1} \cdot \frac{\tan \left(l\_m \cdot \mathsf{PI}\left(\right)\right)}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 5.6e14Initial program 84.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-/.f6490.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
if 5.6e14 < l Initial program 71.2%
Taylor expanded in F around inf
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 (<= (- t_0 (* (/ 1.0 (* F F)) (tan t_0))) -4e-221)
(/ (* (- (PI)) l_m) (* 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}\;t\_0 - \frac{1}{F \cdot F} \cdot \tan t\_0 \leq -4 \cdot 10^{-221}:\\
\;\;\;\;\frac{\left(-\mathsf{PI}\left(\right)\right) \cdot l\_m}{F \cdot 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)))) < -4.00000000000000007e-221Initial program 78.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-/.f6483.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.6
Applied rewrites83.6%
Taylor expanded in l around 0
Applied rewrites68.7%
Taylor expanded in F around 0
Applied rewrites30.4%
Applied rewrites25.0%
if -4.00000000000000007e-221 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) Initial program 83.9%
Taylor expanded in F around inf
Applied rewrites77.3%
Final simplification54.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+14) (- t_0 (/ (/ (tan (* 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 5.6 \cdot 10^{+14}:\\
\;\;\;\;t\_0 - \frac{\frac{\tan \left(l\_m \cdot \mathsf{PI}\left(\right)\right)}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 5.6e14Initial program 84.3%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6490.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.3
Applied rewrites90.3%
if 5.6e14 < l Initial program 71.2%
Taylor expanded in F around inf
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 30000000000000.0) (- t_0 (* (/ l_m F) (/ (PI) 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 30000000000000:\\
\;\;\;\;t\_0 - \frac{l\_m}{F} \cdot \frac{\mathsf{PI}\left(\right)}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 3e13Initial program 84.2%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
times-fracN/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-/.f6490.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.2
Applied rewrites90.2%
Taylor expanded in l around 0
Applied rewrites84.2%
if 3e13 < l Initial program 71.7%
Taylor expanded in F around inf
Applied rewrites98.0%
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 30000000000000.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 30000000000000:\\
\;\;\;\;\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 < 3e13Initial program 84.2%
Taylor expanded in l around 0
Applied rewrites78.1%
if 3e13 < l Initial program 71.7%
Taylor expanded in F around inf
Applied rewrites98.0%
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 81.3%
Taylor expanded in F around inf
Applied rewrites73.5%
herbie shell --seed 2025019
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* (PI) l) (* (/ 1.0 (* F F)) (tan (* (PI) l)))))