\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \leq -0.03140225698466425:\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{\sqrt{\log \left(e^{1 - \cos x}\right)}}}{\frac{x}{\sqrt{\sqrt{1 - \cos x}}}}\\
\mathbf{elif}\;x \leq 0.03002211543800249:\\
\;\;\;\;{x}^{4} \cdot 0.001388888888888889 + \left(0.5 + x \cdot \left(x \cdot -0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{x \cdot \left(x \cdot \left(1 \cdot 1 + \cos x \cdot \left(1 + \cos x\right)\right)\right)}\\
\end{array}double code(double x) {
return (((double) (1.0 - ((double) cos(x)))) / ((double) (x * x)));
}
double code(double x) {
double VAR;
if ((x <= -0.03140225698466425)) {
VAR = ((double) ((((double) sqrt(((double) (1.0 - ((double) cos(x)))))) / x) * (((double) sqrt(((double) sqrt(((double) log(((double) exp(((double) (1.0 - ((double) cos(x)))))))))))) / (x / ((double) sqrt(((double) sqrt(((double) (1.0 - ((double) cos(x))))))))))));
} else {
double VAR_1;
if ((x <= 0.03002211543800249)) {
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) pow(1.0, 3.0)) - ((double) pow(((double) cos(x)), 3.0)))) / ((double) (x * ((double) (x * ((double) (((double) (1.0 * 1.0)) + ((double) (((double) cos(x)) * ((double) (1.0 + ((double) cos(x)))))))))))));
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus x
Results
if x < -0.0314022569846642494Initial program 1.0
rmApplied add-sqr-sqrt1.1
Applied times-frac0.6
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.6
Simplified0.6
rmApplied add-sqr-sqrt0.6
Applied sqrt-prod0.7
Applied associate-/l*0.7
Simplified0.7
if -0.0314022569846642494 < x < 0.03002211543800249Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.03002211543800249 < x Initial program 1.1
rmApplied flip3--1.1
Applied associate-/l/1.1
Simplified1.1
Final simplification0.4
herbie shell --seed 2020196
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))