Average Error: 29.6 → 0.1
Time: 3.5m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -11810.647953296477 \lor \neg \left(x \le 9392.348407456098\right):\\ \;\;\;\;(\left(\frac{-1}{x \cdot x}\right) \cdot \left(\frac{3}{x}\right) + \left(\frac{-1}{x \cdot x} - \frac{3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\log_* (1 + (e^{\log \left(e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}\right)} - 1)^*)\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -11810.647953296477 or 9392.348407456098 < x

    1. Initial program 59.4

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-log-exp59.4

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}\]
    4. Taylor expanded around inf 0.3

      \[\leadsto \color{blue}{-\left(3 \cdot \frac{1}{{x}^{3}} + \left(\frac{1}{{x}^{2}} + 3 \cdot \frac{1}{x}\right)\right)}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{(\left(\frac{-1}{x \cdot x}\right) \cdot \left(\frac{3}{x}\right) + \left(\frac{-1}{x \cdot x} - \frac{3}{x}\right))_*}\]

    if -11810.647953296477 < x < 9392.348407456098

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-log-exp0.1

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}\]
    4. Using strategy rm
    5. Applied log1p-expm1-u0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -11810.647953296477 \lor \neg \left(x \le 9392.348407456098\right):\\ \;\;\;\;(\left(\frac{-1}{x \cdot x}\right) \cdot \left(\frac{3}{x}\right) + \left(\frac{-1}{x \cdot x} - \frac{3}{x}\right))_*\\ \mathbf{else}:\\ \;\;\;\;\log_* (1 + (e^{\log \left(e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}\right)} - 1)^*)\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 +o rules:numerics
(FPCore (x)
  :name "Asymptote C"
  (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))

Details

Time bar (total: 3.5m)Debug log

sample86.0ms

Algorithm
intervals

simplify26.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

26.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.8b

localize26.0ms

Local error

Found 3 expressions with local error:

1.3b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
0.0b
(/ (+ x 1) (- x 1))
0.0b
(/ x (+ x 1))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
3 → 164
Calls

3 calls. Slowest were:

15.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
6.0ms
(/ (+ x 1) (- x 1))
1.0ms
(/ x (+ x 1))

series73.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

47.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
15.0ms
(/ x (+ x 1))
10.0ms
(/ (+ x 1) (- x 1))

simplify42.3s

Counts
235 → 173
Calls

235 calls. Slowest were:

894.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
867.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (sqrt (/ (+ x 1) (- x 1))) (sqrt (/ (+ x 1) (- x 1))))))
789.0ms
(fma 1 (/ x (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune1.2s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

1.3b
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
1.3b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
0.0b
(/ (+ x 1) (- x 1))
0.0b
(exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))

rewrite80.0ms

Algorithm
rewrite-expression-head
Counts
4 → 370
Calls

4 calls. Slowest were:

31.0ms
(exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
18.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
7.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

series130.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

44.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
44.0ms
(exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
32.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
10.0ms
(/ (+ x 1) (- x 1))

simplify1.5m

Counts
437 → 382
Calls

437 calls. Slowest were:

985.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
850.0ms
(fma x (/ 1 (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
800.0ms
(fma (sqrt (/ x (+ x 1))) (sqrt (/ x (+ x 1))) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune3.8s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

1.3b
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
1.3b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
0.5b
(expm1 (log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))))
0.0b
(/ (+ x 1) (- x 1))

rewrite59.0ms

Algorithm
rewrite-expression-head
Counts
4 → 271
Calls

4 calls. Slowest were:

21.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
15.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
6.0ms
(/ (+ x 1) (- x 1))

series186.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

70.0ms
(expm1 (log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))))
50.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
49.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
17.0ms
(/ (+ x 1) (- x 1))

simplify1.1m

Counts
337 → 283
Calls

337 calls. Slowest were:

941.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
786.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (cbrt (/ (+ x 1) (- x 1))) (* (cbrt (/ (+ x 1) (- x 1))) (cbrt (/ (+ x 1) (- x 1)))))))
772.0ms
(log (exp (fma 1 (/ x (+ x 1)) (- (* (/ (+ x 1) (sqrt (- x 1))) (/ 1 (sqrt (- x 1))))))))

prune3.2s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 1 expressions with local error:

0.0b
(fma (+ x 3) x 1)

rewrite0.0ms

Algorithm
rewrite-expression-head
Counts
1 → 10
Calls

1 calls. Slowest were:

0.0ms
(fma (+ x 3) x 1)

series9.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

9.0ms
(fma (+ x 3) x 1)

simplify75.0ms

Counts
3 → 13
Calls

3 calls. Slowest were:

36.0ms
(+ (* 3 x) (+ (pow x 2) 1))
23.0ms
(+ (* 3 x) (+ (pow x 2) 1))
16.0ms
(+ (* 3 x) (+ (pow x 2) 1))

prune68.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

regimes54.0ms

Accuracy

100% (0.0b remaining)

Error of 0.1b against oracle of 0.1b and baseline of 29.6b

bsearch107.0ms

end0.0ms

sample2.1s

Algorithm
intervals