\sin \left(x + \varepsilon\right) - \sin x
\mathsf{fma}\left(\sin x, \cos \varepsilon - 1, \mathsf{log1p}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{expm1}\left(\cos x \cdot \sin \varepsilon\right)\right)\right)\right)\right)double f(double x, double eps) {
double r112704 = x;
double r112705 = eps;
double r112706 = r112704 + r112705;
double r112707 = sin(r112706);
double r112708 = sin(r112704);
double r112709 = r112707 - r112708;
return r112709;
}
double f(double x, double eps) {
double r112710 = x;
double r112711 = sin(r112710);
double r112712 = eps;
double r112713 = cos(r112712);
double r112714 = 1.0;
double r112715 = r112713 - r112714;
double r112716 = cos(r112710);
double r112717 = sin(r112712);
double r112718 = r112716 * r112717;
double r112719 = expm1(r112718);
double r112720 = expm1(r112719);
double r112721 = log1p(r112720);
double r112722 = log1p(r112721);
double r112723 = fma(r112711, r112715, r112722);
return r112723;
}




Bits error versus x




Bits error versus eps
| Original | 37.0 |
|---|---|
| Target | 15.5 |
| Herbie | 0.5 |
Initial program 37.0
rmApplied sin-sum21.4
rmApplied *-un-lft-identity21.4
Applied *-un-lft-identity21.4
Applied distribute-lft-out--21.4
Simplified0.4
rmApplied log1p-expm1-u0.4
rmApplied log1p-expm1-u0.5
Final simplification0.5
herbie shell --seed 2020060 +o rules:numerics
(FPCore (x eps)
:name "2sin (example 3.3)"
:precision binary64
:herbie-target
(* 2 (* (cos (+ x (/ eps 2))) (sin (/ eps 2))))
(- (sin (+ x eps)) (sin x)))