\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.033994064032605062:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\log \left(e^{1 - \cos x}\right)}{x}\\
\mathbf{elif}\;x \le 0.032573444318334172:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{1}{\frac{x}{1 - \cos x}}\\
\end{array}double f(double x) {
double r31546 = 1.0;
double r31547 = x;
double r31548 = cos(r31547);
double r31549 = r31546 - r31548;
double r31550 = r31547 * r31547;
double r31551 = r31549 / r31550;
return r31551;
}
double f(double x) {
double r31552 = x;
double r31553 = -0.03399406403260506;
bool r31554 = r31552 <= r31553;
double r31555 = 1.0;
double r31556 = r31555 / r31552;
double r31557 = 1.0;
double r31558 = cos(r31552);
double r31559 = r31557 - r31558;
double r31560 = exp(r31559);
double r31561 = log(r31560);
double r31562 = r31561 / r31552;
double r31563 = r31556 * r31562;
double r31564 = 0.03257344431833417;
bool r31565 = r31552 <= r31564;
double r31566 = 4.0;
double r31567 = pow(r31552, r31566);
double r31568 = 0.001388888888888889;
double r31569 = 0.5;
double r31570 = 0.041666666666666664;
double r31571 = 2.0;
double r31572 = pow(r31552, r31571);
double r31573 = r31570 * r31572;
double r31574 = r31569 - r31573;
double r31575 = fma(r31567, r31568, r31574);
double r31576 = r31552 / r31559;
double r31577 = r31555 / r31576;
double r31578 = r31556 * r31577;
double r31579 = r31565 ? r31575 : r31578;
double r31580 = r31554 ? r31563 : r31579;
return r31580;
}



Bits error versus x
if x < -0.03399406403260506Initial program 1.2
rmApplied *-un-lft-identity1.2
Applied times-frac0.4
rmApplied add-log-exp0.5
Applied add-log-exp0.5
Applied diff-log0.6
Simplified0.5
if -0.03399406403260506 < x < 0.03257344431833417Initial program 62.1
Taylor expanded around 0 0.0
Simplified0.0
if 0.03257344431833417 < x Initial program 0.9
rmApplied *-un-lft-identity0.9
Applied times-frac0.4
rmApplied clear-num0.5
Final simplification0.3
herbie shell --seed 2020021 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))