\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02993031743019760812507534808446507668123:\\
\;\;\;\;\frac{\frac{\log \left(e^{1 - \cos x}\right)}{x}}{x}\\
\mathbf{elif}\;x \le 0.03087561509222142355768347954381169984117:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, \frac{1}{2}, \frac{1}{720} \cdot {x}^{5} - \frac{1}{24} \cdot {x}^{3}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{1 - \cos x}{x}}}\\
\end{array}double f(double x) {
double r33379 = 1.0;
double r33380 = x;
double r33381 = cos(r33380);
double r33382 = r33379 - r33381;
double r33383 = r33380 * r33380;
double r33384 = r33382 / r33383;
return r33384;
}
double f(double x) {
double r33385 = x;
double r33386 = -0.029930317430197608;
bool r33387 = r33385 <= r33386;
double r33388 = 1.0;
double r33389 = cos(r33385);
double r33390 = r33388 - r33389;
double r33391 = exp(r33390);
double r33392 = log(r33391);
double r33393 = r33392 / r33385;
double r33394 = r33393 / r33385;
double r33395 = 0.030875615092221424;
bool r33396 = r33385 <= r33395;
double r33397 = 0.5;
double r33398 = 0.001388888888888889;
double r33399 = 5.0;
double r33400 = pow(r33385, r33399);
double r33401 = r33398 * r33400;
double r33402 = 0.041666666666666664;
double r33403 = 3.0;
double r33404 = pow(r33385, r33403);
double r33405 = r33402 * r33404;
double r33406 = r33401 - r33405;
double r33407 = fma(r33385, r33397, r33406);
double r33408 = r33407 / r33385;
double r33409 = 1.0;
double r33410 = r33390 / r33385;
double r33411 = r33385 / r33410;
double r33412 = r33409 / r33411;
double r33413 = r33396 ? r33408 : r33412;
double r33414 = r33387 ? r33394 : r33413;
return r33414;
}



Bits error versus x
if x < -0.029930317430197608Initial program 1.1
rmApplied associate-/r*0.5
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.7
Simplified0.6
if -0.029930317430197608 < x < 0.030875615092221424Initial program 62.2
rmApplied associate-/r*61.2
Taylor expanded around 0 0.0
Simplified0.0
if 0.030875615092221424 < x Initial program 1.0
rmApplied associate-/r*0.5
rmApplied clear-num1.0
Final simplification0.4
herbie shell --seed 2019362 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))