Average Error: 28.9 → 0.0
Time: 56.9s
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8.248194718717447 \cdot 10^{+39} \lor \neg \left(x \le 4921536.861747979\right):\\ \;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{\frac{3}{x}}{x \cdot x}\right) - \frac{3}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1 - x \cdot 3}{\left(1 + x\right) \cdot \left(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 < -8.248194718717447e+39 or 4921536.861747979 < x

    1. Initial program 60.1

      \[\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} - \frac{\frac{3}{x}}{x \cdot x}\right) - \frac{3}{x}}\]

    if -8.248194718717447e+39 < x < 4921536.861747979

    1. Initial program 2.7

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(x - 1\right) - \left(x + 1\right) \cdot \left(x + 1\right)}{\left(x + 1\right) \cdot \left(x - 1\right)}}\]
    4. Taylor expanded around 0 0.0

      \[\leadsto \frac{\color{blue}{-\left(3 \cdot x + 1\right)}}{\left(x + 1\right) \cdot \left(x - 1\right)}\]
    5. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -8.248194718717447 \cdot 10^{+39} \lor \neg \left(x \le 4921536.861747979\right):\\ \;\;\;\;\left(\frac{-1}{x \cdot x} - \frac{\frac{3}{x}}{x \cdot x}\right) - \frac{3}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1 - x \cdot 3}{\left(1 + x\right) \cdot \left(x - 1\right)}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 51.7s)Debug log

start148.0ms

Algorithm
intervals

setup41.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.0b

localize24.0ms

Local error

Found 3 expressions with local error:

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

rewrite18.0ms

Algorithm
rewrite-expression-head
Counts
3 → 62
Calls

3 calls. Slowest were:

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

series103.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

69.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
18.0ms
(/ (+ x 1) (- x 1))
16.0ms
(/ x (+ x 1))

simplify1.5s

Counts
51 → 71
Calls

51 calls. Slowest were:

288.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
193.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 2)) 1)))
182.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune607.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize22.0ms

Local error

Found 4 expressions with local error:

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

rewrite39.0ms

Algorithm
rewrite-expression-head
Counts
4 → 141
Calls

4 calls. Slowest were:

19.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
10.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
4.0ms
(* (+ x 1) (- x 1))

series101.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

47.0ms
(* (+ x 1) (- x 1))
27.0ms
(/ (- (* x (- x 1)) (* (+ x 1) (+ x 1))) (* (+ x 1) (- x 1)))
17.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
9.0ms
(* (+ x 1) (+ x 1))

simplify23.2s

Counts
140 → 153
Calls

140 calls. Slowest were:

858.0ms
(- (* (* x (- (pow x 3) (pow 1 3))) (- x 1)) (* (+ (* x x) (+ (* 1 1) (* x 1))) (* (- (* x x) (* 1 1)) (+ x 1))))
752.0ms
(* (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
729.0ms
(- (* (* x (- (pow x 3) (pow 1 3))) (- x 1)) (* (+ (* x x) (+ (* 1 1) (* x 1))) (* (- (* x x) (* 1 1)) (+ x 1))))

prune1.6s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 2 expressions with local error:

14.6b
(/ (- -1 (* 3 x)) (* (+ x 1) (- x 1)))
0.0b
(* (+ x 1) (- x 1))

rewrite22.0ms

Algorithm
rewrite-expression-head
Counts
2 → 61
Calls

2 calls. Slowest were:

13.0ms
(/ (- -1 (* 3 x)) (* (+ x 1) (- x 1)))
8.0ms
(* (+ x 1) (- x 1))

series74.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

44.0ms
(* (+ x 1) (- x 1))
30.0ms
(/ (- -1 (* 3 x)) (* (+ x 1) (- x 1)))

simplify5.6s

Counts
54 → 67
Calls

54 calls. Slowest were:

863.0ms
(* (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
390.0ms
(* (- x 1) (+ (* x x) (+ (* 1 1) (* x 1))))
341.0ms
(* (+ (* x x) (- (* 1 1) (* x 1))) (+ x 1))

prune706.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize35.0ms

Local error

Found 4 expressions with local error:

19.9b
(* (/ (- -1 (* 3 x)) (* (+ (pow x 3) (pow 1 3)) (- x 1))) (- (* x x) (- x 1)))
2.2b
(/ (- -1 (* 3 x)) (* (+ (pow x 3) (pow 1 3)) (- x 1)))
0.0b
(* (+ (pow x 3) (pow 1 3)) (- x 1))
0.0b
(- (* x x) (- x 1))

rewrite69.0ms

Algorithm
rewrite-expression-head
Counts
4 → 125
Calls

4 calls. Slowest were:

37.0ms
(* (/ (- -1 (* 3 x)) (* (+ (pow x 3) (pow 1 3)) (- x 1))) (- (* x x) (- x 1)))
13.0ms
(* (+ (pow x 3) (pow 1 3)) (- x 1))
12.0ms
(/ (- -1 (* 3 x)) (* (+ (pow x 3) (pow 1 3)) (- x 1)))

series92.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

33.0ms
(* (/ (- -1 (* 3 x)) (* (+ (pow x 3) (pow 1 3)) (- x 1))) (- (* x x) (- x 1)))
30.0ms
(/ (- -1 (* 3 x)) (* (+ (pow x 3) (pow 1 3)) (- x 1)))
21.0ms
(* (+ (pow x 3) (pow 1 3)) (- x 1))
8.0ms
(- (* x x) (- x 1))

simplify15.3s

Counts
104 → 137
Calls

104 calls. Slowest were:

589.0ms
(* (+ (pow (pow x 3) 3) (pow (pow 1 3) 3)) (- (* x x) (* 1 1)))
531.0ms
(* (/ (- -1 (* 3 x)) (* (+ (pow x 3) (pow 1 3)) (- x 1))) (- (* x x) (- x 1)))
527.0ms
(* (+ (pow (pow x 3) 3) (pow (pow 1 3) 3)) (- (pow x 3) (pow 1 3)))

prune2.1s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

regimes35.0ms

Accuracy

99.9% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 15.1b

bsearch150.0ms