Average Error: 37.7 → 0.4
Time: 55.1s
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.7
Target15.5
Herbie0.4
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Initial program 37.7

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

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

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

    \[\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 1042149663 
(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: 52.5s)Debug log

sample621.0ms

Algorithm
intervals
Results
256×(pre true 80)
100×(body real 1280)
63×(body real 640)
36×(body real 80)
25×(body real 320)
19×(body real 2560)
13×(body real 160)

simplify43.0ms

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

prune17.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 37.3b

localize35.0ms

Local error

Found 2 expressions with local error:

3.1b
(tan (+ x eps))
2.2b
(- (tan (+ x eps)) (tan x))

rewrite17.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
13.0ms
(- (tan (+ x eps)) (tan x))
3.0ms
(tan (+ x eps))

series245.0ms

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

simplify857.0ms

Counts
15 → 31
Calls
15 calls:
Slowest
286.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
193.0ms
(* (- 1 (* (tan x) (tan eps))) (cos x))
192.0ms
(+ (* x (pow eps 2)) (+ eps (* (pow x 2) eps)))
64.0ms
(+ x (+ (* 1/3 (pow x 3)) eps))
30.0ms
(/ (exp (tan (+ x eps))) (exp (tan x)))

prune498.0ms

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 13.7b

localize48.0ms

Local error

Found 4 expressions with local error:

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

rewrite106.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
60.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
27.0ms
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))
9.0ms
(* (tan x) (tan eps))
8.0ms
(+ (tan x) (tan eps))

series1.3s

Counts
4 → 12
Calls
4 calls:
Slowest
624.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
371.0ms
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))
165.0ms
(* (tan x) (tan eps))
164.0ms
(+ (tan x) (tan eps))

simplify4.1s

Counts
72 → 97
Calls
72 calls:
Slowest
456.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))
431.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)))))
356.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)))
355.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)))
290.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))

prune1.7s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 13.6b

localize98.0ms

Local error

Found 4 expressions with local error:

7.4b
(- (/ (+ (/ (sin eps) (cos eps)) (/ (sin x) (cos x))) (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps))))) (tan x))
0.3b
(/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))
0.2b
(* (sin x) (sin eps))
0.2b
(/ (sin eps) (cos eps))

rewrite220.0ms

Algorithm
rewrite-expression-head
Rules
20×add-exp-log
20×add-cbrt-cube
19×add-sqr-sqrt
16×*-un-lft-identity
14×add-cube-cbrt
11×times-frac
add-log-exp
pow1
cbrt-unprod
prod-exp
div-exp
cbrt-undiv
associate-/l*
associate-/r*
associate-*l*
associate-*r*
difference-of-squares
sin-mult
div-inv
frac-2neg
clear-num
associate-/l/
distribute-lft-out--
flip--
frac-sub
*-commutative
cos-mult
associate-/r/
tan-quot
pow-prod-down
diff-log
flip3--
sub-neg
quot-tan
Counts
4 → 85
Calls
4 calls:
Slowest
185.0ms
(- (/ (+ (/ (sin eps) (cos eps)) (/ (sin x) (cos x))) (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps))))) (tan x))
18.0ms
(/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))
8.0ms
(* (sin x) (sin eps))
7.0ms
(/ (sin eps) (cos eps))

series995.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
687.0ms
(- (/ (+ (/ (sin eps) (cos eps)) (/ (sin x) (cos x))) (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps))))) (tan x))
177.0ms
(/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))
90.0ms
(* (sin x) (sin eps))
42.0ms
(/ (sin eps) (cos eps))

simplify6.0s

Counts
67 → 97
Calls
67 calls:
Slowest
458.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))
365.0ms
(/ (* (* (* (sin x) (sin x)) (sin x)) (* (* (sin eps) (sin eps)) (sin eps))) (* (* (* (cos x) (cos x)) (cos x)) (* (* (cos eps) (cos eps)) (cos eps))))
354.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)))
352.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)))
326.0ms
(/ (* (* (* (sin x) (sin x)) (sin x)) (* (* (sin eps) (sin eps)) (sin eps))) (* (* (* (cos x) (cos eps)) (* (cos x) (cos eps))) (* (cos x) (cos eps))))

prune2.3s

Pruning

16 alts after pruning (16 fresh and 0 done)

Merged error: 12.7b

localize39.0ms

Local error

Found 4 expressions with local error:

8.6b
(- (* (+ (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))

rewrite63.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
24.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
19.0ms
(* (+ (tan x) (tan eps)) (cos x))
9.0ms
(* (tan x) (tan eps))
9.0ms
(* (tan x) (tan eps))

series900.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
364.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
202.0ms
(* (+ (tan x) (tan eps)) (cos x))
168.0ms
(* (tan x) (tan eps))
166.0ms
(* (tan x) (tan eps))

simplify8.1s

Counts
60 → 91
Calls
60 calls:
Slowest
865.0ms
(* (- (tan x) (tan eps)) (+ (* 1 1) (+ (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* 1 (* (tan x) (tan eps))))))
629.0ms
(* (* (* (+ (tan x) (tan eps)) (+ (tan x) (tan eps))) (+ (tan x) (tan eps))) (* (* (cos x) (cos x)) (cos x)))
619.0ms
(* (* (cos x) (cos eps)) (+ (* 1 1) (+ (* (* (tan x) (tan eps)) (* (tan x) (tan eps))) (* 1 (* (tan x) (tan eps))))))
513.0ms
(* (- (* (tan x) (tan x)) (* (tan eps) (tan eps))) (cos x))
458.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))

prune2.0s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 0.1b

regimes299.0ms

Accuracy

0% (0.3b remaining)

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

bsearch5.0ms

end0.0ms

sample21.8s

Algorithm
intervals
Results
8000×(pre true 80)
3248×(body real 1280)
1840×(body real 640)
1092×(body real 80)
825×(body real 320)
644×(body real 2560)
351×(body real 160)