\tan \left(x + \varepsilon\right) - \tan x
\left(\mathsf{fma}\left(\frac{\sin x}{{\left(\cos \varepsilon\right)}^{2}}, \frac{{\left(\sin \varepsilon\right)}^{2}}{\left(1 - \frac{{\left(\sin x\right)}^{2} \cdot {\left(\sin \varepsilon\right)}^{2}}{{\left(\cos x\right)}^{2} \cdot {\left(\cos \varepsilon\right)}^{2}}\right) \cdot \cos x}, \left(\frac{{\left(\sin x\right)}^{2}}{{\left(\cos x\right)}^{2}} + 1\right) \cdot \frac{\sin \varepsilon}{\left(1 - \frac{{\left(\sin x\right)}^{2} \cdot {\left(\sin \varepsilon\right)}^{2}}{{\left(\cos x\right)}^{2} \cdot {\left(\cos \varepsilon\right)}^{2}}\right) \cdot \cos \varepsilon}\right) + \left(\frac{\sin x}{\left(1 - \frac{{\left(\sin x\right)}^{2} \cdot {\left(\sin \varepsilon\right)}^{2}}{{\left(\cos x\right)}^{2} \cdot {\left(\cos \varepsilon\right)}^{2}}\right) \cdot \cos x} - \frac{\sin x}{\cos x}\right)\right) + \tan x \cdot 0double f(double x, double eps) {
double r162076 = x;
double r162077 = eps;
double r162078 = r162076 + r162077;
double r162079 = tan(r162078);
double r162080 = tan(r162076);
double r162081 = r162079 - r162080;
return r162081;
}
double f(double x, double eps) {
double r162082 = x;
double r162083 = sin(r162082);
double r162084 = eps;
double r162085 = cos(r162084);
double r162086 = 2.0;
double r162087 = pow(r162085, r162086);
double r162088 = r162083 / r162087;
double r162089 = sin(r162084);
double r162090 = pow(r162089, r162086);
double r162091 = 1.0;
double r162092 = pow(r162083, r162086);
double r162093 = r162092 * r162090;
double r162094 = cos(r162082);
double r162095 = pow(r162094, r162086);
double r162096 = r162095 * r162087;
double r162097 = r162093 / r162096;
double r162098 = r162091 - r162097;
double r162099 = r162098 * r162094;
double r162100 = r162090 / r162099;
double r162101 = r162092 / r162095;
double r162102 = r162101 + r162091;
double r162103 = r162098 * r162085;
double r162104 = r162089 / r162103;
double r162105 = r162102 * r162104;
double r162106 = fma(r162088, r162100, r162105);
double r162107 = r162083 / r162099;
double r162108 = r162083 / r162094;
double r162109 = r162107 - r162108;
double r162110 = r162106 + r162109;
double r162111 = tan(r162082);
double r162112 = 0.0;
double r162113 = r162111 * r162112;
double r162114 = r162110 + r162113;
return r162114;
}




Bits error versus x




Bits error versus eps
| Original | 37.1 |
|---|---|
| Target | 15.1 |
| Herbie | 0.6 |
Initial program 37.1
rmApplied tan-sum21.8
rmApplied add-cube-cbrt22.3
Applied flip--22.3
Applied associate-/r/22.3
Applied prod-diff22.4
Simplified22.2
Simplified21.8
rmApplied tan-quot21.8
Applied associate-*l/21.8
Applied associate-*r/21.8
Simplified21.8
Taylor expanded around inf 22.0
Simplified0.6
Final simplification0.6
herbie shell --seed 2020046 +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)))