Average Error: 29.2 → 0.0
Time: 1.1m
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{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\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(x \cdot x - 1\right)} \cdot \left(x - 1\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. Using strategy rm
    3. Applied frac-sub60.9

      \[\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{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}}\]

    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 flip-+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 \cdot x - 1 \cdot 1}{x - 1}} \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 \cdot x - 1 \cdot 1\right) \cdot \left(x - 1\right)}{x - 1}}}\]
    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 \cdot x - 1 \cdot 1\right) \cdot \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 -11997.32666981334 \lor \neg \left(x \le 11909.34130082208\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\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(x \cdot x - 1\right)} \cdot \left(x - 1\right)\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 1.1m)Debug log

sample55.0ms

Algorithm
intervals

simplify40.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 26.6b

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

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
3 → 62
Calls

3 calls. Slowest were:

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

series53.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify2.3s

Counts
51 → 71
Calls

51 calls. Slowest were:

528.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
313.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
312.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune640.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

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

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 65
Calls

4 calls. Slowest were:

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

series183.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

75.0ms
(cbrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
44.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
35.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
29.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

simplify4.9s

Counts
45 → 77
Calls

45 calls. Slowest were:

628.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
584.0ms
(cbrt (- (* x (- x 1)) (* (+ x 1) (+ x 1))))
523.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))

prune728.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

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

rewrite47.0ms

Algorithm
rewrite-expression-head
Counts
4 → 129
Calls

4 calls. Slowest were:

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

series100.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

35.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
29.0ms
(* x (- x 1))
27.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
10.0ms
(* (+ x 1) (+ x 1))

simplify24.0s

Counts
125 → 141
Calls

125 calls. Slowest were:

773.0ms
(* (- x 1) (+ (* x x) (- (* 1 1) (* x 1))))
655.0ms
(/ (exp (* x (- x 1))) (exp (* (+ x 1) (+ x 1))))
569.0ms
(- (log (- (* x (- x 1)) (* (+ x 1) (+ x 1)))) (+ (log (+ x 1)) (log (- x 1))))

prune1.2s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

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

rewrite55.0ms

Algorithm
rewrite-expression-head
Counts
4 → 121
Calls

4 calls. Slowest were:

31.0ms
(/ (- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1)) (* (+ x 1) (- x 1)))
14.0ms
(- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1))
5.0ms
(- (* x (- x 1)) (* x (+ x 1)))

series105.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

34.0ms
(* x (+ x 1))
31.0ms
(/ (- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1)) (* (+ x 1) (- x 1)))
27.0ms
(- (- (* x (- x 1)) (* x (+ x 1))) (+ x 1))
14.0ms
(- (* x (- x 1)) (* x (+ x 1)))

simplify25.4s

Counts
112 → 133
Calls

112 calls. Slowest were:

992.0ms
(- (pow (- (* x (- x 1)) (* x (+ x 1))) 3) (pow (+ x 1) 3))
972.0ms
(- (* (- (* x (- x 1)) (* x (+ x 1))) (- (* x (- x 1)) (* x (+ x 1)))) (* (+ x 1) (+ x 1)))
688.0ms
(- (* (- (* (* x (- (* x x) (* 1 1))) (- x 1)) (* (+ x 1) (* x (- (* x x) (* 1 1))))) (- x 1)) (* (* (+ x 1) (- x 1)) (- (* x x) (* 1 1))))

prune1.3s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

regimes59.0ms

Accuracy

100% (0.0b remaining)

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

bsearch152.0ms

end0.0ms

sample2.5s

Algorithm
intervals