Average Error: 31.7 → 0.0
Time: 35.9s
Precision: 64
Internal Precision: 128
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.027951512842069898:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02594659916186999:\\ \;\;\;\;\frac{9}{40} \cdot {x}^{2} - \left(\frac{1}{2} + \frac{27}{2800} \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x - \tan x}}{\frac{1}{x - \sin x}}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if x < -0.027951512842069898

    1. Initial program 0.0

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied div-sub0.0

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]

    if -0.027951512842069898 < x < 0.02594659916186999

    1. Initial program 62.7

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied div-sub62.6

      \[\leadsto \color{blue}{\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}}\]
    4. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\frac{9}{40} \cdot {x}^{2} - \left(\frac{27}{2800} \cdot {x}^{4} + \frac{1}{2}\right)}\]

    if 0.02594659916186999 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.1

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x - \sin x\right)}}{x - \tan x}\]
    4. Applied associate-/l*0.1

      \[\leadsto \color{blue}{\frac{1}{\frac{x - \tan x}{x - \sin x}}}\]
    5. Using strategy rm
    6. Applied div-inv0.2

      \[\leadsto \frac{1}{\color{blue}{\left(x - \tan x\right) \cdot \frac{1}{x - \sin x}}}\]
    7. Applied associate-/r*0.1

      \[\leadsto \color{blue}{\frac{\frac{1}{x - \tan x}}{\frac{1}{x - \sin x}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.027951512842069898:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02594659916186999:\\ \;\;\;\;\frac{9}{40} \cdot {x}^{2} - \left(\frac{1}{2} + \frac{27}{2800} \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x - \tan x}}{\frac{1}{x - \sin x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019021 
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  (/ (- x (sin x)) (- x (tan x))))

Details

Time bar (total: 35.0s)Debug log

sample545.0ms

Algorithm
intervals
Results
191.0ms48×body2560valid
152.0ms79×body1280valid
67.0ms71×body640valid
17.0ms30×body320valid
11.0ms17×body160valid
3.0ms11×body80valid

simplify42.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
41.0ms
(/ (- x (sin x)) (- x (tan x)))

prune14.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.6b

localize31.0ms

Local error

Found 3 expressions with local error:

1.8b
(- x (sin x))
1.8b
(- x (tan x))
0.0b
(/ (- x (sin x)) (- x (tan x)))

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
times-frac
add-exp-log
add-cbrt-cube
flip--
flip3--
add-log-exp
associate-/l*
associate-/r*
pow1
associate-/l/
associate-/r/
sub-neg
div-inv
div-exp
div-sub
frac-2neg
clear-num
cbrt-undiv
Counts
3 → 54
Calls
3 calls:
Slowest
6.0ms
(/ (- x (sin x)) (- x (tan x)))
3.0ms
(- x (sin x))
1.0ms
(- x (tan x))

series229.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
86.0ms
(/ (- x (sin x)) (- x (tan x)))
78.0ms
(- x (tan x))
65.0ms
(- x (sin x))

simplify1.1s

Counts
39 → 63
Calls
39 calls:
Slowest
220.0ms
(- (+ 1 (+ (/ (pow (sin x) 2) (* (pow (cos x) 2) (pow x 2))) (/ (sin x) (* (cos x) x)))) (+ (/ (sin x) x) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))
178.0ms
(- (+ 1 (+ (/ (pow (sin x) 2) (* (pow (cos x) 2) (pow x 2))) (/ (sin x) (* (cos x) x)))) (+ (/ (sin x) x) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))
170.0ms
(/ (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
99.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
68.0ms
(- (+ (* 1/6 (pow x 3)) (* 1/5040 (pow x 7))) (* 1/120 (pow x 5)))

prune612.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

localize6.0ms

Local error

Found 4 expressions with local error:

1.8b
(- x (sin x))
1.8b
(- x (tan x))
0.0b
(/ 1 (/ (- x (tan x)) (- x (sin x))))
0.0b
(/ (- x (tan x)) (- x (sin x)))

rewrite8.0ms

Algorithm
rewrite-expression-head
Rules
19×add-cube-cbrt
19×*-un-lft-identity
19×add-sqr-sqrt
18×times-frac
18×associate-/r*
add-exp-log
add-cbrt-cube
flip--
associate-/r/
flip3--
pow1
add-log-exp
associate-/l*
div-inv
associate-/l/
div-exp
frac-2neg
sub-neg
clear-num
rec-exp
inv-pow
pow-flip
div-sub
cbrt-undiv
Counts
4 → 84
Calls
4 calls:
Slowest
4.0ms
(/ (- x (tan x)) (- x (sin x)))
1.0ms
(/ 1 (/ (- x (tan x)) (- x (sin x))))
1.0ms
(- x (sin x))
0.0ms
(- x (tan x))

series314.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
97.0ms
(/ 1 (/ (- x (tan x)) (- x (sin x))))
97.0ms
(/ (- x (tan x)) (- x (sin x)))
67.0ms
(- x (tan x))
52.0ms
(- x (sin x))

simplify1.5s

Counts
59 → 96
Calls
59 calls:
Slowest
169.0ms
(- (+ 1 (+ (/ (pow (sin x) 2) (* (pow (cos x) 2) (pow x 2))) (/ (sin x) (* (cos x) x)))) (+ (/ (sin x) x) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))
164.0ms
(- (+ (/ (pow (sin x) 2) (pow x 2)) (+ (/ (sin x) x) 1)) (+ (/ (sin x) (* (cos x) x)) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))
163.0ms
(/ (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))) (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))))
146.0ms
(- (+ 1 (+ (/ (pow (sin x) 2) (* (pow (cos x) 2) (pow x 2))) (/ (sin x) (* (cos x) x)))) (+ (/ (sin x) x) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))
144.0ms
(- (+ (/ (pow (sin x) 2) (pow x 2)) (+ (/ (sin x) x) 1)) (+ (/ (sin x) (* (cos x) x)) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))

prune706.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

localize14.0ms

Local error

Found 4 expressions with local error:

1.8b
(- x (sin x))
1.8b
(- x (tan x))
0.0b
(/ (/ 1 (- x (tan x))) (/ 1 (- x (sin x))))
0.0b
(/ 1 (- x (tan x)))

rewrite12.0ms

Algorithm
rewrite-expression-head
Rules
36×times-frac
31×associate-/r/
19×add-cube-cbrt
19×*-un-lft-identity
19×add-sqr-sqrt
17×flip--
17×flip3--
16×div-inv
13×add-exp-log
associate-/r*
associate-/l*
add-cbrt-cube
rec-exp
pow1
add-log-exp
div-exp
frac-2neg
sub-neg
clear-num
associate-/l/
inv-pow
pow-flip
cbrt-undiv
Counts
4 → 105
Calls
4 calls:
Slowest
7.0ms
(/ (/ 1 (- x (tan x))) (/ 1 (- x (sin x))))
1.0ms
(/ 1 (- x (tan x)))
1.0ms
(- x (sin x))
1.0ms
(- x (tan x))

series275.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
82.0ms
(- x (tan x))
75.0ms
(/ 1 (- x (tan x)))
69.0ms
(/ (/ 1 (- x (tan x))) (/ 1 (- x (sin x))))
48.0ms
(- x (sin x))

simplify10.9s

Counts
106 → 117
Calls
106 calls:
Slowest
1.3s
(/ (* (* (/ 1 (- x (tan x))) (/ 1 (- x (tan x)))) (/ 1 (- x (tan x)))) (* (* (/ 1 (- x (sin x))) (/ 1 (- x (sin x)))) (/ 1 (- x (sin x)))))
569.0ms
(+ (/ (pow (sin x) 2) (* (pow (cos x) 2) (pow x 3))) (+ (/ (sin x) (* (cos x) (pow x 2))) (/ 1 x)))
501.0ms
(/ (/ 1 (- x (tan x))) (/ 1 (- x (sin x))))
453.0ms
(/ (/ 1 (- x (tan x))) (/ 1 (- x (sin x))))
427.0ms
(/ (/ 1 (- x (tan x))) (/ 1 (- x (sin x))))

prune1.0s

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0b

localize14.0ms

Local error

Found 4 expressions with local error:

1.8b
(- x (tan x))
1.8b
(- x (tan x))
1.4b
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
0.2b
(/ (sin x) (- x (tan x)))

rewrite20.0ms

Algorithm
rewrite-expression-head
Rules
17×add-sqr-sqrt
14×*-un-lft-identity
12×add-cube-cbrt
10×times-frac
add-log-exp
flip--
associate-/r/
add-exp-log
add-cbrt-cube
flip3--
pow1
associate-/l*
div-inv
distribute-rgt-out--
sub-neg
associate-/r*
difference-of-squares
sub-div
distribute-lft-out--
frac-sub
div-exp
diff-log
frac-2neg
clear-num
cbrt-undiv
Counts
4 → 71
Calls
4 calls:
Slowest
11.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
6.0ms
(/ (sin x) (- x (tan x)))
1.0ms
(- x (tan x))
1.0ms
(- x (tan x))

series464.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
260.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
79.0ms
(/ (sin x) (- x (tan x)))
71.0ms
(- x (tan x))
55.0ms
(- x (tan x))

simplify1.7s

Counts
55 → 83
Calls
55 calls:
Slowest
279.0ms
(/ (* (* (sin x) (sin x)) (sin x)) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
175.0ms
(- (+ 1 (+ (/ (pow (sin x) 2) (* (pow (cos x) 2) (pow x 2))) (/ (sin x) (* (cos x) x)))) (+ (/ (sin x) x) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))
159.0ms
(- (* x (- x (tan x))) (* (- x (tan x)) (sin x)))
153.0ms
(- (+ 1 (+ (/ (pow (sin x) 2) (* (pow (cos x) 2) (pow x 2))) (/ (sin x) (* (cos x) x)))) (+ (/ (sin x) x) (/ (pow (sin x) 2) (* (cos x) (pow x 2)))))
149.0ms
(+ (/ (pow (sin x) 2) (* (cos x) (pow x 2))) (+ (/ (pow (sin x) 3) (* (pow (cos x) 2) (pow x 3))) (/ (sin x) x)))

prune684.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes51.0ms

Accuracy

100% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 31.7b

bsearch125.0ms

end0.0ms

sample14.7s

Algorithm
intervals
Results
7.0s1635×body2560valid
4.7s2737×body1280valid
1.8s1809×body640valid
710.0ms933×body320valid
327.0ms511×body160valid
87.0ms375×body80valid