\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03084679120220890427561677427092945436016:\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{\frac{x}{\frac{\sqrt{1 - \cos x}}{x}}}\\
\mathbf{elif}\;x \le 0.03981852127604897095825009500913438387215:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \frac{-1}{24}, \mathsf{fma}\left(\frac{1}{720}, {x}^{4}, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{\cos x}{x}}{x}\\
\end{array}double f(double x) {
double r20292 = 1.0;
double r20293 = x;
double r20294 = cos(r20293);
double r20295 = r20292 - r20294;
double r20296 = r20293 * r20293;
double r20297 = r20295 / r20296;
return r20297;
}
double f(double x) {
double r20298 = x;
double r20299 = -0.030846791202208904;
bool r20300 = r20298 <= r20299;
double r20301 = 1.0;
double r20302 = cos(r20298);
double r20303 = r20301 - r20302;
double r20304 = sqrt(r20303);
double r20305 = r20304 / r20298;
double r20306 = r20298 / r20305;
double r20307 = r20304 / r20306;
double r20308 = 0.03981852127604897;
bool r20309 = r20298 <= r20308;
double r20310 = r20298 * r20298;
double r20311 = -0.041666666666666664;
double r20312 = 0.001388888888888889;
double r20313 = 4.0;
double r20314 = pow(r20298, r20313);
double r20315 = 0.5;
double r20316 = fma(r20312, r20314, r20315);
double r20317 = fma(r20310, r20311, r20316);
double r20318 = r20301 / r20298;
double r20319 = r20302 / r20298;
double r20320 = r20318 - r20319;
double r20321 = r20320 / r20298;
double r20322 = r20309 ? r20317 : r20321;
double r20323 = r20300 ? r20307 : r20322;
return r20323;
}



Bits error versus x
if x < -0.030846791202208904Initial program 0.9
rmApplied associate-/r*0.5
rmApplied *-un-lft-identity0.5
Applied add-sqr-sqrt0.6
Applied times-frac0.6
Applied associate-/l*1.1
if -0.030846791202208904 < x < 0.03981852127604897Initial program 62.2
Taylor expanded around 0 0.0
Simplified0.0
if 0.03981852127604897 < x Initial program 1.1
rmApplied associate-/r*0.4
rmApplied div-sub0.5
Final simplification0.4
herbie shell --seed 2019323 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))