\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \leq -0.032035318607155715:\\
\;\;\;\;\frac{1}{x} \cdot \frac{1 - \cos x}{x}\\
\mathbf{elif}\;x \leq 0.029706365761949148:\\
\;\;\;\;{x}^{4} \cdot 0.001388888888888889 + \left(0.5 - \left(x \cdot x\right) \cdot 0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{1 - \cos x}}{x}\\
\end{array}(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x)
:precision binary64
(if (<= x -0.032035318607155715)
(* (/ 1.0 x) (/ (- 1.0 (cos x)) x))
(if (<= x 0.029706365761949148)
(+
(* (pow x 4.0) 0.001388888888888889)
(- 0.5 (* (* x x) 0.041666666666666664)))
(* (/ (sqrt (- 1.0 (cos x))) x) (/ (sqrt (- 1.0 (cos x))) x)))))double code(double x) {
return (((double) (1.0 - ((double) cos(x)))) / ((double) (x * x)));
}
double code(double x) {
double tmp;
if ((x <= -0.032035318607155715)) {
tmp = ((double) ((1.0 / x) * (((double) (1.0 - ((double) cos(x)))) / x)));
} else {
double tmp_1;
if ((x <= 0.029706365761949148)) {
tmp_1 = ((double) (((double) (((double) pow(x, 4.0)) * 0.001388888888888889)) + ((double) (0.5 - ((double) (((double) (x * x)) * 0.041666666666666664))))));
} else {
tmp_1 = ((double) ((((double) sqrt(((double) (1.0 - ((double) cos(x)))))) / x) * (((double) sqrt(((double) (1.0 - ((double) cos(x)))))) / x)));
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus x
Results
if x < -0.0320353186071557147Initial program Error: 0.9 bits
rmApplied *-un-lft-identityError: 0.9 bits
Applied times-fracError: 0.5 bits
if -0.0320353186071557147 < x < 0.029706365761949148Initial program Error: 62.3 bits
Taylor expanded around 0 Error: 0.0 bits
SimplifiedError: 0.0 bits
if 0.029706365761949148 < x Initial program Error: 1.2 bits
rmApplied add-sqr-sqrtError: 1.3 bits
Applied times-fracError: 0.6 bits
Final simplificationError: 0.3 bits
herbie shell --seed 2020205
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))