\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \leq -0.02560168368129429:\\
\;\;\;\;\sqrt{\frac{\frac{1 - \cos x}{x}}{x}} \cdot \sqrt{\frac{\frac{\frac{\left(1 \cdot 1 - 0.5\right) - 0.5 \cdot \cos \left(x \cdot 2\right)}{1 + \cos x}}{x}}{x}}\\
\mathbf{elif}\;x \leq 0.025971294136948462:\\
\;\;\;\;{x}^{4} \cdot 0.001388888888888889 + \left(0.5 - \left(x \cdot x\right) \cdot 0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{1 - \cos x}{x}}}\\
\end{array}(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x)
:precision binary64
(if (<= x -0.02560168368129429)
(*
(sqrt (/ (/ (- 1.0 (cos x)) x) x))
(sqrt
(/
(/ (/ (- (- (* 1.0 1.0) 0.5) (* 0.5 (cos (* x 2.0)))) (+ 1.0 (cos x))) x)
x)))
(if (<= x 0.025971294136948462)
(+
(* (pow x 4.0) 0.001388888888888889)
(- 0.5 (* (* x x) 0.041666666666666664)))
(/ 1.0 (/ x (/ (- 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.02560168368129429)) {
tmp = ((double) (((double) sqrt(((((double) (1.0 - ((double) cos(x)))) / x) / x))) * ((double) sqrt((((((double) (((double) (((double) (1.0 * 1.0)) - 0.5)) - ((double) (0.5 * ((double) cos(((double) (x * 2.0)))))))) / ((double) (1.0 + ((double) cos(x))))) / x) / x)))));
} else {
double tmp_1;
if ((x <= 0.025971294136948462)) {
tmp_1 = ((double) (((double) (((double) pow(x, 4.0)) * 0.001388888888888889)) + ((double) (0.5 - ((double) (((double) (x * x)) * 0.041666666666666664))))));
} else {
tmp_1 = (1.0 / (x / (((double) (1.0 - ((double) cos(x)))) / x)));
}
tmp = tmp_1;
}
return tmp;
}



Bits error versus x
Results
if x < -0.0256016836812942884Initial program 1.0
rmApplied clear-num_binary641.0
Simplified1.0
rmApplied add-sqr-sqrt_binary641.1
Simplified1.1
Simplified0.6
rmApplied flip--_binary640.7
rmApplied sqr-cos-a_binary640.8
Applied associate--r+_binary640.8
if -0.0256016836812942884 < x < 0.0259712941369484619Initial program 62.1
Taylor expanded around 0 0.0
Simplified0.0
if 0.0259712941369484619 < x Initial program 1.0
rmApplied clear-num_binary641.1
Simplified1.1
Final simplification0.5
herbie shell --seed 2020210
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))