\cos \left(x + \varepsilon\right) - \cos x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -6.5696410515067922 \cdot 10^{-9} \lor \neg \left(\varepsilon \le 9.2579730885600051 \cdot 10^{-8}\right):\\
\;\;\;\;\log \left(e^{\left(\cos x \cdot \cos \varepsilon - \sin x \cdot \sin \varepsilon\right) - \cos x}\right)\\
\mathbf{else}:\\
\;\;\;\;\varepsilon \cdot \left(\left(\frac{1}{6} \cdot {x}^{3} - x\right) - \varepsilon \cdot \frac{1}{2}\right)\\
\end{array}double f(double x, double eps) {
double r67495 = x;
double r67496 = eps;
double r67497 = r67495 + r67496;
double r67498 = cos(r67497);
double r67499 = cos(r67495);
double r67500 = r67498 - r67499;
return r67500;
}
double f(double x, double eps) {
double r67501 = eps;
double r67502 = -6.569641051506792e-09;
bool r67503 = r67501 <= r67502;
double r67504 = 9.257973088560005e-08;
bool r67505 = r67501 <= r67504;
double r67506 = !r67505;
bool r67507 = r67503 || r67506;
double r67508 = x;
double r67509 = cos(r67508);
double r67510 = cos(r67501);
double r67511 = r67509 * r67510;
double r67512 = sin(r67508);
double r67513 = sin(r67501);
double r67514 = r67512 * r67513;
double r67515 = r67511 - r67514;
double r67516 = r67515 - r67509;
double r67517 = exp(r67516);
double r67518 = log(r67517);
double r67519 = 0.16666666666666666;
double r67520 = 3.0;
double r67521 = pow(r67508, r67520);
double r67522 = r67519 * r67521;
double r67523 = r67522 - r67508;
double r67524 = 0.5;
double r67525 = r67501 * r67524;
double r67526 = r67523 - r67525;
double r67527 = r67501 * r67526;
double r67528 = r67507 ? r67518 : r67527;
return r67528;
}



Bits error versus x



Bits error versus eps
Results
if eps < -6.569641051506792e-09 or 9.257973088560005e-08 < eps Initial program 30.4
rmApplied cos-sum1.1
rmApplied add-log-exp1.2
Applied add-log-exp1.3
Applied add-log-exp1.5
Applied diff-log1.5
Applied diff-log1.6
Simplified1.3
if -6.569641051506792e-09 < eps < 9.257973088560005e-08Initial program 49.3
Taylor expanded around 0 32.3
Simplified32.3
Final simplification16.4
herbie shell --seed 2020018
(FPCore (x eps)
:name "2cos (problem 3.3.5)"
:precision binary64
(- (cos (+ x eps)) (cos x)))