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

    1. Initial program 59.4

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\right)}\]
    4. Using strategy rm
    5. Applied rem-log-exp59.4

      \[\leadsto \color{blue}{\frac{x}{x + 1} - \frac{x + 1}{x - 1}}\]
    6. 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)}\]
    7. Simplified0.0

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

    if -13083.266728584855 < x < 11234.078675704557

    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)}\]
    4. Using strategy rm
    5. Applied rem-log-exp0.1

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

Reproduce

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

Details

Time bar (total: 12.7s)Debug log

sample41.0ms

Algorithm
intervals

simplify14.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

14.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

prune13.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.8b

localize13.0ms

Local error

Found 3 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
3 → 62
Calls

3 calls. Slowest were:

6.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
3.0ms
(/ (+ x 1) (- x 1))
0.0ms
(/ x (+ x 1))

series51.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

30.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
11.0ms
(/ (+ x 1) (- x 1))
10.0ms
(/ x (+ x 1))

simplify2.2s

Counts
51 → 71
Calls

51 calls. Slowest were:

509.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
299.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
284.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune503.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize8.0ms

Local error

Found 4 expressions with local error:

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

rewrite48.0ms

Algorithm
rewrite-expression-head
Counts
4 → 86
Calls

4 calls. Slowest were:

18.0ms
(exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
18.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
6.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))

series163.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

51.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
50.0ms
(log (exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))))
45.0ms
(exp (- (/ x (+ x 1)) (/ (+ x 1) (- x 1))))
17.0ms
(/ (+ x 1) (- x 1))

simplify3.0s

Counts
73 → 98
Calls

73 calls. Slowest were:

457.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
334.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
290.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune695.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize1.0ms

Local error

Found 3 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
3 → 62
Calls

3 calls. Slowest were:

8.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 were:

37.0ms
(- (/ x (+ x 1)) (/ (+ x 1) (- x 1)))
10.0ms
(/ (+ x 1) (- x 1))
10.0ms
(/ x (+ x 1))

simplify1.9s

Counts
51 → 71
Calls

51 calls. Slowest were:

413.0ms
(- (* x (- x 1)) (* (+ x 1) (+ x 1)))
264.0ms
(/ (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (- x 1) (- x 1)) (- x 1)))
257.0ms
(- (+ (* 3 (/ 1 (pow x 3))) (+ (/ 1 (pow x 2)) (* 3 (/ 1 x)))))

prune415.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize8.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:

3.0ms
(* (+ x 3) x)

series20.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

20.0ms
(* (+ x 3) x)

simplify303.0ms

Counts
7 → 16
Calls

7 calls. Slowest were:

239.0ms
(* (- (* x x) (* 3 3)) x)
20.0ms
(* (+ (pow x 3) (pow 3 3)) x)
13.0ms
(+ (* 3 x) (pow x 2))

prune103.0ms

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.0b

regimes103.0ms

Accuracy

100% (0.0b remaining)

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

bsearch184.0ms

end0.0ms

sample2.8s

Algorithm
intervals