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

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -12657.23948929309 or 11711.196287288314 < 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 -12657.23948929309 < x < 11711.196287288314

    1. Initial program 0.1

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

      \[\leadsto \frac{x}{x + 1} - \frac{x + 1}{\color{blue}{\frac{x \cdot x - 1 \cdot 1}{x + 1}}}\]
    4. Applied associate-/r/0.1

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\frac{x + 1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)}\]
    5. Applied add-cube-cbrt0.1

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x}{x + 1}} \cdot \sqrt[3]{\frac{x}{x + 1}}\right) \cdot \sqrt[3]{\frac{x}{x + 1}}} - \frac{x + 1}{x \cdot x - 1 \cdot 1} \cdot \left(x + 1\right)\]
    6. Applied prod-diff0.1

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

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

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

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

Reproduce

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

Details

Time bar (total: 2.4m)Debug log

sample58.0ms

Algorithm
intervals

simplify30.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
30.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.6b

localize35.0ms

Local error

Found 3 expressions with local error:

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

rewrite25.0ms

Algorithm
rewrite-expression-head
Rules
90×prod-diff
75×add-sqr-sqrt
72×*-un-lft-identity
70×add-cube-cbrt
64×times-frac
48×associate-/r/
24×div-inv
18×flip-+
18×flip3-+
flip--
flip3--
fma-neg
associate-/r*
add-log-exp
add-exp-log
add-cbrt-cube
associate-/l*
log1p-expm1-u
pow1
expm1-log1p-u
associate-/l/
difference-of-squares
frac-2neg
clear-num
distribute-lft-out--
frac-sub
div-exp
diff-log
sub-neg
cbrt-undiv
Counts
3 → 164
Calls
3 calls:
Slowest
14.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
7.0ms
(/ (+ x 1) (- x 1))
1.0ms
(/ x (+ x 1))

series51.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
30.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
11.0ms
(/ (+ x 1) (- x 1))
9.0ms
(/ x (+ x 1))

simplify40.6s

Counts
235 → 173
Calls
235 calls:
Slowest
1.0s
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
787.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (sqrt (/ (+ x 1) (- x 1))) (sqrt (/ (+ x 1) (- x 1))))))
776.0ms
(fma x (/ 1 (+ x 1)) (- (* (/ (cbrt (+ x 1)) (cbrt (- x 1))) (/ (* (cbrt (+ x 1)) (cbrt (+ x 1))) (* (cbrt (- x 1)) (cbrt (- x 1)))))))
769.0ms
(fma x (/ 1 (+ x 1)) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))
751.0ms
(fma (sqrt (/ x (+ x 1))) (sqrt (/ x (+ x 1))) (- (* (+ x 1) (/ (+ x 1) (- (* x x) (* 1 1))))))

prune1.2s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize6.0ms

Local error

Found 4 expressions with local error:

3.5b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
3.5b
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
0.0b
(* (sqrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))) (sqrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
0.0b
(/ x (+ x 1))

rewrite83.0ms

Algorithm
rewrite-expression-head
Rules
180×prod-diff
145×add-sqr-sqrt
133×*-un-lft-identity
125×add-cube-cbrt
112×times-frac
90×associate-/r/
45×div-inv
33×flip-+
33×flip3-+
24×sqrt-div
22×flip--
22×flip3--
12×sqrt-prod
12×fma-neg
10×frac-sub
associate-*l*
associate-*r*
pow1
frac-times
difference-of-squares
add-log-exp
add-exp-log
add-cbrt-cube
distribute-lft-out--
log1p-expm1-u
pow1/2
expm1-log1p-u
associate-*r/
associate-*l/
associate-/r*
pow-prod-up
pow-prod-down
diff-log
sub-neg
cbrt-unprod
*-commutative
prod-exp
sqrt-unprod
pow-plus
frac-2neg
rem-square-sqrt
clear-num
pow2
Counts
4 → 298
Calls
4 calls:
Slowest
40.0ms
(* (sqrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))) (sqrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
15.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
15.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
1.0ms
(/ x (+ x 1))

series164.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
53.0ms
(* (sqrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))) (sqrt (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
48.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
48.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
14.0ms
(/ x (+ x 1))

simplify1.5m

Counts
454 → 310
Calls
454 calls:
Slowest
946.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
937.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (/ 1 (- x 1)) (+ x 1))))
850.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
815.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (cbrt (/ (+ x 1) (- x 1))) (* (cbrt (/ (+ x 1) (- x 1))) (cbrt (/ (+ x 1) (- x 1)))))))
813.0ms
(fma (/ x (- (* x x) (* 1 1))) (- x 1) (- (* (sqrt (/ (+ x 1) (- x 1))) (sqrt (/ (+ x 1) (- x 1))))))

prune2.8s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize35.0ms

Local error

Found 3 expressions with local error:

29.1b
(fma (/ -1 (+ -1 x)) (+ 1 x) (/ x (+ 1 x)))
0.0b
(/ -1 (+ -1 x))
0.0b
(/ x (+ 1 x))

rewrite2.0ms

Algorithm
rewrite-expression-head
Rules
associate-/r*
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
associate-/r/
add-log-exp
log1p-expm1-u
add-exp-log
add-cbrt-cube
pow1
expm1-log1p-u
div-inv
flip-+
flip3-+
frac-2neg
clear-num
fma-udef
Counts
3 → 44
Calls
3 calls:
Slowest
0.0ms
(/ -1 (+ -1 x))
0.0ms
(/ x (+ 1 x))
0.0ms
(fma (/ -1 (+ -1 x)) (+ 1 x) (/ x (+ 1 x)))

series45.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
25.0ms
(fma (/ -1 (+ -1 x)) (+ 1 x) (/ x (+ 1 x)))
13.0ms
(/ x (+ 1 x))
7.0ms
(/ -1 (+ -1 x))

simplify1.7s

Counts
19 → 53
Calls
19 calls:
Slowest
608.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
576.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
113.0ms
(- (+ x (pow x 3)) (pow x 2))
73.0ms
(+ (* -1 -1) (- (* x x) (* -1 x)))
72.0ms
(+ (* 1 1) (- (* x x) (* 1 x)))

prune468.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize15.0ms

Local error

Found 4 expressions with local error:

5.6b
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))
0.3b
(/ -1 (* x x))
0.3b
(/ -1 (* x x))
0.0b
(- (/ -1 (* x x)) (/ 3 x))

rewrite7.0ms

Algorithm
rewrite-expression-head
Rules
16×prod-diff
15×*-un-lft-identity
15×add-sqr-sqrt
13×add-cube-cbrt
11×div-inv
add-log-exp
log1p-expm1-u
add-exp-log
fma-neg
add-cbrt-cube
pow1
expm1-log1p-u
frac-2neg
associate-/r*
clear-num
difference-of-squares
distribute-lft-out--
flip--
fma-udef
frac-sub
diff-log
flip3--
sub-neg
Counts
4 → 73
Calls
4 calls:
Slowest
5.0ms
(- (/ -1 (* x x)) (/ 3 x))
0.0ms
(/ -1 (* x x))
0.0ms
(/ -1 (* x x))
0.0ms
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))

series88.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
33.0ms
(- (/ -1 (* x x)) (/ 3 x))
21.0ms
(fma (/ -1 (* x x)) (/ 3 x) (- (/ -1 (* x x)) (/ 3 x)))
17.0ms
(/ -1 (* x x))
16.0ms
(/ -1 (* x x))

simplify3.2s

Counts
52 → 85
Calls
52 calls:
Slowest
647.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
636.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
547.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
136.0ms
(- (* -1 x) (* (* x x) 3))
84.0ms
(fma 1 (/ -1 (* x x)) (- (* (/ 1 x) 3)))

prune572.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes88.0ms

Accuracy

100% (0.0b remaining)

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

bsearch174.0ms

end0.0ms

sample2.6s

Algorithm
intervals