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




Bits error versus x




Bits error versus eps
Results
| Original | 36.9 |
|---|---|
| Target | 14.9 |
| Herbie | 0.3 |
Initial program 36.9
rmApplied tan-quot_binary6436.9
Applied tan-sum_binary6422.1
Applied frac-sub_binary6422.1
Simplified22.1
Simplified22.1
Taylor expanded around inf 0.4
Simplified0.4
rmApplied quot-tan_binary640.3
Final simplification0.3
herbie shell --seed 2021173
(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)))