\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \le -0.0289755674093477682:\\
\;\;\;\;\frac{\log \left(e^{1 - \cos x}\right)}{x \cdot x}\\
\mathbf{elif}\;x \le 0.0323653638594900775:\\
\;\;\;\;\frac{1}{720} \cdot {x}^{4} + \left(\frac{1}{2} - \frac{1}{24} \cdot {x}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{1 - \cos x}}{x} \cdot \frac{\sqrt{\log \left(e^{1 - \cos x}\right)}}{x}\\
\end{array}double code(double x) {
return ((1.0 - cos(x)) / (x * x));
}
double code(double x) {
double temp;
if ((x <= -0.028975567409347768)) {
temp = (log(exp((1.0 - cos(x)))) / (x * x));
} else {
double temp_1;
if ((x <= 0.03236536385949008)) {
temp_1 = ((0.001388888888888889 * pow(x, 4.0)) + (0.5 - (0.041666666666666664 * pow(x, 2.0))));
} else {
temp_1 = ((sqrt((1.0 - cos(x))) / x) * (sqrt(log(exp((1.0 - cos(x))))) / x));
}
temp = temp_1;
}
return temp;
}



Bits error versus x
Results
if x < -0.028975567409347768Initial program 1.0
rmApplied add-log-exp1.1
Applied add-log-exp1.1
Applied diff-log1.3
Simplified1.2
if -0.028975567409347768 < x < 0.03236536385949008Initial program 62.4
Taylor expanded around 0 0.0
rmApplied associate--l+0.0
if 0.03236536385949008 < x Initial program 1.1
rmApplied add-sqr-sqrt1.2
Applied times-frac0.6
rmApplied add-log-exp0.6
Applied add-log-exp0.6
Applied diff-log0.6
Simplified0.6
Final simplification0.5
herbie shell --seed 2020060
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1 (cos x)) (* x x)))