Average Error: 31.0 → 0.0
Time: 1.0m
Precision: 64
Internal Precision: 128
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.02690561339729299:\\ \;\;\;\;\frac{x}{x - \tan x} - \frac{\sin x}{x - \tan x}\\ \mathbf{elif}\;x \le 0.02908726170359111:\\ \;\;\;\;(\left(\frac{9}{40} \cdot x\right) \cdot x + \left((\frac{-27}{2800} \cdot \left({x}^{4}\right) + \frac{-1}{2})_*\right))_*\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{(x \cdot \left(\frac{1}{x - \tan x}\right) + \left(\frac{-\sin x}{x - \tan x}\right))_*}\right)\\ \end{array}\]

Error

Bits error versus x

Derivation

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

    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.02690561339729299 < x < 0.02908726170359111

    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. 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))_*}\]

    if 0.02908726170359111 < 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}}\]
    4. Using strategy rm
    5. Applied div-inv0.2

      \[\leadsto \color{blue}{x \cdot \frac{1}{x - \tan x}} - \frac{\sin x}{x - \tan x}\]
    6. Applied fma-neg0.2

      \[\leadsto \color{blue}{(x \cdot \left(\frac{1}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*}\]
    7. Using strategy rm
    8. Applied add-log-exp0.1

      \[\leadsto \color{blue}{\log \left(e^{(x \cdot \left(\frac{1}{x - \tan x}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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

Details

Time bar (total: 1.0m)Debug log

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

simplify26.0ms

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

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.8b

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

rewrite14.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
7.0ms
(/ (- x (sin x)) (- x (tan x)))
3.0ms
(- x (sin x))
1.0ms
(- x (tan x))

series277.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
120.0ms
(/ (- x (sin x)) (- x (tan x)))
92.0ms
(- x (tan x))
64.0ms
(- x (sin x))

simplify1.5s

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

prune753.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

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

rewrite32.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
17.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
7.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
247.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
77.0ms
(/ (sin x) (- x (tan x)))
70.0ms
(- x (tan x))
69.0ms
(- x (tan x))

simplify31.3s

Counts
239 → 187
Calls
239 calls:
Slowest
714.0ms
(fma (/ x (- (* x x) (* (tan x) (tan x)))) (+ x (tan x)) (- (* (/ (sin x) (- x (tan x))) (/ 1 1))))
681.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))))))))
567.0ms
(fma (/ x (- (* x x) (* (tan x) (tan x)))) (+ x (tan x)) (- (* (/ (sin x) (- x (tan x))) 1)))
493.0ms
(fma x (/ 1 (- x (tan x))) (- (* (/ (cbrt (sin x)) (- x (tan x))) (/ (* (cbrt (sin x)) (cbrt (sin x))) 1))))
485.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.9s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 4 expressions with local error:

1.6b
(fma x (/ 1 (- x (tan x))) (- (/ (sin x) (- x (tan x)))))
1.6b
(- x (tan x))
1.6b
(- x (tan x))
0.1b
(/ (sin x) (- x (tan x)))

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
12×add-cube-cbrt
12×*-un-lft-identity
12×add-sqr-sqrt
times-frac
add-exp-log
add-cbrt-cube
add-log-exp
log1p-expm1-u
pow1
expm1-log1p-u
associate-/l*
flip--
flip3--
associate-/r*
associate-/r/
sub-neg
div-inv
fma-udef
div-exp
frac-2neg
clear-num
cbrt-undiv
Counts
4 → 67
Calls
4 calls:
Slowest
8.0ms
(/ (sin x) (- x (tan x)))
1.0ms
(- x (tan x))
1.0ms
(- x (tan x))
0.0ms
(fma x (/ 1 (- x (tan x))) (- (/ (sin x) (- x (tan x)))))

series520.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
355.0ms
(fma x (/ 1 (- x (tan x))) (- (/ (sin x) (- x (tan x)))))
66.0ms
(/ (sin x) (- x (tan x)))
51.0ms
(- x (tan x))
47.0ms
(- x (tan x))

simplify2.2s

Counts
39 → 79
Calls
39 calls:
Slowest
394.0ms
(/ (* (* (sin x) (sin x)) (sin x)) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
257.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
245.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)))))
240.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)))))
213.0ms
(+ (/ (pow (sin x) 2) (* (cos x) (pow x 2))) (+ (/ (pow (sin x) 3) (* (pow (cos x) 2) (pow x 3))) (/ (sin x) x)))

prune829.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

1.6b
(fma x (/ 1 (- x (tan x))) (- (/ (sin x) (- x (tan x)))))
1.6b
(- x (tan x))
1.6b
(- x (tan x))
0.1b
(/ (sin x) (- x (tan x)))

rewrite5.0ms

Algorithm
rewrite-expression-head
Rules
12×add-cube-cbrt
12×*-un-lft-identity
12×add-sqr-sqrt
times-frac
add-exp-log
add-cbrt-cube
add-log-exp
log1p-expm1-u
pow1
expm1-log1p-u
associate-/l*
flip--
flip3--
associate-/r*
associate-/r/
sub-neg
div-inv
fma-udef
div-exp
frac-2neg
clear-num
cbrt-undiv
Counts
4 → 67
Calls
4 calls:
Slowest
3.0ms
(/ (sin x) (- x (tan x)))
0.0ms
(- x (tan x))
0.0ms
(- x (tan x))
0.0ms
(fma x (/ 1 (- x (tan x))) (- (/ (sin x) (- x (tan x)))))

series443.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
281.0ms
(fma x (/ 1 (- x (tan x))) (- (/ (sin x) (- x (tan x)))))
67.0ms
(/ (sin x) (- x (tan x)))
49.0ms
(- x (tan x))
47.0ms
(- x (tan x))

simplify2.2s

Counts
39 → 79
Calls
39 calls:
Slowest
376.0ms
(/ (* (* (sin x) (sin x)) (sin x)) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
278.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)))))
265.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
231.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)))))
229.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))

prune965.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

regimes73.0ms

Accuracy

100% (0.0b remaining)

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

bsearch151.0ms

end0.0ms

sample17.5s

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)