Average Error: 36.6 → 14.6
Time: 2.6m
Precision: 64
Internal Precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
↓
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -5.141666214214983 \cdot 10^{-54}:\\
\;\;\;\;\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 1.926096771495079 \cdot 10^{-17}:\\
\;\;\;\;{\varepsilon}^{3} \cdot {x}^{2} + \left(\varepsilon + {\varepsilon}^{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(e^{\tan x + \tan \varepsilon}\right)}{1 - \tan x \cdot \tan \varepsilon} - \tan x\\
\end{array}\]
Target
| Original | 36.6 |
|---|
| Target | 14.7 |
|---|
| Herbie | 14.6 |
|---|
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]
Derivation
- Split input into 3 regimes
if eps < -5.141666214214983e-54
Initial program 29.7
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-quot29.6
\[\leadsto \tan \left(x + \varepsilon\right) - \color{blue}{\frac{\sin x}{\cos x}}\]
Applied tan-sum4.0
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \frac{\sin x}{\cos x}\]
Applied frac-sub4.0
\[\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 -5.141666214214983e-54 < eps < 1.926096771495079e-17
Initial program 45.5
\[\tan \left(x + \varepsilon\right) - \tan x\]
Taylor expanded around 0 28.9
\[\leadsto \color{blue}{{\varepsilon}^{3} \cdot {x}^{2} + \left(\varepsilon + {\varepsilon}^{2} \cdot x\right)}\]
if 1.926096771495079e-17 < eps
Initial program 29.1
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-sum1.0
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm Applied add-log-exp2.0
\[\leadsto \frac{\tan x + \color{blue}{\log \left(e^{\tan \varepsilon}\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
Applied add-log-exp2.1
\[\leadsto \frac{\color{blue}{\log \left(e^{\tan x}\right)} + \log \left(e^{\tan \varepsilon}\right)}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
Applied sum-log2.1
\[\leadsto \frac{\color{blue}{\log \left(e^{\tan x} \cdot e^{\tan \varepsilon}\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
Applied simplify2.1
\[\leadsto \frac{\log \color{blue}{\left(e^{\tan x + \tan \varepsilon}\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
- Recombined 3 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(2094665535 3654809497 1731717781 3082199462 566033875 575777438)'
(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)))