\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.033320062920463786:\\
\;\;\;\;\frac{\frac{{1}^{3} - \mathsf{expm1}\left(\mathsf{log1p}\left({\left(\cos x\right)}^{3}\right)\right)}{x}}{\mathsf{fma}\left(1, x \cdot 1, \left(x \cdot \cos x\right) \cdot \left(1 + \cos x\right)\right)}\\
\mathbf{elif}\;x \le 0.0329960873997033124:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\log \left(1 - \cos x\right)}}{x \cdot x}\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / (x * x));
}
double code(double x) {
double temp;
if ((x <= -0.033320062920463786)) {
temp = (((pow(1.0, 3.0) - expm1(log1p(pow(cos(x), 3.0)))) / x) / fma(1.0, (x * 1.0), ((x * cos(x)) * (1.0 + cos(x)))));
} else {
double temp_1;
if ((x <= 0.03299608739970331)) {
temp_1 = fma(pow(x, 4.0), 0.001388888888888889, (0.5 - (0.041666666666666664 * pow(x, 2.0))));
} else {
temp_1 = (exp(log((1.0 - cos(x)))) / (x * x));
}
temp = temp_1;
}
return temp;
}



Bits error versus x
Results
if x < -0.033320062920463786Initial program 1.1
rmApplied *-un-lft-identity1.1
Applied times-frac0.5
rmApplied div-inv0.6
rmApplied flip3--0.6
Applied associate-*l/0.6
Applied frac-times0.6
Simplified0.5
Simplified0.5
rmApplied expm1-log1p-u0.5
if -0.033320062920463786 < x < 0.03299608739970331Initial program 62.2
Taylor expanded around 0 0.0
Simplified0.0
if 0.03299608739970331 < x Initial program 1.0
rmApplied add-exp-log1.0
Final simplification0.4
herbie shell --seed 2020049 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))