\sin \left(x + \varepsilon\right) - \sin x
\sin \varepsilon \cdot \cos x + \log \left({\left(e^{\cos \varepsilon - 1}\right)}^{\left(\sin x\right)}\right)double code(double x, double eps) {
return (sin((x + eps)) - sin(x));
}
double code(double x, double eps) {
return ((sin(eps) * cos(x)) + log(pow(exp((cos(eps) - 1.0)), sin(x))));
}




Bits error versus x




Bits error versus eps
Results
| Original | 37.1 |
|---|---|
| Target | 14.4 |
| Herbie | 0.4 |
Initial program 37.1
rmApplied +-commutative37.1
Applied sin-sum22.5
Applied associate--l+0.4
rmApplied *-un-lft-identity0.4
Applied distribute-rgt-out--0.4
rmApplied add-log-exp0.4
Applied add-log-exp0.4
Applied diff-log0.4
Simplified0.4
rmApplied add-log-exp0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2020066
(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)))