Average Error: 37.2 → 15.4
Time: 40.0s
Precision: 64
Internal Precision: 128
\[\tan \left(x + \varepsilon\right) - \tan x\]
\[\begin{array}{l} \mathbf{if}\;\varepsilon \le -5.381143162538014 \cdot 10^{-10}:\\ \;\;\;\;\frac{1}{\frac{1}{\tan x + \tan \varepsilon} - \frac{\frac{\sin x \cdot \tan \varepsilon}{\cos x}}{\tan x + \tan \varepsilon}} - \tan x\\ \mathbf{elif}\;\varepsilon \le 2.0047394400257063 \cdot 10^{-27}:\\ \;\;\;\;\varepsilon + \left(x \cdot \varepsilon\right) \cdot \left(\varepsilon + x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\frac{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}}{\tan x + \tan \varepsilon}} \cdot \frac{1}{\frac{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}}{\tan x + \tan \varepsilon}} - \tan x \cdot \tan x}{\frac{1}{\frac{1 - \frac{\sin x \cdot \tan \varepsilon}{\cos x}}{\tan x + \tan \varepsilon}} + \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

Original37.2
Target14.8
Herbie15.4
\[\frac{\sin \varepsilon}{\cos x \cdot \cos \left(x + \varepsilon\right)}\]

Derivation

  1. Split input into 3 regimes
  2. if eps < -5.381143162538014e-10

    1. Initial program 29.9

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.5

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\tan x + \tan \varepsilon\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    6. Applied associate-/l*0.6

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x\]
    7. Using strategy rm
    8. Applied tan-quot0.6

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}} - \tan x\]
    9. Applied associate-*l/0.6

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sin x \cdot \tan \varepsilon}{\cos x}}}{\tan x + \tan \varepsilon}} - \tan x\]
    10. Using strategy rm
    11. Applied div-sub0.7

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

    if -5.381143162538014e-10 < eps < 2.0047394400257063e-27

    1. Initial program 45.6

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Using strategy rm
    5. Applied *-un-lft-identity45.5

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\tan x + \tan \varepsilon\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    6. Applied associate-/l*45.7

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

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}} - \tan x\]
    9. Applied associate-*l/45.7

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sin x \cdot \tan \varepsilon}{\cos x}}}{\tan x + \tan \varepsilon}} - \tan x\]
    10. Taylor expanded around 0 30.9

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

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

    if 2.0047394400257063e-27 < eps

    1. Initial program 29.1

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

      \[\leadsto \color{blue}{\frac{\tan x + \tan \varepsilon}{1 - \tan x \cdot \tan \varepsilon}} - \tan x\]
    4. Using strategy rm
    5. Applied *-un-lft-identity1.9

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\tan x + \tan \varepsilon\right)}}{1 - \tan x \cdot \tan \varepsilon} - \tan x\]
    6. Applied associate-/l*2.0

      \[\leadsto \color{blue}{\frac{1}{\frac{1 - \tan x \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}}} - \tan x\]
    7. Using strategy rm
    8. Applied tan-quot2.0

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sin x}{\cos x}} \cdot \tan \varepsilon}{\tan x + \tan \varepsilon}} - \tan x\]
    9. Applied associate-*l/2.0

      \[\leadsto \frac{1}{\frac{1 - \color{blue}{\frac{\sin x \cdot \tan \varepsilon}{\cos x}}}{\tan x + \tan \varepsilon}} - \tan x\]
    10. Using strategy rm
    11. Applied flip--2.2

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

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

Reproduce

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

sample419.0ms

Algorithm
intervals
Results
224.0ms107×body1280valid
80.0ms63×body640valid
73.0ms23×body2560valid
18.0ms21×body320valid
9.0ms17×body160valid
6.0ms25×body80valid

simplify32.0ms

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

prune15.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 40.1b

localize23.0ms

Local error

Found 2 expressions with local error:

3.6b
(tan (+ x eps))
1.4b
(- (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))
1.0ms
(tan (+ x eps))

series174.0ms

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

simplify582.0ms

Counts
15 → 31
Calls
15 calls:
Slowest
198.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
137.0ms
(+ (* x (pow eps 2)) (+ eps (* (pow x 2) eps)))
121.0ms
(* (- 1 (* (tan x) (tan eps))) (cos x))
34.0ms
(+ x (+ (* 1/3 (pow x 3)) eps))
24.0ms
(/ (exp (tan (+ x eps))) (exp (tan x)))

prune373.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 15.6b

localize33.0ms

Local error

Found 4 expressions with local error:

2.8b
(- (/ (+ (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))))

rewrite49.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))))
4.0ms
(* (tan x) (tan eps))
3.0ms
(+ (tan x) (tan eps))

series887.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
424.0ms
(- (/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps)))) (tan x))
258.0ms
(/ (+ (tan x) (tan eps)) (- 1 (* (tan x) (tan eps))))
106.0ms
(* (tan x) (tan eps))
99.0ms
(+ (tan x) (tan eps))

simplify2.6s

Counts
72 → 97
Calls
72 calls:
Slowest
295.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)))))
277.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))
224.0ms
(- (* (+ (tan x) (tan eps)) (cos x)) (* (- 1 (* (tan x) (tan eps))) (sin x)))
218.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)))
216.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)))

prune1.1s

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 15.5b

localize17.0ms

Local error

Found 4 expressions with local error:

7.6b
(- (/ 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))))

rewrite20.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
7.0ms
(/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))
4.0ms
(- (/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))) (tan x))
4.0ms
(* (tan x) (tan eps))
3.0ms
(/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps))))

series1.0s

Counts
4 → 12
Calls
4 calls:
Slowest
409.0ms
(- (/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))) (tan x))
282.0ms
(/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps)))
244.0ms
(/ 1 (/ (- 1 (* (tan x) (tan eps))) (+ (tan x) (tan eps))))
103.0ms
(* (tan x) (tan eps))

simplify4.7s

Counts
90 → 119
Calls
90 calls:
Slowest
338.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))))
278.0ms
(- (pow 1 3) (pow (* (tan x) (tan eps)) 3))
263.0ms
(/ (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))) (+ (/ (sin eps) (cos eps)) (/ (sin x) (cos x))))
253.0ms
(+ (* 1/3 (* (pow x 3) eps)) (+ (* 1/3 (* x (pow eps 3))) (* x eps)))
247.0ms
(/ (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))) (+ (/ (sin eps) (cos eps)) (/ (sin x) (cos x))))

prune1.4s

Pruning

14 alts after pruning (14 fresh and 0 done)

Merged error: 15.4b

localize48.0ms

Local error

Found 4 expressions with local error:

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

rewrite43.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
add-cbrt-cube
distribute-lft-out
associate-/r/
pow1
add-log-exp
tan-quot
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
pow-prod-down
div-sub
diff-log
sub-neg
cbrt-undiv
Counts
4 → 105
Calls
4 calls:
Slowest
18.0ms
(/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps)))
8.0ms
(- (/ 1 (/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps)))) (tan x))
8.0ms
(/ 1 (/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps))))
7.0ms
(* (sin x) (tan eps))

series1.1s

Counts
4 → 12
Calls
4 calls:
Slowest
421.0ms
(- (/ 1 (/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps)))) (tan x))
320.0ms
(/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps)))
266.0ms
(/ 1 (/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps))))
70.0ms
(* (sin x) (tan eps))

simplify7.7s

Counts
87 → 117
Calls
87 calls:
Slowest
692.0ms
(/ (* (* (- 1 (/ (* (sin x) (tan eps)) (cos x))) (- 1 (/ (* (sin x) (tan eps)) (cos x)))) (- 1 (/ (* (sin x) (tan eps)) (cos x)))) (* (* (+ (tan x) (tan eps)) (+ (tan x) (tan eps))) (+ (tan x) (tan eps))))
339.0ms
(/ (exp (/ 1 (/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps))))) (exp (tan x)))
336.0ms
(/ (- 1 (/ (* (sin x) (sin eps)) (* (cos x) (cos eps)))) (+ (/ (sin eps) (cos eps)) (/ (sin x) (cos x))))
278.0ms
(- (/ 1 (/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps)))) (tan x))
274.0ms
(- (/ 1 (/ (- 1 (/ (* (sin x) (tan eps)) (cos x))) (+ (tan x) (tan eps)))) (tan x))

prune1.5s

Pruning

15 alts after pruning (15 fresh and 0 done)

Merged error: 15.4b

regimes384.0ms

Accuracy

89.8% (0.8b remaining)

Error of 15.4b against oracle of 14.6b and baseline of 22.4b

bsearch295.0ms

end0.0ms

sample14.2s

Algorithm
intervals
Results
7.3s3285×body1280valid
3.0s638×body2560valid
2.4s1830×body640valid
895.0ms801×body320valid
327.0ms1079×body80valid
179.0ms367×body160valid