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

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -11461.495204336437 or 10887.392763278185 < x

    1. Initial program 59.3

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip--59.3

      \[\leadsto \color{blue}{\frac{\frac{x}{x + 1} \cdot \frac{x}{x + 1} - \frac{x + 1}{x - 1} \cdot \frac{x + 1}{x - 1}}{\frac{x}{x + 1} + \frac{x + 1}{x - 1}}}\]
    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{-1}{x \cdot x}\right) \cdot \left(\frac{3}{x}\right) + \left(\frac{-1}{x \cdot x} - \frac{3}{x}\right))_*}\]

    if -11461.495204336437 < x < 10887.392763278185

    1. Initial program 0.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied flip--0.1

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

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

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

Reproduce

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

Details

Time bar (total: 4.8m)Debug log

sample65.0ms

Algorithm
intervals

simplify29.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune7.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.0b

localize25.0ms

Local error

Found 3 expressions with local error:

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

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
3 → 164
Calls

3 calls. Slowest were:

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

series78.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

58.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
10.0ms
(/ (+ x 1) (- x 1))
9.0ms
(/ x (+ x 1))

simplify41.1s

Counts
235 → 173
Calls

235 calls. Slowest were:

898.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
808.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (cbrt (/ (+ x 1) (- x 1))) (* (cbrt (/ (+ x 1) (- x 1))) (cbrt (/ (+ x 1) (- x 1)))))))
777.0ms
(fma x (/ 1 (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune1.3s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize26.0ms

Local error

Found 4 expressions with local error:

2.6b
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
0.0b
(* (/ x (+ x 1)) (/ x (+ x 1)))
0.0b
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
0.0b
(* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))

rewrite61.0ms

Algorithm
rewrite-expression-head
Counts
4 → 165
Calls

4 calls. Slowest were:

27.0ms
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
13.0ms
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
11.0ms
(* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))

series185.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

92.0ms
(/ (- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (+ (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
55.0ms
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
20.0ms
(* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))
18.0ms
(* (/ x (+ x 1)) (/ x (+ x 1)))

simplify30.2s

Counts
157 → 177
Calls

157 calls. Slowest were:

1.2s
(* (* (+ x 1) (+ x 1)) (- x 1))
896.0ms
(- (* (* x x) (- x 1)) (* (* (+ x 1) (+ x 1)) (* (+ x 1) (/ (+ x 1) (- x 1)))))
863.0ms
(* (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))) (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))

prune1.4s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize29.0ms

Local error

Found 4 expressions with local error:

2.6b
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (cbrt (* (* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))))
0.0b
(* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
0.0b
(cbrt (* (* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))))
0.0b
(* (/ x (+ x 1)) (/ x (+ x 1)))

rewrite204.0ms

Algorithm
rewrite-expression-head
Counts
4 → 417
Calls

4 calls. Slowest were:

116.0ms
(cbrt (* (* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))))
46.0ms
(* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
25.0ms
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (cbrt (* (* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))))

series90.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

49.0ms
(- (* (/ x (+ x 1)) (/ x (+ x 1))) (cbrt (* (* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))))
16.0ms
(* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))))
14.0ms
(cbrt (* (* (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))) (* (/ (+ x 1) (- x 1)) (/ (+ x 1) (- x 1)))))
11.0ms
(* (/ x (+ x 1)) (/ x (+ x 1)))

simplify3.0m

Counts
604 → 429
Calls

604 calls. Slowest were:

1.9s
(cbrt (* (* (* (+ x 1) (+ x 1)) (* (+ x 1) (/ (+ x 1) (- x 1)))) (* (+ x 1) (+ x 1))))
1.5s
(* (* (+ x 1) (+ x 1)) (cbrt (* (* (- x 1) (- x 1)) (- x 1))))
1.2s
(* (* (+ x 1) (+ x 1)) (cbrt (* (- x 1) (* (- x 1) (- x 1)))))

prune5.2s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.0b

localize35.0ms

Local error

Found 4 expressions with local error:

2.6b
(- (pow (/ x (+ 1 x)) 4) (pow (/ (+ 1 x) (+ x -1)) 4))
0.0b
(pow (/ (+ 1 x) (+ x -1)) 4)
0.0b
(pow (/ x (+ 1 x)) 4)
0.0b
(* (/ x (+ x 1)) (/ x (+ x 1)))

rewrite64.0ms

Algorithm
rewrite-expression-head
Counts
4 → 270
Calls

4 calls. Slowest were:

38.0ms
(- (pow (/ x (+ 1 x)) 4) (pow (/ (+ 1 x) (+ x -1)) 4))
7.0ms
(* (/ x (+ x 1)) (/ x (+ x 1)))
5.0ms
(pow (/ (+ 1 x) (+ x -1)) 4)

series159.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

116.0ms
(- (pow (/ x (+ 1 x)) 4) (pow (/ (+ 1 x) (+ x -1)) 4))
20.0ms
(pow (/ (+ 1 x) (+ x -1)) 4)
12.0ms
(pow (/ x (+ 1 x)) 4)
11.0ms
(* (/ x (+ x 1)) (/ x (+ x 1)))

simplify21.3s

Counts
406 → 282
Calls

406 calls. Slowest were:

951.0ms
(* (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))) (* (* (/ x (+ x 1)) (/ x (+ x 1))) (/ x (+ x 1))))
447.0ms
(fma (pow (/ x (+ (pow 1 3) (pow x 3))) 4) (pow (+ (* 1 1) (- (* x x) (* 1 x))) 4) (- (* (pow (- x -1) 4) (pow (/ (+ 1 x) (- (* x x) (* -1 -1))) 4))))
412.0ms
(- (+ (* 108 (/ 1 (pow x 3))) (+ (* 22 (/ 1 (pow x 2))) (* 12 (/ 1 x)))))

prune3.8s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0.0b

regimes94.0ms

Accuracy

99.9% (0.0b remaining)

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

bsearch135.0ms

end0.0ms

sample2.3s

Algorithm
intervals