\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02680284925783882 \lor \neg \left(x \le 0.0326302713396224922\right):\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{{1}^{3} - {\left(\cos x\right)}^{3}}}{x \cdot \sqrt{1 \cdot 1 + \cos x \cdot \left(\cos x + 1\right)}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / (x * x));
}
double code(double x) {
double temp;
if (((x <= -0.026802849257838823) || !(x <= 0.03263027133962249))) {
temp = ((sqrt((1.0 - cos(x))) / x) * (sqrt((pow(1.0, 3.0) - pow(cos(x), 3.0))) / (x * sqrt(((1.0 * 1.0) + (cos(x) * (cos(x) + 1.0)))))));
} else {
temp = fma(pow(x, 4.0), 0.001388888888888889, (0.5 - (0.041666666666666664 * pow(x, 2.0))));
}
return temp;
}



Bits error versus x
Results
if x < -0.026802849257838823 or 0.03263027133962249 < x Initial program 1.1
rmApplied add-sqr-sqrt1.2
Applied times-frac0.6
rmApplied flip3--0.6
Applied sqrt-div0.6
Applied associate-/l/0.6
Taylor expanded around inf 0.6
Simplified0.6
if -0.026802849257838823 < x < 0.03263027133962249Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
Final simplification0.3
herbie shell --seed 2020065 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))