\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.0266096722673715806:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(1 - \cos x\right)\right)}{x}\\
\mathbf{elif}\;x \le 0.0240834512536182467:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\
\end{array}double f(double x) {
double r27704 = 1.0;
double r27705 = x;
double r27706 = cos(r27705);
double r27707 = r27704 - r27706;
double r27708 = r27705 * r27705;
double r27709 = r27707 / r27708;
return r27709;
}
double f(double x) {
double r27710 = x;
double r27711 = -0.02660967226737158;
bool r27712 = r27710 <= r27711;
double r27713 = 1.0;
double r27714 = r27713 / r27710;
double r27715 = 1.0;
double r27716 = cos(r27710);
double r27717 = r27715 - r27716;
double r27718 = expm1(r27717);
double r27719 = log1p(r27718);
double r27720 = r27719 / r27710;
double r27721 = r27714 * r27720;
double r27722 = 0.024083451253618247;
bool r27723 = r27710 <= r27722;
double r27724 = 4.0;
double r27725 = pow(r27710, r27724);
double r27726 = 0.001388888888888889;
double r27727 = 0.5;
double r27728 = 0.041666666666666664;
double r27729 = 2.0;
double r27730 = pow(r27710, r27729);
double r27731 = r27728 * r27730;
double r27732 = r27727 - r27731;
double r27733 = fma(r27725, r27726, r27732);
double r27734 = r27717 / r27710;
double r27735 = r27734 / r27710;
double r27736 = r27723 ? r27733 : r27735;
double r27737 = r27712 ? r27721 : r27736;
return r27737;
}



Bits error versus x
if x < -0.02660967226737158Initial program 0.9
rmApplied *-un-lft-identity0.9
Applied times-frac0.5
rmApplied log1p-expm1-u0.5
if -0.02660967226737158 < x < 0.024083451253618247Initial program 62.2
Taylor expanded around 0 0.0
Simplified0.0
if 0.024083451253618247 < x Initial program 1.0
rmApplied *-un-lft-identity1.0
Applied times-frac0.5
rmApplied log1p-expm1-u0.5
rmApplied associate-*r/0.4
Simplified0.4
Final simplification0.2
herbie shell --seed 2020046 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))