\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03428006622296721206399894299465813674033:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1 - \cos x}{x}}{x}\right)\right) + \mathsf{fma}\left(\frac{\frac{-1}{x}}{x}, \cos x, \cos x \cdot \frac{\frac{1}{x}}{x}\right)\\
\mathbf{elif}\;x \le 0.02235098969897789805694188203233352396637:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \frac{-1}{24}, \mathsf{fma}\left(\frac{1}{720}, {x}^{4}, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \cos x}{x \cdot x}\\
\end{array}double f(double x) {
double r53794 = 1.0;
double r53795 = x;
double r53796 = cos(r53795);
double r53797 = r53794 - r53796;
double r53798 = r53795 * r53795;
double r53799 = r53797 / r53798;
return r53799;
}
double f(double x) {
double r53800 = x;
double r53801 = -0.03428006622296721;
bool r53802 = r53800 <= r53801;
double r53803 = 1.0;
double r53804 = cos(r53800);
double r53805 = r53803 - r53804;
double r53806 = r53805 / r53800;
double r53807 = r53806 / r53800;
double r53808 = expm1(r53807);
double r53809 = log1p(r53808);
double r53810 = -1.0;
double r53811 = r53810 / r53800;
double r53812 = r53811 / r53800;
double r53813 = 1.0;
double r53814 = r53813 / r53800;
double r53815 = r53814 / r53800;
double r53816 = r53804 * r53815;
double r53817 = fma(r53812, r53804, r53816);
double r53818 = r53809 + r53817;
double r53819 = 0.022350989698977898;
bool r53820 = r53800 <= r53819;
double r53821 = r53800 * r53800;
double r53822 = -0.041666666666666664;
double r53823 = 0.001388888888888889;
double r53824 = 4.0;
double r53825 = pow(r53800, r53824);
double r53826 = 0.5;
double r53827 = fma(r53823, r53825, r53826);
double r53828 = fma(r53821, r53822, r53827);
double r53829 = r53805 / r53821;
double r53830 = r53820 ? r53828 : r53829;
double r53831 = r53802 ? r53818 : r53830;
return r53831;
}



Bits error versus x
if x < -0.03428006622296721Initial program 1.2
rmApplied div-sub1.3
Simplified1.4
Simplified0.6
rmApplied *-un-lft-identity0.6
Applied div-inv0.6
Applied times-frac0.6
Applied add-sqr-sqrt0.7
Applied prod-diff0.6
Simplified0.6
Simplified0.6
rmApplied log1p-expm1-u0.6
Simplified0.5
if -0.03428006622296721 < x < 0.022350989698977898Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.022350989698977898 < x Initial program 1.0
Final simplification0.4
herbie shell --seed 2019196 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
(/ (- 1.0 (cos x)) (* x x)))