\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.03155884382850993041813580930465832352638:\\
\;\;\;\;\frac{\frac{\sqrt[3]{{\left(1 - \cos x\right)}^{3}}}{x}}{x}\\
\mathbf{elif}\;x \le 0.02733685303105121144895406359864864498377:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{24}, x \cdot x, \mathsf{fma}\left(\frac{1}{720}, {x}^{4}, \frac{1}{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \cos x\right) \cdot \frac{\frac{1}{x}}{x}\\
\end{array}double f(double x) {
double r21931 = 1.0;
double r21932 = x;
double r21933 = cos(r21932);
double r21934 = r21931 - r21933;
double r21935 = r21932 * r21932;
double r21936 = r21934 / r21935;
return r21936;
}
double f(double x) {
double r21937 = x;
double r21938 = -0.03155884382850993;
bool r21939 = r21937 <= r21938;
double r21940 = 1.0;
double r21941 = cos(r21937);
double r21942 = r21940 - r21941;
double r21943 = 3.0;
double r21944 = pow(r21942, r21943);
double r21945 = cbrt(r21944);
double r21946 = r21945 / r21937;
double r21947 = r21946 / r21937;
double r21948 = 0.02733685303105121;
bool r21949 = r21937 <= r21948;
double r21950 = -0.041666666666666664;
double r21951 = r21937 * r21937;
double r21952 = 0.001388888888888889;
double r21953 = 4.0;
double r21954 = pow(r21937, r21953);
double r21955 = 0.5;
double r21956 = fma(r21952, r21954, r21955);
double r21957 = fma(r21950, r21951, r21956);
double r21958 = 1.0;
double r21959 = r21958 / r21937;
double r21960 = r21959 / r21937;
double r21961 = r21942 * r21960;
double r21962 = r21949 ? r21957 : r21961;
double r21963 = r21939 ? r21947 : r21962;
return r21963;
}



Bits error versus x
if x < -0.03155884382850993Initial program 1.0
rmApplied associate-/r*0.5
rmApplied add-cbrt-cube0.6
Simplified0.6
if -0.03155884382850993 < x < 0.02733685303105121Initial program 62.3
rmApplied associate-/r*61.4
Taylor expanded around 0 0.0
Simplified0.0
if 0.02733685303105121 < x Initial program 0.9
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 2019303 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))