\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(\frac{1}{720}, {x}^{4}, \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1 - \cos x}{x}}{x}\right)\right)\\
\end{array}double f(double x) {
double r25928 = 1.0;
double r25929 = x;
double r25930 = cos(r25929);
double r25931 = r25928 - r25930;
double r25932 = r25929 * r25929;
double r25933 = r25931 / r25932;
return r25933;
}
double f(double x) {
double r25934 = x;
double r25935 = -0.02660967226737158;
bool r25936 = r25934 <= r25935;
double r25937 = 1.0;
double r25938 = r25937 / r25934;
double r25939 = 1.0;
double r25940 = cos(r25934);
double r25941 = r25939 - r25940;
double r25942 = expm1(r25941);
double r25943 = log1p(r25942);
double r25944 = r25943 / r25934;
double r25945 = r25938 * r25944;
double r25946 = 0.024083451253618247;
bool r25947 = r25934 <= r25946;
double r25948 = 0.001388888888888889;
double r25949 = 4.0;
double r25950 = pow(r25934, r25949);
double r25951 = 0.5;
double r25952 = fma(r25948, r25950, r25951);
double r25953 = 0.041666666666666664;
double r25954 = 2.0;
double r25955 = pow(r25934, r25954);
double r25956 = r25953 * r25955;
double r25957 = r25952 - r25956;
double r25958 = r25941 / r25934;
double r25959 = r25958 / r25934;
double r25960 = expm1(r25959);
double r25961 = log1p(r25960);
double r25962 = r25947 ? r25957 : r25961;
double r25963 = r25936 ? r25945 : r25962;
return r25963;
}



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 log1p-expm1-u0.5
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)))