\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.0332328864535681931 \lor \neg \left(x \le 0.03010910821075468\right):\\
\;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / (x * x));
}
double code(double x) {
double VAR;
if (((x <= -0.03323288645356819) || !(x <= 0.03010910821075468))) {
VAR = (((1.0 - cos(x)) / x) / x);
} else {
VAR = (((0.001388888888888889 * pow(x, 4.0)) + 0.5) - (0.041666666666666664 * pow(x, 2.0)));
}
return VAR;
}



Bits error versus x
Results
if x < -0.03323288645356819 or 0.03010910821075468 < x Initial program 1.1
rmApplied associate-/r*0.5
if -0.03323288645356819 < x < 0.03010910821075468Initial program 62.2
Taylor expanded around 0 0.0
Final simplification0.2
herbie shell --seed 2020078
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))