\sin \left(x + \varepsilon\right) - \sin x
\mathsf{fma}\left(\cos x, \sin \varepsilon, -\mathsf{fma}\left(\sin x, 1 - \cos \varepsilon, 0\right)\right)
(FPCore (x eps) :precision binary64 (- (sin (+ x eps)) (sin x)))
(FPCore (x eps) :precision binary64 (fma (cos x) (sin eps) (- (fma (sin x) (- 1.0 (cos eps)) 0.0))))
double code(double x, double eps) {
return sin((x + eps)) - sin(x);
}
double code(double x, double eps) {
return fma(cos(x), sin(eps), -fma(sin(x), (1.0 - cos(eps)), 0.0));
}




Bits error versus x




Bits error versus eps
| Original | 36.8 |
|---|---|
| Target | 15.4 |
| Herbie | 0.4 |
Initial program 36.8
Applied egg-rr0.4
Taylor expanded in x around inf 0.4
Simplified0.4
Applied egg-rr0.4
Final simplification0.4
herbie shell --seed 2022129
(FPCore (x eps)
:name "2sin (example 3.3)"
:precision binary64
:herbie-target
(* 2.0 (* (cos (+ x (/ eps 2.0))) (sin (/ eps 2.0))))
(- (sin (+ x eps)) (sin x)))