Average Error: 37.2 → 15.3
Time: 46.4s
Precision: 64
Internal Precision: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -5.137551519123668 \cdot 10^{-87} \lor \neg \left(\varepsilon \le 7.274589610278849 \cdot 10^{-41}\right):\\ \;\;\;\;\frac{(\left(\cos x\right) \cdot \left(\tan x + \tan \varepsilon\right) + \left(\sin x \cdot (\left(\tan x\right) \cdot \left(\tan \varepsilon\right) + -1)_*\right))_*}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}\\ \mathbf{else}:\\ \;\;\;\;(\left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right) + \varepsilon)_*\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Target

Original37.2
Target15.6
Herbie15.3
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 2 regimes
  2. if eps < -5.137551519123668e-87 or 7.274589610278849e-41 < eps

    1. Initial program 30.6

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon} - \color{blue}{\frac{\sin x}{\cos x}}\]
    6. Applied frac-sub4.8

      \[\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}}\]
    7. Simplified4.7

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

    if -5.137551519123668e-87 < eps < 7.274589610278849e-41

    1. Initial program 47.2

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Taylor expanded around 0 31.2

      \[\leadsto \color{blue}{x \cdot {\varepsilon}^{2} + \left(\varepsilon + {x}^{2} \cdot \varepsilon\right)}\]
    5. Simplified31.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \le -5.137551519123668 \cdot 10^{-87} \lor \neg \left(\varepsilon \le 7.274589610278849 \cdot 10^{-41}\right):\\ \;\;\;\;\frac{(\left(\cos x\right) \cdot \left(\tan x + \tan \varepsilon\right) + \left(\sin x \cdot (\left(\tan x\right) \cdot \left(\tan \varepsilon\right) + -1)_*\right))_*}{\cos x \cdot \left(1 - \tan x \cdot \tan \varepsilon\right)}\\ \mathbf{else}:\\ \;\;\;\;(\left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right) + \varepsilon)_*\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 +o rules:numerics
(FPCore (x eps)
  :name "2tan (problem 3.3.2)"

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

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

Details

Time bar (total: 44.5s)Debug log

sample433.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

5.0ms
(- (tan (+ x eps)) (tan x))

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 38.3b

localize14.0ms

Local error

Found 2 expressions with local error:

4.4b
(tan (+ x eps))
2.3b
(- (tan (+ x eps)) (tan x))

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
2 → 41
Calls

2 calls. Slowest were:

6.0ms
(- (tan (+ x eps)) (tan x))
2.0ms
(tan (+ x eps))

series166.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

95.0ms
(- (tan (+ x eps)) (tan x))
71.0ms
(tan (+ x eps))

simplify1.1s

Counts
35 → 47
Calls

35 calls. Slowest were:

256.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
238.0ms
(+ (* x (pow eps 2)) (+ eps (* (pow x 2) eps)))
192.0ms
(* (- 1 (* (tan x) (tan eps))) (cos x))

prune379.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 16.9b

localize20.0ms

Local error

Found 4 expressions with local error:

3.0b
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
0.2b
(* (tan x) (tan eps))
0.1b
(+ (tan x) (tan eps))
0.1b
(- 1 (* (tan x) (tan eps)))

rewrite67.0ms

Algorithm
rewrite-expression-head
Counts
4 → 143
Calls

4 calls. Slowest were:

48.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
7.0ms
(+ (tan x) (tan eps))
5.0ms
(* (tan x) (tan eps))

series727.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

384.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
154.0ms
(- 1 (* (tan x) (tan eps)))
94.0ms
(+ (tan x) (tan eps))
93.0ms
(* (tan x) (tan eps))

simplify14.1s

Counts
163 → 155
Calls

163 calls. Slowest were:

631.0ms
(fma (/ 1 (* (cbrt (- 1 (* (tan x) (tan eps)))) (cbrt (- 1 (* (tan x) (tan eps)))))) (/ (+ (tan x) (tan eps)) (cbrt (- 1 (* (tan x) (tan eps))))) (- (* (sqrt (tan x)) (sqrt (tan x)))))
565.0ms
(fma (/ 1 (* (cbrt (- 1 (* (tan x) (tan eps)))) (cbrt (- 1 (* (tan x) (tan eps)))))) (/ (+ (tan x) (tan eps)) (cbrt (- 1 (* (tan x) (tan eps))))) (- (* (sqrt (tan x)) (sqrt (tan x)))))
498.0ms
(fma (/ 1 (* (cbrt (- 1 (* (tan x) (tan eps)))) (cbrt (- 1 (* (tan x) (tan eps)))))) (/ (+ (tan x) (tan eps)) (cbrt (- 1 (* (tan x) (tan eps))))) (- (* (tan x) 1)))

prune1.7s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 16.8b

localize53.0ms

Local error

Found 4 expressions with local error:

3.0b
(fma (/ (+ (tan x) (tan eps)) (- (pow 1 3) (pow (* (tan x) (tan eps)) 3))) (+ (* 1 1) (+ (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* 1 (* (tan x) (tan eps))))) (- (tan x)))
0.3b
(pow (* (tan x) (tan eps)) 3)
0.2b
(* (* (tan x) (tan eps)) (* (tan x) (tan eps)))
0.2b
(* (tan x) (tan eps))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 101
Calls

4 calls. Slowest were:

17.0ms
(* (* (tan x) (tan eps)) (* (tan x) (tan eps)))
4.0ms
(* (tan x) (tan eps))
3.0ms
(pow (* (tan x) (tan eps)) 3)

series1.3s

Counts
4 → 12
Calls

4 calls. Slowest were:

962.0ms
(fma (/ (+ (tan x) (tan eps)) (- (pow 1 3) (pow (* (tan x) (tan eps)) 3))) (+ (* 1 1) (+ (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* 1 (* (tan x) (tan eps))))) (- (tan x)))
145.0ms
(pow (* (tan x) (tan eps)) 3)
130.0ms
(* (* (tan x) (tan eps)) (* (tan x) (tan eps)))
112.0ms
(* (tan x) (tan eps))

simplify5.4s

Counts
83 → 113
Calls

83 calls. Slowest were:

721.0ms
(* (* (* (* (tan x) (tan x)) (tan x)) (* (* (tan eps) (tan eps)) (tan eps))) (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))))
648.0ms
(* (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))) (* (* (* (tan x) (tan x)) (tan x)) (* (* (tan eps) (tan eps)) (tan eps))))
582.0ms
(* (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))) (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))))

prune1.7s

Pruning

15 alts after pruning (15 fresh and 0 done)

Merged error: 16.8b

localize39.0ms

Local error

Found 4 expressions with local error:

3.0b
(fma (/ (+ (tan x) (tan eps)) (- (pow 1 3) (/ (pow (* (sin x) (tan eps)) 3) (pow (cos x) 3)))) (+ (* 1 1) (+ (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* 1 (* (tan x) (tan eps))))) (- (tan x)))
0.3b
(pow (cos x) 3)
0.3b
(pow (* (sin x) (tan eps)) 3)
0.2b
(* (* (tan x) (tan eps)) (* (tan x) (tan eps)))

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 98
Calls

4 calls. Slowest were:

26.0ms
(* (* (tan x) (tan eps)) (* (tan x) (tan eps)))
3.0ms
(pow (* (sin x) (tan eps)) 3)
1.0ms
(pow (cos x) 3)

series1.1s

Counts
4 → 12
Calls

4 calls. Slowest were:

866.0ms
(fma (/ (+ (tan x) (tan eps)) (- (pow 1 3) (/ (pow (* (sin x) (tan eps)) 3) (pow (cos x) 3)))) (+ (* 1 1) (+ (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* 1 (* (tan x) (tan eps))))) (- (tan x)))
107.0ms
(* (* (tan x) (tan eps)) (* (tan x) (tan eps)))
101.0ms
(pow (* (sin x) (tan eps)) 3)
21.0ms
(pow (cos x) 3)

simplify3.7s

Counts
78 → 110
Calls

78 calls. Slowest were:

502.0ms
(* (* (* (* (tan x) (tan x)) (tan x)) (* (* (tan eps) (tan eps)) (tan eps))) (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))))
438.0ms
(* (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))) (* (* (* (tan x) (tan x)) (tan x)) (* (* (tan eps) (tan eps)) (tan eps))))
411.0ms
(* (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))) (* (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* (tan x) (tan eps))))

prune1.6s

Pruning

15 alts after pruning (15 fresh and 0 done)

Merged error: 16.8b

regimes204.0ms

Accuracy

87.5% (0.9b remaining)

Error of 15.3b against oracle of 14.4b and baseline of 21.7b

bsearch243.0ms

end0.0ms

sample10.2s

Algorithm
intervals