\tan \left(x + \varepsilon\right) - \tan x
\frac{\frac{\sin \varepsilon \cdot \cos x}{\cos \varepsilon} + \frac{{\left(\sin x\right)}^{2} \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon}}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}double code(double x, double eps) {
return (tan((x + eps)) - tan(x));
}
double code(double x, double eps) {
return ((((sin(eps) * cos(x)) / cos(eps)) + ((pow(sin(x), 2.0) * sin(eps)) / (cos(x) * cos(eps)))) / ((1.0 - (tan(x) * tan(eps))) * cos(x)));
}




Bits error versus x




Bits error versus eps
Results
| Original | 37.2 |
|---|---|
| Target | 15.0 |
| Herbie | 0.4 |
Initial program 37.2
rmApplied tan-quot37.2
Applied tan-sum22.1
Applied frac-sub22.2
Taylor expanded around inf 0.4
Final simplification0.4
herbie shell --seed 2020091
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:precision binary64
:herbie-target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))