Average Error: 36.7 → 9.0
Time: 40.8s
Precision: 64
Internal precision: 2176
\[\tan \left(x + \varepsilon\right) - \tan x\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -1.9479733961868206 \cdot 10^{-39}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\sin x \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon}} - \tan x\\
\mathbf{if}\;\varepsilon \le 5.496498246559763 \cdot 10^{-32}:\\
\;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\tan x\right)}^2 - {\left(\tan \varepsilon\right)}^2}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x - \tan \varepsilon\right)} - \tan x\\
\end{array}\]
Target
| Original | 36.7 |
| Comparison | 26.5 |
| Herbie | 9.0 |
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]
Derivation
- Split input into 3 regimes.
-
if eps < -1.9479733961868206e-39
Initial program 30.3
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 3.0
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied tan-quot 3.0
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}}} - \tan x\]
Applied tan-quot 3.0
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\sin x}{\cos x}} \cdot \frac{\sin \varepsilon}{\cos \varepsilon}} - \tan x\]
Applied frac-times 3.0
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\sin x \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon}}} - \tan x\]
if -1.9479733961868206e-39 < eps < 5.496498246559763e-32
Initial program 45.3
\[\tan \left(x + \varepsilon\right) - \tan x\]
Applied taylor 17.7
\[\leadsto \varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)\]
Taylor expanded around 0 17.7
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)}\]
Applied simplify 17.7
\[\leadsto \color{blue}{\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon}\]
if 5.496498246559763e-32 < eps
Initial program 30.3
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 2.0
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied flip-+ 2.1
\[\leadsto \frac{\color{blue}{\frac{{\left(\tan x\right)}^2 - {\left(\tan \varepsilon\right)}^2}{\tan x - \tan \varepsilon}}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
Applied associate-/l/ 2.1
\[\leadsto \color{blue}{\frac{{\left(\tan x\right)}^2 - {\left(\tan \varepsilon\right)}^2}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x - \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 '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(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)))