\cos \left(x + \varepsilon\right) - \cos x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -8.39699580404506896243528445638072145972 \cdot 10^{-12} \lor \neg \left(\varepsilon \le 3.588703897944783975981375382800948881101 \cdot 10^{-9}\right):\\
\;\;\;\;1 \cdot \mathsf{fma}\left(\cos \varepsilon, \cos x, -\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\sin x, \sin \varepsilon, \cos x\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left({\varepsilon}^{3} \cdot \frac{1}{24} - \mathsf{fma}\left(\frac{1}{2}, \varepsilon, x\right)\right)\\
\end{array}double f(double x, double eps) {
double r46989 = x;
double r46990 = eps;
double r46991 = r46989 + r46990;
double r46992 = cos(r46991);
double r46993 = cos(r46989);
double r46994 = r46992 - r46993;
return r46994;
}
double f(double x, double eps) {
double r46995 = eps;
double r46996 = -8.396995804045069e-12;
bool r46997 = r46995 <= r46996;
double r46998 = 3.588703897944784e-09;
bool r46999 = r46995 <= r46998;
double r47000 = !r46999;
bool r47001 = r46997 || r47000;
double r47002 = 1.0;
double r47003 = cos(r46995);
double r47004 = x;
double r47005 = cos(r47004);
double r47006 = sin(r47004);
double r47007 = sin(r46995);
double r47008 = fma(r47006, r47007, r47005);
double r47009 = expm1(r47008);
double r47010 = log1p(r47009);
double r47011 = -r47010;
double r47012 = fma(r47003, r47005, r47011);
double r47013 = r47002 * r47012;
double r47014 = 3.0;
double r47015 = pow(r46995, r47014);
double r47016 = 0.041666666666666664;
double r47017 = r47015 * r47016;
double r47018 = 0.5;
double r47019 = fma(r47018, r46995, r47004);
double r47020 = r47017 - r47019;
double r47021 = r46995 * r47020;
double r47022 = r47001 ? r47013 : r47021;
return r47022;
}



Bits error versus x



Bits error versus eps
if eps < -8.396995804045069e-12 or 3.588703897944784e-09 < eps Initial program 30.6
rmApplied cos-sum1.4
rmApplied *-un-lft-identity1.4
Applied *-un-lft-identity1.4
Applied distribute-lft-out--1.4
Simplified1.3
rmApplied log1p-expm1-u1.4
if -8.396995804045069e-12 < eps < 3.588703897944784e-09Initial program 49.8
rmApplied cos-sum49.6
rmApplied add-log-exp49.8
Applied add-log-exp49.8
Applied add-log-exp49.6
Applied diff-log49.6
Applied diff-log49.6
Simplified49.6
Taylor expanded around 0 30.8
Simplified30.8
Final simplification15.6
herbie shell --seed 2020001 +o rules:numerics
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))