Average Error: 37.4 → 13.9
Time: 2.5m
Precision: 64
Internal Precision: 2368
\[\tan \left(x + \varepsilon\right) - \tan x\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{\tan x + \tan \varepsilon}{1 - (e^{\log_* (1 + \tan x \cdot \tan \varepsilon)} - 1)^*} - \tan x \le -3.295028045312774 \cdot 10^{-13}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - (e^{\log_* (1 + \tan x \cdot \tan \varepsilon)} - 1)^*} - \tan x\\
\mathbf{if}\;\frac{\tan x + \tan \varepsilon}{1 - (e^{\log_* (1 + \tan x \cdot \tan \varepsilon)} - 1)^*} - \tan x \le 3.9954989461759 \cdot 10^{-310}:\\
\;\;\;\;(\varepsilon \cdot \left((\left(\varepsilon \cdot x\right) \cdot \left(\varepsilon \cdot x\right) + \left(\varepsilon \cdot x\right))_*\right) + \varepsilon)_*\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan \varepsilon \cdot \tan x\right)}^{3}}} - \tan x\\
\end{array}\]
Target
| Original | 37.4 |
|---|
| Target | 15.2 |
|---|
| Herbie | 13.9 |
|---|
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]
Derivation
- Split input into 3 regimes
if (- (/ (+ (tan x) (tan eps)) (- 1 (expm1 (log1p (* (tan x) (tan eps)))))) (tan x)) < -3.295028045312774e-13
Initial program 27.1
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-sum0.8
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm Applied expm1-log1p-u0.8
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{(e^{\log_* (1 + \tan x \cdot \tan \varepsilon)} - 1)^*}} - \tan x\]
if -3.295028045312774e-13 < (- (/ (+ (tan x) (tan eps)) (- 1 (expm1 (log1p (* (tan x) (tan eps)))))) (tan x)) < 3.9954989461759e-310
Initial program 52.0
\[\tan \left(x + \varepsilon\right) - \tan x\]
Taylor expanded around 0 33.6
\[\leadsto \color{blue}{x \cdot {\varepsilon}^{2} + \left({x}^{2} \cdot {\varepsilon}^{3} + \varepsilon\right)}\]
Applied simplify32.3
\[\leadsto \color{blue}{(\varepsilon \cdot \left((\left(\varepsilon \cdot x\right) \cdot \left(\varepsilon \cdot x\right) + \left(\varepsilon \cdot x\right))_*\right) + \varepsilon)_*}\]
if 3.9954989461759e-310 < (- (/ (+ (tan x) (tan eps)) (- 1 (expm1 (log1p (* (tan x) (tan eps)))))) (tan x))
Initial program 27.0
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-sum1.1
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm Applied add-cbrt-cube1.1
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\sqrt[3]{\left(\tan \varepsilon \cdot \tan \varepsilon\right) \cdot \tan \varepsilon}}} - \tan x\]
Applied add-cbrt-cube1.2
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{\left(\tan x \cdot \tan x\right) \cdot \tan x}} \cdot \sqrt[3]{\left(\tan \varepsilon \cdot \tan \varepsilon\right) \cdot \tan \varepsilon}} - \tan x\]
Applied cbrt-unprod1.1
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{\left(\left(\tan x \cdot \tan x\right) \cdot \tan x\right) \cdot \left(\left(\tan \varepsilon \cdot \tan \varepsilon\right) \cdot \tan \varepsilon\right)}}} - \tan x\]
Applied simplify1.1
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{\color{blue}{{\left(\tan \varepsilon \cdot \tan x\right)}^{3}}}} - \tan x\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed 2020178 +o rules:numerics
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:herbie-target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))