\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):\\
\;\;\;\;\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) + \mathsf{fma}\left(-\cos x, 1, \cos x\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 r53899 = x;
double r53900 = eps;
double r53901 = r53899 + r53900;
double r53902 = cos(r53901);
double r53903 = cos(r53899);
double r53904 = r53902 - r53903;
return r53904;
}
double f(double x, double eps) {
double r53905 = eps;
double r53906 = -8.396995804045069e-12;
bool r53907 = r53905 <= r53906;
double r53908 = 3.588703897944784e-09;
bool r53909 = r53905 <= r53908;
double r53910 = !r53909;
bool r53911 = r53907 || r53910;
double r53912 = cos(r53905);
double r53913 = x;
double r53914 = cos(r53913);
double r53915 = sin(r53913);
double r53916 = sin(r53905);
double r53917 = fma(r53915, r53916, r53914);
double r53918 = expm1(r53917);
double r53919 = log1p(r53918);
double r53920 = -r53919;
double r53921 = fma(r53912, r53914, r53920);
double r53922 = -r53914;
double r53923 = 1.0;
double r53924 = fma(r53922, r53923, r53914);
double r53925 = r53921 + r53924;
double r53926 = 3.0;
double r53927 = pow(r53905, r53926);
double r53928 = 0.041666666666666664;
double r53929 = r53927 * r53928;
double r53930 = 0.5;
double r53931 = fma(r53930, r53905, r53913);
double r53932 = r53929 - r53931;
double r53933 = r53905 * r53932;
double r53934 = r53911 ? r53925 : r53933;
return r53934;
}



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 add-cube-cbrt1.8
Applied add-sqr-sqrt32.6
Applied prod-diff32.6
Simplified1.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)))