Average Error: 36.6 → 10.5
Time: 54.4s
Precision: 64
Ground Truth: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
⬇
\[\begin{array}{l}
\mathbf{if}\;\varepsilon \le -1.5978287878901397 \cdot 10^{-47}:\\
\;\;\;\;\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}} - \tan x\\
\mathbf{if}\;\varepsilon \le 4.820454443524605 \cdot 10^{-45}:\\
\;\;\;\;\left(\varepsilon + {\varepsilon}^3 \cdot \left(x \cdot x\right)\right) + {x}^3 \cdot {\varepsilon}^{4}\\
\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.6 |
| Comparison | 26.5 |
| Herbie | 10.5 |
\[ \frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)} \]
Derivation
- Split input into 3 regimes.
-
if eps < -1.5978287878901397e-47
Initial program 29.9
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 4.1
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied clear-num 4.2
\[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x\]
if -1.5978287878901397e-47 < eps < 4.820454443524605e-45
Initial program 46.2
\[\tan \left(x + \varepsilon\right) - \tan x\]
Applied taylor 20.0
\[\leadsto \varepsilon + \left({\varepsilon}^{3} \cdot {x}^2 + {\varepsilon}^{4} \cdot {x}^{3}\right)\]
Taylor expanded around 0 20.0
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{3} \cdot {x}^2 + {\varepsilon}^{4} \cdot {x}^{3}\right)}\]
Applied simplify 20.0
\[\leadsto \color{blue}{\left(\varepsilon + {\varepsilon}^3 \cdot \left(x \cdot x\right)\right) + {x}^3 \cdot {\varepsilon}^{4}}\]
if 4.820454443524605e-45 < eps
Initial program 29.5
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm
Applied tan-sum 3.2
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm
Applied add-cbrt-cube 3.2
\[\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 3.2
\[\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 3.2
\[\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 --seed '#(3916392738 3454683258 2683473460 599201605 346020274 3845347111)'
(FPCore (x eps)
:name "NMSE problem 3.3.2"
:herbie-expected 28
:target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))