| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 7040 |
\[-0.06388888888888888 \cdot {x}^{4} + x \cdot \left(x \cdot 0.16666666666666666\right)
\]
(FPCore (x) :precision binary64 (/ (- x (sin x)) (tan x)))
(FPCore (x) :precision binary64 (fma (* x 0.16666666666666666) x (* -0.06388888888888888 (pow x 4.0))))
double code(double x) {
return (x - sin(x)) / tan(x);
}
double code(double x) {
return fma((x * 0.16666666666666666), x, (-0.06388888888888888 * pow(x, 4.0)));
}
function code(x) return Float64(Float64(x - sin(x)) / tan(x)) end
function code(x) return fma(Float64(x * 0.16666666666666666), x, Float64(-0.06388888888888888 * (x ^ 4.0))) end
code[x_] := N[(N[(x - N[Sin[x], $MachinePrecision]), $MachinePrecision] / N[Tan[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * 0.16666666666666666), $MachinePrecision] * x + N[(-0.06388888888888888 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x - \sin x}{\tan x}
\mathsf{fma}\left(x \cdot 0.16666666666666666, x, -0.06388888888888888 \cdot {x}^{4}\right)
| Original | 30.6 |
|---|---|
| Target | 0.7 |
| Herbie | 0.4 |
Initial program 30.6
Taylor expanded in x around 0 0.4
Simplified0.4
Applied egg-rr0.4
Applied egg-rr0.4
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.4 |
| Cost | 7040 |
| Alternative 2 | |
|---|---|
| Error | 0.4 |
| Cost | 6976 |
| Alternative 3 | |
|---|---|
| Error | 0.4 |
| Cost | 704 |
| Alternative 4 | |
|---|---|
| Error | 0.7 |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Error | 0.7 |
| Cost | 320 |
herbie shell --seed 2022329
(FPCore (x)
:name "ENA, Section 1.4, Exercise 4a"
:precision binary64
:pre (and (<= -1.0 x) (<= x 1.0))
:herbie-target
(* 0.16666666666666666 (* x x))
(/ (- x (sin x)) (tan x)))