Average Error: 36.9 → 15.1
Time: 1.0m
Precision: 64
Internal Precision: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -2.5404406310779434 \cdot 10^{-12}:\\ \;\;\;\;\frac{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} \cdot \frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x \cdot \tan x}{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} + \tan x}\\ \mathbf{elif}\;\varepsilon \le 4.8213180199108696 \cdot 10^{-67}:\\ \;\;\;\;\left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \frac{{\left(\sin \varepsilon\right)}^{3} \cdot {\left(\sin x\right)}^{3}}{{\left(\cos \varepsilon\right)}^{3} \cdot {\left(\cos x\right)}^{3}}} \cdot \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) + \left(\tan x \cdot \tan \varepsilon + 1\right)\right) - \tan x\\ \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

Original36.9
Target14.9
Herbie15.1
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if eps < -2.5404406310779434e-12

    1. Initial program 28.4

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

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

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

    if -2.5404406310779434e-12 < eps < 4.8213180199108696e-67

    1. Initial program 46.4

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

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

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{{1}^{3} - {\left(\tan x \cdot \tan \varepsilon\right)}^{3}} \cdot \left(1 \cdot 1 + \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) + 1 \cdot \left(\tan x \cdot \tan \varepsilon\right)\right)\right)} - \tan x\]
    7. Simplified46.2

      \[\leadsto \frac{\tan x + \tan \varepsilon}{{1}^{3} - {\left(\tan x \cdot \tan \varepsilon\right)}^{3}} \cdot \color{blue}{\left(\left(1 + \tan \varepsilon \cdot \tan x\right) + \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)\right)} - \tan x\]
    8. Taylor expanded around 0 30.5

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

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

    if 4.8213180199108696e-67 < eps

    1. Initial program 30.2

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

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

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

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

      \[\leadsto \frac{\tan x + \tan \varepsilon}{{1}^{3} - {\left(\tan x \cdot \tan \varepsilon\right)}^{3}} \cdot \color{blue}{\left(\left(1 + \tan \varepsilon \cdot \tan x\right) + \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)\right)} - \tan x\]
    8. Taylor expanded around inf 4.9

      \[\leadsto \frac{\tan x + \tan \varepsilon}{{1}^{3} - \color{blue}{\frac{{\left(\sin x\right)}^{3} \cdot {\left(\sin \varepsilon\right)}^{3}}{{\left(\cos x\right)}^{3} \cdot {\left(\cos \varepsilon\right)}^{3}}}} \cdot \left(\left(1 + \tan \varepsilon \cdot \tan x\right) + \left(\tan \varepsilon \cdot \tan x\right) \cdot \left(\tan \varepsilon \cdot \tan x\right)\right) - \tan x\]
  3. Recombined 3 regimes into one program.
  4. Final simplification15.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\varepsilon \le -2.5404406310779434 \cdot 10^{-12}:\\ \;\;\;\;\frac{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} \cdot \frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} - \tan x \cdot \tan x}{\frac{\tan \varepsilon + \tan x}{1 - \tan x \cdot \tan \varepsilon} + \tan x}\\ \mathbf{elif}\;\varepsilon \le 4.8213180199108696 \cdot 10^{-67}:\\ \;\;\;\;\left(x \cdot \varepsilon\right) \cdot \left(x + \varepsilon\right) + \varepsilon\\ \mathbf{else}:\\ \;\;\;\;\frac{\tan \varepsilon + \tan x}{1 - \frac{{\left(\sin \varepsilon\right)}^{3} \cdot {\left(\sin x\right)}^{3}}{{\left(\cos \varepsilon\right)}^{3} \cdot {\left(\cos x\right)}^{3}}} \cdot \left(\left(\tan x \cdot \tan \varepsilon\right) \cdot \left(\tan x \cdot \tan \varepsilon\right) + \left(\tan x \cdot \tan \varepsilon + 1\right)\right) - \tan x\\ \end{array}\]

Reproduce

herbie shell --seed 2019002 
(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: 1.0m)Debug log

sample424.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: 35.3b

localize43.0ms

Local error

Found 2 expressions with local error:

3.3b
(tan (+ x eps))
1.1b
(- (tan (+ x eps)) (tan x))

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
2 → 25
Calls

2 calls. Slowest were:

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

series180.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

129.0ms
(- (tan (+ x eps)) (tan x))
51.0ms
(tan (+ x eps))

simplify599.0ms

Counts
15 → 31
Calls

15 calls. Slowest were:

198.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
150.0ms
(+ (* x (pow eps 2)) (+ eps (* (pow x 2) eps)))
124.0ms
(* (- 1 (* (tan x) (tan eps))) (cos x))

prune416.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 14.1b

localize37.0ms

Local error

Found 4 expressions with local error:

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

rewrite90.0ms

Algorithm
rewrite-expression-head
Counts
4 → 85
Calls

4 calls. Slowest were:

49.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
23.0ms
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))
9.0ms
(* (tan x) (tan eps))

series928.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

422.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
238.0ms
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))
136.0ms
(* (tan x) (tan eps))
131.0ms
(+ (tan x) (tan eps))

simplify2.9s

Counts
72 → 97
Calls

72 calls. Slowest were:

304.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))
280.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)))
279.0ms
(/ (* (* (+ (tan x) (tan eps)) (+ (tan x) (tan eps))) (+ (tan x) (tan eps))) (* (* (- 1 (* (tan x) (tan eps))) (- 1 (* (tan x) (tan eps)))) (- 1 (* (tan x) (tan eps)))))

prune1.2s

Pruning

18 alts after pruning (18 fresh and 0 done)

Merged error: 13.9b

localize56.0ms

Local error

Found 4 expressions with local error:

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

rewrite113.0ms

Algorithm
rewrite-expression-head
Counts
4 → 140
Calls

4 calls. Slowest were:

93.0ms
(- (* (/ (+ (tan x) (tan eps)) (- (pow 1 3) (pow (* (tan x) (tan eps)) 3))) (+ (+ 1 (* (tan eps) (tan x))) (* (* (tan eps) (tan x)) (* (tan eps) (tan x))))) (tan x))
6.0ms
(* (tan x) (tan eps))
6.0ms
(pow (* (tan x) (tan eps)) 3)

series2.0s

Counts
4 → 12
Calls

4 calls. Slowest were:

1.6s
(- (* (/ (+ (tan x) (tan eps)) (- (pow 1 3) (pow (* (tan x) (tan eps)) 3))) (+ (+ 1 (* (tan eps) (tan x))) (* (* (tan eps) (tan x)) (* (tan eps) (tan x))))) (tan x))
129.0ms
(pow (* (tan x) (tan eps)) 3)
107.0ms
(* (tan eps) (tan x))
106.0ms
(* (tan x) (tan eps))

simplify33.5s

Counts
180 → 152
Calls

180 calls. Slowest were:

683.0ms
(- (* (* (+ (tan x) (tan eps)) (+ (* (+ (pow 1 3) (pow (* (tan eps) (tan x)) 3)) (* (cos eps) (cos eps))) (* (+ (* 1 1) (- (* (* (tan eps) (tan x)) (* (tan eps) (tan x))) (* 1 (* (tan eps) (tan x))))) (* (* (sin eps) (tan x)) (* (sin eps) (tan x)))))) (cos x)) (* (* (- (pow 1 3) (pow (* (tan x) (tan eps)) 3)) (* (+ (* 1 1) (- (* (* (tan eps) (tan x)) (* (tan eps) (tan x))) (* 1 (* (tan eps) (tan x))))) (* (cos eps) (cos eps)))) (sin x)))
571.0ms
(- (* (* (/ (+ (tan x) (tan eps)) (- (pow 1 3) (pow (* (tan x) (tan eps)) 3))) (+ (* (+ (pow 1 3) (pow (* (tan eps) (tan x)) 3)) (* (cos x) (cos eps))) (* (+ (* 1 1) (- (* (* (tan eps) (tan x)) (* (tan eps) (tan x))) (* 1 (* (tan eps) (tan x))))) (* (* (tan eps) (sin x)) (* (sin eps) (tan x)))))) (cos x)) (* (* (+ (* 1 1) (- (* (* (tan eps) (tan x)) (* (tan eps) (tan x))) (* 1 (* (tan eps) (tan x))))) (* (cos x) (cos eps))) (sin x)))
531.0ms
(* (* (- (pow 1 3) (pow (* (tan x) (tan eps)) 3)) (* (- 1 (* (tan eps) (tan x))) (* (cos x) (* (cos eps) (cos x))))) (cos x))

prune2.0s

Pruning

20 alts after pruning (20 fresh and 0 done)

Merged error: 13.9b

localize19.0ms

Local error

Found 4 expressions with local error:

2.6b
(- (/ (+ (tan x) (tan eps)) (- 1 (/ (* (sin x) (tan eps)) (cos x)))) (tan x))
0.2b
(* (sin x) (tan eps))
0.2b
(/ (* (sin x) (tan eps)) (cos x))
0.1b
(/ (+ (tan x) (tan eps)) (- 1 (/ (* (sin x) (tan eps)) (cos x))))

rewrite55.0ms

Algorithm
rewrite-expression-head
Counts
4 → 92
Calls

4 calls. Slowest were:

32.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (/ (* (sin x) (tan eps)) (cos x)))) (tan x))
12.0ms
(/ (+ (tan x) (tan eps)) (- 1 (/ (* (sin x) (tan eps)) (cos x))))
7.0ms
(/ (* (sin x) (tan eps)) (cos x))

series647.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

309.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (/ (* (sin x) (tan eps)) (cos x)))) (tan x))
184.0ms
(/ (+ (tan x) (tan eps)) (- 1 (/ (* (sin x) (tan eps)) (cos x))))
87.0ms
(/ (* (sin x) (tan eps)) (cos x))
67.0ms
(* (sin x) (tan eps))

simplify3.7s

Counts
80 → 104
Calls

80 calls. Slowest were:

393.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)))
360.0ms
(/ (* (* (* (sin x) (tan eps)) (* (sin x) (tan eps))) (* (sin x) (tan eps))) (* (* (cos x) (cos x)) (cos x)))
343.0ms
(/ (* (* (* (sin x) (sin x)) (sin x)) (* (* (tan eps) (tan eps)) (tan eps))) (* (* (cos x) (cos x)) (cos x)))

prune820.0ms

Pruning

19 alts after pruning (19 fresh and 0 done)

Merged error: 13.9b

regimes272.0ms

Accuracy

88.8% (0.9b remaining)

Error of 15.1b against oracle of 14.2b and baseline of 22.0b

bsearch320.0ms

end0.0ms

sample10.0s

Algorithm
intervals