\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.0344878390097593454:\\
\;\;\;\;\frac{\frac{1}{x}}{x} - \frac{\frac{\cos x}{x}}{x}\\
\mathbf{elif}\;x \le 0.03176890082881835:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - \cos x\right)\right)}{x}}{x}\\
\end{array}double f(double x) {
double r29862 = 1.0;
double r29863 = x;
double r29864 = cos(r29863);
double r29865 = r29862 - r29864;
double r29866 = r29863 * r29863;
double r29867 = r29865 / r29866;
return r29867;
}
double f(double x) {
double r29868 = x;
double r29869 = -0.034487839009759345;
bool r29870 = r29868 <= r29869;
double r29871 = 1.0;
double r29872 = r29871 / r29868;
double r29873 = r29872 / r29868;
double r29874 = cos(r29868);
double r29875 = r29874 / r29868;
double r29876 = r29875 / r29868;
double r29877 = r29873 - r29876;
double r29878 = 0.03176890082881835;
bool r29879 = r29868 <= r29878;
double r29880 = 4.0;
double r29881 = pow(r29868, r29880);
double r29882 = 0.001388888888888889;
double r29883 = 0.5;
double r29884 = 0.041666666666666664;
double r29885 = 2.0;
double r29886 = pow(r29868, r29885);
double r29887 = r29884 * r29886;
double r29888 = r29883 - r29887;
double r29889 = fma(r29881, r29882, r29888);
double r29890 = r29871 - r29874;
double r29891 = log1p(r29890);
double r29892 = expm1(r29891);
double r29893 = r29892 / r29868;
double r29894 = r29893 / r29868;
double r29895 = r29879 ? r29889 : r29894;
double r29896 = r29870 ? r29877 : r29895;
return r29896;
}



Bits error versus x
if x < -0.034487839009759345Initial program 1.0
rmApplied *-un-lft-identity1.0
Applied times-frac0.5
rmApplied associate-*r/0.5
Simplified0.5
rmApplied div-sub0.5
Applied div-sub0.6
if -0.034487839009759345 < x < 0.03176890082881835Initial program 62.4
Taylor expanded around 0 0.0
Simplified0.0
if 0.03176890082881835 < x Initial program 1.1
rmApplied *-un-lft-identity1.1
Applied times-frac0.5
rmApplied associate-*r/0.5
Simplified0.4
rmApplied expm1-log1p-u0.5
Final simplification0.3
herbie shell --seed 2020064 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))