\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.034533322447672377:\\
\;\;\;\;\frac{e^{\frac{2}{3} \cdot \log \left(1 - \cos x\right)}}{x} \cdot \frac{\sqrt[3]{\log \left(e^{1 - \cos x}\right)}}{x}\\
\mathbf{elif}\;x \le 0.0342323272118313024:\\
\;\;\;\;\left(\frac{1}{2} + \frac{1}{720} \cdot {x}^{4}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot x} - \frac{\cos x}{x \cdot x}\\
\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.03453332244767238)) {
VAR = ((double) ((((double) exp(((double) (0.6666666666666666 * ((double) log(((double) (1.0 - ((double) cos(x)))))))))) / x) * (((double) cbrt(((double) log(((double) exp(((double) (1.0 - ((double) cos(x)))))))))) / x)));
} else {
double VAR_1;
if ((x <= 0.0342323272118313)) {
VAR_1 = ((double) (((double) (0.5 + ((double) (0.001388888888888889 * ((double) pow(x, 4.0)))))) - ((double) (0.041666666666666664 * ((double) pow(x, 2.0))))));
} else {
VAR_1 = ((double) ((1.0 / ((double) (x * x))) - (((double) cos(x)) / ((double) (x * x)))));
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus x
Results
if x < -0.034533322447672377Initial program 1.0
rmApplied add-cube-cbrt1.4
Applied times-frac0.8
rmApplied add-log-exp0.8
Simplified0.7
rmApplied add-log-exp0.7
Applied add-log-exp0.7
Applied diff-log0.7
Simplified0.7
rmApplied add-exp-log0.7
Simplified0.6
if -0.034533322447672377 < x < 0.0342323272118313024Initial program 62.1
Taylor expanded around 0 0.0
if 0.0342323272118313024 < x Initial program 0.9
rmApplied div-sub1.0
Final simplification0.4
herbie shell --seed 2020182
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))