Average Error: 36.7 → 9.3
Time: 36.6s
Precision: 64
Internal precision: 2432
\[\tan \left(x + \varepsilon\right) - \tan x\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -3.6204066776528013 \cdot 10^{-10}:\\
\;\;\;\;\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.0282379688946755 \cdot 10^{-50}:\\
\;\;\;\;\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}} - \tan x\\
\end{array}\]
Target
| Original | 36.7 |
| Comparison | 27.1 |
| Herbie | 9.3 |
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]
Derivation
- Split input into 3 regimes.
-
if eps < -3.6204066776528013e-10
Initial program 31.4
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-quot 31.3
\[\leadsto \tan \left(x + \varepsilon\right) - \color{blue}{\frac{\sin x}{\cos x}}\]
Applied tan-sum 0.6
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \frac{\sin x}{\cos x}\]
Applied frac-sub 0.6
\[\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 -3.6204066776528013e-10 < eps < 1.0282379688946755e-50
Initial program 44.4
\[\tan \left(x + \varepsilon\right) - \tan x\]
Applied taylor 18.1
\[\leadsto \varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)\]
Taylor expanded around 0 18.1
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)}\]
Applied simplify 18.1
\[\leadsto \color{blue}{\left({x}^2 \cdot {\varepsilon}^3 + {\varepsilon}^{4} \cdot {x}^3\right) + \varepsilon}\]
if 1.0282379688946755e-50 < eps
Initial program 30.2
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 4.0
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied add-cbrt-cube 4.1
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\sqrt[3]{{\left(\tan \varepsilon\right)}^3}}} - \tan x\]
Applied add-cbrt-cube 4.1
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{{\left(\tan x\right)}^3}} \cdot \sqrt[3]{{\left(\tan \varepsilon\right)}^3}} - \tan x\]
Applied cbrt-unprod 4.1
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\sqrt[3]{{\left(\tan x\right)}^3 \cdot {\left(\tan \varepsilon\right)}^3}}} - \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 '#(1066372953 114334025 411438303 1288252006 2962405338 2829794477)'
(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)))