\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.029536016732455837:\\
\;\;\;\;\frac{\log \left(e^{1 - \cos x}\right)}{x \cdot x}\\
\mathbf{elif}\;x \le 0.03411142251183559:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, \frac{1}{720}, \frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{{e}^{\left(\log \left(1 - \cos x\right)\right)}}{x}\\
\end{array}double code(double x) {
return ((double) (((double) (1.0 - ((double) cos(x)))) / ((double) (x * x))));
}
double code(double x) {
double VAR;
if ((x <= -0.029536016732455837)) {
VAR = ((double) (((double) log(((double) exp(((double) (1.0 - ((double) cos(x)))))))) / ((double) (x * x))));
} else {
double VAR_1;
if ((x <= 0.03411142251183559)) {
VAR_1 = ((double) fma(((double) pow(x, 4.0)), 0.001388888888888889, ((double) (0.5 - ((double) (0.041666666666666664 * ((double) pow(x, 2.0))))))));
} else {
VAR_1 = ((double) (((double) (1.0 / x)) * ((double) (((double) pow(((double) M_E), ((double) log(((double) (1.0 - ((double) cos(x)))))))) / x))));
}
VAR = VAR_1;
}
return VAR;
}



Bits error versus x
Results
if x < -0.029536016732455837Initial program 1.0
rmApplied add-log-exp1.0
Applied add-log-exp1.0
Applied diff-log1.1
Simplified1.1
if -0.029536016732455837 < x < 0.03411142251183559Initial program 62.2
Taylor expanded around 0 0.0
Simplified0.0
if 0.03411142251183559 < x Initial program 1.0
rmApplied *-un-lft-identity1.0
Applied times-frac0.5
rmApplied add-exp-log0.5
rmApplied pow10.5
Applied log-pow0.5
Applied exp-prod0.5
Simplified0.5
Final simplification0.4
herbie shell --seed 2020114 +o rules:numerics
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))