\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.0323079859093642272:\\
\;\;\;\;\frac{{1}^{3} - {\left(\cos x\right)}^{3}}{\left(\cos x \cdot \left(\cos x + 1\right) + 1 \cdot 1\right) \cdot {x}^{2}}\\
\mathbf{elif}\;x \le 0.0313796160804084914:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{x} - \frac{\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.03230798590936423)) {
VAR = ((pow(1.0, 3.0) - pow(cos(x), 3.0)) / (((cos(x) * (cos(x) + 1.0)) + (1.0 * 1.0)) * pow(x, 2.0)));
} else {
double VAR_1;
if ((x <= 0.03137961608040849)) {
VAR_1 = (((0.001388888888888889 * pow(x, 4.0)) + 0.5) - (0.041666666666666664 * pow(x, 2.0)));
} else {
VAR_1 = (((1.0 / x) / x) - ((cos(x) / x) / x));
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus x
Results
if x < -0.03230798590936423Initial program 1.1
rmApplied flip3--1.1
Applied associate-/l/1.1
Simplified1.1
if -0.03230798590936423 < x < 0.03137961608040849Initial program 62.3
Taylor expanded around 0 0.0
if 0.03137961608040849 < x Initial program 1.0
rmApplied associate-/r*0.4
rmApplied div-sub0.6
Applied div-sub0.6
Final simplification0.4
herbie shell --seed 2020103
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))