Average Error: 14.6 → 0.1
Time: 9.5s
Precision: 64
Internal Precision: 128
\[\frac{1}{x + 1} - \frac{1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -13507.472987014315 \lor \neg \left(x \le 12154.943809828786\right):\\ \;\;\;\;\frac{1}{{x}^{3}} - \left({x}^{-2} + \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + x} - \frac{1}{x}\\ \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 < -13507.472987014315 or 12154.943809828786 < x

    1. Initial program 29.3

      \[\frac{1}{x + 1} - \frac{1}{x}\]
    2. Taylor expanded around inf 0.9

      \[\leadsto \color{blue}{\frac{1}{{x}^{3}} - \left(\frac{1}{{x}^{4}} + \frac{1}{{x}^{2}}\right)}\]
    3. Using strategy rm
    4. Applied pow-flip0.0

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

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

    if -13507.472987014315 < x < 12154.943809828786

    1. Initial program 0.1

      \[\frac{1}{x + 1} - \frac{1}{x}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -13507.472987014315 \lor \neg \left(x \le 12154.943809828786\right):\\ \;\;\;\;\frac{1}{{x}^{3}} - \left({x}^{-2} + \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + x} - \frac{1}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  (- (/ 1 (+ x 1)) (/ 1 x)))

Details

Time bar (total: 9.2s)Debug log

sample56.0ms

Algorithm
intervals

simplify6.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 13.8b

localize11.0ms

Local error

Found 2 expressions with local error:

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

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
2 → 36
Calls

2 calls. Slowest were:

5.0ms
(- (/ 1 (+ x 1)) (/ 1 x))
1.0ms
(/ 1 (+ x 1))

series45.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

25.0ms
(/ 1 (+ x 1))
20.0ms
(- (/ 1 (+ x 1)) (/ 1 x))

simplify364.0ms

Counts
21 → 42
Calls

21 calls. Slowest were:

64.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
43.0ms
(- (+ (/ 1 (pow x 3)) (/ 1 x)) (/ 1 (pow x 2)))
39.0ms
(- 1 (+ x (/ 1 x)))

prune341.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.1b

localize47.0ms

Local error

Found 4 expressions with local error:

12.0b
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
0.4b
(/ 1 (pow x 3))
0.2b
(/ 1 (pow x 2))
0.2b
(/ 1 (pow x 4))

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 82
Calls

4 calls. Slowest were:

24.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
1.0ms
(/ 1 (pow x 2))
1.0ms
(/ 1 (pow x 3))

series83.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

22.0ms
(/ 1 (pow x 3))
21.0ms
(/ 1 (pow x 2))
20.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
20.0ms
(/ 1 (pow x 4))

simplify2.7s

Counts
46 → 94
Calls

46 calls. Slowest were:

564.0ms
(* (pow x 3) (- (/ 1 (pow x 4)) (/ 1 (pow x 2))))
431.0ms
(- (* 1 (- (/ 1 (pow x 4)) (/ 1 (pow x 2)))) (* (pow x 3) (- (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (* (/ 1 (pow x 2)) (/ 1 (pow x 2))))))
351.0ms
(* (pow x 3) (+ (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (- (* (/ 1 (pow x 2)) (/ 1 (pow x 2))) (* (/ 1 (pow x 4)) (/ 1 (pow x 2))))))

prune897.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize22.0ms

Local error

Found 4 expressions with local error:

12.0b
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (pow x -2)))
0.4b
(/ 1 (pow x 3))
0.2b
(/ 1 (pow x 4))
0.0b
(+ (/ 1 (pow x 4)) (pow x -2))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

21.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (pow x -2)))
4.0ms
(+ (/ 1 (pow x 4)) (pow x -2))
1.0ms
(/ 1 (pow x 3))

series110.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

59.0ms
(+ (/ 1 (pow x 4)) (pow x -2))
20.0ms
(/ 1 (pow x 4))
18.0ms
(/ 1 (pow x 3))
14.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (pow x -2)))

simplify1.6s

Counts
39 → 84
Calls

39 calls. Slowest were:

274.0ms
(- (* 1 (- (/ 1 (pow x 4)) (pow x -2))) (* (pow x 3) (- (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (* (pow x -2) (pow x -2)))))
224.0ms
(* (pow x 3) (+ (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (- (* (pow x -2) (pow x -2)) (* (/ 1 (pow x 4)) (pow x -2)))))
153.0ms
(* (pow x 3) (- (/ 1 (pow x 4)) (pow x -2)))

prune871.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes77.0ms

Accuracy

100% (0.0b remaining)

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

bsearch133.0ms

end0.0ms

sample1.8s

Algorithm
intervals