\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 0.9
rmApplied *-un-lft-identity_binary640.9
Applied times-frac_binary640.5
if -0.0320353186071557147 < x < 0.029706365761949148Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.029706365761949148 < x Initial program 1.2
rmApplied add-sqr-sqrt_binary641.3
Applied times-frac_binary640.6
Final simplification0.3
herbie shell --seed 2020205
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))