Average Error: 37.0 → 0.4
Time: 38.0s
Precision: 64
Internal Precision: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\frac{\frac{\sin \varepsilon}{\cos \varepsilon} \cdot \left(\frac{\sin x}{\cos x} \cdot \sin x + \cos x\right)}{\left(1 - \tan \varepsilon \cdot \tan x\right) \cdot \cos x}\]

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.0
Target15.0
Herbie0.4
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Initial program 37.0

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

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

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

    \[\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. Taylor expanded around -inf 0.4

    \[\leadsto \frac{\color{blue}{\frac{{\left(\sin x\right)}^{2} \cdot \sin \varepsilon}{\cos x \cdot \cos \varepsilon} + \frac{\cos x \cdot \sin \varepsilon}{\cos \varepsilon}}}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\]
  8. Simplified0.4

    \[\leadsto \frac{\color{blue}{\frac{\sin \varepsilon}{\cos \varepsilon} \cdot \left(\sin x \cdot \frac{\sin x}{\cos x} + \cos x\right)}}{\left(1 - \tan x \cdot \tan \varepsilon\right) \cdot \cos x}\]
  9. Final simplification0.4

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

Reproduce

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

sample805.0ms

Algorithm
intervals
Results
256×(pre true 80)
115×(body real 1280)
60×(body real 640)
27×(body real 2560)
25×(body real 80)
17×(body real 320)
12×(body real 160)

simplify7.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
7.0ms
(- (tan (+ x eps)) (tan x))

prune8.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:

3.9b
(tan (+ x eps))
1.6b
(- (tan (+ x eps)) (tan x))

rewrite7.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
tan-quot
*-un-lft-identity
add-sqr-sqrt
add-cube-cbrt
frac-sub
add-exp-log
add-cbrt-cube
tan-sum
pow1
difference-of-squares
distribute-lft-out--
flip--
diff-log
flip3--
sub-neg
Counts
2 → 25
Calls
2 calls:
Slowest
5.0ms
(- (tan (+ x eps)) (tan x))
2.0ms
(tan (+ x eps))

series184.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
107.0ms
(- (tan (+ x eps)) (tan x))
76.0ms
(tan (+ x eps))

simplify624.0ms

Counts
15 → 31
Calls
15 calls:
Slowest
226.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
157.0ms
(+ (* x (pow eps 2)) (+ eps (* (pow x 2) eps)))
133.0ms
(* (- 1 (* (tan x) (tan eps))) (cos x))
32.0ms
(+ x (+ (* 1/3 (pow x 3)) eps))
24.0ms
(/ (exp (tan (+ x eps))) (exp (tan x)))

prune343.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 17.2b

localize32.0ms

Local error

Found 4 expressions with local error:

2.9b
(- (/ (+ (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
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))

rewrite52.0ms

Algorithm
rewrite-expression-head
Rules
27×*-un-lft-identity
20×add-sqr-sqrt
15×add-cube-cbrt
13×times-frac
tan-quot
add-log-exp
add-exp-log
add-cbrt-cube
pow1
distribute-lft-out
associate-/l*
associate-/l/
associate-*l*
associate-*r*
associate-/r*
difference-of-squares
flip--
flip-+
associate-/r/
frac-add
flip3--
flip3-+
distribute-lft-out--
div-inv
cbrt-unprod
frac-sub
*-commutative
associate-*r/
prod-exp
associate-*l/
pow-prod-down
div-exp
diff-log
frac-2neg
sub-neg
sum-log
clear-num
+-commutative
cbrt-undiv
frac-times
Counts
4 → 85
Calls
4 calls:
Slowest
28.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
12.0ms
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))
6.0ms
(+ (tan x) (tan eps))
4.0ms
(* (tan x) (tan eps))

series896.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
410.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
254.0ms
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))
135.0ms
(* (tan x) (tan eps))
96.0ms
(+ (tan x) (tan eps))

simplify2.8s

Counts
72 → 97
Calls
72 calls:
Slowest
316.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))
269.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)))))
262.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)))
261.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)))
215.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))

prune1.1s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 17.0b

localize14.0ms

Local error

Found 4 expressions with local error:

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

rewrite31.0ms

Algorithm
rewrite-expression-head
Rules
40×*-un-lft-identity
25×add-sqr-sqrt
24×times-frac
23×add-cube-cbrt
23×associate-/r*
11×add-exp-log
tan-quot
add-cbrt-cube
distribute-lft-out
associate-/r/
pow1
add-log-exp
div-inv
associate-/l*
associate-*l*
associate-*r*
associate-/l/
distribute-lft-out--
flip--
flip-+
frac-add
div-exp
flip3--
flip3-+
frac-2neg
clear-num
rec-exp
difference-of-squares
inv-pow
pow-flip
cbrt-unprod
frac-sub
*-commutative
associate-*r/
prod-exp
associate-*l/
pow-prod-down
div-sub
diff-log
sub-neg
cbrt-undiv
frac-times
Counts
4 → 107
Calls
4 calls:
Slowest
13.0ms
(/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))
8.0ms
(- (/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))) (tan x))
4.0ms
(* (tan x) (tan eps))
4.0ms
(/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps))))

series1.1s

Counts
4 → 12
Calls
4 calls:
Slowest
406.0ms
(- (/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))) (tan x))
354.0ms
(/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))
250.0ms
(/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps))))
87.0ms
(* (tan x) (tan eps))

simplify5.1s

Counts
90 → 119
Calls
90 calls:
Slowest
353.0ms
(/ (* (* (- 1 (* (tan x) (tan eps))) (- 1 (* (tan x) (tan eps)))) (- 1 (* (tan x) (tan eps)))) (* (* (+ (tan x) (tan eps)) (+ (tan x) (tan eps))) (+ (tan x) (tan eps))))
322.0ms
(/ (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))) (+ (/ (sin eps) (cos eps)) (/ (sin x) (cos x))))
305.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)))
295.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)))
261.0ms
(- (pow 1 3) (pow (* (tan x) (tan eps)) 3))

prune1.4s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 17.0b

localize42.0ms

Local error

Found 4 expressions with local error:

8.0b
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
0.2b
(* (tan x) (tan eps))
0.2b
(* (tan x) (tan eps))
0.2b
(* (+ (tan x) (tan eps)) (cos x))

rewrite58.0ms

Algorithm
rewrite-expression-head
Rules
17×associate-*l/
14×tan-quot
12×*-un-lft-identity
10×add-cube-cbrt
10×add-exp-log
10×associate-*l*
10×add-cbrt-cube
10×pow1
10×add-sqr-sqrt
associate-*r*
add-log-exp
frac-sub
flip--
flip3--
flip-+
cbrt-unprod
*-commutative
prod-exp
frac-add
pow-prod-down
flip3-+
associate-*r/
frac-times
distribute-lft-out
diff-log
sub-neg
Counts
4 → 79
Calls
4 calls:
Slowest
21.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
15.0ms
(* (+ (tan x) (tan eps)) (cos x))
13.0ms
(* (tan x) (tan eps))
8.0ms
(* (tan x) (tan eps))

series564.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
210.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
131.0ms
(* (+ (tan x) (tan eps)) (cos x))
127.0ms
(* (tan x) (tan eps))
96.0ms
(* (tan x) (tan eps))

simplify5.3s

Counts
60 → 91
Calls
60 calls:
Slowest
402.0ms
(* (* (cos x) (cos eps)) (+ (* 1 1) (+ (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* 1 (* (tan x) (tan eps))))))
391.0ms
(* (- (* (tan x) (tan x)) (* (tan eps) (tan eps))) (cos x))
382.0ms
(* (* (* (+ (tan x) (tan eps)) (+ (tan x) (tan eps))) (+ (tan x) (tan eps))) (* (* (cos x) (cos x)) (cos x)))
334.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))
325.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))

prune1.5s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.2b

regimes169.0ms

Accuracy

0% (0.3b remaining)

Error of 0.4b against oracle of 0.2b and baseline of 0.4b

bsearch4.0ms

end0.0ms

sample14.6s

Algorithm
intervals
Results
8000×(pre true 80)
3314×(body real 1280)
1793×(body real 640)
1090×(body real 80)
769×(body real 320)
664×(body real 2560)
370×(body real 160)