\sin \left(x + \varepsilon\right) - \sin x
\mathsf{fma}\left(\sin x, \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{{\left(\cos \varepsilon\right)}^{3} - 1}{\mathsf{fma}\left(\cos \varepsilon, \cos \varepsilon + 1, 1\right)}\right)\right), \cos x \cdot \sin \varepsilon\right)double f(double x, double eps) {
double r96018 = x;
double r96019 = eps;
double r96020 = r96018 + r96019;
double r96021 = sin(r96020);
double r96022 = sin(r96018);
double r96023 = r96021 - r96022;
return r96023;
}
double f(double x, double eps) {
double r96024 = x;
double r96025 = sin(r96024);
double r96026 = eps;
double r96027 = cos(r96026);
double r96028 = 3.0;
double r96029 = pow(r96027, r96028);
double r96030 = 1.0;
double r96031 = r96029 - r96030;
double r96032 = r96027 + r96030;
double r96033 = fma(r96027, r96032, r96030);
double r96034 = r96031 / r96033;
double r96035 = expm1(r96034);
double r96036 = log1p(r96035);
double r96037 = cos(r96024);
double r96038 = sin(r96026);
double r96039 = r96037 * r96038;
double r96040 = fma(r96025, r96036, r96039);
return r96040;
}




Bits error versus x




Bits error versus eps
| Original | 37.1 |
|---|---|
| Target | 15.2 |
| Herbie | 0.4 |
Initial program 37.1
rmApplied sin-sum21.9
rmApplied *-un-lft-identity21.9
Applied *-un-lft-identity21.9
Applied distribute-lft-out--21.9
Simplified0.4
rmApplied log1p-expm1-u0.4
rmApplied flip3--0.4
Simplified0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2020046 +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)))