\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.031288658239448007:\\
\;\;\;\;\frac{1}{x} \cdot \frac{1}{\frac{x}{1 - \cos x}}\\
\mathbf{elif}\;x \le 0.0300611177250478985:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \left(\frac{1}{\frac{x}{{1}^{3} - {\left(\cos x\right)}^{3}}} \cdot \frac{1}{\frac{\mathsf{fma}\left(\cos x, 1 + \cos x, 1 \cdot 1\right)}{1}}\right)\\
\end{array}double f(double x) {
double r40816 = 1.0;
double r40817 = x;
double r40818 = cos(r40817);
double r40819 = r40816 - r40818;
double r40820 = r40817 * r40817;
double r40821 = r40819 / r40820;
return r40821;
}
double f(double x) {
double r40822 = x;
double r40823 = -0.03128865823944801;
bool r40824 = r40822 <= r40823;
double r40825 = 1.0;
double r40826 = r40825 / r40822;
double r40827 = 1.0;
double r40828 = cos(r40822);
double r40829 = r40827 - r40828;
double r40830 = r40822 / r40829;
double r40831 = r40825 / r40830;
double r40832 = r40826 * r40831;
double r40833 = 0.0300611177250479;
bool r40834 = r40822 <= r40833;
double r40835 = 4.0;
double r40836 = pow(r40822, r40835);
double r40837 = 0.001388888888888889;
double r40838 = 0.5;
double r40839 = 0.041666666666666664;
double r40840 = 2.0;
double r40841 = pow(r40822, r40840);
double r40842 = r40839 * r40841;
double r40843 = r40838 - r40842;
double r40844 = fma(r40836, r40837, r40843);
double r40845 = 3.0;
double r40846 = pow(r40827, r40845);
double r40847 = pow(r40828, r40845);
double r40848 = r40846 - r40847;
double r40849 = r40822 / r40848;
double r40850 = r40825 / r40849;
double r40851 = r40827 + r40828;
double r40852 = r40827 * r40827;
double r40853 = fma(r40828, r40851, r40852);
double r40854 = r40853 / r40825;
double r40855 = r40825 / r40854;
double r40856 = r40850 * r40855;
double r40857 = r40826 * r40856;
double r40858 = r40834 ? r40844 : r40857;
double r40859 = r40824 ? r40832 : r40858;
return r40859;
}



Bits error versus x
if x < -0.03128865823944801Initial program 0.8
rmApplied *-un-lft-identity0.8
Applied times-frac0.5
rmApplied clear-num0.5
if -0.03128865823944801 < x < 0.0300611177250479Initial program 62.3
Taylor expanded around 0 0.0
Simplified0.0
if 0.0300611177250479 < x Initial program 1.1
rmApplied *-un-lft-identity1.1
Applied times-frac0.6
rmApplied clear-num0.6
rmApplied flip3--0.6
Applied associate-/r/0.6
Applied add-sqr-sqrt0.6
Applied times-frac0.6
Simplified0.6
Simplified0.6
Final simplification0.3
herbie shell --seed 2020056 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))