\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03391785124353622477011427349680161569268:\\
\;\;\;\;\left(1 - \cos x\right) \cdot \frac{\frac{1}{x}}{x}\\
\mathbf{elif}\;x \le 0.03384107969428518797316840505118307191879:\\
\;\;\;\;\frac{1}{720} \cdot {x}^{4} + \left(\frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot \frac{\cos x - 1}{x}}{x}\\
\end{array}double f(double x) {
double r20234 = 1.0;
double r20235 = x;
double r20236 = cos(r20235);
double r20237 = r20234 - r20236;
double r20238 = r20235 * r20235;
double r20239 = r20237 / r20238;
return r20239;
}
double f(double x) {
double r20240 = x;
double r20241 = -0.033917851243536225;
bool r20242 = r20240 <= r20241;
double r20243 = 1.0;
double r20244 = cos(r20240);
double r20245 = r20243 - r20244;
double r20246 = 1.0;
double r20247 = r20246 / r20240;
double r20248 = r20247 / r20240;
double r20249 = r20245 * r20248;
double r20250 = 0.03384107969428519;
bool r20251 = r20240 <= r20250;
double r20252 = 0.001388888888888889;
double r20253 = 4.0;
double r20254 = pow(r20240, r20253);
double r20255 = r20252 * r20254;
double r20256 = 0.5;
double r20257 = 0.041666666666666664;
double r20258 = 2.0;
double r20259 = pow(r20240, r20258);
double r20260 = r20257 * r20259;
double r20261 = r20256 - r20260;
double r20262 = r20255 + r20261;
double r20263 = -1.0;
double r20264 = r20244 - r20243;
double r20265 = r20264 / r20240;
double r20266 = r20263 * r20265;
double r20267 = r20266 / r20240;
double r20268 = r20251 ? r20262 : r20267;
double r20269 = r20242 ? r20249 : r20268;
return r20269;
}



Bits error versus x
Results
if x < -0.033917851243536225Initial program 1.3
rmApplied associate-/r*0.5
rmApplied *-un-lft-identity0.5
Applied div-inv0.5
Applied times-frac0.6
Simplified0.6
if -0.033917851243536225 < x < 0.03384107969428519Initial program 62.3
Taylor expanded around 0 0.0
rmApplied associate--l+0.0
if 0.03384107969428519 < x Initial program 1.0
rmApplied associate-/r*0.4
Taylor expanded around -inf 0.4
Final simplification0.3
herbie shell --seed 2019356
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))