\frac{1 - \cos x}{x \cdot x}\begin{array}{l}
\mathbf{if}\;x \leq -0.010529840751750804:\\
\;\;\;\;\frac{\frac{\sin x \cdot \tan \left(\frac{x}{2}\right)}{x}}{x}\\
\mathbf{elif}\;x \leq 5.530578574506921 \cdot 10^{-70}:\\
\;\;\;\;{x}^{4} \cdot 0.001388888888888889 + \left(0.5 - \left(x \cdot x\right) \cdot 0.041666666666666664\right)\\
\mathbf{else}:\\
\;\;\;\;\sin x \cdot \frac{\tan \left(\frac{x}{2}\right)}{x \cdot x}\\
\end{array}(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x)
:precision binary64
(if (<= x -0.010529840751750804)
(/ (/ (* (sin x) (tan (/ x 2.0))) x) x)
(if (<= x 5.530578574506921e-70)
(+
(* (pow x 4.0) 0.001388888888888889)
(- 0.5 (* (* x x) 0.041666666666666664)))
(* (sin x) (/ (tan (/ x 2.0)) (* x x))))))double code(double x) {
return (1.0 - cos(x)) / (x * x);
}
double code(double x) {
double tmp;
if (x <= -0.010529840751750804) {
tmp = ((sin(x) * tan(x / 2.0)) / x) / x;
} else if (x <= 5.530578574506921e-70) {
tmp = (pow(x, 4.0) * 0.001388888888888889) + (0.5 - ((x * x) * 0.041666666666666664));
} else {
tmp = sin(x) * (tan(x / 2.0) / (x * x));
}
return tmp;
}



Bits error versus x
Results
if x < -0.0105298407517508043Initial program 0.9
rmApplied flip--_binary64_521.2
Simplified1.0
rmApplied associate-/r*_binary64_230.6
Simplified0.2
rmApplied associate-*l/_binary64_220.2
if -0.0105298407517508043 < x < 5.5305785745069212e-70Initial program 62.7
Taylor expanded around 0 0.0
Simplified0.0
if 5.5305785745069212e-70 < x Initial program 11.2
rmApplied flip--_binary64_5211.4
Simplified1.2
rmApplied associate-/r*_binary64_230.5
Simplified0.2
rmApplied associate-*l/_binary64_220.2
rmApplied *-un-lft-identity_binary64_770.2
Applied *-un-lft-identity_binary64_770.2
Applied times-frac_binary64_830.2
Applied times-frac_binary64_830.2
Simplified0.2
Simplified0.9
Final simplification0.3
herbie shell --seed 2020280
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))