
(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 6 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)))
(*
l_s
(if (<= l_m 160000000.0)
(- (* (PI) l_m) (/ (/ (tan (* l_m (PI))) F) F))
(/ (fma (+ t_0 (PI)) l_m (* (- (PI) t_0) l_m)) 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}\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 160000000:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot l\_m - \frac{\frac{\tan \left(l\_m \cdot \mathsf{PI}\left(\right)\right)}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0 + \mathsf{PI}\left(\right), l\_m, \left(\mathsf{PI}\left(\right) - t\_0\right) \cdot l\_m\right)}{2}\\
\end{array}
\end{array}
\end{array}
if l < 1.6e8Initial program 79.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6485.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.0
Applied rewrites85.0%
if 1.6e8 < l Initial program 57.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.6
Applied rewrites99.6%
Applied rewrites99.6%
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 (* (PI) l_m)))
(*
l_s
(if (<= (- t_0 (* (/ 1.0 (* F F)) (tan t_0))) -2e-157)
(* (/ (- (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 := \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 -2 \cdot 10^{-157}:\\
\;\;\;\;\frac{-\mathsf{PI}\left(\right)}{F \cdot F} \cdot l\_m\\
\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)))) < -1.99999999999999989e-157Initial program 68.1%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6472.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6472.2
Applied rewrites72.2%
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-*.f6456.1
Applied rewrites56.1%
Taylor expanded in F around 0
Applied rewrites20.2%
if -1.99999999999999989e-157 < (-.f64 (*.f64 (PI.f64) l) (*.f64 (/.f64 #s(literal 1 binary64) (*.f64 F F)) (tan.f64 (*.f64 (PI.f64) l)))) Initial program 79.3%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6478.4
Applied rewrites78.4%
Final simplification52.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 160000000.0) (- 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 160000000:\\
\;\;\;\;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 < 1.6e8Initial program 79.4%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lift-*.f64N/A
*-lft-identityN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6485.0
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.0
Applied rewrites85.0%
if 1.6e8 < l Initial program 57.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.6
Applied rewrites99.6%
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 (* (PI) l_m))) (* l_s (if (<= l_m 60000.0) (- t_0 (/ (* (/ (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 := \mathsf{PI}\left(\right) \cdot l\_m\\
l\_s \cdot \begin{array}{l}
\mathbf{if}\;l\_m \leq 60000:\\
\;\;\;\;t\_0 - \frac{\frac{\mathsf{PI}\left(\right)}{F} \cdot l\_m}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 6e4Initial program 79.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-/.f6484.9
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.9
Applied rewrites84.9%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6477.7
Applied rewrites77.7%
if 6e4 < l Initial program 58.3%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.6
Applied rewrites99.6%
Final simplification82.9%
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 60000.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 60000:\\
\;\;\;\;\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 < 6e4Initial program 79.3%
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-*.f6472.0
Applied rewrites72.0%
if 6e4 < l Initial program 58.3%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.6
Applied rewrites99.6%
Final simplification78.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 (* (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 74.3%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6477.2
Applied rewrites77.2%
Final simplification77.2%
herbie shell --seed 2025016
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* (PI) l) (* (/ 1.0 (* F F)) (tan (* (PI) l)))))