Average Error: 29.4 → 0.1
Time: 29.7s
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -15562.517425007405 \lor \neg \left(x \le 10884.524633064508\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}\right)\\ \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 < -15562.517425007405 or 10884.524633064508 < 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 -15562.517425007405 < x < 10884.524633064508

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\log \left(e^{\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 -15562.517425007405 \lor \neg \left(x \le 10884.524633064508\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{\frac{x}{1 + x} - \frac{1 + x}{x - 1}}\right)\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 29.2s)Debug log

sample56.0ms

Algorithm
intervals
Results
256×(pre true 80)
131×(body real 80)
56×(body real 1280)
39×(body real 640)
16×(body real 320)
14×(body real 160)

simplify27.0ms

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.2b

localize42.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.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
6.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
3.0ms
(/ (+ x 1) (- x 1))
0.0ms
(/ x (+ x 1))

series57.0ms

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

simplify2.0s

Counts
51 → 71
Calls
51 calls:
Slowest
446.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
314.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
232.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
218.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
197.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 2)) 1)))

prune366.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

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

rewrite85.0ms

Algorithm
rewrite-expression-head
Rules
30×add-sqr-sqrt
21×*-un-lft-identity
15×add-cube-cbrt
12×times-frac
12×exp-prod
add-log-exp
log-pow
difference-of-squares
add-exp-log
add-cbrt-cube
log-prod
pow1
exp-sum
distribute-lft-out--
associate-/l*
sub-neg
associate-/r*
associate-/l/
rem-exp-log
flip--
associate-/r/
diff-log
exp-diff
flip3--
div-inv
flip-+
frac-sub
rem-log-exp
div-exp
flip3-+
frac-2neg
clear-num
log-div
cbrt-undiv
Counts
4 → 86
Calls
4 calls:
Slowest
35.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
30.0ms
(exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
11.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
6.0ms
(/ (+ x 1) (- x 1))

series137.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
47.0ms
(exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
45.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
34.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
11.0ms
(/ (+ x 1) (- x 1))

simplify3.0s

Counts
73 → 98
Calls
73 calls:
Slowest
467.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
329.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
275.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
259.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))
249.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune795.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize7.0ms

Local error

Found 4 expressions with local error:

8.3b
(- (/ 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))

rewrite12.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
6.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
4.0ms
(* (+ x 1) (/ 1 (- x 1)))
1.0ms
(/ 1 (- x 1))
0.0ms
(/ x (+ x 1))

series83.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
50.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
17.0ms
(* (+ x 1) (/ 1 (- x 1)))
9.0ms
(/ x (+ x 1))
6.0ms
(/ 1 (- x 1))

simplify6.0s

Counts
56 → 90
Calls
56 calls:
Slowest
575.0ms
(* (- (* x x) (* 1 1)) (/ 1 (- x 1)))
571.0ms
(- (* x (+ (* x x) (- (* 1 1) (* x 1)))) (* (+ x 1) (* (+ (pow x 3) (pow 1 3)) (/ 1 (- x 1)))))
562.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
392.0ms
(* (+ x 1) (* (+ (* x x) (- (* 1 1) (* x 1))) (- x 1)))
369.0ms
(* (+ x 1) (* (- x 1) (- x 1)))

prune607.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 4 expressions with local error:

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

rewrite48.0ms

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

series143.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
47.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
44.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
36.0ms
(- (/ x (+ x 1)) (* (+ x 1) (/ 1 (- x 1))))
17.0ms
(* (+ x 1) (/ 1 (- x 1)))

simplify12.3s

Counts
71 → 93
Calls
71 calls:
Slowest
645.0ms
(* (- (* x x) (* 1 1)) (/ 1 (- x 1)))
494.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
467.0ms
(* (+ x 1) (+ (* x x) (- (* 1 1) (* x 1))))
451.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
416.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))

prune960.0ms

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0.0b

regimes95.0ms

Accuracy

99.9% (0.0b remaining)

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

bsearch96.0ms

end0.0ms

sample2.3s

Algorithm
intervals
Results
8000×(pre true 80)
4096×(body real 80)
1767×(body real 1280)
1213×(body real 640)
610×(body real 320)
314×(body real 160)