Average Error: 31.3 → 0.1
Time: 1.1m
Precision: 64
Internal Precision: 128
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.5738644795251036 \lor \neg \left(x \le 1.5667946788322475\right):\\ \;\;\;\;(\left(\sqrt{\frac{x}{x - \tan x}}\right) \cdot \left(\sqrt{\frac{x}{x - \tan x}}\right) + \left(\frac{-\sin x}{x - \tan x}\right))_*\\ \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 < -1.5738644795251036 or 1.5667946788322475 < 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 add-sqr-sqrt0.1

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

      \[\leadsto \color{blue}{(\left(\sqrt{\frac{x}{x - \tan x}}\right) \cdot \left(\sqrt{\frac{x}{x - \tan x}}\right) + \left(-\frac{\sin x}{x - \tan x}\right))_*}\]

    if -1.5738644795251036 < x < 1.5667946788322475

    1. Initial program 62.4

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around 0 0.2

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

      \[\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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.5738644795251036 \lor \neg \left(x \le 1.5667946788322475\right):\\ \;\;\;\;(\left(\sqrt{\frac{x}{x - \tan x}}\right) \cdot \left(\sqrt{\frac{x}{x - \tan x}}\right) + \left(\frac{-\sin x}{x - \tan x}\right))_*\\ \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 2018362 +o rules:numerics
(FPCore (x)
  :name "sintan (problem 3.4.5)"
  (/ (- x (sin x)) (- x (tan x))))

Details

Time bar (total: 44.3s)Debug log

start1.1s

Algorithm
intervals

setup24.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 37.4b

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
3 → 60
Calls

3 calls. Slowest were:

6.0ms
(/ (- x (sin x)) (- x (tan x)))
3.0ms
(- x (sin x))
1.0ms
(- x (tan x))

series244.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

103.0ms
(/ (- x (sin x)) (- x (tan x)))
79.0ms
(- x (tan x))
62.0ms
(- x (sin x))

simplify1.6s

Counts
39 → 69
Calls

39 calls. Slowest were:

331.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)))))
253.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)))))
221.0ms
(/ (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))

prune672.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize32.0ms

Local error

Found 3 expressions with local error:

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

rewrite2.0ms

Algorithm
rewrite-expression-head
Counts
3 → 30
Calls

3 calls. Slowest were:

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

series78.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

38.0ms
(fma -27/2800 (pow x 4) -1/2)
28.0ms
(fma (* 9/40 x) x (fma -27/2800 (pow x 4) -1/2))
12.0ms
(* 9/40 x)

simplify391.0ms

Counts
9 → 39
Calls

9 calls. Slowest were:

114.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
113.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
86.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))

prune535.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize8.0ms

Local error

Found 4 expressions with local error:

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

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 175
Calls

4 calls. Slowest were:

11.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
7.0ms
(/ (sin x) (- x (tan x)))
1.0ms
(- x (tan x))

series535.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

307.0ms
(- (/ x (- x (tan x))) (/ (sin x) (- x (tan x))))
95.0ms
(/ (sin x) (- x (tan x)))
68.0ms
(- x (tan x))
66.0ms
(- x (tan x))

simplify33.6s

Counts
239 → 187
Calls

239 calls. Slowest were:

627.0ms
(fma (- (/ (sin x) (sqrt (- x (tan x))))) (/ 1 (sqrt (- x (tan x)))) (* (/ (sin x) (sqrt (- x (tan x)))) (/ 1 (sqrt (- x (tan x))))))
553.0ms
(fma (sqrt (/ x (- x (tan x)))) (sqrt (/ x (- x (tan x)))) (- (* (/ (cbrt (sin x)) (cbrt (- x (tan x)))) (/ (* (cbrt (sin x)) (cbrt (sin x))) (* (cbrt (- x (tan x))) (cbrt (- x (tan x))))))))
545.0ms
(fma x (/ 1 (- x (tan x))) (- (* (/ (cbrt (sin x)) (- x (tan x))) (/ (* (cbrt (sin x)) (cbrt (sin x))) 1))))

prune1.6s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize9.0ms

Local error

Found 4 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
4 → 70
Calls

4 calls. Slowest were:

3.0ms
(/ (sin x) (- x (tan x)))
0.0ms
(- x (tan x))
0.0ms
(- x (tan x))

series256.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

78.0ms
(- x (tan x))
63.0ms
(- x (tan x))
59.0ms
(- x (tan x))
56.0ms
(/ (sin x) (- x (tan x)))

simplify2.1s

Counts
39 → 82
Calls

39 calls. Slowest were:

565.0ms
(/ (* (* (sin x) (sin x)) (sin x)) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
266.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
265.0ms
(+ (/ (pow (sin x) 2) (* (cos x) (pow x 2))) (+ (/ (pow (sin x) 3) (* (pow (cos x) 2) (pow x 3))) (/ (sin x) x)))

prune997.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes70.0ms

Accuracy

99.8% (0.1b remaining)

Error of 0.1b against oracle of 0.0b and baseline of 31.8b

bsearch242.0ms