| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 7680 |
\[\left(0.001388888888888889 \cdot {x}^{6} + \left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot -0.041666666666666664\right)\right)\right) + \left(x \cdot x\right) \cdot 0.5
\]
(FPCore (x) :precision binary64 (- 1.0 (cos x)))
(FPCore (x) :precision binary64 (fma (* x x) (fma x (* x -0.041666666666666664) 0.5) (* 0.001388888888888889 (pow x 6.0))))
double code(double x) {
return 1.0 - cos(x);
}
double code(double x) {
return fma((x * x), fma(x, (x * -0.041666666666666664), 0.5), (0.001388888888888889 * pow(x, 6.0)));
}
function code(x) return Float64(1.0 - cos(x)) end
function code(x) return fma(Float64(x * x), fma(x, Float64(x * -0.041666666666666664), 0.5), Float64(0.001388888888888889 * (x ^ 6.0))) end
code[x_] := N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * -0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision] + N[(0.001388888888888889 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
1 - \cos x
\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot -0.041666666666666664, 0.5\right), 0.001388888888888889 \cdot {x}^{6}\right)
| Original | 30.8 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 30.8
Applied egg-rr0.0
Simplified0.0
[Start]0.0 | \[ \left(\sin x \cdot \sin x\right) \cdot \frac{1}{1 + \cos x}
\] |
|---|---|
associate-*r/ [=>]0.0 | \[ \color{blue}{\frac{\left(\sin x \cdot \sin x\right) \cdot 1}{1 + \cos x}}
\] |
*-rgt-identity [=>]0.0 | \[ \frac{\color{blue}{\sin x \cdot \sin x}}{1 + \cos x}
\] |
associate-*r/ [<=]0.0 | \[ \color{blue}{\sin x \cdot \frac{\sin x}{1 + \cos x}}
\] |
hang-0p-tan [=>]0.0 | \[ \sin x \cdot \color{blue}{\tan \left(\frac{x}{2}\right)}
\] |
Taylor expanded in x around 0 0.0
Simplified0.0
[Start]0.0 | \[ 0.5 \cdot {x}^{2} + \left(-0.041666666666666664 \cdot {x}^{4} + 0.001388888888888889 \cdot {x}^{6}\right)
\] |
|---|---|
associate-+r+ [=>]0.0 | \[ \color{blue}{\left(0.5 \cdot {x}^{2} + -0.041666666666666664 \cdot {x}^{4}\right) + 0.001388888888888889 \cdot {x}^{6}}
\] |
*-commutative [=>]0.0 | \[ \left(\color{blue}{{x}^{2} \cdot 0.5} + -0.041666666666666664 \cdot {x}^{4}\right) + 0.001388888888888889 \cdot {x}^{6}
\] |
*-commutative [=>]0.0 | \[ \left({x}^{2} \cdot 0.5 + \color{blue}{{x}^{4} \cdot -0.041666666666666664}\right) + 0.001388888888888889 \cdot {x}^{6}
\] |
metadata-eval [<=]0.0 | \[ \left({x}^{2} \cdot 0.5 + {x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot -0.041666666666666664\right) + 0.001388888888888889 \cdot {x}^{6}
\] |
pow-sqr [<=]0.0 | \[ \left({x}^{2} \cdot 0.5 + \color{blue}{\left({x}^{2} \cdot {x}^{2}\right)} \cdot -0.041666666666666664\right) + 0.001388888888888889 \cdot {x}^{6}
\] |
associate-*l* [=>]0.0 | \[ \left({x}^{2} \cdot 0.5 + \color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot -0.041666666666666664\right)}\right) + 0.001388888888888889 \cdot {x}^{6}
\] |
distribute-lft-out [=>]0.0 | \[ \color{blue}{{x}^{2} \cdot \left(0.5 + {x}^{2} \cdot -0.041666666666666664\right)} + 0.001388888888888889 \cdot {x}^{6}
\] |
fma-def [=>]0.0 | \[ \color{blue}{\mathsf{fma}\left({x}^{2}, 0.5 + {x}^{2} \cdot -0.041666666666666664, 0.001388888888888889 \cdot {x}^{6}\right)}
\] |
unpow2 [=>]0.0 | \[ \mathsf{fma}\left(\color{blue}{x \cdot x}, 0.5 + {x}^{2} \cdot -0.041666666666666664, 0.001388888888888889 \cdot {x}^{6}\right)
\] |
+-commutative [=>]0.0 | \[ \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot -0.041666666666666664 + 0.5}, 0.001388888888888889 \cdot {x}^{6}\right)
\] |
unpow2 [=>]0.0 | \[ \mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot -0.041666666666666664 + 0.5, 0.001388888888888889 \cdot {x}^{6}\right)
\] |
associate-*l* [=>]0.0 | \[ \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(x \cdot -0.041666666666666664\right)} + 0.5, 0.001388888888888889 \cdot {x}^{6}\right)
\] |
fma-def [=>]0.0 | \[ \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, x \cdot -0.041666666666666664, 0.5\right)}, 0.001388888888888889 \cdot {x}^{6}\right)
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 7680 |
| Alternative 2 | |
|---|---|
| Error | 0.0 |
| Cost | 832 |
| Alternative 3 | |
|---|---|
| Error | 0.3 |
| Cost | 320 |
herbie shell --seed 2023027
(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)))