Average Error: 29.4 → 0.2
Time: 3.3m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -13564.282494661315 \lor \neg \left(x \le 1.0092784462051199\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{\frac{(e^{\log_* (1 + \left(\frac{x \cdot x}{\frac{1 + x}{-1 + x}} - \frac{1 + x}{-1 + x} \cdot \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)\right))} - 1)^*}{\left(x - 1\right) \cdot \left(1 + x\right)}}{\frac{1 + x}{x - 1} + \frac{x}{1 + x}}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -13564.282494661315 or 1.0092784462051199 < x

    1. Initial program 58.9

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

      \[\leadsto \color{blue}{\frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \frac{x + 1}{x - 1} \cdot \frac{x + 1}{x - 1}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}}\]
    4. Using strategy rm
    5. Applied div-inv59.1

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

      \[\leadsto \frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \color{blue}{\left(x + 1\right) \cdot \left(\frac{1}{x - 1} \cdot \frac{x + 1}{x - 1}\right)}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}\]
    7. Using strategy rm
    8. Applied associate-*l/59.1

      \[\leadsto \frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \left(x + 1\right) \cdot \color{blue}{\frac{1 \cdot \frac{x + 1}{x - 1}}{x - 1}}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}\]
    9. Applied associate-*r/58.9

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{\frac{x \cdot x}{\frac{1 + x}{x + -1}} - \left(\left(1 + x\right) \cdot \left(1 + x\right)\right) \cdot \frac{1 + x}{x + -1}}}{\left(x + 1\right) \cdot \left(x - 1\right)}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}\]
    13. Taylor expanded around inf 0.6

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

      \[\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 -13564.282494661315 < x < 1.0092784462051199

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \frac{x + 1}{x - 1} \cdot \frac{x + 1}{x - 1}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}}\]
    4. Using strategy rm
    5. Applied div-inv0.1

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

      \[\leadsto \frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \color{blue}{\left(x + 1\right) \cdot \left(\frac{1}{x - 1} \cdot \frac{x + 1}{x - 1}\right)}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}\]
    7. Using strategy rm
    8. Applied associate-*l/0.1

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

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

      \[\leadsto \frac{\color{blue}{\frac{x \cdot \frac{x}{x + 1}}{x + 1}} - \frac{\left(x + 1\right) \cdot \left(1 \cdot \frac{x + 1}{x - 1}\right)}{x - 1}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}\]
    11. Applied frac-sub0.1

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

      \[\leadsto \frac{\frac{\color{blue}{\frac{x \cdot x}{\frac{1 + x}{x + -1}} - \left(\left(1 + x\right) \cdot \left(1 + x\right)\right) \cdot \frac{1 + x}{x + -1}}}{\left(x + 1\right) \cdot \left(x - 1\right)}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}\]
    13. Using strategy rm
    14. Applied expm1-log1p-u0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -13564.282494661315 \lor \neg \left(x \le 1.0092784462051199\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{\frac{(e^{\log_* (1 + \left(\frac{x \cdot x}{\frac{1 + x}{-1 + x}} - \frac{1 + x}{-1 + x} \cdot \left(\left(1 + x\right) \cdot \left(1 + x\right)\right)\right))} - 1)^*}{\left(x - 1\right) \cdot \left(1 + x\right)}}{\frac{1 + x}{x - 1} + \frac{x}{1 + x}}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 3.2m)Debug log

sample48.0ms

Algorithm
intervals

simplify14.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.9b

localize23.0ms

Local error

Found 3 expressions with local error:

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

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

series58.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify43.4s

Counts
235 → 173
Calls

235 calls. Slowest were:

940.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
859.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (cbrt (/ (+ x 1) (- x 1))) (* (cbrt (/ (+ x 1) (- x 1))) (cbrt (/ (+ x 1) (- x 1)))))))
815.0ms
(fma x (/ 1 (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune1.5s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.1b

localize29.0ms

Local error

Found 4 expressions with local error:

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

rewrite95.0ms

Algorithm
rewrite-expression-head
Counts
4 → 155
Calls

4 calls. Slowest were:

42.0ms
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
21.0ms
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
15.0ms
(* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))

series240.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

101.0ms
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
78.0ms
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
39.0ms
(+ (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
22.0ms
(* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))

simplify30.0s

Counts
145 → 167
Calls

145 calls. Slowest were:

889.0ms
(* (* (+ x 1) (+ x 1)) (- x 1))
879.0ms
(* (+ x 1) (* (- x 1) (- x 1)))
819.0ms
(- (* (* x x) (- x 1)) (* (* (+ x 1) (+ x 1)) (* (+ x 1) (/ (+ x 1) (- x 1)))))

prune1.4s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 4 expressions with local error:

7.3b
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1)))))
0.1b
(* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1))))
0.0b
(+ (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
0.0b
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1))))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))

rewrite91.0ms

Algorithm
rewrite-expression-head
Counts
4 → 177
Calls

4 calls. Slowest were:

41.0ms
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1))))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
18.0ms
(+ (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
17.0ms
(* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1))))

series232.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

107.0ms
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1))))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
63.0ms
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1)))))
40.0ms
(+ (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
22.0ms
(* (+ x 1) (* (/ 1 (- x 1)) (/ (+ x 1) (- x 1))))

simplify50.2s

Counts
191 → 189
Calls

191 calls. Slowest were:

1.1s
(- (* (* x x) (- x 1)) (* (* (+ x 1) (+ x 1)) (* (+ x 1) (* 1 (/ (+ x 1) (- x 1))))))
997.0ms
(* (* (+ x 1) (+ x 1)) (* (- x 1) (* (- x 1) (- x 1))))
996.0ms
(* (* (+ x 1) (+ x 1)) (- x 1))

prune2.2s

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.0b

localize61.0ms

Local error

Found 4 expressions with local error:

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

rewrite134.0ms

Algorithm
rewrite-expression-head
Counts
4 → 227
Calls

4 calls. Slowest were:

68.0ms
(/ (/ (- (/ (* x x) (/ (+ 1 x) (+ x -1))) (* (* (+ 1 x) (+ 1 x)) (/ (+ 1 x) (+ x -1)))) (* (+ x 1) (- x 1))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
38.0ms
(- (/ (* x x) (/ (+ 1 x) (+ x -1))) (* (* (+ 1 x) (+ 1 x)) (/ (+ 1 x) (+ x -1))))
13.0ms
(+ (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

series284.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

131.0ms
(/ (/ (- (/ (* x x) (/ (+ 1 x) (+ x -1))) (* (* (+ 1 x) (+ 1 x)) (/ (+ 1 x) (+ x -1)))) (* (+ x 1) (- x 1))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
93.0ms
(- (/ (* x x) (/ (+ 1 x) (+ x -1))) (* (* (+ 1 x) (+ 1 x)) (/ (+ 1 x) (+ x -1))))
41.0ms
(+ (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
18.0ms
(/ (+ x 1) (- x 1))

simplify59.3s

Counts
292 → 239
Calls

292 calls. Slowest were:

994.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 2)) 1)))
885.0ms
(* (/ (+ 1 x) (+ x -1)) (+ x -1))
776.0ms
(/ (/ (sqrt (- (/ (* x x) (/ (+ 1 x) (+ x -1))) (* (* (+ 1 x) (+ 1 x)) (/ (+ 1 x) (+ x -1))))) (- x 1)) (cbrt (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))

prune2.8s

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0.0b

regimes53.0ms

Accuracy

99.5% (0.1b remaining)

Error of 0.2b against oracle of 0.0b and baseline of 29.5b

bsearch139.0ms

end0.0ms

sample2.2s

Algorithm
intervals