\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.030582628052299624 \lor \neg \left(x \le 0.0299428859058577142\right):\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos 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 temp;
if (((x <= -0.030582628052299624) || !(x <= 0.029942885905857714))) {
temp = ((sqrt((1.0 - cos(x))) / x) * (sqrt((1.0 - cos(x))) / x));
} else {
temp = (((0.001388888888888889 * pow(x, 4.0)) + 0.5) - (0.041666666666666664 * pow(x, 2.0)));
}
return temp;
}



Bits error versus x
Results
if x < -0.030582628052299624 or 0.029942885905857714 < x Initial program 1.1
rmApplied add-sqr-sqrt1.2
Applied times-frac0.6
if -0.030582628052299624 < x < 0.029942885905857714Initial program 62.3
Taylor expanded around 0 0.0
Final simplification0.3
herbie shell --seed 2020058
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))