\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03299151901246776:\\
\;\;\;\;\frac{\left(1 - \cos x\right) \cdot \frac{1}{x}}{x}\\
\mathbf{elif}\;x \le 0.032971011098790887:\\
\;\;\;\;\frac{1}{2} + \left(\frac{1}{720} \cdot {x}^{4} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{\cos x}{x}}{x}\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / (x * x));
}
double code(double x) {
double VAR;
if ((x <= -0.03299151901246776)) {
VAR = (((1.0 - cos(x)) * (1.0 / x)) / x);
} else {
double VAR_1;
if ((x <= 0.03297101109879089)) {
VAR_1 = (0.5 + ((0.001388888888888889 * pow(x, 4.0)) - (0.041666666666666664 * pow(x, 2.0))));
} else {
VAR_1 = (((1.0 / x) - (cos(x) / x)) / x);
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus x
Results
if x < -0.03299151901246776Initial program 0.9
rmApplied associate-/r*0.4
rmApplied div-inv0.5
if -0.03299151901246776 < x < 0.03297101109879089Initial program 62.2
Taylor expanded around 0 0.0
rmApplied +-commutative0.0
Applied associate--l+0.0
if 0.03297101109879089 < x Initial program 1.0
rmApplied associate-/r*0.5
rmApplied div-sub0.6
Final simplification0.3
herbie shell --seed 2020071
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))