\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03155884382850993041813580930465832352638:\\
\;\;\;\;\frac{\frac{1 + \cos x}{\frac{x \cdot \frac{\left(1 - \cos x\right) \cdot \left(1 + \cos x\right)}{1 - \cos x}}{1 - \cos x}}}{x}\\
\mathbf{elif}\;x \le 0.03328058389703145159010944098554318770766:\\
\;\;\;\;\left(\frac{1}{720} \cdot {x}^{4} + \frac{1}{2}\right) - \frac{1}{24} \cdot {x}^{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{x} - \frac{\frac{\cos x}{x}}{x}\\
\end{array}double f(double x) {
double r17986 = 1.0;
double r17987 = x;
double r17988 = cos(r17987);
double r17989 = r17986 - r17988;
double r17990 = r17987 * r17987;
double r17991 = r17989 / r17990;
return r17991;
}
double f(double x) {
double r17992 = x;
double r17993 = -0.03155884382850993;
bool r17994 = r17992 <= r17993;
double r17995 = 1.0;
double r17996 = cos(r17992);
double r17997 = r17995 + r17996;
double r17998 = r17995 - r17996;
double r17999 = r17998 * r17997;
double r18000 = r17999 / r17998;
double r18001 = r17992 * r18000;
double r18002 = r18001 / r17998;
double r18003 = r17997 / r18002;
double r18004 = r18003 / r17992;
double r18005 = 0.03328058389703145;
bool r18006 = r17992 <= r18005;
double r18007 = 0.001388888888888889;
double r18008 = 4.0;
double r18009 = pow(r17992, r18008);
double r18010 = r18007 * r18009;
double r18011 = 0.5;
double r18012 = r18010 + r18011;
double r18013 = 0.041666666666666664;
double r18014 = 2.0;
double r18015 = pow(r17992, r18014);
double r18016 = r18013 * r18015;
double r18017 = r18012 - r18016;
double r18018 = r17995 / r17992;
double r18019 = r18018 / r17992;
double r18020 = r17996 / r17992;
double r18021 = r18020 / r17992;
double r18022 = r18019 - r18021;
double r18023 = r18006 ? r18017 : r18022;
double r18024 = r17994 ? r18004 : r18023;
return r18024;
}



Bits error versus x
Results
if x < -0.03155884382850993Initial program 1.0
rmApplied associate-/r*0.5
rmApplied flip--0.6
Applied associate-/l/0.7
rmApplied difference-of-squares0.5
Applied associate-/l*0.5
rmApplied flip-+0.7
Simplified0.5
if -0.03155884382850993 < x < 0.03328058389703145Initial program 62.3
Taylor expanded around 0 0.0
if 0.03328058389703145 < x Initial program 0.9
rmApplied associate-/r*0.5
rmApplied div-sub0.6
Applied div-sub0.6
Final simplification0.3
herbie shell --seed 2019303
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))