Average Error: 31.0 → 0.0
Time: 28.6s
Precision: 64
Internal Precision: 128
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02690561339729299 \lor \neg \left(x \le 0.021977241461929545\right):\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;\frac{9}{40} \cdot {x}^{2} - \left(\frac{1}{2} + \frac{27}{2800} \cdot {x}^{4}\right)\\ \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 2 regimes
  2. if x < -0.02690561339729299 or 0.021977241461929545 < x

    1. Initial program 0.1

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

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

    if -0.02690561339729299 < x < 0.021977241461929545

    1. Initial program 62.7

      \[\frac{x - \sin x}{x - \tan x}\]
    2. 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)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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

Details

Time bar (total: 28.1s)Debug log

sample665.0ms

Algorithm
intervals
Results
256×(pre true 80)
95×(body real 1280)
54×(body real 640)
47×(body real 2560)
32×(body real 320)
14×(body real 80)
14×(body real 160)

simplify387.0ms

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

prune14.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.8b

localize33.0ms

Local error

Found 3 expressions with local error:

1.6b
(- x (sin x))
1.6b
(- 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))

series236.0ms

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

simplify1.2s

Counts
39 → 63
Calls
39 calls:
Slowest
223.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)))))
214.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)))))
158.0ms
(/ (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
143.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
67.0ms
(- (+ (* 1/6 (pow x 3)) (* 1/5040 (pow x 7))) (* 1/120 (pow x 5)))

prune544.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 4 expressions with local error:

1.6b
(- x (tan x))
1.6b
(- x (tan x))
1.3b
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
0.1b
(/ (sin x) (- x (tan x)))

rewrite12.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
6.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
4.0ms
(/ (sin x) (- x (tan x)))
1.0ms
(- x (tan x))
0.0ms
(- x (tan x))

series544.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
290.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
91.0ms
(/ (sin x) (- x (tan x)))
85.0ms
(- x (tan x))
77.0ms
(- x (tan x))

simplify2.1s

Counts
55 → 83
Calls
55 calls:
Slowest
322.0ms
(/ (* (* (sin x) (sin x)) (sin x)) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
255.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)))))
247.0ms
(- (* x (- x (tan x))) (* (- x (tan x)) (sin x)))
174.0ms
(+ (/ (pow (sin x) 2) (* (cos x) (pow x 2))) (+ (/ (pow (sin x) 3) (* (pow (cos x) 2) (pow x 3))) (/ (sin x) x)))
167.0ms
(+ (/ (pow (sin x) 2) (* (cos x) (pow x 2))) (+ (/ (pow (sin x) 3) (* (pow (cos x) 2) (pow x 3))) (/ (sin x) x)))

prune777.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize20.0ms

Local error

Found 3 expressions with local error:

15.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))

rewrite9.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
6.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
1.0ms
(* 27/2800 (pow x 4))
1.0ms
(* 9/40 (pow x 2))

series66.0ms

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

simplify300.0ms

Counts
16 → 45
Calls
16 calls:
Slowest
95.0ms
(/ (exp (* 9/40 (pow x 2))) (exp (+ (* 27/2800 (pow x 4)) 1/2)))
61.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
58.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
52.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
6.0ms
(* 9/40 (pow x 2))

prune398.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize32.0ms

Local error

Found 4 expressions with local error:

15.0b
(/ (- (* x x) (* (sin x) (sin x))) (* (- x (tan x)) (+ x (sin x))))
1.6b
(- (* x x) (* (sin x) (sin x)))
1.6b
(- x (tan x))
0.3b
(* (sin x) (sin x))

rewrite35.0ms

Algorithm
rewrite-expression-head
Rules
11×add-exp-log
11×add-cbrt-cube
pow1
add-cube-cbrt
associate-/r/
*-un-lft-identity
add-sqr-sqrt
add-log-exp
flip--
flip3--
associate-/l*
times-frac
frac-times
difference-of-squares
flip-+
associate-*l*
associate-*r*
flip3-+
associate-/l/
sqr-sin
cbrt-unprod
associate-*r/
prod-exp
associate-*l/
div-exp
sub-neg
cbrt-undiv
associate--r-
sin-mult
div-inv
pow-prod-up
*-commutative
pow-prod-down
div-sub
diff-log
pow-plus
frac-2neg
associate-/r*
clear-num
pow2
Counts
4 → 81
Calls
4 calls:
Slowest
18.0ms
(/ (- (* x x) (* (sin x) (sin x))) (* (- x (tan x)) (+ x (sin x))))
8.0ms
(- (* x x) (* (sin x) (sin x)))
7.0ms
(* (sin x) (sin x))
1.0ms
(- x (tan x))

series341.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
178.0ms
(/ (- (* x x) (* (sin x) (sin x))) (* (- x (tan x)) (+ x (sin x))))
80.0ms
(- x (tan x))
57.0ms
(- (* x x) (* (sin x) (sin x)))
26.0ms
(* (sin x) (sin x))

simplify3.6s

Counts
56 → 93
Calls
56 calls:
Slowest
294.0ms
(- (log (- (* x x) (* (sin x) (sin x)))) (log (* (- x (tan x)) (+ x (sin x)))))
287.0ms
(/ (* (* (- (* x x) (* (sin x) (sin x))) (- (* x x) (* (sin x) (sin x)))) (- (* x x) (* (sin x) (sin x)))) (* (* (* (- x (tan x)) (+ x (sin x))) (* (- x (tan x)) (+ x (sin x)))) (* (- x (tan x)) (+ x (sin x)))))
286.0ms
(/ (* x x) (* (- x (tan x)) (+ x (sin x))))
244.0ms
(/ (* (* (- (* x x) (* (sin x) (sin x))) (- (* x x) (* (sin x) (sin x)))) (- (* x x) (* (sin x) (sin x)))) (* (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))) (* (* (+ x (sin x)) (+ x (sin x))) (+ x (sin x)))))
244.0ms
(/ (- (* x x) (* (sin x) (sin x))) (+ x (sin x)))

prune848.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

regimes51.0ms

Accuracy

100% (0.0b remaining)

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

bsearch158.0ms

end0.0ms

sample15.7s

Algorithm
intervals
Results
8000×(pre true 80)
2820×(body real 1280)
1826×(body real 640)
1594×(body real 2560)
897×(body real 320)
485×(body real 160)
378×(body real 80)