Average Error: 30.9 → 0.0
Time: 38.7s
Precision: 64
Internal Precision: 128
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02980904249937881:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.026383143248524282:\\ \;\;\;\;\frac{9}{40} \cdot {x}^{2} - \left(\frac{1}{2} + \frac{27}{2800} \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \sin x}{x - \tan 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.02980904249937881

    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.02980904249937881 < x < 0.026383143248524282

    1. Initial program 62.8

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

      \[\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.026383143248524282 < x

    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}}\]
    4. Using strategy rm
    5. Applied sub-div0.0

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

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

Reproduce

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

Details

Time bar (total: 38.0s)Debug log

sample808.0ms

Algorithm
intervals
Results
256×(pre true 80)
91×(body real 1280)
66×(body real 640)
50×(body real 2560)
27×(body real 320)
13×(body real 160)
(body real 80)

simplify19.0ms

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

prune47.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.1b

localize41.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.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)))
1.0ms
(- x (sin x))
1.0ms
(- x (tan x))

series345.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
177.0ms
(/ (- x (sin x)) (- x (tan x)))
107.0ms
(- x (tan x))
61.0ms
(- x (sin x))

simplify1.8s

Counts
39 → 63
Calls
39 calls:
Slowest
340.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)))))
316.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)))))
263.0ms
(/ (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
192.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
108.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))

prune940.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize22.0ms

Local error

Found 4 expressions with local error:

1.5b
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
1.5b
(- x (tan x))
1.5b
(- x (tan x))
0.1b
(/ (sin x) (- x (tan x)))

rewrite26.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
14.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
8.0ms
(/ (sin x) (- x (tan x)))
1.0ms
(- x (tan x))
1.0ms
(- x (tan x))

series715.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
407.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
115.0ms
(/ (sin x) (- x (tan x)))
97.0ms
(- x (tan x))
96.0ms
(- x (tan x))

simplify3.4s

Counts
55 → 83
Calls
55 calls:
Slowest
535.0ms
(/ (* (* (sin x) (sin x)) (sin x)) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
380.0ms
(- (* x (- x (tan x))) (* (- x (tan x)) (sin x)))
291.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)))))
285.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)))))
271.0ms
(+ (/ (pow (sin x) 2) (* (cos x) (pow x 2))) (+ (/ (pow (sin x) 3) (* (pow (cos x) 2) (pow x 3))) (/ (sin x) x)))

prune1.2s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize1.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.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)))
1.0ms
(- x (sin x))
1.0ms
(- x (tan x))

series307.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
149.0ms
(/ (- x (sin x)) (- x (tan x)))
98.0ms
(- x (tan x))
61.0ms
(- x (sin x))

simplify1.7s

Counts
39 → 63
Calls
39 calls:
Slowest
292.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)))))
287.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)))))
263.0ms
(/ (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
188.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
105.0ms
(- (+ (* 1/6 (pow x 3)) (* 1/5040 (pow x 7))) (* 1/120 (pow x 5)))

prune838.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize51.0ms

Local error

Found 3 expressions with local error:

16.5b
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
0.2b
(* 9/40 (pow x 2))
0.1b
(* 27/2800 (pow x 4))

rewrite17.0ms

Algorithm
rewrite-expression-head
Rules
associate-*r*
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1
*-commutative
unpow2
associate--r+
flip--
diff-log
flip3--
sub-neg
Counts
3 → 36
Calls
3 calls:
Slowest
11.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
3.0ms
(* 9/40 (pow x 2))
3.0ms
(* 27/2800 (pow x 4))

series99.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
40.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
36.0ms
(* 27/2800 (pow x 4))
23.0ms
(* 9/40 (pow x 2))

simplify480.0ms

Counts
16 → 45
Calls
16 calls:
Slowest
149.0ms
(/ (exp (* 9/40 (pow x 2))) (exp (+ (* 27/2800 (pow x 4)) 1/2)))
93.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
92.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
90.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
8.0ms
(* 9/40 (pow x 2))

prune631.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes119.0ms

Accuracy

100% (0.0b remaining)

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

bsearch250.0ms

end0.0ms

sample24.1s

Algorithm
intervals
Results
8000×(pre true 80)
2713×(body real 1280)
1893×(body real 640)
1615×(body real 2560)
929×(body real 320)
487×(body real 160)
363×(body real 80)