\tan \left(x + \varepsilon\right) - \tan x
\frac{\mathsf{fma}\left(\frac{{\left(\sin x\right)}^{2}}{\cos x}, \frac{\sin \varepsilon}{\cos \varepsilon}, \frac{\sin \varepsilon \cdot \cos x}{\cos \varepsilon}\right)}{\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 (fma((pow(sin(x), 2.0) / cos(x)), (sin(eps) / cos(eps)), ((sin(eps) * cos(x)) / cos(eps))) / ((1.0 - (tan(x) * tan(eps))) * cos(x)));
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.8 |
|---|---|
| Target | 14.9 |
| Herbie | 0.4 |
Initial program 36.8
rmApplied tan-quot36.8
Applied tan-sum22.0
Applied frac-sub22.1
Taylor expanded around inf 0.4
Simplified0.4
Final simplification0.4
herbie shell --seed 2020079 +o rules:numerics
(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)))