\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03161448669661249405438141479862679261714:\\
\;\;\;\;\frac{\frac{\log \left(e^{1 \cdot \left(1 \cdot 1\right) - \left(\frac{1}{2} + \frac{1}{2} \cdot \cos \left(x + x\right)\right) \cdot \cos x}\right)}{x \cdot \mathsf{fma}\left(1 + \cos x, \cos x, 1 \cdot 1\right)}}{x}\\
\mathbf{elif}\;x \le 0.0364141473996223707931818580618710257113:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \frac{1}{720} \cdot \left(x \cdot x\right), \mathsf{fma}\left(\frac{-1}{24}, x \cdot x, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{1}^{3} - \mathsf{expm1}\left(\mathsf{log1p}\left(\cos x \cdot \left(\cos x \cdot \cos x\right)\right)\right)}{x \cdot \mathsf{fma}\left(1 + \cos x, \cos x, 1 \cdot 1\right)}}{x}\\
\end{array}double f(double x) {
double r808018 = 1.0;
double r808019 = x;
double r808020 = cos(r808019);
double r808021 = r808018 - r808020;
double r808022 = r808019 * r808019;
double r808023 = r808021 / r808022;
return r808023;
}
double f(double x) {
double r808024 = x;
double r808025 = -0.031614486696612494;
bool r808026 = r808024 <= r808025;
double r808027 = 1.0;
double r808028 = r808027 * r808027;
double r808029 = r808027 * r808028;
double r808030 = 0.5;
double r808031 = r808024 + r808024;
double r808032 = cos(r808031);
double r808033 = r808030 * r808032;
double r808034 = r808030 + r808033;
double r808035 = cos(r808024);
double r808036 = r808034 * r808035;
double r808037 = r808029 - r808036;
double r808038 = exp(r808037);
double r808039 = log(r808038);
double r808040 = r808027 + r808035;
double r808041 = fma(r808040, r808035, r808028);
double r808042 = r808024 * r808041;
double r808043 = r808039 / r808042;
double r808044 = r808043 / r808024;
double r808045 = 0.03641414739962237;
bool r808046 = r808024 <= r808045;
double r808047 = r808024 * r808024;
double r808048 = 0.001388888888888889;
double r808049 = r808048 * r808047;
double r808050 = -0.041666666666666664;
double r808051 = fma(r808050, r808047, r808030);
double r808052 = fma(r808047, r808049, r808051);
double r808053 = 3.0;
double r808054 = pow(r808027, r808053);
double r808055 = r808035 * r808035;
double r808056 = r808035 * r808055;
double r808057 = log1p(r808056);
double r808058 = expm1(r808057);
double r808059 = r808054 - r808058;
double r808060 = r808059 / r808042;
double r808061 = r808060 / r808024;
double r808062 = r808046 ? r808052 : r808061;
double r808063 = r808026 ? r808044 : r808062;
return r808063;
}



Bits error versus x
if x < -0.031614486696612494Initial program 1.1
rmApplied associate-/r*0.4
rmApplied flip3--0.5
Applied associate-/l/0.5
Simplified0.5
rmApplied add-log-exp0.5
Applied add-log-exp0.5
Applied diff-log0.5
Simplified0.5
rmApplied sqr-cos0.6
Simplified0.6
if -0.031614486696612494 < x < 0.03641414739962237Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.03641414739962237 < x Initial program 1.1
rmApplied associate-/r*0.5
rmApplied flip3--0.5
Applied associate-/l/0.5
Simplified0.5
rmApplied expm1-log1p-u0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2019170 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1.0 (cos x)) (* x x)))