\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02826034963706557101570382428690209053457:\\
\;\;\;\;\sqrt{\frac{\frac{\frac{1 \cdot \left(1 \cdot 1\right) - \left(\cos x \cdot \cos x\right) \cdot \cos x}{\mathsf{fma}\left(\cos x, \cos x + 1, 1 \cdot 1\right)}}{x}}{x}} \cdot \sqrt{\frac{\frac{\log \left(e^{1 - \cos x}\right)}{x}}{x}}\\
\mathbf{elif}\;x \le 0.02946672320662404448432525327916664537042:\\
\;\;\;\;\mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{720}, \mathsf{fma}\left(x \cdot x, \frac{-1}{24}, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \cos x\right) \cdot \frac{\frac{1}{x}}{x}\\
\end{array}double f(double x) {
double r720447 = 1.0;
double r720448 = x;
double r720449 = cos(r720448);
double r720450 = r720447 - r720449;
double r720451 = r720448 * r720448;
double r720452 = r720450 / r720451;
return r720452;
}
double f(double x) {
double r720453 = x;
double r720454 = -0.02826034963706557;
bool r720455 = r720453 <= r720454;
double r720456 = 1.0;
double r720457 = r720456 * r720456;
double r720458 = r720456 * r720457;
double r720459 = cos(r720453);
double r720460 = r720459 * r720459;
double r720461 = r720460 * r720459;
double r720462 = r720458 - r720461;
double r720463 = r720459 + r720456;
double r720464 = fma(r720459, r720463, r720457);
double r720465 = r720462 / r720464;
double r720466 = r720465 / r720453;
double r720467 = r720466 / r720453;
double r720468 = sqrt(r720467);
double r720469 = r720456 - r720459;
double r720470 = exp(r720469);
double r720471 = log(r720470);
double r720472 = r720471 / r720453;
double r720473 = r720472 / r720453;
double r720474 = sqrt(r720473);
double r720475 = r720468 * r720474;
double r720476 = 0.029466723206624044;
bool r720477 = r720453 <= r720476;
double r720478 = r720453 * r720453;
double r720479 = r720478 * r720478;
double r720480 = 0.001388888888888889;
double r720481 = -0.041666666666666664;
double r720482 = 0.5;
double r720483 = fma(r720478, r720481, r720482);
double r720484 = fma(r720479, r720480, r720483);
double r720485 = 1.0;
double r720486 = r720485 / r720453;
double r720487 = r720486 / r720453;
double r720488 = r720469 * r720487;
double r720489 = r720477 ? r720484 : r720488;
double r720490 = r720455 ? r720475 : r720489;
return r720490;
}



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