\frac{1 - \cos x}{x \cdot x}
\begin{array}{l}
t_0 := 1 - \cos x\\
\mathbf{if}\;x \leq -0.10095045016015487:\\
\;\;\;\;\frac{{\left({t_0}^{3}\right)}^{0.3333333333333333}}{x \cdot x}\\
\mathbf{elif}\;x \leq 0.10469358202942775:\\
\;\;\;\;\mathsf{fma}\left(0.001388888888888889, {x}^{4}, 0.5\right) - \mathsf{fma}\left(0.041666666666666664, x \cdot x, 2.48015873015873 \cdot 10^{-5} \cdot {x}^{6}\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{e^{\log t_0 \cdot 0.5}}{x}\right)}^{2}\\
\end{array}
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (* x x)))
(FPCore (x)
:precision binary64
(let* ((t_0 (- 1.0 (cos x))))
(if (<= x -0.10095045016015487)
(/ (pow (pow t_0 3.0) 0.3333333333333333) (* x x))
(if (<= x 0.10469358202942775)
(-
(fma 0.001388888888888889 (pow x 4.0) 0.5)
(fma 0.041666666666666664 (* x x) (* 2.48015873015873e-5 (pow x 6.0))))
(pow (/ (exp (* (log t_0) 0.5)) x) 2.0)))))double code(double x) {
return (1.0 - cos(x)) / (x * x);
}
double code(double x) {
double t_0 = 1.0 - cos(x);
double tmp;
if (x <= -0.10095045016015487) {
tmp = pow(pow(t_0, 3.0), 0.3333333333333333) / (x * x);
} else if (x <= 0.10469358202942775) {
tmp = fma(0.001388888888888889, pow(x, 4.0), 0.5) - fma(0.041666666666666664, (x * x), (2.48015873015873e-5 * pow(x, 6.0)));
} else {
tmp = pow((exp((log(t_0) * 0.5)) / x), 2.0);
}
return tmp;
}



Bits error versus x
if x < -0.100950450160154873Initial program 1.0
Applied egg-rr1.0
if -0.100950450160154873 < x < 0.10469358202942775Initial program 62.1
Taylor expanded in x around 0 0.0
Simplified0.0
if 0.10469358202942775 < x Initial program 1.0
Applied egg-rr0.5
Applied egg-rr0.6
Final simplification0.4
herbie shell --seed 2022127
(FPCore (x)
:name "cos2 (problem 3.4.1)"
:precision binary64
(/ (- 1.0 (cos x)) (* x x)))