Average Error: 37.4 → 15.1
Time: 1.2m
Precision: 64
Internal Precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
↓
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -1.17608081698636 \cdot 10^{-17}:\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\\
\mathbf{if}\;\varepsilon \le 3.965998440074552 \cdot 10^{-36}:\\
\;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\\
\end{array}\]
Target
| Original | 37.4 |
|---|
| Target | 15.0 |
|---|
| Herbie | 15.1 |
|---|
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]
Derivation
- Split input into 2 regimes
if eps < -1.17608081698636e-17 or 3.965998440074552e-36 < eps
Initial program 30.2
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-sum1.9
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm Applied flip--2.0
\[\leadsto \frac{\tan x + \tan \varepsilon}{\color{blue}{\frac{1 \cdot 1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)}{1 + \tan x \cdot \tan \varepsilon}}} - \tan x\]
Applied associate-/r/2.0
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 \cdot 1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right)} - \tan x\]
Applied simplify2.0
\[\leadsto \color{blue}{\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)}} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\]
if -1.17608081698636e-17 < eps < 3.965998440074552e-36
Initial program 45.7
\[\tan \left(x + \varepsilon\right) - \tan x\]
Taylor expanded around 0 30.1
\[\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 '#(1063282112 2455465480 4141627379 3773598652 1647277307 776739644)'
(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)))