\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.030963531967900033:\\
\;\;\;\;\frac{1}{x} \cdot \frac{e^{\log \left(1 - \cos x\right)}}{x}\\
\mathbf{elif}\;x \le 0.029848537881546774:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \cos x}{x}}{x}\\
\end{array}double f(double x) {
double r18548 = 1.0;
double r18549 = x;
double r18550 = cos(r18549);
double r18551 = r18548 - r18550;
double r18552 = r18549 * r18549;
double r18553 = r18551 / r18552;
return r18553;
}
double f(double x) {
double r18554 = x;
double r18555 = -0.030963531967900033;
bool r18556 = r18554 <= r18555;
double r18557 = 1.0;
double r18558 = r18557 / r18554;
double r18559 = 1.0;
double r18560 = cos(r18554);
double r18561 = r18559 - r18560;
double r18562 = log(r18561);
double r18563 = exp(r18562);
double r18564 = r18563 / r18554;
double r18565 = r18558 * r18564;
double r18566 = 0.029848537881546774;
bool r18567 = r18554 <= r18566;
double r18568 = 0.001388888888888889;
double r18569 = 4.0;
double r18570 = pow(r18554, r18569);
double r18571 = r18568 * r18570;
double r18572 = 0.5;
double r18573 = r18571 + r18572;
double r18574 = 0.041666666666666664;
double r18575 = 2.0;
double r18576 = pow(r18554, r18575);
double r18577 = r18574 * r18576;
double r18578 = r18573 - r18577;
double r18579 = r18561 / r18554;
double r18580 = r18579 / r18554;
double r18581 = r18567 ? r18578 : r18580;
double r18582 = r18556 ? r18565 : r18581;
return r18582;
}



Bits error versus x
Results
if x < -0.030963531967900033Initial program 1.1
rmApplied associate-/r*0.5
rmApplied add-sqr-sqrt64.0
Applied add-sqr-sqrt64.0
Applied *-un-lft-identity64.0
Applied times-frac64.0
Applied times-frac64.0
Simplified64.0
Simplified0.5
rmApplied add-exp-log0.5
if -0.030963531967900033 < x < 0.029848537881546774Initial program 62.4
Taylor expanded around 0 0.0
if 0.029848537881546774 < x Initial program 0.8
rmApplied associate-/r*0.5
rmApplied add-sqr-sqrt0.6
Applied add-sqr-sqrt0.7
Applied *-un-lft-identity0.7
Applied times-frac0.7
Applied times-frac0.7
Simplified0.6
Simplified0.5
rmApplied *-un-lft-identity0.5
Applied *-un-lft-identity0.5
Applied times-frac0.5
Applied associate-*l*0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2019199
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1.0 (cos x)) (* x x)))