Average Error: 36.7 → 7.8
Time: 2.7m
Precision: 64
Internal Precision: 2176
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -1.7387217572195604 \cdot 10^{-16}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \log \left(e^{\tan x \cdot \tan \varepsilon}\right)} - \tan x\\ \mathbf{if}\;\varepsilon \le 3.0621192337477256 \cdot 10^{-40}:\\ \;\;\;\;\varepsilon + \left({\varepsilon}^{3} \cdot {x}^{2} + {\varepsilon}^{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan x + \tan \varepsilon}{1 - \log \left(e^{\tan x \cdot \tan \varepsilon}\right)} - \tan x\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original36.7
Target27.4
Herbie7.8
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 2 regimes
  2. if eps < -1.7387217572195604e-16 or 3.0621192337477256e-40 < eps

    1. Initial program 29.8

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

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

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

    if -1.7387217572195604e-16 < eps < 3.0621192337477256e-40

    1. Initial program 45.3

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

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

Runtime

Time bar (total: 2.7m)Debug logProfile

herbie shell --seed '#(1062803647 245428163 493620569 3595423923 1908391097 2390014376)' 
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"
  :herbie-expected 28

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

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