Average Error: 37.2 → 10.9
Time: 32.9s
Precision: 64
Internal precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -2.4110780158260123 \cdot 10^{-56}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x \cdot \tan \varepsilon\right)}^3}} - \tan x\\
\mathbf{if}\;\varepsilon \le 1.365390054847707 \cdot 10^{-47}:\\
\;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \log \left(e^{\tan x \cdot \tan \varepsilon}\right)} - \tan x\\
\end{array}\]
Target
| Original | 37.2 |
| Comparison | 26.5 |
| Herbie | 10.9 |
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]
Derivation
- Split input into 3 regimes.
-
if eps < -2.4110780158260123e-56
Initial program 30.3
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 4.7
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied add-cbrt-cube 4.7
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{{\left(\tan x \cdot \tan \varepsilon\right)}^3}}} - \tan x\]
if -2.4110780158260123e-56 < eps < 1.365390054847707e-47
Initial program 46.8
\[\tan \left(x + \varepsilon\right) - \tan x\]
Applied taylor 20.2
\[\leadsto \varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)\]
Taylor expanded around 0 20.2
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)}\]
Applied simplify 20.2
\[\leadsto \color{blue}{\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon}\]
if 1.365390054847707e-47 < eps
Initial program 30.6
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 3.9
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied add-log-exp 4.0
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\log \left(e^{\tan x \cdot \tan \varepsilon}\right)}} - \tan x\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1065003094 2074156664 2352254222 753858891 3745550101 3374585842)'
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:herbie-expected 28
:target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))