\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.037855314436600819:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{\log \left(e^{1 - \cos x}\right)}{x}}{x}\right)\right)\\
\mathbf{elif}\;x \le 0.03032722926070993:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{\log \left(e^{1 - \cos x}\right)}}{\sqrt{x}}}{\frac{x \cdot \sqrt{x}}{\sqrt{1 - \cos x}}}\\
\end{array}double f(double x) {
double r27964 = 1.0;
double r27965 = x;
double r27966 = cos(r27965);
double r27967 = r27964 - r27966;
double r27968 = r27965 * r27965;
double r27969 = r27967 / r27968;
return r27969;
}
double f(double x) {
double r27970 = x;
double r27971 = -0.03785531443660082;
bool r27972 = r27970 <= r27971;
double r27973 = 1.0;
double r27974 = cos(r27970);
double r27975 = r27973 - r27974;
double r27976 = exp(r27975);
double r27977 = log(r27976);
double r27978 = r27977 / r27970;
double r27979 = r27978 / r27970;
double r27980 = expm1(r27979);
double r27981 = log1p(r27980);
double r27982 = 0.03032722926070993;
bool r27983 = r27970 <= r27982;
double r27984 = 4.0;
double r27985 = pow(r27970, r27984);
double r27986 = 0.001388888888888889;
double r27987 = 0.5;
double r27988 = 0.041666666666666664;
double r27989 = 2.0;
double r27990 = pow(r27970, r27989);
double r27991 = r27988 * r27990;
double r27992 = r27987 - r27991;
double r27993 = fma(r27985, r27986, r27992);
double r27994 = sqrt(r27977);
double r27995 = sqrt(r27970);
double r27996 = r27994 / r27995;
double r27997 = r27970 * r27995;
double r27998 = sqrt(r27975);
double r27999 = r27997 / r27998;
double r28000 = r27996 / r27999;
double r28001 = r27983 ? r27993 : r28000;
double r28002 = r27972 ? r27981 : r28001;
return r28002;
}



Bits error versus x
if x < -0.03785531443660082Initial program 1.1
rmApplied associate-/r*0.5
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.7
Simplified0.6
rmApplied log1p-expm1-u0.6
if -0.03785531443660082 < x < 0.03032722926070993Initial program 62.2
Taylor expanded around 0 0.0
Simplified0.0
if 0.03032722926070993 < x Initial program 0.9
rmApplied associate-/r*0.4
rmApplied add-log-exp0.5
Applied add-log-exp0.5
Applied diff-log0.6
Simplified0.5
rmApplied add-sqr-sqrt0.7
Applied add-sqr-sqrt0.7
Applied times-frac0.7
Applied associate-/l*0.7
Simplified0.6
Final simplification0.3
herbie shell --seed 2020027 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))