Average Error: 36.7 → 9.3
Time: 33.7s
Precision: 64
Internal precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -4.1660066365355184 \cdot 10^{-24}:\\
\;\;\;\;\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\
\mathbf{if}\;\varepsilon \le 2.6866613583039565 \cdot 10^{-28}:\\
\;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}\right)}^2 - {\left(\tan x\right)}^2}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} + \tan x}\\
\end{array}\]
Target
| Original | 36.7 |
| Comparison | 27.3 |
| Herbie | 9.3 |
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]
Derivation
- Split input into 3 regimes.
-
if eps < -4.1660066365355184e-24
Initial program 30.0
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-quot 29.8
\[\leadsto \tan \left(x + \varepsilon\right) - \color{blue}{\frac{\sin x}{\cos x}}\]
Applied tan-sum 1.9
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \frac{\sin x}{\cos x}\]
Applied frac-sub 1.9
\[\leadsto \color{blue}{\frac{\left(\tan x + \tan \varepsilon\right) \cdot \cos x - \left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}}\]
if -4.1660066365355184e-24 < eps < 2.6866613583039565e-28
Initial program 45.5
\[\tan \left(x + \varepsilon\right) - \tan x\]
Applied taylor 18.6
\[\leadsto \varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)\]
Taylor expanded around 0 18.6
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)}\]
Applied simplify 18.6
\[\leadsto \color{blue}{\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon}\]
if 2.6866613583039565e-28 < eps
Initial program 29.5
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 1.8
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied flip-- 1.9
\[\leadsto \color{blue}{\frac{{\left(\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}\right)}^2 - {\left(\tan x\right)}^2}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} + \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 '#(1064875752 1442698706 3150723005 1316518582 2592983078 3835530843)'
(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)))