Average Error: 36.8 → 13.9
Time: 1.7m
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 -7.790785835907791 \cdot 10^{-43}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\\ \mathbf{if}\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right) \le 4.969624599042136 \cdot 10^{-20}:\\ \;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.8
Target15.4
Herbie13.9
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 2 regimes
  2. if (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < -7.790785835907791e-43 or 4.969624599042136e-20 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x)))

    1. Initial program 35.8

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Using strategy rm
    3. Applied tan-sum12.8

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Using strategy rm
    5. Applied flip--12.8

      \[\leadsto \frac{\tan x + \tan \varepsilon}{\color{blue}{\frac{1 \cdot 1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)}{1 + \tan x \cdot \tan \varepsilon}}} - \tan x\]
    6. Applied associate-/r/12.8

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 \cdot 1 - \left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right)} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right)} - \tan x\]
    7. Applied simplify12.8

      \[\leadsto \color{blue}{\frac{\tan \varepsilon + \tan x}{1 - \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)}} \cdot \left(1 + \tan x \cdot \tan \varepsilon\right) - \tan x\]

    if -7.790785835907791e-43 < (+ eps (+ (* (pow eps 3) (pow x 2)) (* (pow eps 2) x))) < 4.969624599042136e-20

    1. Initial program 39.0

      \[\tan \left(x + \varepsilon\right) - \tan x\]
    2. Taylor expanded around 0 16.1

      \[\leadsto \color{blue}{\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.7m)Debug logProfile

herbie shell --seed '#(1071821486 549052472 3784827256 1559736200 3548510075 881134285)' 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"

  :herbie-target
  (/ (sin eps) (* (cos x) (cos (+ x eps))))

  (- (tan (+ x eps)) (tan x)))