Average Error: 28.9 → 0.1
Time: 18.6s
Precision: 64
Internal Precision: 128
\[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0213722907636507 \lor \neg \left(x \le 11495.118956785265\right):\\ \;\;\;\;\left(\frac{-3}{x} - \frac{1}{x \cdot x}\right) + \frac{\frac{-3}{x}}{x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\sqrt{1 + x}}}{\sqrt{1 + x}} - \frac{1 + x}{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 < -1.0213722907636507 or 11495.118956785265 < x

    1. Initial program 59.1

      \[\frac{x}{x + 1} - \frac{x + 1}{x - 1}\]
    2. Taylor expanded around -inf 0.4

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

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

    if -1.0213722907636507 < x < 11495.118956785265

    1. Initial program 0.0

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

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

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

Reproduce

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

Details

Time bar (total: 13.5s)Debug log

start131.0ms

Algorithm
intervals

setup36.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.7b

localize32.0ms

Local error

Found 3 expressions with local error:

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

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
3 → 62
Calls

3 calls. Slowest were:

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

series67.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

44.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
12.0ms
(/ x (+ x 1))
11.0ms
(/ (+ x 1) (- x 1))

simplify2.3s

Counts
51 → 71
Calls

51 calls. Slowest were:

490.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
300.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
276.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune528.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize17.0ms

Local error

Found 4 expressions with local error:

6.0b
(+ (- (/ -3 x) (/ 1 (* x x))) (/ (/ -3 x) (* x x)))
0.5b
(/ 1 (* x x))
0.1b
(/ (/ -3 x) (* x x))
0.0b
(- (/ -3 x) (/ 1 (* x x)))

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
4 → 74
Calls

4 calls. Slowest were:

30.0ms
(+ (- (/ -3 x) (/ 1 (* x x))) (/ (/ -3 x) (* x x)))
4.0ms
(- (/ -3 x) (/ 1 (* x x)))
3.0ms
(/ (/ -3 x) (* x x))

series87.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

40.0ms
(- (/ -3 x) (/ 1 (* x x)))
25.0ms
(/ (/ -3 x) (* x x))
12.0ms
(+ (- (/ -3 x) (/ 1 (* x x))) (/ (/ -3 x) (* x x)))
9.0ms
(/ 1 (* x x))

simplify3.3s

Counts
47 → 86
Calls

47 calls. Slowest were:

659.0ms
(/ (* (* (/ -3 x) (/ -3 x)) (/ -3 x)) (* (* (* x x) (* x x)) (* x x)))
511.0ms
(* (+ (* (/ -3 x) (/ -3 x)) (+ (* (/ 1 (* x x)) (/ 1 (* x x))) (* (/ -3 x) (/ 1 (* x x))))) (* x x))
316.0ms
(+ (* (- (* (/ -3 x) (/ -3 x)) (* (/ 1 (* x x)) (/ 1 (* x x)))) (* x x)) (* (+ (/ -3 x) (/ 1 (* x x))) (/ -3 x)))

prune871.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 4 expressions with local error:

9.0b
(- (/ (/ x (sqrt (+ x 1))) (sqrt (+ x 1))) (/ (+ x 1) (- x 1)))
0.1b
(/ x (sqrt (+ x 1)))
0.0b
(/ (/ x (sqrt (+ x 1))) (sqrt (+ x 1)))
0.0b
(/ (+ x 1) (- x 1))

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 133
Calls

4 calls. Slowest were:

15.0ms
(- (/ (/ x (sqrt (+ x 1))) (sqrt (+ x 1))) (/ (+ x 1) (- x 1)))
6.0ms
(/ (+ x 1) (- x 1))
4.0ms
(/ (/ x (sqrt (+ x 1))) (sqrt (+ x 1)))

series104.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

43.0ms
(- (/ (/ x (sqrt (+ x 1))) (sqrt (+ x 1))) (/ (+ x 1) (- x 1)))
26.0ms
(/ x (sqrt (+ x 1)))
17.0ms
(/ (+ x 1) (- x 1))
17.0ms
(/ (/ x (sqrt (+ x 1))) (sqrt (+ x 1)))

simplify3.9s

Counts
153 → 145
Calls

153 calls. Slowest were:

351.0ms
(- (* (/ x (sqrt (+ x 1))) (- x 1)) (* (sqrt (+ x 1)) (+ x 1)))
309.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
269.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune1.4s

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize7.0ms

Local error

Found 1 expressions with local error:

0.0b
(* (+ x 3) x)

rewrite3.0ms

Algorithm
rewrite-expression-head
Counts
1 → 13
Calls

1 calls. Slowest were:

2.0ms
(* (+ x 3) x)

series19.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

19.0ms
(* (+ x 3) x)

simplify304.0ms

Counts
7 → 16
Calls

7 calls. Slowest were:

224.0ms
(* (- (* x x) (* 3 3)) x)
34.0ms
(* (+ (pow x 3) (pow 3 3)) x)
17.0ms
(+ (* 3 x) (pow x 2))

prune140.0ms

Pruning

5 alts after pruning (2 fresh and 3 done)

Merged error: 0.0b

regimes80.0ms

Accuracy

100% (0.0b remaining)

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

bsearch121.0ms