\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.029466469328828359:\\
\;\;\;\;\frac{\frac{{1}^{3} - \mathsf{expm1}\left(\mathsf{log1p}\left({\left(\cos x\right)}^{3}\right)\right)}{\mathsf{fma}\left(\cos x, 1 + \cos x, 1 \cdot 1\right)}}{x \cdot x}\\
\mathbf{elif}\;x \le 0.03308393611677984:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot 1 - \cos x \cdot \cos x}{\left(x \cdot x\right) \cdot \left(1 + \cos x\right)}\\
\end{array}double f(double x) {
double r33113 = 1.0;
double r33114 = x;
double r33115 = cos(r33114);
double r33116 = r33113 - r33115;
double r33117 = r33114 * r33114;
double r33118 = r33116 / r33117;
return r33118;
}
double f(double x) {
double r33119 = x;
double r33120 = -0.02946646932882836;
bool r33121 = r33119 <= r33120;
double r33122 = 1.0;
double r33123 = 3.0;
double r33124 = pow(r33122, r33123);
double r33125 = cos(r33119);
double r33126 = pow(r33125, r33123);
double r33127 = log1p(r33126);
double r33128 = expm1(r33127);
double r33129 = r33124 - r33128;
double r33130 = r33122 + r33125;
double r33131 = r33122 * r33122;
double r33132 = fma(r33125, r33130, r33131);
double r33133 = r33129 / r33132;
double r33134 = r33119 * r33119;
double r33135 = r33133 / r33134;
double r33136 = 0.033083936116779844;
bool r33137 = r33119 <= r33136;
double r33138 = 4.0;
double r33139 = pow(r33119, r33138);
double r33140 = 0.001388888888888889;
double r33141 = 0.5;
double r33142 = 0.041666666666666664;
double r33143 = 2.0;
double r33144 = pow(r33119, r33143);
double r33145 = r33142 * r33144;
double r33146 = r33141 - r33145;
double r33147 = fma(r33139, r33140, r33146);
double r33148 = r33125 * r33125;
double r33149 = r33131 - r33148;
double r33150 = r33134 * r33130;
double r33151 = r33149 / r33150;
double r33152 = r33137 ? r33147 : r33151;
double r33153 = r33121 ? r33135 : r33152;
return r33153;
}



Bits error versus x
if x < -0.02946646932882836Initial program 1.0
rmApplied flip3--1.0
Simplified1.0
rmApplied expm1-log1p-u1.0
if -0.02946646932882836 < x < 0.033083936116779844Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.033083936116779844 < x Initial program 1.2
rmApplied flip--1.4
Applied associate-/l/1.4
Final simplification0.6
herbie shell --seed 2020089 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))