Average Error: 37.1 → 14.1
Time: 1.5m
Precision: 64
Internal Precision: 2368
\[\tan \left(x + \varepsilon\right) - \tan x\]
↓
\[\begin{array}{l}
\mathbf{if}\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right) \le -1.5421536156885885 \cdot 10^{-12}:\\
\;\;\;\;\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 + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right) \le 2.883339850385901 \cdot 10^{-07}:\\
\;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(\tan x\right)}^{3} + {\left(\tan \varepsilon\right)}^{3}}{\left(\tan \varepsilon \cdot \tan \varepsilon - \left(\tan \varepsilon - \tan x\right) \cdot \tan x\right) \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)} - \tan x\\
\end{array}\]
Target
| Original | 37.1 |
|---|
| Target | 15.1 |
|---|
| Herbie | 14.1 |
|---|
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]
Derivation
- Split input into 3 regimes
if (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < -1.5421536156885885e-12
Initial program 37.1
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-quot36.9
\[\leadsto \tan \left(x + \varepsilon\right) - \color{blue}{\frac{\sin x}{\cos x}}\]
Applied tan-sum9.7
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \frac{\sin x}{\cos x}\]
Applied frac-sub9.7
\[\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 -1.5421536156885885e-12 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < 2.883339850385901e-07
Initial program 38.1
\[\tan \left(x + \varepsilon\right) - \tan x\]
Taylor expanded around 0 15.4
\[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)}\]
if 2.883339850385901e-07 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x)))
Initial program 36.4
\[\tan \left(x + \varepsilon\right) - \tan x\]
- Using strategy
rm Applied tan-sum14.7
\[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
- Using strategy
rm Applied flip3-+15.0
\[\leadsto \frac{\color{blue}{\frac{{\left(\tan x\right)}^{3} + {\left(\tan \varepsilon\right)}^{3}}{\tan x \cdot \tan x + \left(\tan \varepsilon \cdot \tan \varepsilon - \tan x \cdot \tan \varepsilon\right)}}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
Applied associate-/l/15.0
\[\leadsto \color{blue}{\frac{{\left(\tan x\right)}^{3} + {\left(\tan \varepsilon\right)}^{3}}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan x + \left(\tan \varepsilon \cdot \tan \varepsilon - \tan x \cdot \tan \varepsilon\right)\right)}} - \tan x\]
Applied simplify15.0
\[\leadsto \frac{{\left(\tan x\right)}^{3} + {\left(\tan \varepsilon\right)}^{3}}{\color{blue}{\left(\tan \varepsilon \cdot \tan \varepsilon - \left(\tan \varepsilon - \tan x\right) \cdot \tan x\right) \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}} - \tan x\]
- Recombined 3 regimes into one program.
Runtime
herbie shell --seed '#(1071373924 2949776965 1885069702 3247780810 90874544 2263903749)'
(FPCore (x eps)
:name "2tan (problem 3.3.2)"
:herbie-target
(/ (sin eps) (* (cos x) (cos (+ x eps))))
(- (tan (+ x eps)) (tan x)))