
(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 9 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 1.9e+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 1.9 \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 < 1.9e14Initial program 82.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.3
Applied rewrites89.3%
if 1.9e14 < l Initial program 62.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.8
Applied rewrites99.8%
Final simplification91.5%
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 (* (pow (* F F) -1.0) (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 - {\left(F \cdot F\right)}^{-1} \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 76.0%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6482.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6482.2
Applied rewrites82.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-*.f6465.3
Applied rewrites65.3%
Taylor expanded in F around 0
Applied rewrites24.0%
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 81.1%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6472.4
Applied rewrites72.4%
Final simplification49.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 (* (PI) l_m)))
(*
l_s
(if (<= l_m 135000000000.0) (- t_0 (* (pow (* F F) -1.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 135000000000:\\
\;\;\;\;t\_0 - {\left(F \cdot F\right)}^{-1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 1.35e11Initial program 82.9%
lift-tan.f64N/A
tan-+PI-revN/A
lower-tan.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
lower-fma.f6457.2
Applied rewrites57.2%
Taylor expanded in l around 0
Applied rewrites76.5%
if 1.35e11 < l Initial program 62.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.8
Applied rewrites99.8%
Final simplification81.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 135000000000.0) (- t_0 (/ (/ 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 135000000000:\\
\;\;\;\;t\_0 - \frac{\frac{t\_0}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 1.35e11Initial program 82.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.3
Applied rewrites89.3%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6482.9
Applied rewrites82.9%
Applied rewrites83.0%
if 1.35e11 < l Initial program 62.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.8
Applied rewrites99.8%
Final simplification86.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 135000000000.0) (- t_0 (/ (* (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}\;l\_m \leq 135000000000:\\
\;\;\;\;t\_0 - \frac{\mathsf{PI}\left(\right) \cdot \frac{l\_m}{F}}{F}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if l < 1.35e11Initial program 82.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.3
Applied rewrites89.3%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6482.9
Applied rewrites82.9%
Applied rewrites82.9%
if 1.35e11 < l Initial program 62.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.8
Applied rewrites99.8%
Final simplification86.4%
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 135000000000.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 135000000000:\\
\;\;\;\;\left(\mathsf{PI}\left(\right) - \frac{\frac{\mathsf{PI}\left(\right)}{F}}{F}\right) \cdot l\_m\\
\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot l\_m\\
\end{array}
\end{array}
if l < 1.35e11Initial program 82.9%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
*-lft-identityN/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6489.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6489.3
Applied rewrites89.3%
Taylor expanded in l around 0
*-commutativeN/A
associate-*l/N/A
lower-*.f64N/A
lower-/.f64N/A
lower-PI.f6482.9
Applied rewrites82.9%
Taylor expanded in l around 0
distribute-lft-out--N/A
fp-cancel-sub-signN/A
mul-1-negN/A
*-commutativeN/A
associate-*r*N/A
distribute-lft-inN/A
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-PI.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lower-PI.f6476.5
Applied rewrites76.5%
if 1.35e11 < l Initial program 62.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.8
Applied rewrites99.8%
Final simplification81.3%
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 135000000000.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 135000000000:\\
\;\;\;\;\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 < 1.35e11Initial program 82.9%
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.5
Applied rewrites76.5%
if 1.35e11 < l Initial program 62.6%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.8
Applied rewrites99.8%
Final simplification81.3%
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 78.7%
Taylor expanded in F around inf
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6470.6
Applied rewrites70.6%
Final simplification70.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 0.0))
l\_m = fabs(l);
l\_s = copysign(1.0, l);
double code(double l_s, double F, double l_m) {
return l_s * 0.0;
}
l\_m = abs(l)
l\_s = copysign(1.0d0, l)
real(8) function code(l_s, f, l_m)
real(8), intent (in) :: l_s
real(8), intent (in) :: f
real(8), intent (in) :: l_m
code = l_s * 0.0d0
end function
l\_m = Math.abs(l);
l\_s = Math.copySign(1.0, l);
public static double code(double l_s, double F, double l_m) {
return l_s * 0.0;
}
l\_m = math.fabs(l) l\_s = math.copysign(1.0, l) def code(l_s, F, l_m): return l_s * 0.0
l\_m = abs(l) l\_s = copysign(1.0, l) function code(l_s, F, l_m) return Float64(l_s * 0.0) end
l\_m = abs(l); l\_s = sign(l) * abs(1.0); function tmp = code(l_s, F, l_m) tmp = l_s * 0.0; end
l\_m = N[Abs[l], $MachinePrecision]
l\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[l]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[l$95$s_, F_, l$95$m_] := N[(l$95$s * 0.0), $MachinePrecision]
\begin{array}{l}
l\_m = \left|\ell\right|
\\
l\_s = \mathsf{copysign}\left(1, \ell\right)
\\
l\_s \cdot 0
\end{array}
Initial program 78.7%
lift-*.f64N/A
lift-/.f64N/A
frac-2negN/A
metadata-evalN/A
lift-tan.f64N/A
tan-quotN/A
frac-timesN/A
lower-/.f64N/A
mul-1-negN/A
sin-+PI-revN/A
lower-sin.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-PI.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f6458.5
lift-*.f64N/A
*-commutativeN/A
Applied rewrites58.5%
Taylor expanded in l around 0
sin-PIN/A
div03.0
Applied rewrites3.0%
herbie shell --seed 2024332
(FPCore (F l)
:name "VandenBroeck and Keller, Equation (6)"
:precision binary64
(- (* (PI) l) (* (/ 1.0 (* F F)) (tan (* (PI) l)))))