\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)}{\mathsf{fma}\left(\cos x, \sqrt{1 + \cos x} \cdot \sqrt{1 + \cos x}, 1 \cdot 1\right)}}{x}\\
\mathbf{elif}\;x \le 0.03141600742422194503244980978706735186279:\\
\;\;\;\;\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{\frac{{1}^{3} - \sqrt[3]{{\left({\left(\cos x\right)}^{3}\right)}^{3}}}{\mathsf{fma}\left(\cos x, 1 + \cos x, 1 \cdot 1\right)}}{x}\\
\end{array}double f(double x) {
double r35196 = 1.0;
double r35197 = x;
double r35198 = cos(r35197);
double r35199 = r35196 - r35198;
double r35200 = r35197 * r35197;
double r35201 = r35199 / r35200;
return r35201;
}
double f(double x) {
double r35202 = x;
double r35203 = -0.030204237643336285;
bool r35204 = r35202 <= r35203;
double r35205 = 1.0;
double r35206 = r35205 / r35202;
double r35207 = 1.0;
double r35208 = 3.0;
double r35209 = pow(r35207, r35208);
double r35210 = cos(r35202);
double r35211 = pow(r35210, r35208);
double r35212 = exp(r35211);
double r35213 = log(r35212);
double r35214 = r35209 - r35213;
double r35215 = r35207 + r35210;
double r35216 = sqrt(r35215);
double r35217 = r35216 * r35216;
double r35218 = r35207 * r35207;
double r35219 = fma(r35210, r35217, r35218);
double r35220 = r35214 / r35219;
double r35221 = r35220 / r35202;
double r35222 = r35206 * r35221;
double r35223 = 0.031416007424221945;
bool r35224 = r35202 <= r35223;
double r35225 = 4.0;
double r35226 = pow(r35202, r35225);
double r35227 = 0.001388888888888889;
double r35228 = 0.5;
double r35229 = 0.041666666666666664;
double r35230 = 2.0;
double r35231 = pow(r35202, r35230);
double r35232 = r35229 * r35231;
double r35233 = r35228 - r35232;
double r35234 = fma(r35226, r35227, r35233);
double r35235 = pow(r35211, r35208);
double r35236 = cbrt(r35235);
double r35237 = r35209 - r35236;
double r35238 = fma(r35210, r35215, r35218);
double r35239 = r35237 / r35238;
double r35240 = r35239 / r35202;
double r35241 = r35206 * r35240;
double r35242 = r35224 ? r35234 : r35241;
double r35243 = r35204 ? r35222 : r35242;
return r35243;
}



Bits error versus x
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
rmApplied add-sqr-sqrt0.5
if -0.030204237643336285 < x < 0.031416007424221945Initial program 62.2
Taylor expanded around 0 0.0
Simplified0.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 add-cbrt-cube0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2019347 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))