\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \leq -5.059410338124564 \cdot 10^{-113} \lor \neg \left(\varepsilon \leq 3.2766669081460135 \cdot 10^{-68}\right):\\
\;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x + \sin x \cdot \left(\tan x \cdot \tan \varepsilon + -1\right)}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}\\
\mathbf{else}:\\
\;\;\;\;\varepsilon + x \cdot \left(\varepsilon \cdot \left(\varepsilon + x\right)\right)\\
\end{array}(FPCore (x eps) :precision binary64 (- (tan (+ x eps)) (tan x)))
(FPCore (x eps)
:precision binary64
(if (or (<= eps -5.059410338124564e-113)
(not (<= eps 3.2766669081460135e-68)))
(/
(+
(* (+ (tan x) (tan eps)) (cos x))
(* (sin x) (+ (* (tan x) (tan eps)) -1.0)))
(* (cos x) (- 1.0 (* (tan x) (tan eps)))))
(+ eps (* x (* eps (+ eps x))))))double code(double x, double eps) {
return ((double) (((double) tan(((double) (x + eps)))) - ((double) tan(x))));
}
double code(double x, double eps) {
double tmp;
if (((eps <= -5.059410338124564e-113) || !(eps <= 3.2766669081460135e-68))) {
tmp = (((double) (((double) (((double) (((double) tan(x)) + ((double) tan(eps)))) * ((double) cos(x)))) + ((double) (((double) sin(x)) * ((double) (((double) (((double) tan(x)) * ((double) tan(eps)))) + -1.0)))))) / ((double) (((double) cos(x)) * ((double) (1.0 - ((double) (((double) tan(x)) * ((double) tan(eps)))))))));
} else {
tmp = ((double) (eps + ((double) (x * ((double) (eps * ((double) (eps + x))))))));
}
return tmp;
}




Bits error versus x




Bits error versus eps
Results
| Original | 37.1 |
|---|---|
| Target | 15.5 |
| Herbie | 15.7 |
if eps < -5.0594103381245639e-113 or 3.2766669081460135e-68 < eps Initial program Error: 31.5 bits
rmApplied tan-quotError: 31.3 bits
Applied tan-sumError: 7.6 bits
Applied frac-subError: 7.6 bits
SimplifiedError: 7.6 bits
if -5.0594103381245639e-113 < eps < 3.2766669081460135e-68Initial program Error: 47.9 bits
Taylor expanded around 0 Error: 31.4 bits
SimplifiedError: 31.1 bits
Final simplificationError: 15.7 bits
herbie shell --seed 2020204
(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)))