Average Error: 29.2 → 0.0
Time: 4.7m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -11997.32666981334 \lor \neg \left(x \le 11909.34130082208\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}:\\ \;\;\;\;(x \cdot x + \left(1 - x\right))_* \cdot \frac{\left(\left(x - 1\right) \cdot x - \left(1 + x\right) \cdot x\right) - \left(1 + x\right)}{\left(x - 1\right) \cdot \left(1 + {x}^{3}\right)}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -11997.32666981334 or 11909.34130082208 < x

    1. Initial program 59.2

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. 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)}\]
    3. 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 -11997.32666981334 < x < 11909.34130082208

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}\]
    4. Using strategy rm
    5. Applied distribute-rgt-in0.1

      \[\leadsto \frac{x \cdot \left(x - 1\right) - \color{blue}{\left(x \cdot \left(x + 1\right) + 1 \cdot \left(x + 1\right)\right)}}{\left(x + 1\right) \cdot \left(x - 1\right)}\]
    6. Applied associate--r+0.1

      \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x - 1\right) - x \cdot \left(x + 1\right)\right) - 1 \cdot \left(x + 1\right)}}{\left(x + 1\right) \cdot \left(x - 1\right)}\]
    7. Simplified0.1

      \[\leadsto \frac{\left(x \cdot \left(x - 1\right) - x \cdot \left(x + 1\right)\right) - \color{blue}{\left(x + 1\right)}}{\left(x + 1\right) \cdot \left(x - 1\right)}\]
    8. Using strategy rm
    9. Applied flip3-+0.1

      \[\leadsto \frac{\left(x \cdot \left(x - 1\right) - x \cdot \left(x + 1\right)\right) - \left(x + 1\right)}{\color{blue}{\frac{{x}^{3} + {1}^{3}}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}} \cdot \left(x - 1\right)}\]
    10. Applied associate-*l/0.1

      \[\leadsto \frac{\left(x \cdot \left(x - 1\right) - x \cdot \left(x + 1\right)\right) - \left(x + 1\right)}{\color{blue}{\frac{\left({x}^{3} + {1}^{3}\right) \cdot \left(x - 1\right)}{x \cdot x + \left(1 \cdot 1 - x \cdot 1\right)}}}\]
    11. Applied associate-/r/0.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -11997.32666981334 \lor \neg \left(x \le 11909.34130082208\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}:\\ \;\;\;\;(x \cdot x + \left(1 - x\right))_* \cdot \frac{\left(\left(x - 1\right) \cdot x - \left(1 + x\right) \cdot x\right) - \left(1 + x\right)}{\left(x - 1\right) \cdot \left(1 + {x}^{3}\right)}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 4.6m)Debug log

sample74.0ms

Algorithm
intervals

simplify28.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 26.6b

localize23.0ms

Local error

Found 3 expressions with local error:

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

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
3 → 164
Calls

3 calls. Slowest were:

8.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
3.0ms
(/ (+ x 1) (- x 1))
0.0ms
(/ x (+ x 1))

series68.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

48.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
10.0ms
(/ (+ x 1) (- x 1))
10.0ms
(/ x (+ x 1))

simplify46.2s

Counts
235 → 173
Calls

235 calls. Slowest were:

1.1s
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
949.0ms
(fma 1 (/ x (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
918.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (cbrt (/ (+ x 1) (- x 1))) (* (cbrt (/ (+ x 1) (- x 1))) (cbrt (/ (+ x 1) (- x 1)))))))

prune1.2s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 4 expressions with local error:

1.6b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
1.6b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
1.6b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
0.0b
(cbrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))

rewrite65.0ms

Algorithm
rewrite-expression-head
Counts
4 → 361
Calls

4 calls. Slowest were:

15.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
14.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
11.0ms
(cbrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))

series209.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

97.0ms
(cbrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
48.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
33.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
31.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

simplify2.3m

Counts
597 → 373
Calls

597 calls. Slowest were:

1.3s
(fma 1 (/ x (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
1.2s
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
1.1s
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))

prune4.0s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 4 expressions with local error:

15.8b
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
0.0b
(* (+ x 1) (+ x 1))
0.0b
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
0.0b
(* x (- x 1))

rewrite50.0ms

Algorithm
rewrite-expression-head
Counts
4 → 139
Calls

4 calls. Slowest were:

25.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
11.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
8.0ms
(* (+ x 1) (+ x 1))

series99.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

33.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
28.0ms
(* x (- x 1))
28.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
10.0ms
(* (+ x 1) (+ x 1))

simplify28.7s

Counts
127 → 151
Calls

127 calls. Slowest were:

1.1s
(* (+ (* x x) (- (* 1 1) (* x 1))) (- x 1))
852.0ms
(- (pow (* x (- x 1)) 3) (pow (* (+ x 1) (+ x 1)) 3))
800.0ms
(* (+ x 1) (* (+ (* x x) (- (* 1 1) (* x 1))) (+ (* x x) (- (* 1 1) (* x 1)))))

prune1.5s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize20.0ms

Local error

Found 4 expressions with local error:

15.8b
(- (* x (- x 1)) (* x (+ x 1)))
13.5b
(/ (- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1)) (* (+ x 1) (- x 1)))
0.0b
(- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1))
0.0b
(* x (+ x 1))

rewrite83.0ms

Algorithm
rewrite-expression-head
Counts
4 → 148
Calls

4 calls. Slowest were:

39.0ms
(/ (- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1)) (* (+ x 1) (- x 1)))
30.0ms
(- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1))
7.0ms
(- (* x (- x 1)) (* x (+ x 1)))

series94.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

31.0ms
(/ (- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1)) (* (+ x 1) (- x 1)))
25.0ms
(- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1))
19.0ms
(- (* x (- x 1)) (* x (+ x 1)))
18.0ms
(* x (+ x 1))

simplify57.2s

Counts
141 → 160
Calls

141 calls. Slowest were:

3.8s
(- (* (- (* x (- x 1)) (* x (+ x 1))) (- (* x (- x 1)) (* x (+ x 1)))) (* (+ x 1) (+ x 1)))
1.6s
(/ (- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1)) (- x 1))
1.6s
(fma (* (cbrt (- (* x (- x 1)) (* x (+ x 1)))) (cbrt (- (* x (- x 1)) (* x (+ x 1))))) (cbrt (- (* x (- x 1)) (* x (+ x 1)))) (- (* (+ x 1) 1)))

prune1.4s

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

regimes31.0ms

Accuracy

100% (0.0b remaining)

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

bsearch146.0ms

end0.0ms

sample2.2s

Algorithm
intervals