Average Error: 31.4 → 0.0
Time: 59.3s
Precision: 64
Internal Precision: 128
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.026465599327529912 \lor \neg \left(x \le 0.033509852340848724\right):\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;(\left(\frac{9}{40} \cdot x\right) \cdot x + \left((\frac{-27}{2800} \cdot \left({x}^{4}\right) + \frac{-1}{2})_*\right))_*\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.026465599327529912 or 0.033509852340848724 < 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.026465599327529912 < x < 0.033509852340848724

    1. Initial program 62.8

      \[\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. Simplified0.0

      \[\leadsto \color{blue}{(\left(\frac{9}{40} \cdot x\right) \cdot x + \left((\frac{-27}{2800} \cdot \left({x}^{4}\right) + \frac{-1}{2})_*\right))_*}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

herbie shell --seed 2019022 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  (/ (- x (sin x)) (- x (tan x))))

Details

Time bar (total: 58.8s)Debug log

sample632.0ms

Algorithm
intervals
Results
350.0ms60×body2560valid
127.0ms82×body1280valid
43.0ms45×body640valid
25.0ms37×body320valid
8.0ms16×body160valid
4.0ms16×body80valid

simplify15.0ms

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.3b

localize61.0ms

Local error

Found 3 expressions with local error:

0.7b
(- x (sin x))
0.7b
(- 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*
log1p-expm1-u
associate-/r*
pow1
expm1-log1p-u
associate-/l/
associate-/r/
sub-neg
div-inv
div-exp
div-sub
frac-2neg
clear-num
cbrt-undiv
Counts
3 → 60
Calls
3 calls:
Slowest
5.0ms
(/ (- x (sin x)) (- x (tan x)))
3.0ms
(- x (sin x))
1.0ms
(- x (tan x))

series207.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
89.0ms
(/ (- x (sin x)) (- x (tan x)))
72.0ms
(- x (tan x))
46.0ms
(- x (sin x))

simplify1.4s

Counts
39 → 69
Calls
39 calls:
Slowest
236.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)))))
234.0ms
(/ (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
221.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)))))
211.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
89.0ms
(- (+ (* 1/6 (pow x 3)) (* 1/5040 (pow x 7))) (* 1/120 (pow x 5)))

prune652.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize10.0ms

Local error

Found 4 expressions with local error:

0.7b
(- x (tan x))
0.7b
(- x (tan x))
0.4b
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
0.1b
(/ (sin x) (- x (tan x)))

rewrite15.0ms

Algorithm
rewrite-expression-head
Rules
90×prod-diff
75×add-sqr-sqrt
72×*-un-lft-identity
70×add-cube-cbrt
64×times-frac
50×associate-/r/
28×flip--
28×flip3--
25×div-inv
add-log-exp
add-exp-log
fma-neg
add-cbrt-cube
log1p-expm1-u
pow1
expm1-log1p-u
associate-/l*
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 → 175
Calls
4 calls:
Slowest
8.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
3.0ms
(/ (sin x) (- x (tan x)))
1.0ms
(- x (tan x))
0.0ms
(- x (tan x))

series486.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
274.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
77.0ms
(- x (tan x))
77.0ms
(/ (sin x) (- x (tan x)))
58.0ms
(- x (tan x))

simplify30.2s

Counts
239 → 187
Calls
239 calls:
Slowest
644.0ms
(fma (/ x (- (pow x 3) (pow (tan x) 3))) (+ (* x x) (+ (* (tan x) (tan x)) (* x (tan x)))) (- (* (cbrt (/ (sin x) (- x (tan x)))) (* (cbrt (/ (sin x) (- x (tan x)))) (cbrt (/ (sin x) (- x (tan x))))))))
498.0ms
(fma (/ x (- (* x x) (* (tan x) (tan x)))) (+ x (tan x)) (- (* (/ (sin x) (- x (tan x))) 1)))
456.0ms
(fma x (/ 1 (- x (tan x))) (- (* (/ (cbrt (sin x)) (- x (tan x))) (/ (* (cbrt (sin x)) (cbrt (sin x))) 1))))
445.0ms
(fma (/ x (- (* x x) (* (tan x) (tan x)))) (+ x (tan x)) (- (* (/ (sin x) (- x (tan x))) (/ 1 1))))
422.0ms
(fma (sqrt (/ x (- x (tan x)))) (sqrt (/ x (- x (tan x)))) (- (* (/ (sin x) (cbrt (- x (tan x)))) (/ 1 (* (cbrt (- x (tan x))) (cbrt (- x (tan x))))))))

prune1.5s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize22.0ms

Local error

Found 3 expressions with local error:

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

rewrite1.0ms

Algorithm
rewrite-expression-head
Rules
add-log-exp
log1p-expm1-u
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
expm1-log1p-u
add-sqr-sqrt
fma-udef
*-commutative
Counts
3 → 30
Calls
3 calls:
Slowest
0.0ms
(* 9/40 x)
0.0ms
(fma -27/2800 (pow x 4) -1/2)
0.0ms
(fma (* 9/40 x) x (fma -27/2800 (pow x 4) -1/2))

series64.0ms

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

simplify237.0ms

Counts
9 → 39
Calls
9 calls:
Slowest
66.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
66.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
63.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
13.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))
13.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))

prune254.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize23.0ms

Local error

Found 4 expressions with local error:

14.1b
(/ (- (* x x) (* (sin x) (sin x))) (* (- x (tan x)) (+ x (sin x))))
0.7b
(- (* x x) (* (sin x) (sin x)))
0.7b
(- x (tan x))
0.2b
(* (sin x) (sin x))

rewrite32.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*
log1p-expm1-u
times-frac
frac-times
expm1-log1p-u
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
prod-diff
div-sub
diff-log
fma-neg
pow-plus
frac-2neg
associate-/r*
clear-num
pow2
Counts
4 → 91
Calls
4 calls:
Slowest
17.0ms
(/ (- (* x x) (* (sin x) (sin x))) (* (- x (tan x)) (+ x (sin x))))
7.0ms
(* (sin x) (sin x))
5.0ms
(- (* x x) (* (sin x) (sin x)))
1.0ms
(- x (tan x))

series294.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
149.0ms
(/ (- (* x x) (* (sin x) (sin x))) (* (- x (tan x)) (+ x (sin x))))
77.0ms
(- x (tan x))
45.0ms
(- (* x x) (* (sin x) (sin x)))
23.0ms
(* (sin x) (sin x))

simplify4.8s

Counts
58 → 103
Calls
58 calls:
Slowest
609.0ms
(/ (* x x) (* (- x (tan x)) (+ x (sin x))))
545.0ms
(/ (- (* x x) (* (sin x) (sin x))) (+ x (sin x)))
265.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)))))
255.0ms
(* (+ x (tan x)) (+ (* x x) (- (* (sin x) (sin x)) (* x (sin x)))))
246.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)))))

prune980.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes61.0ms

Accuracy

100% (0.0b remaining)

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

bsearch179.0ms

end0.0ms

sample16.7s

Algorithm
intervals
Results
6.4s1601×body2560valid
6.0s2768×body1280valid
2.6s1825×body640valid
1.2s933×body320valid
284.0ms474×body160valid
103.0ms399×body80valid