\sin \left(x + \varepsilon\right) - \sin x
\mathsf{fma}\left(\sin x, \log \left(e^{\mathsf{log1p}\left(\mathsf{expm1}\left(\cos \varepsilon - 1\right)\right)}\right), \cos x \cdot \sin \varepsilon\right)double f(double x, double eps) {
double r112693 = x;
double r112694 = eps;
double r112695 = r112693 + r112694;
double r112696 = sin(r112695);
double r112697 = sin(r112693);
double r112698 = r112696 - r112697;
return r112698;
}
double f(double x, double eps) {
double r112699 = x;
double r112700 = sin(r112699);
double r112701 = eps;
double r112702 = cos(r112701);
double r112703 = 1.0;
double r112704 = r112702 - r112703;
double r112705 = expm1(r112704);
double r112706 = log1p(r112705);
double r112707 = exp(r112706);
double r112708 = log(r112707);
double r112709 = cos(r112699);
double r112710 = sin(r112701);
double r112711 = r112709 * r112710;
double r112712 = fma(r112700, r112708, r112711);
return r112712;
}




Bits error versus x




Bits error versus eps
| Original | 37.1 |
|---|---|
| Target | 15.0 |
| Herbie | 0.5 |
Initial program 37.1
rmApplied sin-sum22.0
Taylor expanded around inf 22.0
Simplified0.4
rmApplied add-log-exp0.4
Applied add-log-exp0.4
Applied diff-log0.5
Simplified0.4
rmApplied log1p-expm1-u0.5
Final simplification0.5
herbie shell --seed 2020062 +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)))