Average Error: 29.4 → 0.1
Time: 1.0m
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -15731.583965646452 \lor \neg \left(x \le 9865.742309267576\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}:\\ \;\;\;\;\sqrt[3]{\left(\left(\frac{x}{1 + x} - \frac{1 + x}{x - 1}\right) \cdot \left(\frac{x}{1 + x} - \frac{1 + x}{x - 1}\right)\right) \cdot \left(\frac{x}{1 + x} - \frac{1 + x}{x - 1}\right)}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -15731.583965646452 or 9865.742309267576 < x

    1. Initial program 59.2

      \[\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 -15731.583965646452 < x < 9865.742309267576

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied add-cbrt-cube0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -15731.583965646452 \lor \neg \left(x \le 9865.742309267576\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}:\\ \;\;\;\;\sqrt[3]{\left(\left(\frac{x}{1 + x} - \frac{1 + x}{x - 1}\right) \cdot \left(\frac{x}{1 + x} - \frac{1 + x}{x - 1}\right)\right) \cdot \left(\frac{x}{1 + x} - \frac{1 + x}{x - 1}\right)}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 1.0m)Debug log

sample85.0ms

Algorithm
intervals

simplify28.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.6b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
3 → 164
Calls

3 calls. Slowest were:

19.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
4.0ms
(/ (+ x 1) (- x 1))
0.0ms
(/ x (+ x 1))

series50.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

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

simplify41.2s

Counts
235 → 173
Calls

235 calls. Slowest were:

1.0s
(fma (sqrt (/ x (+ x 1))) (sqrt (/ x (+ x 1))) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
782.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (sqrt (/ (+ x 1) (- x 1))) (sqrt (/ (+ x 1) (- x 1))))))
761.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (cbrt (/ (+ x 1) (- x 1))) (* (cbrt (/ (+ x 1) (- x 1))) (cbrt (/ (+ x 1) (- x 1)))))))

prune1.3s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

localize26.0ms

Local error

Found 4 expressions with local error:

6.4b
(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))

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
4 → 73
Calls

4 calls. Slowest were:

11.0ms
(- (/ -1 (* x x)) (/ 3 x))
1.0ms
(/ -1 (* x x))
1.0ms
(/ -1 (* x x))

series84.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

24.0ms
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))
22.0ms
(- (/ -1 (* x x)) (/ 3 x))
20.0ms
(/ -1 (* x x))
18.0ms
(/ -1 (* x x))

simplify3.0s

Counts
52 → 85
Calls

52 calls. Slowest were:

595.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
502.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
501.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune570.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.0b

localize20.0ms

Local error

Found 4 expressions with local error:

18.6b
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
18.6b
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
18.6b
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
6.4b
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
4 → 49
Calls

4 calls. Slowest were:

1.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
1.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
1.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))

series228.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
70.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
59.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
23.0ms
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))

simplify5.2s

Counts
21 → 61
Calls

21 calls. Slowest were:

607.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
503.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
502.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune468.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.0b

localize34.0ms

Local error

Found 4 expressions with local error:

18.6b
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
18.6b
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
18.6b
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
18.6b
(cbrt (fma (/ -1 (* x x)) (+ 1 (/ 3 x)) (/ -3 x)))

rewrite3.0ms

Algorithm
rewrite-expression-head
Counts
4 → 52
Calls

4 calls. Slowest were:

1.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
1.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
1.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))

series262.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
72.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
58.0ms
(cbrt (fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x))))
55.0ms
(cbrt (fma (/ -1 (* x x)) (+ 1 (/ 3 x)) (/ -3 x)))

simplify4.4s

Counts
24 → 64
Calls

24 calls. Slowest were:

350.0ms
(cbrt (sqrt (fma (/ -1 (* x x)) (+ 1 (/ 3 x)) (/ -3 x))))
284.0ms
(cbrt (* (cbrt (fma (/ -1 (* x x)) (+ 1 (/ 3 x)) (/ -3 x))) (cbrt (fma (/ -1 (* x x)) (+ 1 (/ 3 x)) (/ -3 x)))))
270.0ms
(+ (* 1/9 (* x (exp (* 1/3 (- (log -3) (* 3 (log x))))))) (+ (* 26/81 (* (pow x 2) (exp (* 1/3 (- (log -3) (* 3 (log x))))))) (exp (* 1/3 (- (log -3) (* 3 (log x)))))))

prune889.0ms

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

regimes140.0ms

Accuracy

99.9% (0.0b remaining)

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

bsearch107.0ms

end0.0ms

sample2.3s

Algorithm
intervals