\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02623489072028305918449220257571141701192:\\
\;\;\;\;\frac{1}{x} \cdot \left(\sqrt{1 - \cos x} \cdot \frac{\sqrt{1 - \cos x}}{x}\right)\\
\mathbf{elif}\;x \le 0.03474417225563055516834864988595654722303:\\
\;\;\;\;\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{1}{x} \cdot \frac{\log \left(e^{1 - \cos x}\right)}{x}\\
\end{array}double f(double x) {
double r33573 = 1.0;
double r33574 = x;
double r33575 = cos(r33574);
double r33576 = r33573 - r33575;
double r33577 = r33574 * r33574;
double r33578 = r33576 / r33577;
return r33578;
}
double f(double x) {
double r33579 = x;
double r33580 = -0.02623489072028306;
bool r33581 = r33579 <= r33580;
double r33582 = 1.0;
double r33583 = r33582 / r33579;
double r33584 = 1.0;
double r33585 = cos(r33579);
double r33586 = r33584 - r33585;
double r33587 = sqrt(r33586);
double r33588 = r33587 / r33579;
double r33589 = r33587 * r33588;
double r33590 = r33583 * r33589;
double r33591 = 0.034744172255630555;
bool r33592 = r33579 <= r33591;
double r33593 = r33579 * r33579;
double r33594 = -0.041666666666666664;
double r33595 = 0.001388888888888889;
double r33596 = 4.0;
double r33597 = pow(r33579, r33596);
double r33598 = 0.5;
double r33599 = fma(r33595, r33597, r33598);
double r33600 = fma(r33593, r33594, r33599);
double r33601 = exp(r33586);
double r33602 = log(r33601);
double r33603 = r33602 / r33579;
double r33604 = r33583 * r33603;
double r33605 = r33592 ? r33600 : r33604;
double r33606 = r33581 ? r33590 : r33605;
return r33606;
}



Bits error versus x
if x < -0.02623489072028306Initial program 1.0
rmApplied *-un-lft-identity1.0
Applied times-frac0.6
rmApplied *-un-lft-identity0.6
Applied add-sqr-sqrt0.7
Applied times-frac0.7
Simplified0.7
if -0.02623489072028306 < x < 0.034744172255630555Initial program 62.4
Taylor expanded around 0 0.0
Simplified0.0
if 0.034744172255630555 < x Initial program 1.0
rmApplied *-un-lft-identity1.0
Applied times-frac0.5
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.7
Simplified0.6
Final simplification0.3
herbie shell --seed 2019350 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))