\sin \left(x + \varepsilon\right) - \sin x
\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{fma}\left(\sin x, \log \left(e^{\cos \varepsilon - 1}\right), \cos x \cdot \sin \varepsilon\right)\right)\right)double f(double x, double eps) {
double r95762 = x;
double r95763 = eps;
double r95764 = r95762 + r95763;
double r95765 = sin(r95764);
double r95766 = sin(r95762);
double r95767 = r95765 - r95766;
return r95767;
}
double f(double x, double eps) {
double r95768 = x;
double r95769 = sin(r95768);
double r95770 = eps;
double r95771 = cos(r95770);
double r95772 = 1.0;
double r95773 = r95771 - r95772;
double r95774 = exp(r95773);
double r95775 = log(r95774);
double r95776 = cos(r95768);
double r95777 = sin(r95770);
double r95778 = r95776 * r95777;
double r95779 = fma(r95769, r95775, r95778);
double r95780 = expm1(r95779);
double r95781 = log1p(r95780);
return r95781;
}




Bits error versus x




Bits error versus eps
| Original | 36.9 |
|---|---|
| Target | 15.2 |
| Herbie | 0.5 |
Initial program 36.9
rmApplied sin-sum21.7
Applied associate--l+21.7
Taylor expanded around inf 21.7
Simplified0.4
rmApplied log1p-expm1-u0.5
rmApplied add-log-exp0.5
Applied add-log-exp0.5
Applied diff-log0.5
Simplified0.5
Final simplification0.5
herbie shell --seed 2020083 +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)))