Average Error: 28.8 → 0.1
Time: 27.3s
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 10295.895657573294\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 + x} - \left(1 + x\right) \cdot \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 < -12657.23948929309 or 10295.895657573294 < x

    1. Initial program 59.2

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Using strategy rm
    3. Applied div-inv59.4

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

    if -12657.23948929309 < x < 10295.895657573294

    1. Initial program 0.1

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

      \[\leadsto \frac{x}{x + 1} - \color{blue}{\left(x + 1\right) \cdot \frac{1}{x - 1}}\]
  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 10295.895657573294\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 + x} - \left(1 + x\right) \cdot \frac{1}{x - 1}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 27.1s)Debug log

sample73.0ms

Algorithm
intervals

simplify14.0ms

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.6b

localize22.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))

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
17×add-sqr-sqrt
14×*-un-lft-identity
12×add-cube-cbrt
10×times-frac
associate-/r*
add-log-exp
add-exp-log
add-cbrt-cube
associate-/r/
associate-/l*
pow1
associate-/l/
difference-of-squares
flip--
div-inv
flip-+
flip3--
flip3-+
frac-2neg
clear-num
distribute-lft-out--
frac-sub
div-exp
diff-log
sub-neg
cbrt-undiv
Counts
3 → 62
Calls
3 calls:
Slowest
7.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
3.0ms
(/ (+ x 1) (- x 1))
0.0ms
(/ x (+ x 1))

series83.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
49.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
17.0ms
(/ (+ x 1) (- x 1))
16.0ms
(/ x (+ x 1))

simplify1.9s

Counts
51 → 71
Calls
51 calls:
Slowest
446.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
271.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
211.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
208.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 2)) 1)))
199.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune496.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize15.0ms

Local error

Found 4 expressions with local error:

8.6b
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
0.1b
(* (+ x 1) (/ 1 (- x 1)))
0.0b
(/ 1 (- x 1))
0.0b
(/ x (+ x 1))

rewrite27.0ms

Algorithm
rewrite-expression-head
Rules
add-exp-log
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
pow1
add-log-exp
frac-sub
associate-/r/
associate-*r*
add-cbrt-cube
associate-/r*
flip-+
flip3-+
associate-*l/
frac-times
flip--
div-inv
associate-*l*
flip3--
un-div-inv
associate-*r/
prod-exp
frac-2neg
clear-num
rec-exp
inv-pow
pow-flip
cbrt-unprod
*-commutative
pow-prod-down
diff-log
sub-neg
Counts
4 → 78
Calls
4 calls:
Slowest
12.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
8.0ms
(* (+ x 1) (/ 1 (- x 1)))
2.0ms
(/ 1 (- x 1))
1.0ms
(/ x (+ x 1))

series73.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
34.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
16.0ms
(/ x (+ x 1))
13.0ms
(* (+ x 1) (/ 1 (- x 1)))
11.0ms
(/ 1 (- x 1))

simplify5.6s

Counts
56 → 90
Calls
56 calls:
Slowest
549.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
522.0ms
(* (- (* x x) (* 1 1)) (/ 1 (- x 1)))
385.0ms
(* (+ x 1) (+ (* x x) (- (* 1 1) (* x 1))))
362.0ms
(/ (exp (/ x (+ x 1))) (exp (* (+ x 1) (/ 1 (- x 1)))))
347.0ms
(* (+ x 1) (* (- x 1) (- x 1)))

prune631.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize13.0ms

Local error

Found 4 expressions with local error:

8.6b
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
8.6b
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
0.1b
(* (+ x 1) (/ 1 (- x 1)))
0.1b
(* (+ x 1) (/ 1 (- x 1)))

rewrite45.0ms

Algorithm
rewrite-expression-head
Rules
12×frac-sub
12×add-exp-log
12×associate-*r*
add-log-exp
flip-+
add-cube-cbrt
associate-*l/
add-cbrt-cube
flip3-+
*-un-lft-identity
pow1
frac-times
add-sqr-sqrt
associate-*l*
flip--
un-div-inv
associate-/r/
associate-*r/
prod-exp
flip3--
div-inv
cbrt-unprod
*-commutative
pow-prod-down
diff-log
sub-neg
rec-exp
Counts
4 → 90
Calls
4 calls:
Slowest
12.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
12.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
10.0ms
(* (+ x 1) (/ 1 (- x 1)))
8.0ms
(* (+ x 1) (/ 1 (- x 1)))

series121.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
51.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
49.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
11.0ms
(* (+ x 1) (/ 1 (- x 1)))
10.0ms
(* (+ x 1) (/ 1 (- x 1)))

simplify10.5s

Counts
78 → 102
Calls
78 calls:
Slowest
637.0ms
(* (- (* x x) (* 1 1)) (/ 1 (- x 1)))
612.0ms
(* (- (* x x) (* 1 1)) (/ 1 (- x 1)))
518.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
480.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
435.0ms
(* (+ x 1) (+ (* x x) (- (* 1 1) (* x 1))))

prune1.1s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize29.0ms

Local error

Found 4 expressions with local error:

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

rewrite52.0ms

Algorithm
rewrite-expression-head
Rules
16×*-un-lft-identity
11×add-log-exp
add-sqr-sqrt
add-exp-log
div-inv
add-cube-cbrt
add-cbrt-cube
pow1
distribute-lft-out--
associate-/l*
times-frac
distribute-lft-out
frac-add
flip--
pow-flip
frac-sub
diff-log
flip3--
frac-2neg
sub-neg
sum-log
associate-/r*
clear-num
associate-+l+
associate-/l/
difference-of-squares
inv-pow
flip-+
associate-+l-
div-exp
flip3-+
rec-exp
+-commutative
cbrt-undiv
pow2
Counts
4 → 74
Calls
4 calls:
Slowest
37.0ms
(+ (- (/ -3 x) (/ 1 (* x x))) (/ (/ -3 x) (* x x)))
7.0ms
(- (/ -3 x) (/ 1 (* x x)))
5.0ms
(/ (/ -3 x) (* x x))
1.0ms
(/ 1 (* x x))

series438.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
377.0ms
(- (/ -3 x) (/ 1 (* x x)))
26.0ms
(/ (/ -3 x) (* x x))
22.0ms
(+ (- (/ -3 x) (/ 1 (* x x))) (/ (/ -3 x) (* x x)))
13.0ms
(/ 1 (* x x))

simplify2.9s

Counts
47 → 86
Calls
47 calls:
Slowest
568.0ms
(/ (* (* (/ -3 x) (/ -3 x)) (/ -3 x)) (* (* (* x x) (* x x)) (* x x)))
361.0ms
(* (+ (* (/ -3 x) (/ -3 x)) (+ (* (/ 1 (* x x)) (/ 1 (* x x))) (* (/ -3 x) (/ 1 (* x x))))) (* x x))
271.0ms
(+ (* (- (* (/ -3 x) (/ -3 x)) (* (/ 1 (* x x)) (/ 1 (* x x)))) (* x x)) (* (+ (/ -3 x) (/ 1 (* x x))) (/ -3 x)))
228.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
221.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune623.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes44.0ms

Accuracy

100% (0.0b remaining)

Error of 0.1b against oracle of 0.1b and baseline of 28.9b

bsearch167.0ms

end0.0ms

sample2.1s

Algorithm
intervals