Average Error: 36.2 → 9.1
Time: 54.3s
Precision: 64
Internal precision: 2176
\[\tan \left(x + \varepsilon\right) - \tan x\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -8.215474236625967 \cdot 10^{-36}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}} - \tan x\\
\mathbf{if}\;\varepsilon \le 1.097745022759887 \cdot 10^{-20}:\\
\;\;\;\;\left(\varepsilon + {\varepsilon}^{4} \cdot {x}^3\right) + \left(x \cdot x\right) \cdot {\varepsilon}^3\\
\mathbf{else}:\\
\;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}} - \tan x\\
\end{array}\]
Target
| Original | 36.2 |
| Comparison | 26.7 |
| Herbie | 9.1 |
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]
Derivation
- Split input into 2 regimes.
-
if eps < -8.215474236625967e-36 or 1.097745022759887e-20 < eps
Initial program 29.9
\[\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 tan-quot 2.0
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon}}} - \tan x\]
Applied associate-*r/ 2.0
\[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \color{blue}{\frac{\tan x \cdot \sin \varepsilon}{\cos \varepsilon}}} - \tan x\]
if -8.215474236625967e-36 < eps < 1.097745022759887e-20
Initial program 43.9
\[\tan \left(x + \varepsilon\right) - \tan x\]
Applied taylor 18.0
\[\leadsto \varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)\]
Taylor expanded around 0 18.0
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{4} \cdot {x}^{3} + {\varepsilon}^{3} \cdot {x}^2\right)}\]
Applied simplify 18.0
\[\leadsto \color{blue}{\left(\varepsilon + {\varepsilon}^{4} \cdot {x}^3\right) + \left(x \cdot x\right) \cdot {\varepsilon}^3}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(3283856077 3183919125 3399458751 396155847 3688194147 1862413033)'
(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)))