Average Error: 28.9 → 0.0
Time: 1.7m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -17880101892810302.0 \lor \neg \left(x \le 123538.45092554518\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{\left(\left(-2 - x\right) + x\right) - \frac{1 + x}{x}}{\frac{(x \cdot x + -1)_*}{x}}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -17880101892810302.0 or 123538.45092554518 < x

    1. Initial program 60.0

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. 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)}\]
    3. 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 -17880101892810302.0 < x < 123538.45092554518

    1. Initial program 0.7

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -17880101892810302.0 \lor \neg \left(x \le 123538.45092554518\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{\left(\left(-2 - x\right) + x\right) - \frac{1 + x}{x}}{\frac{(x \cdot x + -1)_*}{x}}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 1.6m)Debug log

start131.0ms

Algorithm
intervals

setup46.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.7b

localize50.0ms

Local error

Found 3 expressions with local error:

2.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:

9.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
3.0ms
(/ (+ x 1) (- x 1))
0.0ms
(/ x (+ x 1))

series65.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify45.7s

Counts
235 → 173
Calls

235 calls. Slowest were:

1.2s
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
973.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (cbrt (/ (+ x 1) (- x 1))) (* (cbrt (/ (+ x 1) (- x 1))) (cbrt (/ (+ x 1) (- x 1)))))))
954.0ms
(fma x (/ 1 (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune2.0s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize19.0ms

Local error

Found 4 expressions with local error:

6.0b
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))
0.5b
(/ -1 (* x x))
0.5b
(/ -1 (* x x))
0.0b
(- (/ -1 (* x x)) (/ 3 x))

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
4 → 73
Calls

4 calls. Slowest were:

5.0ms
(- (/ -1 (* x x)) (/ 3 x))
0.0ms
(/ -1 (* x x))
0.0ms
(/ -1 (* x x))

series67.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

30.0ms
(- (/ -1 (* x x)) (/ 3 x))
15.0ms
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))
11.0ms
(/ -1 (* x x))
11.0ms
(/ -1 (* x x))

simplify3.4s

Counts
52 → 85
Calls

52 calls. Slowest were:

680.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
605.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
600.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune905.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.0b

localize19.0ms

Local error

Found 4 expressions with local error:

6.0b
(fma (/ -1 (* x x)) (/ 3 x) (fma 3 (/ -1 x) (/ (/ -1 x) x)))
0.5b
(/ -1 (* x x))
0.2b
(fma 3 (/ -1 x) (/ (/ -1 x) x))
0.1b
(/ (/ -1 x) x)

rewrite3.0ms

Algorithm
rewrite-expression-head
Counts
4 → 50
Calls

4 calls. Slowest were:

2.0ms
(/ (/ -1 x) x)
0.0ms
(/ -1 (* x x))
0.0ms
(fma (/ -1 (* x x)) (/ 3 x) (fma 3 (/ -1 x) (/ (/ -1 x) x)))

series91.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

42.0ms
(fma 3 (/ -1 x) (/ (/ -1 x) x))
19.0ms
(/ (/ -1 x) x)
15.0ms
(fma (/ -1 (* x x)) (/ 3 x) (fma 3 (/ -1 x) (/ (/ -1 x) x)))
14.0ms
(/ -1 (* x x))

simplify2.1s

Counts
14 → 62
Calls

14 calls. Slowest were:

647.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
614.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
554.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune764.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 4 expressions with local error:

2.5b
(- (/ 1 (/ (+ x 1) x)) (/ (+ x 1) (- x 1)))
0.1b
(/ 1 (/ (+ x 1) x))
0.0b
(/ (+ x 1) (- x 1))
0.0b
(/ (+ x 1) x)

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 169
Calls

4 calls. Slowest were:

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

series124.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

58.0ms
(- (/ 1 (/ (+ x 1) x)) (/ (+ x 1) (- x 1)))
32.0ms
(/ (+ x 1) x)
17.0ms
(/ 1 (/ (+ x 1) x))
17.0ms
(/ (+ x 1) (- x 1))

simplify38.5s

Counts
212 → 181
Calls

212 calls. Slowest were:

1.5s
(fma 1 (/ 1 (/ (+ x 1) x)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
1.1s
(fma 1 (/ 1 (/ (+ x 1) x)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
966.0ms
(fma (sqrt (/ 1 (/ (+ x 1) x))) (sqrt (/ 1 (/ (+ x 1) x))) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune1.5s

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0.0b

regimes43.0ms

Accuracy

99.9% (0.0b remaining)

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

bsearch164.0ms