\sin \left(x + \varepsilon\right) - \sin x
2 \cdot \left(\mathsf{fma}\left(\cos \left(\frac{1}{2} \cdot \varepsilon\right), \cos x, -\sin x \cdot \sin \left(\frac{1}{2} \cdot \varepsilon\right)\right) \cdot \sin \left(\frac{1}{2} \cdot \varepsilon\right)\right)double f(double x, double eps) {
double r96785 = x;
double r96786 = eps;
double r96787 = r96785 + r96786;
double r96788 = sin(r96787);
double r96789 = sin(r96785);
double r96790 = r96788 - r96789;
return r96790;
}
double f(double x, double eps) {
double r96791 = 2.0;
double r96792 = 0.5;
double r96793 = eps;
double r96794 = r96792 * r96793;
double r96795 = cos(r96794);
double r96796 = x;
double r96797 = cos(r96796);
double r96798 = sin(r96796);
double r96799 = sin(r96794);
double r96800 = r96798 * r96799;
double r96801 = -r96800;
double r96802 = fma(r96795, r96797, r96801);
double r96803 = r96802 * r96799;
double r96804 = r96791 * r96803;
return r96804;
}




Bits error versus x




Bits error versus eps
| Original | 37.1 |
|---|---|
| Target | 15.2 |
| Herbie | 0.3 |
Initial program 37.1
rmApplied diff-sin37.5
Simplified15.3
Taylor expanded around inf 15.3
Simplified15.2
rmApplied fma-udef15.2
Applied cos-sum0.3
Taylor expanded around inf 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2019326 +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)))