| Alternative 1 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 26816 |
\[-0.16666666666666666 \cdot {x}^{3} + \left(2.7557319223985893 \cdot 10^{-6} \cdot {x}^{9} + \left(-0.0001984126984126984 \cdot {x}^{7} + 0.008333333333333333 \cdot {x}^{5}\right)\right)
\]

(FPCore (x) :precision binary64 (- (sin x) x))
(FPCore (x)
:precision binary64
(fma
-0.16666666666666666
(pow x 3.0)
(fma
0.008333333333333333
(pow x 5.0)
(+
(* -0.0001984126984126984 (pow x 7.0))
(* 2.7557319223985893e-6 (pow x 9.0))))))double code(double x) {
return sin(x) - x;
}
double code(double x) {
return fma(-0.16666666666666666, pow(x, 3.0), fma(0.008333333333333333, pow(x, 5.0), ((-0.0001984126984126984 * pow(x, 7.0)) + (2.7557319223985893e-6 * pow(x, 9.0)))));
}
function code(x) return Float64(sin(x) - x) end
function code(x) return fma(-0.16666666666666666, (x ^ 3.0), fma(0.008333333333333333, (x ^ 5.0), Float64(Float64(-0.0001984126984126984 * (x ^ 7.0)) + Float64(2.7557319223985893e-6 * (x ^ 9.0))))) end
code[x_] := N[(N[Sin[x], $MachinePrecision] - x), $MachinePrecision]
code[x_] := N[(-0.16666666666666666 * N[Power[x, 3.0], $MachinePrecision] + N[(0.008333333333333333 * N[Power[x, 5.0], $MachinePrecision] + N[(N[(-0.0001984126984126984 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision] + N[(2.7557319223985893e-6 * N[Power[x, 9.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sin x - x
\mathsf{fma}\left(-0.16666666666666666, {x}^{3}, \mathsf{fma}\left(0.008333333333333333, {x}^{5}, -0.0001984126984126984 \cdot {x}^{7} + 2.7557319223985893 \cdot 10^{-6} \cdot {x}^{9}\right)\right)
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
| Original | 69.8% |
|---|---|
| Target | 99.8% |
| Herbie | 98.9% |
Initial program 72.4%
Taylor expanded in x around 0 97.9%
Simplified97.9%
Applied egg-rr97.9%
Final simplification97.9%
| Alternative 1 | |
|---|---|
| Accuracy | 98.9% |
| Cost | 26816 |
| Alternative 2 | |
|---|---|
| Accuracy | 98.8% |
| Cost | 20096 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.5% |
| Cost | 13440 |
| Alternative 4 | |
|---|---|
| Accuracy | 98.6% |
| Cost | 13376 |
| Alternative 5 | |
|---|---|
| Accuracy | 98.0% |
| Cost | 6656 |
| Alternative 6 | |
|---|---|
| Accuracy | 69.8% |
| Cost | 6592 |
| Alternative 7 | |
|---|---|
| Accuracy | 6.5% |
| Cost | 128 |
herbie shell --seed 2023161
(FPCore (x)
:name "bug500 (missed optimization)"
:precision binary64
:pre (and (< -1000.0 x) (< x 1000.0))
:herbie-target
(if (< (fabs x) 0.07) (- (+ (- (/ (pow x 3.0) 6.0) (/ (pow x 5.0) 120.0)) (/ (pow x 7.0) 5040.0))) (- (sin x) x))
(- (sin x) x))