\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02927801672355929279989439351084001827985:\\
\;\;\;\;\left(1 - \cos x\right) \cdot \frac{\frac{1}{x}}{x}\\
\mathbf{elif}\;x \le 0.02874724167449887318737111741029366385192:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{e}^{\left(\log \left(1 - \cos x\right)\right)}}{x}}{x}\\
\end{array}double f(double x) {
double r18842 = 1.0;
double r18843 = x;
double r18844 = cos(r18843);
double r18845 = r18842 - r18844;
double r18846 = r18843 * r18843;
double r18847 = r18845 / r18846;
return r18847;
}
double f(double x) {
double r18848 = x;
double r18849 = -0.029278016723559293;
bool r18850 = r18848 <= r18849;
double r18851 = 1.0;
double r18852 = cos(r18848);
double r18853 = r18851 - r18852;
double r18854 = 1.0;
double r18855 = r18854 / r18848;
double r18856 = r18855 / r18848;
double r18857 = r18853 * r18856;
double r18858 = 0.028747241674498873;
bool r18859 = r18848 <= r18858;
double r18860 = 0.001388888888888889;
double r18861 = 4.0;
double r18862 = pow(r18848, r18861);
double r18863 = r18860 * r18862;
double r18864 = 0.5;
double r18865 = r18863 + r18864;
double r18866 = 0.041666666666666664;
double r18867 = 2.0;
double r18868 = pow(r18848, r18867);
double r18869 = r18866 * r18868;
double r18870 = r18865 - r18869;
double r18871 = exp(1.0);
double r18872 = log(r18853);
double r18873 = pow(r18871, r18872);
double r18874 = r18873 / r18848;
double r18875 = r18874 / r18848;
double r18876 = r18859 ? r18870 : r18875;
double r18877 = r18850 ? r18857 : r18876;
return r18877;
}



Bits error versus x
Results
if x < -0.029278016723559293Initial program 1.1
rmApplied associate-/r*0.4
rmApplied *-un-lft-identity0.4
Applied div-inv0.5
Applied times-frac0.5
Simplified0.5
if -0.029278016723559293 < x < 0.028747241674498873Initial program 62.2
Taylor expanded around 0 0.0
if 0.028747241674498873 < x Initial program 1.0
rmApplied associate-/r*0.5
rmApplied add-exp-log0.5
rmApplied pow10.5
Applied log-pow0.5
Applied exp-prod0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2019308
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))