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

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -8.80985298240059e+48 or 126507.6676441063 < x

    1. Initial program 59.8

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

      \[\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. 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 -8.80985298240059e+48 < x < 126507.6676441063

    1. Initial program 3.3

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

      \[\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. Taylor expanded around 0 0.0

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

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

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

Reproduce

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

Details

Time bar (total: 2.0m)Debug log

start105.0ms

Algorithm
intervals

setup46.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 23.8b

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

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:

51.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
11.0ms
(/ x (+ x 1))
10.0ms
(/ (+ x 1) (- x 1))

simplify46.0s

Counts
235 → 173
Calls

235 calls. Slowest were:

943.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
866.0ms
(fma 1 (/ x (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
860.0ms
(fma (sqrt (/ x (+ x 1))) (sqrt (/ x (+ x 1))) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune1.7s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 4 expressions with local error:

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

rewrite42.0ms

Algorithm
rewrite-expression-head
Counts
4 → 139
Calls

4 calls. Slowest were:

21.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
10.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
7.0ms
(* (+ x 1) (+ x 1))

series87.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

32.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
28.0ms
(* x (- x 1))
17.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
10.0ms
(* (+ x 1) (+ x 1))

simplify29.5s

Counts
127 → 151
Calls

127 calls. Slowest were:

1.2s
(* (+ (* x x) (- (* 1 1) (* x 1))) (- x 1))
1.1s
(* (+ (* x x) (+ (* 1 1) (* x 1))) (+ (* x x) (- (* 1 1) (* x 1))))
881.0ms
(- (pow (* x (- x 1)) 3) (pow (* (+ x 1) (+ x 1)) 3))

prune1.5s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize7.0ms

Local error

Found 3 expressions with local error:

13.1b
(/ (fma -3 x -1) (* (+ x 1) (- x 1)))
0.1b
(fma -3 x -1)
0.0b
(* (+ x 1) (- x 1))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
3 → 72
Calls

3 calls. Slowest were:

11.0ms
(/ (fma -3 x -1) (* (+ x 1) (- x 1)))
8.0ms
(* (+ x 1) (- x 1))
0.0ms
(fma -3 x -1)

series89.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

37.0ms
(* (+ x 1) (- x 1))
30.0ms
(/ (fma -3 x -1) (* (+ x 1) (- x 1)))
21.0ms
(fma -3 x -1)

simplify7.3s

Counts
54 → 81
Calls

54 calls. Slowest were:

1.4s
(* (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
620.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
619.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune973.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize17.0ms

Local error

Found 4 expressions with local error:

18.6b
(* (/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))) (* (- x 1) (+ x 1)))
2.3b
(/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1))))
0.1b
(* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))
0.1b
(fma -3 x -1)

rewrite73.0ms

Algorithm
rewrite-expression-head
Counts
4 → 140
Calls

4 calls. Slowest were:

35.0ms
(* (/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))) (* (- x 1) (+ x 1)))
18.0ms
(* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))
16.0ms
(/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1))))

series108.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

49.0ms
(* (/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))) (* (- x 1) (+ x 1)))
23.0ms
(fma -3 x -1)
21.0ms
(/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1))))
14.0ms
(* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))

simplify31.1s

Counts
122 → 152
Calls

122 calls. Slowest were:

1.2s
(* (/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))) (* (- x 1) (+ x 1)))
1.1s
(* (/ (fma -3 x -1) (* (- (* x x) (* 1 1)) (- (* x x) (* 1 1)))) (* (- x 1) (+ x 1)))
737.0ms
(/ (fma -3 x -1) (* (- (pow (* x x) 3) (pow (* 1 1) 3)) (- (pow (* x x) 3) (pow (* 1 1) 3))))

prune2.1s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

regimes47.0ms

Accuracy

99.9% (0.0b remaining)

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

bsearch175.0ms