\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03020423764333628538492071413656958611682:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\frac{{1}^{3} - \log \left(e^{{\left(\cos x\right)}^{3}}\right)}{\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1}}{x}\\
\mathbf{elif}\;x \le 0.03141600742422194503244980978706735186279:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\frac{{\left({1}^{3}\right)}^{3} - {\left({\left(\cos x\right)}^{3}\right)}^{3}}{\left({1}^{6} + {\left(\cos x\right)}^{3} \cdot \left({1}^{3} + {\left(\cos x\right)}^{3}\right)\right) \cdot \left(\cos x \cdot \left(1 + \cos x\right) + 1 \cdot 1\right)}}{x}\\
\end{array}double f(double x) {
double r20661 = 1.0;
double r20662 = x;
double r20663 = cos(r20662);
double r20664 = r20661 - r20663;
double r20665 = r20662 * r20662;
double r20666 = r20664 / r20665;
return r20666;
}
double f(double x) {
double r20667 = x;
double r20668 = -0.030204237643336285;
bool r20669 = r20667 <= r20668;
double r20670 = 1.0;
double r20671 = r20670 / r20667;
double r20672 = 1.0;
double r20673 = 3.0;
double r20674 = pow(r20672, r20673);
double r20675 = cos(r20667);
double r20676 = pow(r20675, r20673);
double r20677 = exp(r20676);
double r20678 = log(r20677);
double r20679 = r20674 - r20678;
double r20680 = r20672 + r20675;
double r20681 = r20675 * r20680;
double r20682 = r20672 * r20672;
double r20683 = r20681 + r20682;
double r20684 = r20679 / r20683;
double r20685 = r20684 / r20667;
double r20686 = r20671 * r20685;
double r20687 = 0.031416007424221945;
bool r20688 = r20667 <= r20687;
double r20689 = 0.001388888888888889;
double r20690 = 4.0;
double r20691 = pow(r20667, r20690);
double r20692 = r20689 * r20691;
double r20693 = 0.5;
double r20694 = r20692 + r20693;
double r20695 = 0.041666666666666664;
double r20696 = 2.0;
double r20697 = pow(r20667, r20696);
double r20698 = r20695 * r20697;
double r20699 = r20694 - r20698;
double r20700 = pow(r20674, r20673);
double r20701 = pow(r20676, r20673);
double r20702 = r20700 - r20701;
double r20703 = 6.0;
double r20704 = pow(r20672, r20703);
double r20705 = r20674 + r20676;
double r20706 = r20676 * r20705;
double r20707 = r20704 + r20706;
double r20708 = r20707 * r20683;
double r20709 = r20702 / r20708;
double r20710 = r20709 / r20667;
double r20711 = r20671 * r20710;
double r20712 = r20688 ? r20699 : r20711;
double r20713 = r20669 ? r20686 : r20712;
return r20713;
}



Bits error versus x
Results
if x < -0.030204237643336285Initial program 1.1
rmApplied *-un-lft-identity1.1
Applied times-frac0.5
rmApplied flip3--0.5
Simplified0.5
rmApplied add-log-exp0.5
if -0.030204237643336285 < x < 0.031416007424221945Initial program 62.2
Taylor expanded around 0 0.0
if 0.031416007424221945 < x Initial program 1.2
rmApplied *-un-lft-identity1.2
Applied times-frac0.5
rmApplied flip3--0.5
Simplified0.5
rmApplied flip3--0.5
Applied associate-/l/0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2019347
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))