\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02740531929745840256096300890931161120534:\\
\;\;\;\;\frac{\frac{\sqrt{\log \left(e^{1 - \cos x}\right)}}{x}}{x} \cdot \sqrt{1 - \cos x}\\
\mathbf{elif}\;x \le 0.03110675776409119533405522872726578498259:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \frac{-1}{24}, \mathsf{fma}\left(x \cdot x, \left(x \cdot x\right) \cdot \frac{1}{720}, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt{1 - \cos x}}{x}}{x} \cdot \sqrt{1 - \cos x}\\
\end{array}double f(double x) {
double r762331 = 1.0;
double r762332 = x;
double r762333 = cos(r762332);
double r762334 = r762331 - r762333;
double r762335 = r762332 * r762332;
double r762336 = r762334 / r762335;
return r762336;
}
double f(double x) {
double r762337 = x;
double r762338 = -0.027405319297458403;
bool r762339 = r762337 <= r762338;
double r762340 = 1.0;
double r762341 = cos(r762337);
double r762342 = r762340 - r762341;
double r762343 = exp(r762342);
double r762344 = log(r762343);
double r762345 = sqrt(r762344);
double r762346 = r762345 / r762337;
double r762347 = r762346 / r762337;
double r762348 = sqrt(r762342);
double r762349 = r762347 * r762348;
double r762350 = 0.031106757764091195;
bool r762351 = r762337 <= r762350;
double r762352 = r762337 * r762337;
double r762353 = -0.041666666666666664;
double r762354 = 0.001388888888888889;
double r762355 = r762352 * r762354;
double r762356 = 0.5;
double r762357 = fma(r762352, r762355, r762356);
double r762358 = fma(r762352, r762353, r762357);
double r762359 = r762348 / r762337;
double r762360 = r762359 / r762337;
double r762361 = r762360 * r762348;
double r762362 = r762351 ? r762358 : r762361;
double r762363 = r762339 ? r762349 : r762362;
return r762363;
}



Bits error versus x
if x < -0.027405319297458403Initial program 1.2
rmApplied associate-/r*0.5
rmApplied *-un-lft-identity0.5
Applied *-un-lft-identity0.5
Applied add-sqr-sqrt0.6
Applied times-frac0.6
Applied times-frac0.6
Simplified0.6
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.6
Simplified0.6
if -0.027405319297458403 < x < 0.031106757764091195Initial program 62.4
Taylor expanded around 0 0.0
Simplified0.0
if 0.031106757764091195 < x Initial program 1.0
rmApplied associate-/r*0.5
rmApplied *-un-lft-identity0.5
Applied *-un-lft-identity0.5
Applied add-sqr-sqrt0.6
Applied times-frac0.6
Applied times-frac0.6
Simplified0.6
Final simplification0.3
herbie shell --seed 2019168 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1.0 (cos x)) (* x x)))