\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03237572141906872036365427902637748047709:\\
\;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\
\mathbf{elif}\;x \le 0.03382760307135756344676380535929638426751:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{24}, x \cdot x, \mathsf{fma}\left(\frac{1}{720}, {x}^{4}, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{{1}^{3} - \log \left(e^{\cos x \cdot {\left(\cos x\right)}^{2}}\right)}{\mathsf{fma}\left(1, 1, \cos x \cdot \left(\cos x + 1\right)\right)}}{x}}{x}\\
\end{array}double f(double x) {
double r22539 = 1.0;
double r22540 = x;
double r22541 = cos(r22540);
double r22542 = r22539 - r22541;
double r22543 = r22540 * r22540;
double r22544 = r22542 / r22543;
return r22544;
}
double f(double x) {
double r22545 = x;
double r22546 = -0.03237572141906872;
bool r22547 = r22545 <= r22546;
double r22548 = 1.0;
double r22549 = cos(r22545);
double r22550 = r22548 - r22549;
double r22551 = r22550 / r22545;
double r22552 = r22551 / r22545;
double r22553 = 0.03382760307135756;
bool r22554 = r22545 <= r22553;
double r22555 = -0.041666666666666664;
double r22556 = r22545 * r22545;
double r22557 = 0.001388888888888889;
double r22558 = 4.0;
double r22559 = pow(r22545, r22558);
double r22560 = 0.5;
double r22561 = fma(r22557, r22559, r22560);
double r22562 = fma(r22555, r22556, r22561);
double r22563 = 3.0;
double r22564 = pow(r22548, r22563);
double r22565 = 2.0;
double r22566 = pow(r22549, r22565);
double r22567 = r22549 * r22566;
double r22568 = exp(r22567);
double r22569 = log(r22568);
double r22570 = r22564 - r22569;
double r22571 = r22549 + r22548;
double r22572 = r22549 * r22571;
double r22573 = fma(r22548, r22548, r22572);
double r22574 = r22570 / r22573;
double r22575 = r22574 / r22545;
double r22576 = r22575 / r22545;
double r22577 = r22554 ? r22562 : r22576;
double r22578 = r22547 ? r22552 : r22577;
return r22578;
}



Bits error versus x
if x < -0.03237572141906872Initial program 1.1
rmApplied associate-/r*0.5
if -0.03237572141906872 < x < 0.03382760307135756Initial program 62.2
Taylor expanded around 0 0.0
Simplified0.0
if 0.03382760307135756 < x Initial program 0.9
rmApplied associate-/r*0.5
rmApplied flip3--0.5
Simplified0.5
rmApplied add-log-exp0.6
rmApplied cube-mult0.6
Simplified0.6
Final simplification0.3
herbie shell --seed 2019212 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))