Average Error: 31.8 → 0.0
Time: 29.5s
Precision: 64
Internal Precision: 128
\[\frac{x - \sin x}{x - \tan x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.024178796645617315 \lor \neg \left(x \le 0.0282092826919728\right):\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;(\left(x \cdot \frac{9}{40}\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.024178796645617315 or 0.0282092826919728 < x

    1. Initial program 0.1

      \[\frac{x - \sin x}{x - \tan x}\]
    2. Taylor expanded around -inf 0.1

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

    if -0.024178796645617315 < x < 0.0282092826919728

    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.024178796645617315 \lor \neg \left(x \le 0.0282092826919728\right):\\ \;\;\;\;\frac{x - \sin x}{x - \tan x}\\ \mathbf{else}:\\ \;\;\;\;(\left(x \cdot \frac{9}{40}\right) \cdot x + \left((\frac{-27}{2800} \cdot \left({x}^{4}\right) + \frac{-1}{2})_*\right))_*\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 29.1s)Debug log

sample592.0ms

Algorithm
intervals

simplify30.0ms

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

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.9b

localize22.0ms

Local error

Found 3 expressions with local error:

1.6b
(- x (tan x))
1.4b
(- x (sin x))
0.0b
(/ (- x (sin x)) (- x (tan x)))

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

series638.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
476.0ms
(- x (tan x))
113.0ms
(/ (- x (sin x)) (- x (tan x)))
49.0ms
(- x (sin x))

simplify1.4s

Counts
39 → 69
Calls
39 calls:
Slowest
251.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)))))
250.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)))))
199.0ms
(- (+ (* 1/3 (pow x 3)) (+ (* 2/15 (pow x 5)) (* 17/315 (pow x 7)))))
179.0ms
(/ (* (* (- x (sin x)) (- x (sin x))) (- x (sin x))) (* (* (- x (tan x)) (- x (tan x))) (- x (tan x))))
109.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))

prune760.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize26.0ms

Local error

Found 3 expressions with local error:

0.1b
(* 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))

rewrite2.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
1.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))

series105.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
60.0ms
(fma -27/2800 (pow x 4) -1/2)
32.0ms
(fma (* 9/40 x) x (fma -27/2800 (pow x 4) -1/2))
13.0ms
(* 9/40 x)

simplify366.0ms

Counts
9 → 39
Calls
9 calls:
Slowest
109.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
95.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
89.0ms
(- (* 9/40 (pow x 2)) (+ (* 27/2800 (pow x 4)) 1/2))
23.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))
21.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))

prune313.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 4 expressions with local error:

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

rewrite7.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
rem-cbrt-cube
*-commutative
pow3
pow1/3
cbrt-prod
Counts
4 → 42
Calls
4 calls:
Slowest
6.0ms
(cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))
0.0ms
(* 9/40 x)
0.0ms
(fma -27/2800 (pow x 4) -1/2)
0.0ms
(fma -27/2800 (pow x 4) -1/2)

series125.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
50.0ms
(cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))
34.0ms
(fma -27/2800 (pow x 4) -1/2)
33.0ms
(fma -27/2800 (pow x 4) -1/2)
7.0ms
(* 9/40 x)

simplify210.0ms

Counts
13 → 54
Calls
13 calls:
Slowest
32.0ms
(cbrt (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)))
21.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))
21.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))
21.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))
21.0ms
(- (+ (* 27/2800 (pow x 4)) 1/2))

prune377.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize17.0ms

Local error

Found 4 expressions with local error:

15.1b
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
15.1b
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
15.1b
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
6.6b
(cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))

rewrite19.0ms

Algorithm
rewrite-expression-head
Rules
16×cbrt-prod
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-log-exp
log1p-expm1-u
add-exp-log
pow1/3
add-cbrt-cube
pow1
expm1-log1p-u
rem-cbrt-cube
pow3
Counts
4 → 54
Calls
4 calls:
Slowest
9.0ms
(cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))
3.0ms
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
3.0ms
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
3.0ms
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))

series2.0s

Counts
4 → 12
Calls
4 calls:
Slowest
677.0ms
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
632.0ms
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
601.0ms
(cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))
57.0ms
(cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))

simplify4.7s

Counts
25 → 66
Calls
25 calls:
Slowest
460.0ms
(cbrt (sqrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))))
427.0ms
(cbrt (sqrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))))
402.0ms
(cbrt (* (cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))) (cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))))
394.0ms
(cbrt (* (cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))) (cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))))
370.0ms
(cbrt (* (cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2)))) (cbrt (cbrt (* (* (fma -27/2800 (pow x 4) -1/2) (fma -27/2800 (pow x 4) -1/2)) (fma -27/2800 (pow x 4) -1/2))))))

prune519.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

regimes80.0ms

Accuracy

100% (0.0b remaining)

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

bsearch189.0ms

end0.0ms

sample16.6s

Algorithm
intervals