\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02740531929745840256096300890931161120534:\\
\;\;\;\;\frac{\frac{\sqrt{\log \left(e^{1 - \cos x}\right)}}{x}}{x} \cdot \sqrt{1 - \cos x}\\
\mathbf{elif}\;x \le 0.03110675776409119533405522872726578498259:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \frac{1}{720} - \frac{1}{24}\right) + \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \cos x} \cdot \frac{\frac{\sqrt{1 - \cos x}}{x}}{x}\\
\end{array}double f(double x) {
double r877244 = 1.0;
double r877245 = x;
double r877246 = cos(r877245);
double r877247 = r877244 - r877246;
double r877248 = r877245 * r877245;
double r877249 = r877247 / r877248;
return r877249;
}
double f(double x) {
double r877250 = x;
double r877251 = -0.027405319297458403;
bool r877252 = r877250 <= r877251;
double r877253 = 1.0;
double r877254 = cos(r877250);
double r877255 = r877253 - r877254;
double r877256 = exp(r877255);
double r877257 = log(r877256);
double r877258 = sqrt(r877257);
double r877259 = r877258 / r877250;
double r877260 = r877259 / r877250;
double r877261 = sqrt(r877255);
double r877262 = r877260 * r877261;
double r877263 = 0.031106757764091195;
bool r877264 = r877250 <= r877263;
double r877265 = r877250 * r877250;
double r877266 = 0.001388888888888889;
double r877267 = r877265 * r877266;
double r877268 = 0.041666666666666664;
double r877269 = r877267 - r877268;
double r877270 = r877265 * r877269;
double r877271 = 0.5;
double r877272 = r877270 + r877271;
double r877273 = r877261 / r877250;
double r877274 = r877273 / r877250;
double r877275 = r877261 * r877274;
double r877276 = r877264 ? r877272 : r877275;
double r877277 = r877252 ? r877262 : r877276;
return r877277;
}



Bits error versus x
Results
if x < -0.027405319297458403Initial program 1.2
rmApplied associate-/r*0.5
rmApplied *-un-lft-identity0.5
Applied *-un-lft-identity0.5
Applied add-sqr-sqrt0.6
Applied times-frac0.6
Applied times-frac0.6
Simplified0.6
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.6
Simplified0.6
if -0.027405319297458403 < x < 0.031106757764091195Initial program 62.4
Taylor expanded around 0 0.0
Simplified0.0
if 0.031106757764091195 < x Initial program 1.0
rmApplied associate-/r*0.5
rmApplied *-un-lft-identity0.5
Applied *-un-lft-identity0.5
Applied add-sqr-sqrt0.6
Applied times-frac0.6
Applied times-frac0.6
Simplified0.6
Final simplification0.3
herbie shell --seed 2019168
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1.0 (cos x)) (* x x)))