\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.02826034963706557101570382428690209053457:\\
\;\;\;\;\sqrt{\frac{\frac{\log \left(e^{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - \cos x\right)\right)}\right)}{x}}{x}} \cdot \sqrt{\frac{\frac{1 - \cos x}{x}}{x}}\\
\mathbf{elif}\;x \le 0.02946672320662404448432525327916664537042:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \frac{-1}{24}, \mathsf{fma}\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right), \frac{1}{720}, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{x} \cdot \left(1 - \cos x\right)\\
\end{array}double f(double x) {
double r718801 = 1.0;
double r718802 = x;
double r718803 = cos(r718802);
double r718804 = r718801 - r718803;
double r718805 = r718802 * r718802;
double r718806 = r718804 / r718805;
return r718806;
}
double f(double x) {
double r718807 = x;
double r718808 = -0.02826034963706557;
bool r718809 = r718807 <= r718808;
double r718810 = 1.0;
double r718811 = cos(r718807);
double r718812 = r718810 - r718811;
double r718813 = log1p(r718812);
double r718814 = expm1(r718813);
double r718815 = exp(r718814);
double r718816 = log(r718815);
double r718817 = r718816 / r718807;
double r718818 = r718817 / r718807;
double r718819 = sqrt(r718818);
double r718820 = r718812 / r718807;
double r718821 = r718820 / r718807;
double r718822 = sqrt(r718821);
double r718823 = r718819 * r718822;
double r718824 = 0.029466723206624044;
bool r718825 = r718807 <= r718824;
double r718826 = r718807 * r718807;
double r718827 = -0.041666666666666664;
double r718828 = r718826 * r718826;
double r718829 = 0.001388888888888889;
double r718830 = 0.5;
double r718831 = fma(r718828, r718829, r718830);
double r718832 = fma(r718826, r718827, r718831);
double r718833 = 1.0;
double r718834 = r718833 / r718807;
double r718835 = r718834 / r718807;
double r718836 = r718835 * r718812;
double r718837 = r718825 ? r718832 : r718836;
double r718838 = r718809 ? r718823 : r718837;
return r718838;
}



Bits error versus x
if x < -0.02826034963706557Initial program 1.0
rmApplied associate-/r*0.4
rmApplied add-sqr-sqrt0.5
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.6
Simplified0.6
rmApplied expm1-log1p-u0.6
if -0.02826034963706557 < x < 0.029466723206624044Initial program 62.3
rmApplied associate-/r*61.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.029466723206624044 < x Initial program 1.0
rmApplied associate-/r*0.5
rmApplied *-un-lft-identity0.5
Applied div-inv0.5
Applied times-frac0.5
Simplified0.5
Final simplification0.3
herbie shell --seed 2019200 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1.0 (cos x)) (* x x)))