Average Error: 36.9 → 7.2
Time: 3.9m
Precision: 64
Internal Precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
↓
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -5.820154306538017 \cdot 10^{-17}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan \varepsilon \cdot \tan x\right)}^{3}}} - \tan x\\
\mathbf{if}\;\varepsilon \le 1.9089152008804126 \cdot 10^{-17}:\\
\;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan \varepsilon \cdot \tan x\right)}^{3}}} - \tan x\\
\end{array}\]
Target
| Original | 36.9 |
|---|
| Target | 28.0 |
|---|
| Herbie | 7.2 |
|---|
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]
Derivation
- Split input into 2 regimes
if eps < -5.820154306538017e-17 or 1.9089152008804126e-17 < eps
Initial program 30.1
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-sum0.9
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm Applied add-cbrt-cube0.9
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\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\]
Applied simplify0.9
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{\color{blue}{{\left(\tan \varepsilon \cdot \tan x\right)}^{3}}}} - \tan x\]
if -5.820154306538017e-17 < eps < 1.9089152008804126e-17
Initial program 44.9
\[\tan \left(x + \varepsilon\right) - \tan x\]
Taylor expanded around 0 14.5
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:herbie-expected 28
:herbie-target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))