\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.0309273812351459031 \lor \neg \left(x \le 0.023960596481684263\right):\\
\;\;\;\;1 \cdot \frac{1 - \cos x}{{x}^{2}}\\
\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.030927381235145903) || !(x <= 0.023960596481684263))) {
temp = (1.0 * ((1.0 - cos(x)) / pow(x, 2.0)));
} 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.030927381235145903 or 0.023960596481684263 < 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.7
Simplified0.6
rmApplied *-un-lft-identity0.6
Applied associate-*l*0.6
Simplified1.1
if -0.030927381235145903 < x < 0.023960596481684263Initial program 62.4
Taylor expanded around 0 0.0
Simplified0.0
Final simplification0.6
herbie shell --seed 2020060 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))