(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x) :precision binary64 (fma 0.5 (* x x) (fma (pow x 4.0) -0.041666666666666664 (* 0.001388888888888889 (pow x 6.0)))))
double code(double x) {
return 1.0 - cos(x);
}
double code(double x) {
return fma(0.5, (x * x), fma(pow(x, 4.0), -0.041666666666666664, (0.001388888888888889 * pow(x, 6.0))));
}
function code(x) return Float64(1.0 - cos(x)) end
function code(x) return fma(0.5, Float64(x * x), fma((x ^ 4.0), -0.041666666666666664, Float64(0.001388888888888889 * (x ^ 6.0)))) end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(0.5 * N[(x * x), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * -0.041666666666666664 + N[(0.001388888888888889 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \cos x
\mathsf{fma}\left(0.5, x \cdot x, \mathsf{fma}\left({x}^{4}, -0.041666666666666664, 0.001388888888888889 \cdot {x}^{6}\right)\right)




Bits error versus x
| Original | 30.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 30.5
Taylor expanded in x around 0 0.0
Simplified0.0
Final simplification0.0
herbie shell --seed 2022134
(FPCore (x)
:name "ENA, Section 1.4, Mentioned, A"
:precision binary64
:pre (and (<= -0.01 x) (<= x 0.01))
:herbie-target
(/ (* (sin x) (sin x)) (+ 1.0 (cos x)))
(- 1.0 (cos x)))