\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.031288658239448007 \lor \neg \left(x \le 0.0246736691289138228\right):\\
\;\;\;\;\frac{\frac{1}{x}}{x} \cdot \left(1 - \cos x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / (x * x));
}
double code(double x) {
double temp;
if (((x <= -0.03128865823944801) || !(x <= 0.024673669128913823))) {
temp = (((1.0 / x) / x) * (1.0 - cos(x)));
} else {
temp = fma(pow(x, 4.0), 0.001388888888888889, (0.5 - (0.041666666666666664 * pow(x, 2.0))));
}
return temp;
}



Bits error versus x
Results
if x < -0.03128865823944801 or 0.024673669128913823 < x Initial program 0.9
rmApplied *-un-lft-identity0.9
Applied times-frac0.5
rmApplied clear-num0.5
rmApplied associate-/r/0.6
Applied associate-*r*0.6
Simplified0.5
if -0.03128865823944801 < x < 0.024673669128913823Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
Final simplification0.3
herbie shell --seed 2020056 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))