\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.0289755674093477682:\\
\;\;\;\;\frac{\log \left(e^{1 - \cos x}\right)}{x \cdot x}\\
\mathbf{elif}\;x \le 0.0323653638594900775:\\
\;\;\;\;\frac{1}{720} \cdot {x}^{4} + \left(\frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\log \left(e^{1 - \cos x}\right)}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\
\end{array}double f(double x) {
double r22858 = 1.0;
double r22859 = x;
double r22860 = cos(r22859);
double r22861 = r22858 - r22860;
double r22862 = r22859 * r22859;
double r22863 = r22861 / r22862;
return r22863;
}
double f(double x) {
double r22864 = x;
double r22865 = -0.028975567409347768;
bool r22866 = r22864 <= r22865;
double r22867 = 1.0;
double r22868 = cos(r22864);
double r22869 = r22867 - r22868;
double r22870 = exp(r22869);
double r22871 = log(r22870);
double r22872 = r22864 * r22864;
double r22873 = r22871 / r22872;
double r22874 = 0.03236536385949008;
bool r22875 = r22864 <= r22874;
double r22876 = 0.001388888888888889;
double r22877 = 4.0;
double r22878 = pow(r22864, r22877);
double r22879 = r22876 * r22878;
double r22880 = 0.5;
double r22881 = 0.041666666666666664;
double r22882 = 2.0;
double r22883 = pow(r22864, r22882);
double r22884 = r22881 * r22883;
double r22885 = r22880 - r22884;
double r22886 = r22879 + r22885;
double r22887 = sqrt(r22871);
double r22888 = r22887 / r22864;
double r22889 = sqrt(r22869);
double r22890 = r22889 / r22864;
double r22891 = r22888 * r22890;
double r22892 = r22875 ? r22886 : r22891;
double r22893 = r22866 ? r22873 : r22892;
return r22893;
}



Bits error versus x
Results
if x < -0.028975567409347768Initial program 1.0
rmApplied add-log-exp1.1
Applied add-log-exp1.1
Applied diff-log1.3
Simplified1.2
if -0.028975567409347768 < x < 0.03236536385949008Initial program 62.4
Taylor expanded around 0 0.0
rmApplied associate--l+0.0
if 0.03236536385949008 < x Initial program 1.1
rmApplied add-sqr-sqrt1.2
Applied times-frac0.6
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.6
Simplified0.6
Final simplification0.5
herbie shell --seed 2020060
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))