\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.034013493959747065:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, 1, -\cos x\right)}{x \cdot x}\\
\mathbf{elif}\;x \le 0.029815137429186504:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{1}{2}, x, \mathsf{fma}\left(\frac{1}{720}, {x}^{5}, {x}^{3} \cdot \frac{-1}{24}\right)\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{e}^{\left(\log \left(\log \left(e^{1 - \cos x}\right)\right)\right)}}{x}}{x}\\
\end{array}double f(double x) {
double r23615 = 1.0;
double r23616 = x;
double r23617 = cos(r23616);
double r23618 = r23615 - r23617;
double r23619 = r23616 * r23616;
double r23620 = r23618 / r23619;
return r23620;
}
double f(double x) {
double r23621 = x;
double r23622 = -0.034013493959747065;
bool r23623 = r23621 <= r23622;
double r23624 = 1.0;
double r23625 = 1.0;
double r23626 = cos(r23621);
double r23627 = -r23626;
double r23628 = fma(r23624, r23625, r23627);
double r23629 = r23621 * r23621;
double r23630 = r23628 / r23629;
double r23631 = 0.029815137429186504;
bool r23632 = r23621 <= r23631;
double r23633 = 0.5;
double r23634 = 0.001388888888888889;
double r23635 = 5.0;
double r23636 = pow(r23621, r23635);
double r23637 = 3.0;
double r23638 = pow(r23621, r23637);
double r23639 = -0.041666666666666664;
double r23640 = r23638 * r23639;
double r23641 = fma(r23634, r23636, r23640);
double r23642 = fma(r23633, r23621, r23641);
double r23643 = r23642 / r23621;
double r23644 = exp(1.0);
double r23645 = r23625 - r23626;
double r23646 = exp(r23645);
double r23647 = log(r23646);
double r23648 = log(r23647);
double r23649 = pow(r23644, r23648);
double r23650 = r23649 / r23621;
double r23651 = r23650 / r23621;
double r23652 = r23632 ? r23643 : r23651;
double r23653 = r23623 ? r23630 : r23652;
return r23653;
}



Bits error versus x
if x < -0.034013493959747065Initial program 1.1
rmApplied *-un-lft-identity1.1
Applied fma-neg1.1
if -0.034013493959747065 < x < 0.029815137429186504Initial program 62.3
rmApplied associate-/r*61.4
Taylor expanded around 0 0.0
Simplified0.0
if 0.029815137429186504 < x Initial program 0.9
rmApplied associate-/r*0.5
rmApplied add-exp-log0.5
rmApplied pow10.5
Applied log-pow0.5
Applied exp-prod0.5
Simplified0.5
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.7
Simplified0.6
Final simplification0.4
herbie shell --seed 2019198 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1.0 (cos x)) (* x x)))