Average Error: 37.2 → 15.4
Time: 33.3s
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{\cos x \cdot \left(\tan \varepsilon + \tan x\right) - \left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\ \mathbf{else}:\\ \;\;\;\;\varepsilon + \left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus eps

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original37.2
Target15.6
Herbie15.4
\[\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-quot30.5

      \[\leadsto \tan \left(x + \varepsilon\right) - \color{blue}{\frac{\sin x}{\cos x}}\]
    4. Applied tan-sum4.8

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \frac{\sin x}{\cos x}\]
    5. 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}}\]

    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}{\varepsilon + \left(x \cdot \varepsilon\right) \cdot \left(\varepsilon + x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification15.4

    \[\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{\cos x \cdot \left(\tan \varepsilon + \tan x\right) - \left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \sin x}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\\ \mathbf{else}:\\ \;\;\;\;\varepsilon + \left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 
(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: 31.4s)Debug log

sample431.0ms

Algorithm
intervals

simplify4.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 38.3b

localize21.0ms

Local error

Found 2 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
2 → 25
Calls

2 calls. Slowest were:

11.0ms
(- (tan (+ x eps)) (tan x))
3.0ms
(tan (+ x eps))

series198.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

116.0ms
(tan (+ x eps))
82.0ms
(- (tan (+ x eps)) (tan x))

simplify467.0ms

Counts
15 → 31
Calls

15 calls. Slowest were:

142.0ms
(+ (* x (pow eps 2)) (+ eps (* (pow x 2) eps)))
141.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
102.0ms
(* (- 1 (* (tan x) (tan eps))) (cos x))

prune349.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 16.9b

localize27.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)))

rewrite50.0ms

Algorithm
rewrite-expression-head
Counts
4 → 60
Calls

4 calls. Slowest were:

31.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
8.0ms
(* (tan x) (tan eps))
7.0ms
(+ (tan x) (tan eps))

series728.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

378.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
120.0ms
(+ (tan x) (tan eps))
117.0ms
(* (tan x) (tan eps))
113.0ms
(- 1 (* (tan x) (tan eps)))

simplify2.1s

Counts
36 → 72
Calls

36 calls. Slowest were:

397.0ms
(- 1 (+ (* 1/3 (* (pow x 3) eps)) (* x eps)))
263.0ms
(- (+ (/ (sin eps) (* (cos eps) (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))))) (/ (sin x) (* (cos x) (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps))))))) (/ (sin x) (cos x)))
262.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))

prune947.0ms

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 16.8b

localize25.0ms

Local error

Found 4 expressions with local error:

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

rewrite61.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

45.0ms
(- (/ (+ (tan x) (tan eps)) (log (exp (- 1 (* (tan x) (tan eps)))))) (tan x))
8.0ms
(* (tan x) (tan eps))
4.0ms
(exp (- 1 (* (tan x) (tan eps))))

series738.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

367.0ms
(- (/ (+ (tan x) (tan eps)) (log (exp (- 1 (* (tan x) (tan eps)))))) (tan x))
150.0ms
(exp (- 1 (* (tan x) (tan eps))))
118.0ms
(log (exp (- 1 (* (tan x) (tan eps)))))
103.0ms
(* (tan x) (tan eps))

simplify3.2s

Counts
48 → 80
Calls

48 calls. Slowest were:

356.0ms
(- 1 (+ (* 1/3 (* (pow x 3) eps)) (* x eps)))
317.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (log (exp (- 1 (* (tan x) (tan eps))))) (sin x)))
290.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))

prune1.2s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 16.8b

localize2.0ms

Local error

Found 4 expressions with local error:

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

rewrite54.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

43.0ms
(- (/ (+ (tan x) (tan eps)) (log (exp (- 1 (* (tan x) (tan eps)))))) (tan x))
4.0ms
(* (tan x) (tan eps))
3.0ms
(exp (- 1 (* (tan x) (tan eps))))

series723.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

355.0ms
(- (/ (+ (tan x) (tan eps)) (log (exp (- 1 (* (tan x) (tan eps)))))) (tan x))
146.0ms
(exp (- 1 (* (tan x) (tan eps))))
125.0ms
(log (exp (- 1 (* (tan x) (tan eps)))))
96.0ms
(* (tan x) (tan eps))

simplify3.2s

Counts
48 → 80
Calls

48 calls. Slowest were:

456.0ms
(- 1 (+ (* 1/3 (* (pow x 3) eps)) (* x eps)))
351.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (log (exp (- 1 (* (tan x) (tan eps))))) (sin x)))
290.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))

prune1.2s

Pruning

16 alts after pruning (15 fresh and 1 done)

Merged error: 16.8b

regimes332.0ms

Accuracy

87.5% (0.9b remaining)

Error of 15.4b against oracle of 14.4b and baseline of 21.8b

bsearch731.0ms

end0.0ms

sample14.6s

Algorithm
intervals