\tan \left(x + \varepsilon\right) - \tan x
\begin{array}{l}
\mathbf{if}\;\varepsilon \le -1.538105143778487014527009869176991195373 \cdot 10^{-19}:\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \sqrt[3]{\left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)}} - \tan x\\
\mathbf{elif}\;\varepsilon \le 2.35543875174405530005124676624834885103 \cdot 10^{-56}:\\
\;\;\;\;\varepsilon + \varepsilon \cdot \left(x \cdot \left(x + \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \frac{\tan \varepsilon \cdot \sin x}{\cos x}} - \tan x\\
\end{array}double f(double x, double eps) {
double r5832137 = x;
double r5832138 = eps;
double r5832139 = r5832137 + r5832138;
double r5832140 = tan(r5832139);
double r5832141 = tan(r5832137);
double r5832142 = r5832140 - r5832141;
return r5832142;
}
double f(double x, double eps) {
double r5832143 = eps;
double r5832144 = -1.538105143778487e-19;
bool r5832145 = r5832143 <= r5832144;
double r5832146 = tan(r5832143);
double r5832147 = x;
double r5832148 = tan(r5832147);
double r5832149 = r5832146 + r5832148;
double r5832150 = 1.0;
double r5832151 = r5832148 * r5832146;
double r5832152 = r5832151 * r5832151;
double r5832153 = r5832152 * r5832151;
double r5832154 = cbrt(r5832153);
double r5832155 = r5832150 - r5832154;
double r5832156 = r5832149 / r5832155;
double r5832157 = r5832156 - r5832148;
double r5832158 = 2.3554387517440553e-56;
bool r5832159 = r5832143 <= r5832158;
double r5832160 = r5832147 + r5832143;
double r5832161 = r5832147 * r5832160;
double r5832162 = r5832143 * r5832161;
double r5832163 = r5832143 + r5832162;
double r5832164 = sin(r5832147);
double r5832165 = r5832146 * r5832164;
double r5832166 = cos(r5832147);
double r5832167 = r5832165 / r5832166;
double r5832168 = r5832150 - r5832167;
double r5832169 = r5832149 / r5832168;
double r5832170 = r5832169 - r5832148;
double r5832171 = r5832159 ? r5832163 : r5832170;
double r5832172 = r5832145 ? r5832157 : r5832171;
return r5832172;
}




Bits error versus x




Bits error versus eps
Results
| Original | 36.9 |
|---|---|
| Target | 15.1 |
| Herbie | 15.1 |
if eps < -1.538105143778487e-19Initial program 29.6
rmApplied tan-sum1.1
rmApplied add-cbrt-cube1.2
if -1.538105143778487e-19 < eps < 2.3554387517440553e-56Initial program 45.5
Taylor expanded around 0 30.6
Simplified30.6
if 2.3554387517440553e-56 < eps Initial program 30.6
rmApplied tan-sum4.6
rmApplied add-cbrt-cube4.7
rmApplied tan-quot4.7
Applied associate-*l/4.7
Applied tan-quot4.7
Applied associate-*l/4.7
Applied tan-quot4.7
Applied associate-*l/4.7
Applied frac-times4.7
Applied frac-times4.7
Applied cbrt-div4.7
Simplified4.7
Simplified4.6
Final simplification15.1
herbie shell --seed 2019192
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:herbie-target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))