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



Bits error versus x
Results
if x < -0.02026115641790327Initial program 1.0
rmApplied associate-/r*0.4
rmApplied flip--0.7
rmApplied sqr-cos-a0.9
Applied associate--r+0.8
Simplified0.8
if -0.02026115641790327 < x < 0.033747369637332478Initial program 61.5
Taylor expanded around 0 0.0
Simplified0.0
if 0.033747369637332478 < x Initial program 1.1
rmApplied associate-/r*0.5
rmApplied div-sub0.6
Final simplification0.4
herbie shell --seed 2020184
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))