\sin \left(x + \varepsilon\right) - \sin x
\mathsf{fma}\left(\cos x, \sin \varepsilon, \log \left(e^{\sin x \cdot \cos \varepsilon - \sin x}\right)\right)double f(double x, double eps) {
double r4877426 = x;
double r4877427 = eps;
double r4877428 = r4877426 + r4877427;
double r4877429 = sin(r4877428);
double r4877430 = sin(r4877426);
double r4877431 = r4877429 - r4877430;
return r4877431;
}
double f(double x, double eps) {
double r4877432 = x;
double r4877433 = cos(r4877432);
double r4877434 = eps;
double r4877435 = sin(r4877434);
double r4877436 = sin(r4877432);
double r4877437 = cos(r4877434);
double r4877438 = r4877436 * r4877437;
double r4877439 = r4877438 - r4877436;
double r4877440 = exp(r4877439);
double r4877441 = log(r4877440);
double r4877442 = fma(r4877433, r4877435, r4877441);
return r4877442;
}




Bits error versus x




Bits error versus eps
| Original | 37.3 |
|---|---|
| Target | 15.5 |
| Herbie | 0.5 |
Initial program 37.3
rmApplied sin-sum21.6
Taylor expanded around inf 21.6
Simplified21.6
Taylor expanded around inf 21.6
Simplified0.4
rmApplied add-log-exp14.8
Applied add-log-exp0.5
Applied diff-log0.5
Simplified0.5
Final simplification0.5
herbie shell --seed 2019179 +o rules:numerics
(FPCore (x eps)
:name "2sin (example 3.3)"
:herbie-target
(* 2.0 (* (cos (+ x (/ eps 2.0))) (sin (/ eps 2.0))))
(- (sin (+ x eps)) (sin x)))