| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 6976 |
\[\mathsf{fma}\left(-0.041666666666666664, x \cdot x, 0.5\right) \cdot \left(x \cdot x\right)
\]
(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x) :precision binary64 (fma (* x 0.5) x (* (pow x 4.0) -0.041666666666666664)))
double code(double x) {
return 1.0 - cos(x);
}
double code(double x) {
return fma((x * 0.5), x, (pow(x, 4.0) * -0.041666666666666664));
}
function code(x) return Float64(1.0 - cos(x)) end
function code(x) return fma(Float64(x * 0.5), x, Float64((x ^ 4.0) * -0.041666666666666664)) end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * 0.5), $MachinePrecision] * x + N[(N[Power[x, 4.0], $MachinePrecision] * -0.041666666666666664), $MachinePrecision]), $MachinePrecision]
1 - \cos x
\mathsf{fma}\left(x \cdot 0.5, x, {x}^{4} \cdot -0.041666666666666664\right)
| Original | 29.9 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 29.9
Taylor expanded in x around 0 0.0
Simplified0.0
Applied egg-rr0.0
Simplified0.0
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 6976 |
| Alternative 2 | |
|---|---|
| Error | 0.3 |
| Cost | 320 |
herbie shell --seed 2023033
(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)))