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

    1. Initial program 29.3

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

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

      \[\leadsto \color{blue}{\frac{-2}{{x}^{6}} + \left(\frac{-2}{{x}^{4}} + \frac{-2}{x \cdot x}\right)}\]
    4. Using strategy rm
    5. Applied associate-/r*0.1

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

    if -292.47442415369994 < x < 484.8501943030043

    1. Initial program 0.0

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

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

Reproduce

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

Details

Time bar (total: 31.8s)Debug log

sample53.0ms

Algorithm
intervals

simplify6.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 15.1b

localize13.0ms

Local error

Found 3 expressions with local error:

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

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
3 → 103
Calls

3 calls. Slowest were:

12.0ms
(- (/ 1 (+ x 1)) (/ 1 (- x 1)))
2.0ms
(/ 1 (- x 1))
2.0ms
(/ 1 (+ x 1))

series62.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify18.4s

Counts
108 → 112
Calls

108 calls. Slowest were:

1.1s
(fma (- (+ x 1)) (/ 1 (- (* x x) (* 1 1))) (* (+ x 1) (/ 1 (- (* x x) (* 1 1)))))
1.1s
(fma (- (+ x 1)) (/ 1 (- (* x x) (* 1 1))) (* (+ x 1) (/ 1 (- (* x x) (* 1 1)))))
1.0s
(fma (- (+ x 1)) (/ 1 (- (* x x) (* 1 1))) (* (+ x 1) (/ 1 (- (* x x) (* 1 1)))))

prune822.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.5b

localize34.0ms

Local error

Found 4 expressions with local error:

0.5b
(/ -2 (* x x))
0.3b
(/ -2 (pow x 4))
0.2b
(/ -2 (pow x 6))
0.0b
(+ (/ -2 (pow x 4)) (/ -2 (* x x)))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

5.0ms
(+ (/ -2 (pow x 4)) (/ -2 (* x x)))
0.0ms
(/ -2 (pow x 4))
0.0ms
(/ -2 (pow x 6))

series110.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

54.0ms
(+ (/ -2 (pow x 4)) (/ -2 (* x x)))
22.0ms
(/ -2 (pow x 6))
18.0ms
(/ -2 (* x x))
15.0ms
(/ -2 (pow x 4))

simplify478.0ms

Counts
25 → 75
Calls

25 calls. Slowest were:

164.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))))
145.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))))
113.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))))

prune686.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 4 expressions with local error:

0.3b
(/ -2 (pow x 4))
0.2b
(/ -2 (pow x 6))
0.1b
(/ (/ -2 x) x)
0.0b
(+ (/ -2 (pow x 4)) (/ (/ -2 x) x))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
4 → 66
Calls

4 calls. Slowest were:

7.0ms
(+ (/ -2 (pow x 4)) (/ (/ -2 x) x))
2.0ms
(/ (/ -2 x) x)
1.0ms
(/ -2 (pow x 4))

series95.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

39.0ms
(+ (/ -2 (pow x 4)) (/ (/ -2 x) x))
26.0ms
(/ -2 (pow x 6))
19.0ms
(/ -2 (pow x 4))
10.0ms
(/ (/ -2 x) x)

simplify473.0ms

Counts
26 → 78
Calls

26 calls. Slowest were:

145.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))))
134.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))))
121.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))))

prune771.0ms

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0b

localize34.0ms

Local error

Found 4 expressions with local error:

28.4b
(/ (fma (/ -2 x) (pow x 4) (* -2 x)) (pow x 5))
2.3b
(fma (/ -2 x) (pow x 4) (* -2 x))
0.2b
(/ -2 (pow x 6))
0.0b
(+ (/ -2 (pow x 6)) (/ (fma (/ -2 x) (pow x 4) (* -2 x)) (pow x 5)))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 74
Calls

4 calls. Slowest were:

11.0ms
(+ (/ -2 (pow x 6)) (/ (fma (/ -2 x) (pow x 4) (* -2 x)) (pow x 5)))
7.0ms
(/ (fma (/ -2 x) (pow x 4) (* -2 x)) (pow x 5))
1.0ms
(/ -2 (pow x 6))

series273.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

130.0ms
(/ (fma (/ -2 x) (pow x 4) (* -2 x)) (pow x 5))
73.0ms
(fma (/ -2 x) (pow x 4) (* -2 x))
47.0ms
(+ (/ -2 (pow x 6)) (/ (fma (/ -2 x) (pow x 4) (* -2 x)) (pow x 5)))
23.0ms
(/ -2 (pow x 6))

simplify6.2s

Counts
47 → 86
Calls

47 calls. Slowest were:

1.0s
(- (+ (* 2 x) (* 2 (pow x 3))))
955.0ms
(- (+ (* 2 x) (* 2 (pow x 3))))
903.0ms
(- (+ (* 2 x) (* 2 (pow x 3))))

prune1.0s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0b

regimes113.0ms

Accuracy

99.7% (0.0b remaining)

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

bsearch146.0ms

end0.0ms

sample1.9s

Algorithm
intervals